This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/16310] New: Inconsistent HI, LO parts of addresses


* the options given when GCC was configured/built;

Configured with: /home/niva/src/gcc-3.4-binutils/configure
--with-headers=/home/niva/src/OC2000-22-jan-04-include
--without-libs --enable-generated-files-in-srcdir
--enable-threads=posix -with-dwarf2 --disable-shared
--target=mips64-none-elf --verbose --enable-checking
--enable-languages=c --srcdir=/home/niva/src/gcc-3.4-binutils
--prefix=/home/niva/local-osina --enable-cpp

     * the complete command line that triggers the bug;

./mips64-none-elf-gcc -O2 -G 0  relocbug.c -c -save-temps -v

     * the compiler output (error messages, warnings, etc.);

No error messages

     * the  preprocessed  file (*.i*) that triggers the bug, generated by
       adding -save-temps to the complete compilation command, or, in the
       case  of  a  bug  report for the GNAT front end, a complete set of
       source files (see below).

static int P, R;

short *Pshrt = 1+(short*)&P;      // Here the correct addresses
short *Rshrt = 1+(short*)&R;      // of P and R will be generated
                                  // in the .data section.
short E(int i)
{
 return  (short) (i ? P : R);  // Here one of the addresses will
                               // be wrong.
}


     * the resultant assembler code is

	.file	1 "relocbug.c"
	.section .mdebug.abiO64
	.previous
	.globl	Rshrt
	.data
	.align	2
	.type	Rshrt, @object
	.size	Rshrt, 4
Rshrt:
	.word	R+2
	.globl	Pshrt
	.align	2
	.type	Pshrt, @object
	.size	Pshrt, 4
Pshrt:
	.word	P+2
	.text
	.align	2
	.align	3
	.globl	E
	.ent	E
E:
	.frame	$sp,0,$31		# vars= 0, regs= 0/0, args= 0, gp= 0
	.mask	0x00000000,0
	.fmask	0x00000000,0
	.set	noreorder
	.set	nomacro
	
	beql	$4,$0,$L2
	lui	$2,%hi(R)

	lui	$2,%hi(P)
	j	$31
	lh	$2,%lo(P+2)($2)

	.align	3
$L2:
	j	$31
	lh	$2,%lo(R+2)($2)

	.set	macro
	.set	reorder
	.end	E

     * the error is that gas 2.15 configured as specified above
       is unable to properly associate %hi(R) and %lo(R+2) in function E.

       Running "mips64-none-elf-objdump -r relocbug.o" gives

relocbug.o:     file format elf32-bigmips

RELOCATION RECORDS FOR [.text]:
OFFSET   TYPE              VALUE
00000004 R_MIPS_HI16       .bss
00000008 R_MIPS_HI16       .bss
00000010 R_MIPS_LO16       .bss
0000001c R_MIPS_LO16       .bss

       while the proper order of relocation records is

00000008 R_MIPS_HI16       .bss
00000010 R_MIPS_LO16       .bss
00000004 R_MIPS_HI16       .bss
0000001c R_MIPS_LO16       .bss

       As a result, ld incorrectly calculates address of R when called as

mips64-niisi-elf-ld -e E -Tbss=0x447ffc -mips4 -v -O2 -G 0 -o relocbug relocbug.o

       The result would be correct if compiler generates

	lui	$2,%hi(R+2)
	lui	$2,%hi(P+2)

       instead of

	lui	$2,%hi(R)
	lui	$2,%hi(P)

-- 
           Summary: Inconsistent HI, LO parts of addresses
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: niva at niisi dot msk dot ru
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: mips64-none-elf


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16310


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]