public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/16310] New: Inconsistent HI, LO parts of addresses
@ 2004-07-01  9:34 niva at niisi dot msk dot ru
  2004-07-01 17:56 ` [Bug target/16310] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: niva at niisi dot msk dot ru @ 2004-07-01  9:34 UTC (permalink / raw)
  To: gcc-bugs

* 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/16310] Inconsistent HI, LO parts of addresses
  2004-07-01  9:34 [Bug c/16310] New: Inconsistent HI, LO parts of addresses niva at niisi dot msk dot ru
@ 2004-07-01 17:56 ` pinskia at gcc dot gnu dot org
  2004-07-03 11:06 ` rsandifo at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-01 17:56 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |target
           Keywords|                            |wrong-code


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/16310] Inconsistent HI, LO parts of addresses
  2004-07-01  9:34 [Bug c/16310] New: Inconsistent HI, LO parts of addresses niva at niisi dot msk dot ru
  2004-07-01 17:56 ` [Bug target/16310] " pinskia at gcc dot gnu dot org
@ 2004-07-03 11:06 ` rsandifo at gcc dot gnu dot org
  2004-07-03 11:12 ` rsandifo at gcc dot gnu dot org
  2004-07-17 11:06 ` rsandifo at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2004-07-03 11:06 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rsandifo at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/16310] Inconsistent HI, LO parts of addresses
  2004-07-01  9:34 [Bug c/16310] New: Inconsistent HI, LO parts of addresses niva at niisi dot msk dot ru
  2004-07-01 17:56 ` [Bug target/16310] " pinskia at gcc dot gnu dot org
  2004-07-03 11:06 ` rsandifo at gcc dot gnu dot org
@ 2004-07-03 11:12 ` rsandifo at gcc dot gnu dot org
  2004-07-17 11:06 ` rsandifo at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2004-07-03 11:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rsandifo at gcc dot gnu dot org  2004-07-03 11:12 -------
I think we should treat gcc's output as correct.  Could you try
the binutils patch posted here:

http://sources.redhat.com/ml/binutils/2004-07/msg00038.html

...which also gives the rationale for patching binutils rather
than gcc.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |WAITING


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug target/16310] Inconsistent HI, LO parts of addresses
  2004-07-01  9:34 [Bug c/16310] New: Inconsistent HI, LO parts of addresses niva at niisi dot msk dot ru
                   ` (2 preceding siblings ...)
  2004-07-03 11:12 ` rsandifo at gcc dot gnu dot org
@ 2004-07-17 11:06 ` rsandifo at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: rsandifo at gcc dot gnu dot org @ 2004-07-17 11:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From rsandifo at gcc dot gnu dot org  2004-07-17 11:06 -------
As per the message linked earlier, it's really up to gas to
order the relocations correctly.  Fixed in binutils mainline.

Thanks very much for reporting this.  And sorry for the "INVALID"
thing, since it was clearly a toolchain bug.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-07-17 11:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-01  9:34 [Bug c/16310] New: Inconsistent HI, LO parts of addresses niva at niisi dot msk dot ru
2004-07-01 17:56 ` [Bug target/16310] " pinskia at gcc dot gnu dot org
2004-07-03 11:06 ` rsandifo at gcc dot gnu dot org
2004-07-03 11:12 ` rsandifo at gcc dot gnu dot org
2004-07-17 11:06 ` rsandifo at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).