summaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-05-25 17:41:32 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-05-25 17:41:32 +0000
commit946593d19f203b02efd45b5102dd2787d9418e24 (patch)
tree5988de1a80f005860c0712a8679edb872e9063de /ld
parentf6cc7b1a4ec26e3f629949c4834945d6bcbc7267 (diff)
downloadbinutils-redhat-946593d19f203b02efd45b5102dd2787d9418e24.tar.gz
Handle STT_GNU_IFUNC symols when building shared library.
bfd/ 2012-05-25 H.J. Lu <hongjiu.lu@intel.com> Backport from mainline 2012-01-06 H.J. Lu <hongjiu.lu@intel.com> PR ld/12366 PR ld/12371 * elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Properly handle symbols marked with regular reference, but not non-GOT reference when building shared library. * elf32-i386.c (elf_i386_gc_sweep_hook): Properly handle local and global STT_GNU_IFUNC symols when building shared library. * elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise. ld/testsuite/ 2012-05-25 H.J. Lu <hongjiu.lu@intel.com> Backport from mainline 2012-01-06 H.J. Lu <hongjiu.lu@intel.com> PR ld/12366 PR ld/12371 * ld-ifunc/ifunc-10-i386.s: Add more tests. * ld-ifunc/ifunc-10-x86-64.s: Likewise. * ld-ifunc/ifunc-11-i386.s: Likewise. * ld-ifunc/ifunc-11-x86-64.s: Likewise. * ld-ifunc/ifunc-12-i386.d: New. * ld-ifunc/ifunc-12-i386.s: Likewise. * ld-ifunc/ifunc-12-x86-64.d: Likewise. * ld-ifunc/ifunc-12-x86-64.s: Likewise. * ld-ifunc/ifunc-13-i386.d: Likewise. * ld-ifunc/ifunc-13-x86-64.d: Likewise. * ld-ifunc/ifunc-13a-i386.s: Likewise. * ld-ifunc/ifunc-13a-x86-64.s: Likewise. * ld-ifunc/ifunc-13b-i386.s: Likewise. * ld-ifunc/ifunc-13b-x86-64.s: Likewise.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog23
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-10-i386.s6
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-10-x86-64.s5
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-11-i386.s10
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-11-x86-64.s5
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-12-i386.d6
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-12-i386.s25
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-12-x86-64.d6
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-12-x86-64.s24
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-13-i386.d19
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-13-x86-64.d18
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-13a-i386.s10
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s10
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-13b-i386.s5
-rw-r--r--ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s5
15 files changed, 175 insertions, 2 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 8c7d51570f..4dfdd57855 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,26 @@
+2012-05-25 H.J. Lu <hongjiu.lu@intel.com>
+
+ Backport from mainline
+ 2012-01-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/12366
+ PR ld/12371
+ * ld-ifunc/ifunc-10-i386.s: Add more tests.
+ * ld-ifunc/ifunc-10-x86-64.s: Likewise.
+ * ld-ifunc/ifunc-11-i386.s: Likewise.
+ * ld-ifunc/ifunc-11-x86-64.s: Likewise.
+
+ * ld-ifunc/ifunc-12-i386.d: New.
+ * ld-ifunc/ifunc-12-i386.s: Likewise.
+ * ld-ifunc/ifunc-12-x86-64.d: Likewise.
+ * ld-ifunc/ifunc-12-x86-64.s: Likewise.
+ * ld-ifunc/ifunc-13-i386.d: Likewise.
+ * ld-ifunc/ifunc-13-x86-64.d: Likewise.
+ * ld-ifunc/ifunc-13a-i386.s: Likewise.
+ * ld-ifunc/ifunc-13a-x86-64.s: Likewise.
+ * ld-ifunc/ifunc-13b-i386.s: Likewise.
+ * ld-ifunc/ifunc-13b-x86-64.s: Likewise.
+
2011-05-15 Richard Sandiford <rdsandiford@googlemail.com>
* lib/ld-lib.exp (run_ld_link_tests): Simplify pass/fail logic.
diff --git a/ld/testsuite/ld-ifunc/ifunc-10-i386.s b/ld/testsuite/ld-ifunc/ifunc-10-i386.s
index 8411e815eb..76c5bef9bd 100644
--- a/ld/testsuite/ld-ifunc/ifunc-10-i386.s
+++ b/ld/testsuite/ld-ifunc/ifunc-10-i386.s
@@ -6,6 +6,8 @@ foo:
movl ifunc@GOTOFF(%ecx), %eax
call ifunc@PLT
call ifunc
+ movl xxx@GOT(%ecx), %eax
+ movl xxx, %eax
ret
.section .text.bar,"ax",@progbits
@@ -18,3 +20,7 @@ bar:
.type ifunc, @gnu_indirect_function
ifunc:
ret
+
+ .section .data.foo,"aw",@progbits
+xxx:
+ .long ifunc
diff --git a/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s b/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s
index ea6f8c2d16..11e29b52b4 100644
--- a/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s
+++ b/ld/testsuite/ld-ifunc/ifunc-10-x86-64.s
@@ -6,6 +6,7 @@ foo:
movl ifunc(%rip), %eax
call ifunc@PLT
call ifunc
+ movl xxx(%rip), %eax
ret
.section .text.bar,"ax",@progbits
@@ -18,3 +19,7 @@ bar:
.type ifunc, @gnu_indirect_function
ifunc:
ret
+
+ .section .data.foo,"aw",@progbits
+xxx:
+ .quad ifunc
diff --git a/ld/testsuite/ld-ifunc/ifunc-11-i386.s b/ld/testsuite/ld-ifunc/ifunc-11-i386.s
index 06f592400e..e0e4740795 100644
--- a/ld/testsuite/ld-ifunc/ifunc-11-i386.s
+++ b/ld/testsuite/ld-ifunc/ifunc-11-i386.s
@@ -3,9 +3,11 @@
foo:
.global foo
movl ifunc@GOT(%ecx), %eax
- movl ifunc@GOTOFF(%ecx), %eax
+ movl ifunc@GOTOFF(%ecx), %eax
call ifunc@PLT
call ifunc
+ movl xxx@GOT(%ecx), %eax
+ movl xxx, %eax
ret
.section .text.bar,"ax",@progbits
@@ -16,6 +18,10 @@ bar:
.section .text.ifunc,"ax",@progbits
.type ifunc, @gnu_indirect_function
- .global ifunc
+ .global ifunc
ifunc:
ret
+
+ .section .data.foo,"aw",@progbits
+xxx:
+ .long ifunc
diff --git a/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s b/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s
index 70d4fbfdb1..8525419b52 100644
--- a/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s
+++ b/ld/testsuite/ld-ifunc/ifunc-11-x86-64.s
@@ -6,6 +6,7 @@ foo:
movl ifunc(%rip), %eax
call ifunc@PLT
call ifunc
+ movl xxx(%rip), %eax
ret
.section .text.bar,"ax",@progbits
@@ -19,3 +20,7 @@ bar:
.global ifunc
ifunc:
ret
+
+ .section .data.foo,"aw",@progbits
+xxx:
+ .quad ifunc
diff --git a/ld/testsuite/ld-ifunc/ifunc-12-i386.d b/ld/testsuite/ld-ifunc/ifunc-12-i386.d
new file mode 100644
index 0000000000..de1418154e
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-12-i386.d
@@ -0,0 +1,6 @@
+#ld: -shared -m elf_i386 -e bar --gc-sections
+#as: --32
+#readelf: -r --wide
+#target: x86_64-*-* i?86-*-*
+
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-ifunc/ifunc-12-i386.s b/ld/testsuite/ld-ifunc/ifunc-12-i386.s
new file mode 100644
index 0000000000..840302f3ef
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-12-i386.s
@@ -0,0 +1,25 @@
+ .section .text.foo,"ax",@progbits
+ .type foo, @function
+foo:
+ movl ifunc@GOT(%ecx), %eax
+ movl ifunc@GOTOFF(%ecx), %eax
+ call ifunc@PLT
+ call ifunc
+ movl xxx@GOT(%ecx), %eax
+ movl xxx, %eax
+ ret
+
+ .section .text.bar,"ax",@progbits
+ .type bar, @function
+bar:
+ .global bar
+ ret
+
+ .section .text.ifunc,"ax",@progbits
+ .type ifunc, @gnu_indirect_function
+ifunc:
+ ret
+
+ .section .data.foo,"aw",@progbits
+xxx:
+ .long ifunc
diff --git a/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d
new file mode 100644
index 0000000000..40f07c38bb
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-12-x86-64.d
@@ -0,0 +1,6 @@
+#ld: -shared -m elf_x86_64 -e bar --gc-sections
+#as: --64
+#readelf: -r --wide
+#target: x86_64-*-*
+
+There are no relocations in this file.
diff --git a/ld/testsuite/ld-ifunc/ifunc-12-x86-64.s b/ld/testsuite/ld-ifunc/ifunc-12-x86-64.s
new file mode 100644
index 0000000000..491684bdc2
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-12-x86-64.s
@@ -0,0 +1,24 @@
+ .section .text.foo,"ax",@progbits
+ .type foo, @function
+foo:
+ movl ifunc@GOTPCREL(%rip), %eax
+ movl ifunc(%rip), %eax
+ call ifunc@PLT
+ call ifunc
+ movl xxx(%rip), %eax
+ ret
+
+ .section .text.bar,"ax",@progbits
+ .type bar, @function
+bar:
+ .global bar
+ ret
+
+ .section .text.ifunc,"ax",@progbits
+ .type ifunc, @gnu_indirect_function
+ifunc:
+ ret
+
+ .section .data.foo,"aw",@progbits
+xxx:
+ .quad ifunc
diff --git a/ld/testsuite/ld-ifunc/ifunc-13-i386.d b/ld/testsuite/ld-ifunc/ifunc-13-i386.d
new file mode 100644
index 0000000000..162c3e40f9
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-13-i386.d
@@ -0,0 +1,19 @@
+#source: ifunc-13a-i386.s
+#source: ifunc-13b-i386.s
+#ld: -shared -m elf_i386 -z nocombreloc
+#as: --32
+#readelf: -r --wide
+#target: x86_64-*-* i?86-*-*
+
+Relocation section '.rel.got' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+#...
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_GLOB_DAT[ ]+ifunc\(\)[ ]+ifunc
+#...
+Relocation section '.rel.ifunc' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_32[ ]+ifunc\(\)[ ]+ifunc
+#...
+Relocation section '.rel.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_JUMP_SLOT[ ]+ifunc\(\)[ ]+ifunc
diff --git a/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d
new file mode 100644
index 0000000000..d0c064773a
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-13-x86-64.d
@@ -0,0 +1,18 @@
+#source: ifunc-13a-x86-64.s
+#source: ifunc-13b-x86-64.s
+#ld: -shared -m elf_x86_64 -z nocombreloc
+#as: --64
+#readelf: -r --wide
+#target: x86_64-*-*
+
+Relocation section '.rela.got' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_GLOB_DAT[ ]+ifunc\(\)[ ]+ifunc \+ 0
+#...
+Relocation section '.rela.ifunc' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_64[ ]+ifunc\(\)[ ]+ifunc \+ 0
+#...
+Relocation section '.rela.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_JUMP_SLOT[ ]+ifunc\(\)[ ]+ifunc \+ 0
diff --git a/ld/testsuite/ld-ifunc/ifunc-13a-i386.s b/ld/testsuite/ld-ifunc/ifunc-13a-i386.s
new file mode 100644
index 0000000000..eb893af3d3
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-13a-i386.s
@@ -0,0 +1,10 @@
+ .text
+ .type foo, @function
+ .global
+foo:
+ movl xxx@GOT(%ebx), %eax
+ ret
+
+ .data
+xxx:
+ .long ifunc
diff --git a/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s b/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s
new file mode 100644
index 0000000000..5bfc9e03b0
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-13a-x86-64.s
@@ -0,0 +1,10 @@
+ .text
+ .type foo, @function
+ .global
+foo:
+ movl xxx(%rip), %eax
+ ret
+
+ .data
+xxx:
+ .quad ifunc
diff --git a/ld/testsuite/ld-ifunc/ifunc-13b-i386.s b/ld/testsuite/ld-ifunc/ifunc-13b-i386.s
new file mode 100644
index 0000000000..3560394298
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-13b-i386.s
@@ -0,0 +1,5 @@
+ .text
+ .type ifunc, @gnu_indirect_function
+ .globl ifunc
+ifunc:
+ ret
diff --git a/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s b/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s
new file mode 100644
index 0000000000..3560394298
--- /dev/null
+++ b/ld/testsuite/ld-ifunc/ifunc-13b-x86-64.s
@@ -0,0 +1,5 @@
+ .text
+ .type ifunc, @gnu_indirect_function
+ .globl ifunc
+ifunc:
+ ret