aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2011-01-06 18:45:05 +0000
committerH.J. Lu <hjl.tools@gmail.com>2011-01-06 18:45:05 +0000
commit3db2e7dda697d71311d698f21d7c65b8ec1774ca (patch)
tree673b7abbfab3b1b454a5d9677950f0a919ca83d1 /ld
parentccfc3d6e06d5b9d2ebd8b8e4239f1313e33f40ac (diff)
downloadgdb-3db2e7dda697d71311d698f21d7c65b8ec1774ca.zip
gdb-3db2e7dda697d71311d698f21d7c65b8ec1774ca.tar.gz
gdb-3db2e7dda697d71311d698f21d7c65b8ec1774ca.tar.bz2
Handle STT_GNU_IFUNC symols when building shared library.
bfd/ 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-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/ChangeLog20
-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, 172 insertions, 2 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 0b23082..c379f99 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,23 @@
+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-01-03 H.J. Lu <hongjiu.lu@intel.com>
* ld-x86-64/dummy.s: New.
diff --git a/ld/testsuite/ld-ifunc/ifunc-10-i386.s b/ld/testsuite/ld-ifunc/ifunc-10-i386.s
index 8411e81..76c5bef 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 ea6f8c2..11e29b5 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 06f5924..e0e4740 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 70d4fbf..8525419 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 0000000..de14181
--- /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 0000000..840302f
--- /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 0000000..40f07c3
--- /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 0000000..491684b
--- /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 0000000..162c3e4
--- /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 0000000..d0c0647
--- /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 0000000..eb893af
--- /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 0000000..5bfc9e0
--- /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 0000000..3560394
--- /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 0000000..3560394
--- /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