This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
as for sh-any-elf (weak symbol)
- To: binutils at sourceware dot cygnus dot com
- Subject: as for sh-any-elf (weak symbol)
- From: kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- Date: Thu, 26 Oct 2000 23:09:39 +0900
Hi,
It seems that as for sh-any-elf target gives a wrong valued
in place relocation for the reference to the weak data symbol.
For example,
.data
.align 2
d0:
.long 1
.global w0
w0:
.long 0
.weak w0
.text
.align 5
f:
mov.l .L3,r1
mov.l @r1,r0
rts
nop
.align 2
.L3:
.long w0
is assembled to
00000000 <f>:
0: d1 01 mov.l 8 <f+0x8>,r1 ! 0xfffffffc
2: 60 12 mov.l @r1,r0
4: 00 0b rts
6: 00 09 nop
8: ff ff .word 0xffff
a: ff fc .word 0xfffc
with a relocation
Offset Info Type Symbol's Value Symbol's Name Addend
00000008 00601 R_SH_DIR32 00000004 w0 + 0
and ld gives
00001000 <f>:
1000: d1 01 mov.l 1008 <f+0x8>,r1 ! 0x108c
1002: 60 12 mov.l @r1,r0
1004: 00 0b rts
1006: 00 09 nop
1008: 00 00 .word 0x0000
100a: 10 8c mov.l r8,@(48,r0)
which returns the content of d0 not of w0.
11: 0000108c 0 NOTYPE LOCAL DEFAULT 2 d0
12: 00001000 0 NOTYPE LOCAL DEFAULT 1 f
13: 00001090 0 NOTYPE WEAK DEFAULT 2 w0
If the line .weak w0 is deleted from the source, everything
is ok. I guess that the code
/* The function adjust_reloc_syms won't convert a reloc against a weak
symbol into a reloc against a section, but bfd_install_relocation
will screw up if the symbol is defined, so we have to adjust val here
to avoid the screw up later. */
if (fixP->fx_addsy != NULL
&& S_IS_WEAK (fixP->fx_addsy))
val -= S_GET_VALUE (fixP->fx_addsy);
in function md_apply_fix of gas/config/tc-sh.c causes this.
--
kazumoto Kojima
Mail kkojima@rr.iij4u.or.jp
URL http://rr.iij4u.or.jp/~kkojima