Use bfd_is_abs_section to check discarded input section
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 27 Aug 2014 14:59:48 +0000 (07:59 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 27 Aug 2014 14:59:48 +0000 (07:59 -0700)
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.

bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/pr17306a.s [new file with mode: 0644]
ld/testsuite/ld-i386/pr17306b.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr17306a.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/pr17306b.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index 3f81ba49c9839f8ec47c8399ee2395f9ce5dd50e..bba079f481f4fc36bf3f04ef1ed38d870b13ee30 100644 (file)
@@ -1,3 +1,10 @@
+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
index 7c4b4bb918dfe37172264e8fb11903adfcedf2c9..a00d47cb5b8cbb850994fb9a9ba98d2261d07da1 100644 (file)
@@ -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;
index f71291e87fa16e362c1160c22224fa4ba00077ea..9d18a545a9f7f313db81e7d23bb8bc8e13ccf519 100644 (file)
@@ -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;
index a7bde81a7c857a51772f9c3726f0d0e05ffdf12d..51355efc7d7411244424d7adc7cebc48cb00747e 100644 (file)
@@ -1,3 +1,14 @@
+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
index 875c816b43a834aab4467b2d6a223fae845bb12d..30be98a3e5c87bef149325494478a20746cd54bb 100644 (file)
@@ -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 (file)
index 0000000..fe2d49c
--- /dev/null
@@ -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 (file)
index 0000000..2f84e52
--- /dev/null
@@ -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 (file)
index 0000000..a2ee48d
--- /dev/null
@@ -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 (file)
index 0000000..c63bd2a
--- /dev/null
@@ -0,0 +1,2 @@
+       .text
+       movq    foo@GOTPCREL(%rip), %rax
index a9af367e12f85060862482b7bb3fe64dc8a60490..54786a78a22d3196b186f629aabbb3b175f297af 100644 (file)
@@ -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,