This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: MIPS md_apply_fix()(?) problem.
- From: "H . J . Lu" <hjl at lucon dot org>
- To: cgd at broadcom dot com
- Cc: rsandifo at redhat dot com, binutils at sources dot redhat dot com
- Date: Thu, 15 Nov 2001 17:41:51 -0800
- Subject: Re: MIPS md_apply_fix()(?) problem.
- References: <yov53d3f5woj.fsf@broadcom.com>
On Thu, Nov 15, 2001 at 05:30:52PM -0800, cgd@broadcom.com wrote:
> So, I ran across a rather serious problem, which i believe is caused
> by Richard S's change:
>
> 2001-08-03 Richard Sandiford <rsandifo@redhat.com>
>
> * config/tc-mips.c (md_apply_fix): Don't subtract the symbol value
> from GPREL addends.
>
> The test case below assembles incorrectly with that change. (If you
> read the test, you end up thinking "WTF?!?!?!" that's unrelated!!!
> but read on! FYI, this test case is distilled from assembly code
> generated compiling a mips linux kernel w/ gcc 3.0.1.)
>
> Assemble it with mips-{elf,linux}-as -o foo.o foo.s; it's that easy. 8-)
>
> Before that change, you get:
>
> 0: 3c050000 lui a1,0x0
> 0: R_MIPS_HI16 boot_mem_map
> 4: 00b12821 addu a1,a1,s1
> 8: 8ca5000c lw a1,12(a1)
> 8: R_MIPS_LO16 boot_mem_map
> c: 00000000 nop
>
> After you get:
>
> 0: 3c050000 lui a1,0x0
> 0: R_MIPS_HI16 boot_mem_map
> 4: 00b12821 addu a1,a1,s1
> 8: 8ca50010 lw a1,16(a1)
> 8: R_MIPS_LO16 boot_mem_map
> c: 00000000 nop
>
> Note the 12 -> 16 you get in the instruction @ 0x8. This is the
> offset of "boot_mem_map" in .bss in the object file produced by
> assembling this source. (If you then go on to final link, it still
> produces a value off by the same offset, in this example 4.)
>
FWIW, I got this with binutils 2.11.92.0.10 and 2.11.92.0.11. It seems
ok to me. FYI, I used "-G 0 -mno-abicalls -fno-pic" for kernel.
H.J.
----
foo.o: file format elf32-tradlittlemips
Disassembly of section .text:
00000000 <fn>:
0: 3c050000 lui a1,0x0
0: R_MIPS_HI16 boot_mem_map
4: 00b12821 addu a1,a1,s1
8: 8ca5000c lw a1,12(a1)
8: R_MIPS_LO16 boot_mem_map
c: 00000000 nop