gas:
2009-10-07 Vincent Riviere <vincent.riviere@freesbee.fr> PR gas/3041 * config/tc-m68k.c (tc_gen_reloc): Fix addend for relocations located in data section an referencing a weak symbol. gas/testsuite: 2009-10-07 Vincent Riviere <vincent.riviere@freesbee.fr> PR gas/3041 * gas/m68k/all.exp: Added "p3041data". * gas/m68k/p3041.d, gas/m68k/p3041.s: Added tests of weak references from text section to all possible sections. * gas/m68k/p3041data.d, gas/m68k/p3041data.s: New test. Check weak references from data section.
This commit is contained in:
parent
279017b761
commit
b2b7424819
8 changed files with 149 additions and 17 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-10-013 Vincent Riviere <vincent.riviere@freesbee.fr>
|
||||
|
||||
PR gas/3041
|
||||
* config/tc-m68k.c (tc_gen_reloc): Fix addend for relocations
|
||||
located in data section an referencing a weak symbol.
|
||||
|
||||
2009-10-07 Nathan Sidwell <nathan@codesourcery.com>
|
||||
|
||||
* config/tc-arm.c (mapping_state, mapping_state_2): Make dummy
|
||||
|
|
|
@ -1326,10 +1326,29 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp)
|
|||
&& fixp->fx_addsy
|
||||
&& S_IS_WEAK (fixp->fx_addsy)
|
||||
&& ! bfd_is_und_section (S_GET_SEGMENT (fixp->fx_addsy)))
|
||||
/* PR gas/3041 Adjust addend in order to force bfd_install_relocation()
|
||||
to put the symbol offset into frags referencing a weak symbol. */
|
||||
{
|
||||
/* PR gas/3041 References to weak symbols must be treated as extern
|
||||
in order to be overridable by the linker, even if they are defined
|
||||
in the same object file. So the original addend must be written
|
||||
"as is" into the output section without further processing.
|
||||
The addend value must be hacked here in order to force
|
||||
bfd_install_relocation() to write the original value into the
|
||||
output section.
|
||||
1) MD_APPLY_SYM_VALUE() is set to 1 for m68k/a.out, so the symbol
|
||||
value has already been added to the addend in fixup_segment(). We
|
||||
have to remove it.
|
||||
2) bfd_install_relocation() will incorrectly treat this symbol as
|
||||
resolved, so it will write the symbol value plus its addend and
|
||||
section VMA. As a workaround we can tweak the addend value here in
|
||||
order to get the original value in the section after the call to
|
||||
bfd_install_relocation(). */
|
||||
reloc->addend = fixp->fx_addnumber
|
||||
- (S_GET_VALUE (fixp->fx_addsy) * 2);
|
||||
/* Fix because of MD_APPLY_SYM_VALUE() */
|
||||
- S_GET_VALUE (fixp->fx_addsy)
|
||||
/* Fix for bfd_install_relocation() */
|
||||
- (S_GET_VALUE (fixp->fx_addsy)
|
||||
+ S_GET_SEGMENT (fixp->fx_addsy)->vma);
|
||||
}
|
||||
else
|
||||
reloc->addend = 0;
|
||||
#else
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
2009-10-13 Vincent Riviere <vincent.riviere@freesbee.fr>
|
||||
|
||||
PR gas/3041
|
||||
* gas/m68k/all.exp: Added "p3041data".
|
||||
* gas/m68k/p3041.d, gas/m68k/p3041.s: Added tests of weak references
|
||||
from text section to all possible sections.
|
||||
* gas/m68k/p3041data.d, gas/m68k/p3041data.s: New test. Check weak
|
||||
references from data section.
|
||||
|
||||
2009-10-08 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
PR gas/10704
|
||||
|
|
|
@ -71,6 +71,7 @@ if { [istarget m68*-*-*] || [istarget fido*-*-*] } then {
|
|||
|
||||
if { [istarget *-*-netbsd] } then {
|
||||
run_dump_test p3041
|
||||
run_dump_test p3041data
|
||||
}
|
||||
|
||||
set testname "68000 operands"
|
||||
|
|
|
@ -1,15 +1,36 @@
|
|||
#name: PR 3041
|
||||
#objdump: -dr
|
||||
#objdump: -tdr
|
||||
|
||||
.*: file format .*
|
||||
|
||||
Disassembly of section .text:
|
||||
SYMBOL TABLE:
|
||||
00000036 w \.text 0000 00 0f mytext
|
||||
0000003e w \.data 0000 00 10 mydata
|
||||
0000004a w \.bss 0000 00 11 mybss
|
||||
|
||||
0+ <.*>:
|
||||
0: 4ef9 0000 0002 [ ]+jmp 2 <mylabel-0x6>
|
||||
2: .* mylabel
|
||||
6: 4e71 [ ]+nop
|
||||
Disassembly of section \.text:
|
||||
|
||||
0+8 <mylabel>:
|
||||
8: 4e71 [ ]+nop
|
||||
a: 4e71 [ ]+nop
|
||||
00000000 <.*>:
|
||||
0: 41f9 0000 0000 lea 0 <.*>,%a0
|
||||
2: 32 mytext
|
||||
6: 41f9 0000 0002 lea 2 <.*>,%a0
|
||||
8: 32 mytext
|
||||
c: 41f9 ffff fffc lea fffffffc <.*>,%a0
|
||||
e: 32 mytext
|
||||
12: 41f9 0000 0000 lea 0 <.*>,%a0
|
||||
14: 32 mydata
|
||||
18: 41f9 0000 0003 lea 3 <.*>,%a0
|
||||
1a: 32 mydata
|
||||
1e: 41f9 ffff ffff lea ffffffff <.*>,%a0
|
||||
20: 32 mydata
|
||||
24: 41f9 0000 0000 lea 0 <.*>,%a0
|
||||
26: 32 mybss
|
||||
2a: 41f9 0000 0001 lea 1 <.*>,%a0
|
||||
2c: 32 mybss
|
||||
30: 41f9 ffff fffe lea fffffffe <.*>,%a0
|
||||
32: 32 mybss
|
||||
|
||||
00000036 <mytext>:
|
||||
36: 4e71 nop
|
||||
38: 4e71 nop
|
||||
3a: 4e71 nop
|
||||
|
|
|
@ -1,6 +1,27 @@
|
|||
jmp mylabel+2
|
||||
nop
|
||||
.weak mylabel
|
||||
mylabel:
|
||||
lea mytext,%a0
|
||||
lea mytext+2,%a0
|
||||
lea mytext-4,%a0
|
||||
lea mydata,%a0
|
||||
lea mydata+3,%a0
|
||||
lea mydata-1,%a0
|
||||
lea mybss,%a0
|
||||
lea mybss+1,%a0
|
||||
lea mybss-2,%a0
|
||||
.weak mytext
|
||||
mytext:
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
|
||||
.data
|
||||
.word 0x8081
|
||||
.weak mydata
|
||||
mydata:
|
||||
.word 0x8283
|
||||
.word 0x8485
|
||||
|
||||
.bss
|
||||
.skip 6
|
||||
.weak mybss
|
||||
mybss:
|
||||
.skip 2
|
||||
|
|
28
gas/testsuite/gas/m68k/p3041data.d
Normal file
28
gas/testsuite/gas/m68k/p3041data.d
Normal file
|
@ -0,0 +1,28 @@
|
|||
#name: PR 3041 data
|
||||
#objdump: -trs
|
||||
|
||||
.*: file format .*
|
||||
|
||||
SYMBOL TABLE:
|
||||
00000006 w \.text 0000 00 0f mytext
|
||||
00000014 w \.data 0000 00 10 mydata
|
||||
00000040 w \.bss 0000 00 11 mybss
|
||||
|
||||
RELOCATION RECORDS FOR \[\.data\]:
|
||||
OFFSET TYPE VALUE
|
||||
00000004 32 mytext
|
||||
00000008 32 mytext
|
||||
0000000c 32 mytext
|
||||
00000010 32 mydata
|
||||
00000014 32 mydata
|
||||
00000018 32 mydata
|
||||
0000001c 32 mybss
|
||||
00000020 32 mybss
|
||||
00000024 32 mybss
|
||||
|
||||
Contents of section .text:
|
||||
0000 4e714e71 4e714e71 .*
|
||||
Contents of section .data:
|
||||
0008 12345678 00000000 00000001 fffffffd .*
|
||||
0018 00000000 00000003 fffffffe 00000000 .*
|
||||
0028 00000002 ffffffff .*
|
27
gas/testsuite/gas/m68k/p3041data.s
Normal file
27
gas/testsuite/gas/m68k/p3041data.s
Normal file
|
@ -0,0 +1,27 @@
|
|||
.text
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
.weak mytext
|
||||
mytext:
|
||||
nop
|
||||
|
||||
.data
|
||||
.long 0x12345678
|
||||
.long mytext
|
||||
.long mytext+1
|
||||
.weak mydata
|
||||
mydata:
|
||||
.long mytext-3
|
||||
.long mydata
|
||||
.long mydata+3
|
||||
.long mydata-2
|
||||
.long mybss
|
||||
.long mybss+2
|
||||
.long mybss-1
|
||||
|
||||
.bss
|
||||
.skip 16
|
||||
.weak mybss
|
||||
mybss:
|
||||
.word 1
|
Loading…
Reference in a new issue