Don't check undefined symbol for IFUNC reloc
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 15 Jun 2016 17:35:38 +0000 (10:35 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 16 Jun 2016 18:28:29 +0000 (11:28 -0700)
Since x86 elf_*_check_relocs is called after all symbols have been
resolved, there is no need to check undefined symbols for relocations
against IFUNC symbols.

bfd/

* elf32-i386.c (elf_i386_check_relocs): Don't check undefined
symbols for relocations against IFUNC symbols.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.

ld/

* testsuite/ld-i386/i386.exp: Run pr19636-2e-nacl.
* testsuite/ld-i386/pr19636-2e.d: Skip for NaCl targets.
Remove .rel.plt section.
* testsuite/ld-i386/pr19636-2e-nacl.d: New file.

bfd/elf32-i386.c
bfd/elf64-x86-64.c
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/pr19636-2e-nacl.d [new file with mode: 0644]
ld/testsuite/ld-i386/pr19636-2e.d

index a5197788386873f52ed8927685f79151261be2f2..2b7de3397f9fa7d01d3c1c5d8ff4ebc84600fa01 100644 (file)
@@ -2149,15 +2149,12 @@ elf_i386_check_relocs (bfd *abfd,
          if (eh != NULL && (sec->flags & SEC_CODE) != 0)
            eh->has_non_got_reloc = 1;
 do_relocation:
-         /* STT_GNU_IFUNC symbol must go through PLT even if it is
-            locally defined and undefined symbol may turn out to be
-            a STT_GNU_IFUNC symbol later.  */
+         /* We are called after all symbols have been resolved.  Only
+            relocation against STT_GNU_IFUNC symbol must go through
+            PLT.  */
          if (h != NULL
              && (bfd_link_executable (info)
-                 || ((h->type == STT_GNU_IFUNC
-                      || h->root.type == bfd_link_hash_undefweak
-                      || h->root.type == bfd_link_hash_undefined)
-                     && SYMBOLIC_BIND (info, h))))
+                 || h->type == STT_GNU_IFUNC))
            {
              /* If this reloc is in a read-only section, we might
                 need a copy reloc.  We can't check reliably at this
index 9044aab4c561c86f854f74e0a8d38900d242cac1..57a3c73b83a5fd5a2bc05cbfec4b69d2e8a9ca5d 100644 (file)
@@ -2541,15 +2541,12 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 pointer:
          if (eh != NULL && (sec->flags & SEC_CODE) != 0)
            eh->has_non_got_reloc = 1;
-         /* STT_GNU_IFUNC symbol must go through PLT even if it is
-            locally defined and undefined symbol may turn out to be
-            a STT_GNU_IFUNC symbol later.  */
+         /* We are called after all symbols have been resolved.  Only
+            relocation against STT_GNU_IFUNC symbol must go through
+            PLT.  */
          if (h != NULL
              && (bfd_link_executable (info)
-                 || ((h->type == STT_GNU_IFUNC
-                      || h->root.type == bfd_link_hash_undefweak
-                      || h->root.type == bfd_link_hash_undefined)
-                     && SYMBOLIC_BIND (info, h))))
+                 || h->type == STT_GNU_IFUNC))
            {
              /* If this reloc is in a read-only section, we might
                 need a copy reloc.  We can't check reliably at this
index 846892035dbb19406170242a5075e442ccf93115..98f0b1c73fe7e75ed24a417fa8cebd0d7226cd8b 100644 (file)
@@ -372,6 +372,7 @@ run_dump_test "pr19636-2c-nacl"
 run_dump_test "pr19636-2d"
 run_dump_test "pr19636-2d-nacl"
 run_dump_test "pr19636-2e"
+run_dump_test "pr19636-2e-nacl"
 run_dump_test "pr19636-3a"
 run_dump_test "pr19636-3b"
 run_dump_test "pr19636-3c"
diff --git a/ld/testsuite/ld-i386/pr19636-2e-nacl.d b/ld/testsuite/ld-i386/pr19636-2e-nacl.d
new file mode 100644 (file)
index 0000000..f791128
--- /dev/null
@@ -0,0 +1,21 @@
+#source: pr19636-2.s
+#as: --32 -mrelax-relocations=no
+#ld: -shared -Bsymbolic -m elf_i386
+#readelf : -r --wide --dyn-syms
+#target: i?86-*-nacl* x86_64-*-nacl*
+
+Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 3 entries:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +func
+[0-9a-f]+ +[0-9a-f]+ +R_386_PC32 +0+ +func
+[0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func
+
+Relocation section '\.rel\.plt' at offset [0x0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func
+
+Symbol table '\.dynsym' contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +WEAK +DEFAULT +UND +func
+#pass
index c985242718b4ee52a9c245b2f5920fcd12c7dc2d..148e3060a7f62de94a211f20dd5cbd49fedbbaef 100644 (file)
@@ -2,6 +2,7 @@
 #as: --32 -mrelax-relocations=no
 #ld: -shared -Bsymbolic -m elf_i386
 #readelf : -r --wide --dyn-syms
+#notarget: i?86-*-nacl* x86_64-*-nacl*
 
 Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 3 entries:
  +Offset +Info +Type +Sym. Value +Symbol's Name
@@ -9,10 +10,6 @@ Relocation section '\.rel\.dyn' at offset [0x0-9a-f]+ contains 3 entries:
 [0-9a-f]+ +[0-9a-f]+ +R_386_PC32 +0+ +func
 [0-9a-f]+ +[0-9a-f]+ +R_386_GLOB_DAT +0+ +func
 
-Relocation section '\.rel\.plt' at offset [0x0-9a-f]+ contains 1 entries:
- +Offset +Info +Type +Sym. Value +Symbol's Name
-[0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func
-
 Symbol table '\.dynsym' contains [0-9]+ entries:
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
 #...
This page took 0.032633 seconds and 4 git commands to generate.