diff options
author | Nick Clifton <nickc@redhat.com> | 2009-10-13 08:55:31 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2009-10-13 08:55:31 +0000 |
commit | b2b7424819829f8f0377907b3f03319a20e6355d (patch) | |
tree | d0f4aeca7db867d05d7e7e10443c633e8d2271fb | |
parent | 279017b761dcda4b0e94e6c91676afb091c85cbc (diff) | |
download | gdb-b2b7424819829f8f0377907b3f03319a20e6355d.zip gdb-b2b7424819829f8f0377907b3f03319a20e6355d.tar.gz gdb-b2b7424819829f8f0377907b3f03319a20e6355d.tar.bz2 |
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.
-rw-r--r-- | gas/ChangeLog | 6 | ||||
-rw-r--r-- | gas/config/tc-m68k.c | 27 | ||||
-rw-r--r-- | gas/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gas/testsuite/gas/m68k/all.exp | 1 | ||||
-rw-r--r-- | gas/testsuite/gas/m68k/p3041.d | 39 | ||||
-rw-r--r-- | gas/testsuite/gas/m68k/p3041.s | 27 | ||||
-rw-r--r-- | gas/testsuite/gas/m68k/p3041data.d | 28 | ||||
-rw-r--r-- | gas/testsuite/gas/m68k/p3041data.s | 27 |
8 files changed, 148 insertions, 16 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index d77f274..ac3953d 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -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 diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index 7bb6828..9616ba5 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -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. */ - reloc->addend = fixp->fx_addnumber - - (S_GET_VALUE (fixp->fx_addsy) * 2); + { + /* 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 + /* 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 diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index a7cadf0..4a093bf 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -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 diff --git a/gas/testsuite/gas/m68k/all.exp b/gas/testsuite/gas/m68k/all.exp index 9cb9c2c..4a93561 100644 --- a/gas/testsuite/gas/m68k/all.exp +++ b/gas/testsuite/gas/m68k/all.exp @@ -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" diff --git a/gas/testsuite/gas/m68k/p3041.d b/gas/testsuite/gas/m68k/p3041.d index b4a41c4..f05648e 100644 --- a/gas/testsuite/gas/m68k/p3041.d +++ b/gas/testsuite/gas/m68k/p3041.d @@ -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 diff --git a/gas/testsuite/gas/m68k/p3041.s b/gas/testsuite/gas/m68k/p3041.s index 96a8910..4114216 100644 --- a/gas/testsuite/gas/m68k/p3041.s +++ b/gas/testsuite/gas/m68k/p3041.s @@ -1,6 +1,27 @@ - jmp mylabel+2 + 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 - .weak mylabel -mylabel: nop nop + + .data + .word 0x8081 + .weak mydata +mydata: + .word 0x8283 + .word 0x8485 + + .bss + .skip 6 + .weak mybss +mybss: + .skip 2 diff --git a/gas/testsuite/gas/m68k/p3041data.d b/gas/testsuite/gas/m68k/p3041data.d new file mode 100644 index 0000000..91b2895 --- /dev/null +++ b/gas/testsuite/gas/m68k/p3041data.d @@ -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 .* diff --git a/gas/testsuite/gas/m68k/p3041data.s b/gas/testsuite/gas/m68k/p3041data.s new file mode 100644 index 0000000..73cbc39 --- /dev/null +++ b/gas/testsuite/gas/m68k/p3041data.s @@ -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 |