aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-10-26 06:10:23 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-10-26 08:11:55 -0700
commita6af384b19c63bab4a1803c09592c5b5bd8674c2 (patch)
treebe13c54b14d178b3c327ea1e372b2337980e7d95 /ld
parent7cc53fba0a4e5c316a6e86fdae28f8cc9d0f9a68 (diff)
downloadgdb-a6af384b19c63bab4a1803c09592c5b5bd8674c2.zip
gdb-a6af384b19c63bab4a1803c09592c5b5bd8674c2.tar.gz
gdb-a6af384b19c63bab4a1803c09592c5b5bd8674c2.tar.bz2
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')
-rw-r--r--ld/testsuite/ChangeLog24
-rw-r--r--ld/testsuite/ld-i386/lea1.s4
-rw-r--r--ld/testsuite/ld-i386/lea1a.d2
-rw-r--r--ld/testsuite/ld-i386/lea1b.d2
-rw-r--r--ld/testsuite/ld-i386/lea1c.d2
-rw-r--r--ld/testsuite/ld-i386/mov1.s4
-rw-r--r--ld/testsuite/ld-i386/mov1a.d2
-rw-r--r--ld/testsuite/ld-i386/mov1b.d2
-rw-r--r--ld/testsuite/ld-x86-64/lea1.s4
-rw-r--r--ld/testsuite/ld-x86-64/lea1a.d2
-rw-r--r--ld/testsuite/ld-x86-64/lea1b.d2
-rw-r--r--ld/testsuite/ld-x86-64/lea1c.d2
-rw-r--r--ld/testsuite/ld-x86-64/lea1d.d2
-rw-r--r--ld/testsuite/ld-x86-64/lea1e.d2
-rw-r--r--ld/testsuite/ld-x86-64/lea1f.d2
-rw-r--r--ld/testsuite/ld-x86-64/mov1.s4
-rw-r--r--ld/testsuite/ld-x86-64/mov1a.d2
-rw-r--r--ld/testsuite/ld-x86-64/mov1b.d2
-rw-r--r--ld/testsuite/ld-x86-64/mov1c.d2
-rw-r--r--ld/testsuite/ld-x86-64/mov1d.d2
20 files changed, 70 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 90a31e6..42558ba 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,27 @@
+2015-10-26 H.J. Lu <hongjiu.lu@intel.com>
+
+ 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.
+
2015-10-23 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19167
diff --git a/ld/testsuite/ld-i386/lea1.s b/ld/testsuite/ld-i386/lea1.s
index f754ec0..8849a38 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 0435d34..d882522 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 8cef2c4..b3f6507 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 54ec0de..dd76258 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 c813e71..0ed8015 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 d8ce6b8..d189627 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 583dfc8..ae40862 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
diff --git a/ld/testsuite/ld-x86-64/lea1.s b/ld/testsuite/ld-x86-64/lea1.s
index c2a499c..07a2e35 100644
--- a/ld/testsuite/ld-x86-64/lea1.s
+++ b/ld/testsuite/ld-x86-64/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:
movq foo@GOTPCREL(%rip), %rax
movq bar@GOTPCREL(%rip), %rax
+ movq __start_my_section@GOTPCREL(%rip), %rax
+ movq __stop_my_section@GOTPCREL(%rip), %rax
.size _start, .-_start
.comm pad,4,4
.comm bar,4,4
diff --git a/ld/testsuite/ld-x86-64/lea1a.d b/ld/testsuite/ld-x86-64/lea1a.d
index 75dad70..36e9f54 100644
--- a/ld/testsuite/ld-x86-64/lea1a.d
+++ b/ld/testsuite/ld-x86-64/lea1a.d
@@ -11,4 +11,6 @@ Disassembly of section .text:
#...
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__start_my_section>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__stop_my_section>
#pass
diff --git a/ld/testsuite/ld-x86-64/lea1b.d b/ld/testsuite/ld-x86-64/lea1b.d
index d968ca2..a92acd7 100644
--- a/ld/testsuite/ld-x86-64/lea1b.d
+++ b/ld/testsuite/ld-x86-64/lea1b.d
@@ -11,4 +11,6 @@ Disassembly of section .text:
#...
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__start_my_section>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__stop_my_section>
#pass
diff --git a/ld/testsuite/ld-x86-64/lea1c.d b/ld/testsuite/ld-x86-64/lea1c.d
index 5f7e6c3..072b1ee 100644
--- a/ld/testsuite/ld-x86-64/lea1c.d
+++ b/ld/testsuite/ld-x86-64/lea1c.d
@@ -11,4 +11,6 @@ Disassembly of section .text:
#...
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__start_my_section>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__stop_my_section>
#pass
diff --git a/ld/testsuite/ld-x86-64/lea1d.d b/ld/testsuite/ld-x86-64/lea1d.d
index 524980f..2613061 100644
--- a/ld/testsuite/ld-x86-64/lea1d.d
+++ b/ld/testsuite/ld-x86-64/lea1d.d
@@ -11,4 +11,6 @@ Disassembly of section .text:
#...
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__start_my_section>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__stop_my_section>
#pass
diff --git a/ld/testsuite/ld-x86-64/lea1e.d b/ld/testsuite/ld-x86-64/lea1e.d
index 22e6dcc..109c1cd 100644
--- a/ld/testsuite/ld-x86-64/lea1e.d
+++ b/ld/testsuite/ld-x86-64/lea1e.d
@@ -11,4 +11,6 @@ Disassembly of section .text:
#...
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__start_my_section>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__stop_my_section>
#pass
diff --git a/ld/testsuite/ld-x86-64/lea1f.d b/ld/testsuite/ld-x86-64/lea1f.d
index 9aff34d..8d6cd78 100644
--- a/ld/testsuite/ld-x86-64/lea1f.d
+++ b/ld/testsuite/ld-x86-64/lea1f.d
@@ -11,4 +11,6 @@ Disassembly of section .text:
#...
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea -0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <foo>
[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <bar>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__start_my_section>
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__stop_my_section>
#pass
diff --git a/ld/testsuite/ld-x86-64/mov1.s b/ld/testsuite/ld-x86-64/mov1.s
index 2a11b7a..844129c 100644
--- a/ld/testsuite/ld-x86-64/mov1.s
+++ b/ld/testsuite/ld-x86-64/mov1.s
@@ -1,6 +1,10 @@
.text
+ .weak __start_my_section
+ .weak __stop_my_section
.globl _start
.type _start, @function
_start:
movq _DYNAMIC@GOTPCREL(%rip), %rax
+ movq __start_my_section@GOTPCREL(%rip), %rax
+ movq __stop_my_section@GOTPCREL(%rip), %rax
.size _start, .-_start
diff --git a/ld/testsuite/ld-x86-64/mov1a.d b/ld/testsuite/ld-x86-64/mov1a.d
index df156be..4ac6d7e 100644
--- a/ld/testsuite/ld-x86-64/mov1a.d
+++ b/ld/testsuite/ld-x86-64/mov1a.d
@@ -10,4 +10,6 @@ Disassembly of section .text:
#...
[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
+[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
+[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
#pass
diff --git a/ld/testsuite/ld-x86-64/mov1b.d b/ld/testsuite/ld-x86-64/mov1b.d
index 2f2f6f5..f112c1c 100644
--- a/ld/testsuite/ld-x86-64/mov1b.d
+++ b/ld/testsuite/ld-x86-64/mov1b.d
@@ -10,4 +10,6 @@ Disassembly of section .text:
#...
[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
+[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
+[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
#pass
diff --git a/ld/testsuite/ld-x86-64/mov1c.d b/ld/testsuite/ld-x86-64/mov1c.d
index a57e1c1..bb7bab1 100644
--- a/ld/testsuite/ld-x86-64/mov1c.d
+++ b/ld/testsuite/ld-x86-64/mov1c.d
@@ -10,4 +10,6 @@ Disassembly of section .text:
#...
[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
+[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
+[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
#pass
diff --git a/ld/testsuite/ld-x86-64/mov1d.d b/ld/testsuite/ld-x86-64/mov1d.d
index 955d33e..794a546 100644
--- a/ld/testsuite/ld-x86-64/mov1d.d
+++ b/ld/testsuite/ld-x86-64/mov1d.d
@@ -10,4 +10,6 @@ Disassembly of section .text:
#...
[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
+[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
+[ ]*[a-f0-9]+: 48 8b 05 ([0-9a-f]{2} ){4} * mov 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <_DYNAMIC\+0x[a-f0-9]+>
#pass