diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-10-26 06:10:23 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-10-26 06:10:38 -0700 |
commit | e99717784e628eb85c8495952c1dec562586b0f1 (patch) | |
tree | 7788d394f792445417c99d64830895c12d2ed7a2 /ld/testsuite/ld-i386 | |
parent | 48ffa2b8cd986527a41654c3b27755bbf6762048 (diff) | |
download | binutils-gdb-e99717784e628eb85c8495952c1dec562586b0f1.tar.gz |
Properly convert address load of __start_XXX/__stop_XXX
Since __start_XXX and __stop_XXX symbols aren't defined when address
load is being converted, we need to check if there is an XXX output
section to get their section and value. This patch adds a new function,
bfd_link_get_defined_symbol, to search for the XXX output section to
check if __start_XXX and __stop_XXX symbols are defined.
bfd/
PR ld/19171
* elf32-i386.c (elf_i386_convert_load): Call
bfd_link_get_defined_symbol to check if a symbol is defined.
* elf64-x86-64.c (elf_x86_64_convert_load): Call
bfd_link_get_defined_symbol to get defined symbol section and
value.
* linker.c (bfd_link_get_defined_symbol): New function.
* bfd-in2.h: Regenerated.
ld/testsuite/
PR ld/19171
* ld-i386/lea1.s: Add tests for address load of __start_XXX
and __stop_XXX.
* ld-i386/mov1.s: Likewise.
* ld-x86-64/lea1.s: Likewise.
* ld-x86-64/mov1.s: Likewise.
* ld-i386/lea1a.d: Updated.
* ld-i386/lea1b.d: Likewise.
* ld-i386/lea1c.d: Likewise.
* ld-i386/mov1a.d: Likewise.
* ld-i386/mov1b.d: Likewise.
* ld-x86-64/lea1a.d: Likewise.
* ld-x86-64/lea1b.d: Likewise.
* ld-x86-64/lea1c.d: Likewise.
* ld-x86-64/lea1d.d: Likewise.
* ld-x86-64/lea1e.d: Likewise.
* ld-x86-64/lea1f.d: Likewise.
* ld-x86-64/mov1a.d: Likewise.
* ld-x86-64/mov1b.d: Likewise.
* ld-x86-64/mov1c.d: Likewise.
* ld-x86-64/mov1d.d: Likewise.
Diffstat (limited to 'ld/testsuite/ld-i386')
-rw-r--r-- | ld/testsuite/ld-i386/lea1.s | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/lea1a.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/lea1b.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/lea1c.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/mov1.s | 4 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/mov1a.d | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-i386/mov1b.d | 2 |
7 files changed, 18 insertions, 0 deletions
diff --git a/ld/testsuite/ld-i386/lea1.s b/ld/testsuite/ld-i386/lea1.s index f754ec03374..8849a38fb7a 100644 --- a/ld/testsuite/ld-i386/lea1.s +++ b/ld/testsuite/ld-i386/lea1.s @@ -1,3 +1,5 @@ + .section my_section,"aw",@progbits + .long 0x12345678 .text .globl foo .type foo, @function @@ -9,6 +11,8 @@ foo: _start: movl foo@GOT(%ecx), %eax movl bar@GOT(%ecx), %eax + movl __start_my_section@GOT(%ecx), %eax + movl __stop_my_section@GOT(%ecx), %eax .size _start, .-_start .comm pad,4,4 .comm bar,4,4 diff --git a/ld/testsuite/ld-i386/lea1a.d b/ld/testsuite/ld-i386/lea1a.d index 0435d3495b9..d8825227008 100644 --- a/ld/testsuite/ld-i386/lea1a.d +++ b/ld/testsuite/ld-i386/lea1a.d @@ -11,4 +11,6 @@ Disassembly of section .text: #... [ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%ecx\),%eax [ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%ecx\),%eax +[ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%ecx\),%eax +[ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%ecx\),%eax #pass diff --git a/ld/testsuite/ld-i386/lea1b.d b/ld/testsuite/ld-i386/lea1b.d index 8cef2c4f64a..b3f6507d177 100644 --- a/ld/testsuite/ld-i386/lea1b.d +++ b/ld/testsuite/ld-i386/lea1b.d @@ -11,4 +11,6 @@ Disassembly of section .text: #... [ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%ecx\),%eax [ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%ecx\),%eax +[ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%ecx\),%eax +[ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%ecx\),%eax #pass diff --git a/ld/testsuite/ld-i386/lea1c.d b/ld/testsuite/ld-i386/lea1c.d index 54ec0deb18e..dd76258be34 100644 --- a/ld/testsuite/ld-i386/lea1c.d +++ b/ld/testsuite/ld-i386/lea1c.d @@ -11,4 +11,6 @@ Disassembly of section .text: #... [ ]*[a-f0-9]+: 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+,%eax [ ]*[a-f0-9]+: 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+,%eax +[ ]*[a-f0-9]+: 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+,%eax +[ ]*[a-f0-9]+: 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+,%eax #pass diff --git a/ld/testsuite/ld-i386/mov1.s b/ld/testsuite/ld-i386/mov1.s index c813e718b18..0ed8015e7e4 100644 --- a/ld/testsuite/ld-i386/mov1.s +++ b/ld/testsuite/ld-i386/mov1.s @@ -1,6 +1,10 @@ .text + .weak __start_my_section + .weak __stop_my_section .globl _start .type _start, @function _start: movl _DYNAMIC@GOT(%ecx), %eax + movl __start_my_section@GOT(%ecx), %eax + movl __stop_my_section@GOT(%ecx), %eax .size _start, .-_start diff --git a/ld/testsuite/ld-i386/mov1a.d b/ld/testsuite/ld-i386/mov1a.d index d8ce6b821f7..d189627744a 100644 --- a/ld/testsuite/ld-i386/mov1a.d +++ b/ld/testsuite/ld-i386/mov1a.d @@ -10,4 +10,6 @@ Disassembly of section .text: #... [ ]*[a-f0-9]+: 8b 81 ([0-9a-f]{2} ){4} * mov -0x[a-f0-9]+\(%ecx\),%eax +[ ]*[a-f0-9]+: 8b 81 ([0-9a-f]{2} ){4} * mov -0x[a-f0-9]+\(%ecx\),%eax +[ ]*[a-f0-9]+: 8b 81 ([0-9a-f]{2} ){4} * mov -0x[a-f0-9]+\(%ecx\),%eax #pass diff --git a/ld/testsuite/ld-i386/mov1b.d b/ld/testsuite/ld-i386/mov1b.d index 583dfc82d46..ae40862384e 100644 --- a/ld/testsuite/ld-i386/mov1b.d +++ b/ld/testsuite/ld-i386/mov1b.d @@ -10,4 +10,6 @@ Disassembly of section .text: #... [ ]*[a-f0-9]+: 8b 81 ([0-9a-f]{2} ){4} * mov -0x[a-f0-9]+\(%ecx\),%eax +[ ]*[a-f0-9]+: 8b 81 ([0-9a-f]{2} ){4} * mov -0x[a-f0-9]+\(%ecx\),%eax +[ ]*[a-f0-9]+: 8b 81 ([0-9a-f]{2} ){4} * mov -0x[a-f0-9]+\(%ecx\),%eax #pass |