This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [committed, PATCH] PR ld/18841: Data relocations with IFUNC symbols can lead to segfault


On Tue, Aug 18, 2015 at 09:52:16AM -0700, H.J. Lu wrote:
> elf_XXX_reloc_type_class should return reloc_class_ifunc for relocation
> against STT_GNU_IFUNC symbol.
> 
> bfd/
> 
> 	PR ld/18841
> 	* elf-bfd.h (elf_link_hash_table): Add dynsym.
> 	* elf32-i386.c (elf_i386_reloc_type_class): Return
> 	reloc_class_ifunc for relocation against STT_GNU_IFUNC symbol.
> 	* elf64-x86-64.c (elf_x86_64_reloc_type_class): Likewise.
> 	* elflink.c (_bfd_elf_link_create_dynamic_sections): Set dynsym.
> 	(bfd_elf_size_dynsym_hash_dynstr): Use dynsym.
> 	(elf_final_link_info): Remove dynsym_sec.
> 	(elf_link_output_extsym): Replace dynsym_sec with dynsym.
> 	(bfd_elf_final_link): Remove reference to dynsym_sec.  Replace
> 	dynsym_sec with dynsym.
> 
> ld/testsuite/
> 
> 	PR ld/18841
> 	* ld-ifunc/ifunc.exp: Add a test for PR ld/18841.
> 	* ld-ifunc/pr18841.out: New file.
> 	* ld-ifunc/pr18841a.c: Likewise.
> 	* ld-ifunc/pr18841b.c: Likewise.

I checked in this patch to add another test.

H.J.
---
	PR ld/18841
	* ld-ifunc/ifunc.exp: Add another test for PR ld/18841.
	* ld-ifunc/pr18841c.c: New file.
---
 ld/testsuite/ChangeLog           |  6 ++++++
 ld/testsuite/ld-ifunc/ifunc.exp  | 26 +++++++++++++++++++++-----
 ld/testsuite/ld-ifunc/pr18841c.c | 17 +++++++++++++++++
 3 files changed, 44 insertions(+), 5 deletions(-)
 create mode 100644 ld/testsuite/ld-ifunc/pr18841c.c

diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index b8546d0..ce3b310 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,6 +1,12 @@
 2015-08-18  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/18841
+	* ld-ifunc/ifunc.exp: Add another test for PR ld/18841.
+	* ld-ifunc/pr18841c.c: New file.
+
+2015-08-18  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR ld/18841
 	* ld-ifunc/ifunc.exp: Add a test for PR ld/18841.
 	* ld-ifunc/pr18841.out: New file.
 	* ld-ifunc/pr18841a.c: Likewise.
diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp
index b0f6de0..d3bebdd 100644
--- a/ld/testsuite/ld-ifunc/ifunc.exp
+++ b/ld/testsuite/ld-ifunc/ifunc.exp
@@ -473,12 +473,20 @@ run_cc_link_tests [list \
 	"libpr18808.so" \
     ] \
     [list \
-	"Build libpr18841.so" \
+	"Build libpr18841b.so" \
 	"-shared" \
 	"-fPIC -O0 -g" \
 	{ pr18841b.c } \
 	{} \
-	"libpr18841.so" \
+	"libpr18841b.so" \
+    ] \
+    [list \
+	"Build libpr18841c.so" \
+	"-shared" \
+	"-fPIC -O0 -g" \
+	{ pr18841c.c } \
+	{} \
+	"libpr18841c.so" \
     ] \
 ]
 
@@ -492,11 +500,19 @@ run_ld_link_exec_tests [] [list \
 	"pr18808.out" \
     ] \
     [list \
-	"Run pr18841" \
-	"tmpdir/libpr18841.so" \
+	"Run pr18841 with libpr18841b.so" \
+	"tmpdir/libpr18841b.so" \
+	"" \
+	{ pr18841a.c } \
+	"pr18841b" \
+	"pr18841.out" \
+    ] \
+    [list \
+	"Run pr18841 with libpr18841c.so" \
+	"tmpdir/libpr18841c.so" \
 	"" \
 	{ pr18841a.c } \
-	"pr18841" \
+	"pr18841c" \
 	"pr18841.out" \
     ] \
 ]
diff --git a/ld/testsuite/ld-ifunc/pr18841c.c b/ld/testsuite/ld-ifunc/pr18841c.c
new file mode 100644
index 0000000..03a6354
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/pr18841c.c
@@ -0,0 +1,17 @@
+void foo() __attribute__((ifunc("resolve_foo")));
+
+static void foo_impl() {}
+extern void zoo(void);
+void (*pz)(void) = zoo;
+
+void test()
+{
+  void (*pg)(void) = foo;
+  pg();
+}
+
+static void* resolve_foo()
+{
+  pz();
+  return foo_impl;
+}
-- 
2.4.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]