Fix up handling of hidden ifunc relocs on i?86

This commit is contained in:
Jakub Jelinek 2012-03-16 16:38:12 +01:00
parent e1e91fbd79
commit d601902f2a
3 changed files with 171 additions and 1 deletions

View File

@ -0,0 +1,141 @@
2012-03-09 H.J. Lu <hongjiu.lu@intel.com>
PR ld/13817
* bfd/elf32-i386.c (elf_i386_relocate_section): Restore
R_386_IRELATIVE.
* * elf64-x86-64.c (elf_x86_64_relocate_section): Restore
R_X86_64_IRELATIVE.
* ld-i386/pr13302.d: Updated.
* ld-x86-64/pr13082-5b.d: Likewise.
* ld-x86-64/pr13082-6a.d: Likewise.
* ld-x86-64/pr13082-6b.d: Likewise.
--- bfd/elf32-i386.c 21 Oct 2011 19:37:14 -0000 1.265
+++ bfd/elf32-i386.c 9 Mar 2012 16:28:36 -0000 1.266
@@ -3257,7 +3257,6 @@ elf_i386_relocate_section (bfd *output_b
bfd_byte *loc;
asection *sreloc;
bfd_vma offset;
- bfd_boolean relocate;
/* Need a dynamic relocation to get the real function
adddress. */
@@ -3278,14 +3277,15 @@ elf_i386_relocate_section (bfd *output_b
|| info->executable)
{
/* This symbol is resolved locally. */
- outrel.r_info = ELF32_R_INFO (0, R_386_RELATIVE);
- relocate = TRUE;
+ outrel.r_info = ELF32_R_INFO (0, R_386_IRELATIVE);
+ bfd_put_32 (output_bfd,
+ (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset),
+ contents + offset);
}
else
- {
- outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
- relocate = FALSE;
- }
+ outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
sreloc = htab->elf.irelifunc;
loc = sreloc->contents;
@@ -3298,8 +3298,7 @@ elf_i386_relocate_section (bfd *output_b
we need to include the symbol value so that it
becomes an addend for the dynamic reloc. For an
internal symbol, we have updated addend. */
- if (! relocate)
- continue;
+ continue;
}
/* FALLTHROUGH */
case R_386_PC32:
--- bfd/elf64-x86-64.c 6 Mar 2012 20:15:56 -0000 1.248
+++ bfd/elf64-x86-64.c 9 Mar 2012 16:28:36 -0000 1.249
@@ -3156,7 +3156,6 @@ elf_x86_64_relocate_section (bfd *output
{
Elf_Internal_Rela outrel;
asection *sreloc;
- bfd_boolean relocate;
/* Need a dynamic relocation to get the real function
address. */
@@ -3176,15 +3175,15 @@ elf_x86_64_relocate_section (bfd *output
|| info->executable)
{
/* This symbol is resolved locally. */
- outrel.r_info = htab->r_info (0, R_X86_64_RELATIVE);
- outrel.r_addend = relocation;
- relocate = TRUE;
+ outrel.r_info = htab->r_info (0, R_X86_64_IRELATIVE);
+ outrel.r_addend = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
}
else
{
outrel.r_info = htab->r_info (h->dynindx, r_type);
outrel.r_addend = 0;
- relocate = FALSE;
}
sreloc = htab->elf.irelifunc;
@@ -3195,8 +3194,7 @@ elf_x86_64_relocate_section (bfd *output
we need to include the symbol value so that it
becomes an addend for the dynamic reloc. For an
internal symbol, we have updated addend. */
- if (! relocate)
- continue;
+ continue;
}
/* FALLTHROUGH */
case R_X86_64_PC32:
--- ld/testsuite/ld-i386/pr13302.d 21 Oct 2011 19:37:15 -0000 1.1
+++ ld/testsuite/ld-i386/pr13302.d 9 Mar 2012 16:28:37 -0000 1.2
@@ -5,7 +5,7 @@
Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name
-[0-9a-f]+ +[0-9a-f]+ +R_386_RELATIVE +
+[0-9a-f]+ +[0-9a-f]+ +R_386_IRELATIVE +
Relocation section '.rel.plt' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name
--- ld/testsuite/ld-x86-64/pr13082-5b.d 21 Oct 2011 19:37:15 -0000 1.2
+++ ld/testsuite/ld-x86-64/pr13082-5b.d 9 Mar 2012 16:28:38 -0000 1.3
@@ -6,7 +6,7 @@
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
--- ld/testsuite/ld-x86-64/pr13082-6a.d 21 Oct 2011 19:37:15 -0000 1.2
+++ ld/testsuite/ld-x86-64/pr13082-6a.d 9 Mar 2012 16:28:38 -0000 1.3
@@ -6,7 +6,7 @@
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
--- ld/testsuite/ld-x86-64/pr13082-6b.d 21 Oct 2011 19:37:15 -0000 1.2
+++ ld/testsuite/ld-x86-64/pr13082-6b.d 9 Mar 2012 16:28:38 -0000 1.3
@@ -6,7 +6,7 @@
Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend
-[0-9a-f]+ +[0-9a-f]+ +R_X86_64_RELATIVE +[0-9a-f]+
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_IRELATIVE +[0-9a-f]+
Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries:
Offset Info Type Sym. Value Symbol's Name \+ Addend

View File

@ -13,3 +13,23 @@ index 698702b..1d429cf 100644
[@option{-p}|@option{--no-params}]
[@option{-t}|@option{--types}]
[@option{-i}|@option{--no-verbose}]
diff -rup a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
--- a/binutils/doc/binutils.texi 2012-03-14 10:19:44.256863358 -0600
+++ b/binutils/doc/binutils.texi 2012-03-14 10:20:15.077695863 -0600
@@ -2946,14 +2946,14 @@ characters trailing after a mangled name
@table @env
@item -_
-@itemx --strip-underscores
+@itemx --strip-underscore
On some systems, both the C and C++ compilers put an underscore in front
of every name. For example, the C name @code{foo} gets the low-level
name @code{_foo}. This option removes the initial underscore. Whether
@command{c++filt} removes the underscore by default is target dependent.
@item -n
-@itemx --no-strip-underscores
+@itemx --no-strip-underscore
Do not remove the initial underscore.
@item -p

View File

@ -17,7 +17,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.22.52.0.1
Release: 8%{?dist}
Release: 10%{?dist}
License: GPLv3+
Group: Development/Tools
URL: http://sources.redhat.com/binutils
@ -47,6 +47,8 @@ Patch11: binutils-2.22.52.0.1-relro-on-by-default.patch
Patch12: binutils-2.22.52.0.1-x86_64-hidden-ifunc.patch
# From upstream
Patch13: binutils-2.22.52.0.1-tsx.patch
# From upstream
Patch14: binutils-2.22.52.0.1-hidden-ifunc.patch
%define gold_arches %ix86 x86_64
@ -152,6 +154,7 @@ using libelf instead of BFD.
%endif
%patch12 -p0 -b .x86_64-hidden-ifunc~
%patch13 -p0 -b .tsx~
%patch14 -p0 -b .hidden-ifunc~
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -446,6 +449,12 @@ exit 0
%endif # %{isnative}
%changelog
* Fri Mar 16 2012 Jakub Jelinek <jakub@redhat.com> - 2.22.52.0.1-10
- Fix up handling of hidden ifunc relocs on i?86
* Wed Mar 13 2012 Jeff Law <law@redhat.com> - 2.22.52.0.1-9
- Fix c++filt docs (2nd instance) (#797752)
* Wed Mar 07 2012 Jakub Jelinek <jakub@redhat.com> - 2.22.52.0.1-8
- Fix up handling of hidden ifunc relocs on x86_64
- Add Intel TSX support