This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: Support ld -r on local STT_GNU_IFUNC symbols
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sources dot redhat dot com
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Thu, 16 Jul 2009 07:24:06 -0700
- Subject: PATCH: Support ld -r on local STT_GNU_IFUNC symbols
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
I checked in this patch to support ld -r on local STT_GNU_IFUNC symbols
H.J.
----
bfd/
2009-07-16 H.J. Lu <hongjiu.lu@intel.com>
* elf32-i386.c (elf_i386_relocate_section): Don't get local
STT_GNU_IFUNC symbol for relocatable link.
* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
ld/testsuite/
2009-07-16 H.J. Lu <hongjiu.lu@intel.com>
* ld-ifunc/ifunc-5r-local-i386.d: New.
* ld-ifunc/ifunc-5r-local-x86-64.d: Likewise.
Index: ld/testsuite/ld-ifunc/ifunc-5r-local-i386.d
===================================================================
--- ld/testsuite/ld-ifunc/ifunc-5r-local-i386.d (revision 0)
+++ ld/testsuite/ld-ifunc/ifunc-5r-local-i386.d (revision 0)
@@ -0,0 +1,11 @@
+#source: ifunc-5-local-i386.s
+#ld: -r -m elf_i386
+#as: --32
+#readelf: -r --wide
+#target: x86_64-*-* i?86-*-*
+
+Relocation section '.rel.text' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_GOTPC[ ]+0+[ ]+_GLOBAL_OFFSET_TABLE_[ ]*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_PLT32[ ]+foo\(\)[ ]+foo[ ]*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_GOT32[ ]+foo\(\)[ ]+foo[ ]*
Index: ld/testsuite/ld-ifunc/ifunc-5r-local-x86-64.d
===================================================================
--- ld/testsuite/ld-ifunc/ifunc-5r-local-x86-64.d (revision 0)
+++ ld/testsuite/ld-ifunc/ifunc-5r-local-x86-64.d (revision 0)
@@ -0,0 +1,10 @@
+#source: ifunc-5-local-x86-64.s
+#as: --64
+#ld: -r -melf_x86_64
+#readelf: -r --wide
+#target: x86_64-*-*
+
+Relocation section '.rela.text' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_PLT32[ ]+foo\(\)[ ]+foo - 4
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_GOTPCREL[ ]+foo\(\)[ ]+foo - 4
Index: bfd/elf64-x86-64.c
===================================================================
--- bfd/elf64-x86-64.c (revision 6395)
+++ bfd/elf64-x86-64.c (working copy)
@@ -2612,7 +2612,8 @@ elf64_x86_64_relocate_section (bfd *outp
&sec, rel);
/* Relocate against local STT_GNU_IFUNC symbol. */
- if (ELF64_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
+ if (!info->relocatable
+ && ELF64_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
{
h = elf64_x86_64_get_local_sym_hash (htab, input_bfd,
rel, FALSE);
Index: bfd/elf32-i386.c
===================================================================
--- bfd/elf32-i386.c (revision 6395)
+++ bfd/elf32-i386.c (working copy)
@@ -2891,7 +2891,8 @@ elf_i386_relocate_section (bfd *output_b
break;
}
}
- else if (ELF32_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
+ else if (!info->relocatable
+ && ELF32_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)
{
/* Relocate against local STT_GNU_IFUNC symbol. */
h = elf_i386_get_local_sym_hash (htab, input_bfd,