aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2014-08-27 07:59:48 -0700
committerH.J. Lu <hjl.tools@gmail.com>2014-08-27 07:59:48 -0700
commitc8831961f9fecf81e90fe7c8c94b47e01ee64662 (patch)
tree22fb029acee0d6388275d2628613dd74bfaa2063
parent29a9f53e857c5d55df852d0a5d5c41a9247c16a2 (diff)
downloadgdb-c8831961f9fecf81e90fe7c8c94b47e01ee64662.zip
gdb-c8831961f9fecf81e90fe7c8c94b47e01ee64662.tar.gz
gdb-c8831961f9fecf81e90fe7c8c94b47e01ee64662.tar.bz2
Use bfd_is_abs_section to check discarded input section
bfd/ PR ld/17306 * elf32-i386.c (elf_i386_convert_mov_to_lea): Use bfd_is_abs_section to check discarded input section. * elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise. ld/testsuite/ PR ld/17306 * ld-i386/i386.exp (i386tests): Add tests for PR ld/17306. * ld-x86-64/x86-64.exp (x86_64tests): Likewise. * ld-i386/pr17306a.s: New file. * ld-i386/pr17306b.s: Likewise. * ld-x86-64/pr17306a.s: Likewise. * ld-x86-64/pr17306b.s: Likewise.
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elf32-i386.c2
-rw-r--r--bfd/elf64-x86-64.c2
-rw-r--r--ld/testsuite/ChangeLog11
-rw-r--r--ld/testsuite/ld-i386/i386.exp4
-rw-r--r--ld/testsuite/ld-i386/pr17306a.s9
-rw-r--r--ld/testsuite/ld-i386/pr17306b.s2
-rw-r--r--ld/testsuite/ld-x86-64/pr17306a.s9
-rw-r--r--ld/testsuite/ld-x86-64/pr17306b.s2
-rw-r--r--ld/testsuite/ld-x86-64/x86-64.exp4
10 files changed, 50 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3f81ba4..bba079f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,12 @@
2014-08-27 H.J. Lu <hongjiu.lu@intel.com>
+ PR ld/17306
+ * elf32-i386.c (elf_i386_convert_mov_to_lea): Use bfd_is_abs_section
+ to check discarded input section.
+ * elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.
+
+2014-08-27 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/17313
* elflink.c (elf_link_add_object_symbols): Don't attach dynamic
sections to input from ld --just-symbols.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 7c4b4bb..a00d47c 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -2533,7 +2533,7 @@ elf_i386_convert_mov_to_lea (bfd *abfd, asection *sec,
/* Nothing to do if there are no codes, no relocations or no output. */
if ((sec->flags & (SEC_CODE | SEC_RELOC)) != (SEC_CODE | SEC_RELOC)
|| sec->reloc_count == 0
- || discarded_section (sec))
+ || bfd_is_abs_section (sec->output_section))
return TRUE;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index f71291e..9d18a54 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -2777,7 +2777,7 @@ elf_x86_64_convert_mov_to_lea (bfd *abfd, asection *sec,
/* Nothing to do if there are no codes, no relocations or no output. */
if ((sec->flags & (SEC_CODE | SEC_RELOC)) != (SEC_CODE | SEC_RELOC)
|| sec->reloc_count == 0
- || discarded_section (sec))
+ || bfd_is_abs_section (sec->output_section))
return TRUE;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index a7bde81..51355ef 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,5 +1,16 @@
2014-08-27 H.J. Lu <hongjiu.lu@intel.com>
+ PR ld/17306
+ * ld-i386/i386.exp (i386tests): Add tests for PR ld/17306.
+ * ld-x86-64/x86-64.exp (x86_64tests): Likewise.
+
+ * ld-i386/pr17306a.s: New file.
+ * ld-i386/pr17306b.s: Likewise.
+ * ld-x86-64/pr17306a.s: Likewise.
+ * ld-x86-64/pr17306b.s: Likewise.
+
+2014-08-27 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/17313
* ld-i386/i386.exp (i386tests): Add tests for PR ld/17313.
* ld-x86-64/x86-64.exp (x86_64tests): Likewise.
diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp
index 875c816..30be98a 100644
--- a/ld/testsuite/ld-i386/i386.exp
+++ b/ld/testsuite/ld-i386/i386.exp
@@ -187,6 +187,10 @@ set i386tests {
"--32" {zero.s} {} ""}
{"PR ld/17313 (2)" "-melf_i386 -shared --just-symbols=tmpdir/zero.o" ""
"--32" {lea1.s} {} "libpr17313.so"}
+ {"PR ld/17306 (1)" "-melf_i386" ""
+ "--32" {pr17306b.s} {} ""}
+ {"PR ld/17306 (2)" "-melf_i386 -shared -Bsymbolic --just-symbols=tmpdir/pr17306b.o" ""
+ "--32" {pr17306a.s} {} "libpr17306.so"}
}
# So as to avoid rewriting every last test case here in a nacl variant,
diff --git a/ld/testsuite/ld-i386/pr17306a.s b/ld/testsuite/ld-i386/pr17306a.s
new file mode 100644
index 0000000..fe2d49c
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr17306a.s
@@ -0,0 +1,9 @@
+ .data
+ .globl foo
+foo:
+ .long -1
+ .text
+ .globl _start
+ .type _start, @function
+_start:
+ pushl foo@GOT(%ebx)
diff --git a/ld/testsuite/ld-i386/pr17306b.s b/ld/testsuite/ld-i386/pr17306b.s
new file mode 100644
index 0000000..2f84e52
--- /dev/null
+++ b/ld/testsuite/ld-i386/pr17306b.s
@@ -0,0 +1,2 @@
+ .text
+ movl foo@GOT(%ebx), %eax
diff --git a/ld/testsuite/ld-x86-64/pr17306a.s b/ld/testsuite/ld-x86-64/pr17306a.s
new file mode 100644
index 0000000..a2ee48d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr17306a.s
@@ -0,0 +1,9 @@
+ .data
+ .globl foo
+foo:
+ .quad -1
+ .text
+ .globl _start
+ .type _start, @function
+_start:
+ pushq foo@GOTPCREL(%rip)
diff --git a/ld/testsuite/ld-x86-64/pr17306b.s b/ld/testsuite/ld-x86-64/pr17306b.s
new file mode 100644
index 0000000..c63bd2a
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr17306b.s
@@ -0,0 +1,2 @@
+ .text
+ movq foo@GOTPCREL(%rip), %rax
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index a9af367..54786a7 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -140,6 +140,10 @@ set x86_64tests {
"--64" {dummy.s} {} ""}
{"PR ld/17313 (2)" "-melf_x86_64 -shared --just-symbols=tmpdir/dummy.o" ""
"--64" {lea1.s} {} "libpr17313.so"}
+ {"PR ld/17306 (1)" "-melf_x86_64" ""
+ "--64" {pr17306b.s} {} ""}
+ {"PR ld/17306 (2)" "-melf_x86_64 -shared -Bsymbolic --just-symbols=tmpdir/pr17306b.o" ""
+ "--64" {pr17306a.s} {} "libpr17306.so"}
}
# So as to avoid rewriting every last test case here in a nacl variant,