bfd/
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 2 Jun 2009 17:31:42 +0000 (17:31 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 2 Jun 2009 17:31:42 +0000 (17:31 +0000)
2009-06-02  H.J. Lu  <hongjiu.lu@intel.com>

* elf32-i386.c (elf_i386_check_relocs): Increment
got.refcount for R_386_GOT32/R_386_GOTOFF relocations
against STT_GNU_IFUNC symbol.
(elf_i386_allocate_dynrelocs): Set got.refcount to 0 if
local STT_GNU_IFUNC definition is used.
(elf_i386_relocate_section): Handle got.offset != -1 for
R_386_GOT32/R_386_GOTOFF relocations against STT_GNU_IFUNC
symbol.

* elf64-x86-64.c (elf64_x86_64_check_relocs): Increment
got.refcount for R_X86_64_GOTPCREL/R_X86_64_GOTPCREL64
relocations against STT_GNU_IFUNC symbol.
(elf64_x86_64_allocate_dynrelocs): Set got.refcount to 0 if
local STT_GNU_IFUNC definition is used.
(elf64_x86_64_relocate_section): Handle got.offset != -1
for R_X86_64_GOTPCREL/R_X86_64_GOTPCREL64 relocations against
STT_GNU_IFUNC symbol.

ld/testsuite/

2009-06-02  H.J. Lu  <hongjiu.lu@intel.com>

* ld-ifunc/ifunc-5-i386.d: Renamed to ...
* ld-ifunc/ifunc-5a-i386.d: This.

* ld-ifunc/ifunc-5-x86-64.d: Renamed to ...
* ld-ifunc/ifunc-5a-x86-64.d: This.

* ld-ifunc/ifunc-5b-i386.d: New.
* ld-ifunc/ifunc-5b-x86-64.d: Likewise.
* ld-ifunc/ifunc-6a-i386.d: Likewise.
* ld-ifunc/ifunc-6a-x86-64.d: Likewise.
* ld-ifunc/ifunc-6b-i386.d: Likewise.
* ld-ifunc/ifunc-6b-x86-64.d: Likewise.
* ld-ifunc/ifunc-6-i386.s: Likewise.
* ld-ifunc/ifunc-6-x86-64.s: Likewise.
* ld-ifunc/ifunc-7a-i386.d: Likewise.
* ld-ifunc/ifunc-7a-x86-64.d: Likewise.
* ld-ifunc/ifunc-7b-i386.d: Likewise.
* ld-ifunc/ifunc-7b-x86-64.d: Likewise.
* ld-ifunc/ifunc-7-i386.s: Likewise.
* ld-ifunc/ifunc-7-x86-64.s: Likewise.

22 files changed:
bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
ld/testsuite/ChangeLog
ld/testsuite/ld-ifunc/ifunc-5-i386.d [deleted file]
ld/testsuite/ld-ifunc/ifunc-5-x86-64.d [deleted file]
ld/testsuite/ld-ifunc/ifunc-5a-i386.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-5a-x86-64.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-5b-i386.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-5b-x86-64.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-6-i386.s [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-6-x86-64.s [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-6a-i386.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-6a-x86-64.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-6b-i386.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-6b-x86-64.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-7-i386.s [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-7-x86-64.s [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-7a-i386.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-7a-x86-64.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-7b-i386.d [new file with mode: 0644]
ld/testsuite/ld-ifunc/ifunc-7b-x86-64.d [new file with mode: 0644]

index b7cf0effe0288e56d27aa37b30ad0d38657a96f7..77f080c9278c97a965cf9f74e880cd7f06ab70ff 100644 (file)
@@ -1,3 +1,23 @@
+2009-06-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf32-i386.c (elf_i386_check_relocs): Increment
+       got.refcount for R_386_GOT32/R_386_GOTOFF relocations
+       against STT_GNU_IFUNC symbol.
+       (elf_i386_allocate_dynrelocs): Set got.refcount to 0 if
+       local STT_GNU_IFUNC definition is used.
+       (elf_i386_relocate_section): Handle got.offset != -1 for
+       R_386_GOT32/R_386_GOTOFF relocations against STT_GNU_IFUNC
+       symbol.
+
+       * elf64-x86-64.c (elf64_x86_64_check_relocs): Increment
+       got.refcount for R_X86_64_GOTPCREL/R_X86_64_GOTPCREL64
+       relocations against STT_GNU_IFUNC symbol.
+       (elf64_x86_64_allocate_dynrelocs): Set got.refcount to 0 if
+       local STT_GNU_IFUNC definition is used.
+       (elf64_x86_64_relocate_section): Handle got.offset != -1
+       for R_X86_64_GOTPCREL/R_X86_64_GOTPCREL64 relocations against
+       STT_GNU_IFUNC symbol.
+
 2009-06-01  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/10205
index 70c579e76fc66ad1792a6250cf64af8560e4e6ce..ade5aa8cceeb1df8e00747dfcc7a7ecff14f3f1c 100644 (file)
@@ -1336,6 +1336,7 @@ elf_i386_check_relocs (bfd *abfd,
 
                case R_386_GOT32:
                case R_386_GOTOFF:
+                 h->got.refcount += 1;
                  if (htab->sgot == NULL
                      && !elf_i386_create_got_section (htab->elf.dynobj,
                                                       info))
@@ -1999,8 +2000,13 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       if (h->dynindx == -1 || h->forced_local)
        eh->dyn_relocs = NULL;
 
-      /* STT_GNU_IFUNC symbol uses .got.plt, not .got.  */
-      h->got.refcount = 0;
+      /* STT_GNU_IFUNC symbol uses .got.plt, not .got.  But for
+        shared library, we must go through GOT and we can't
+        use R_386_IRELATIVE unless it is forced local.   */
+      if (!info->shared 
+         || info->symbolic
+         || h->forced_local)
+       h->got.refcount = 0;
     }
   else if (htab->elf.dynamic_sections_created
           && h->plt.refcount > 0)
@@ -2908,55 +2914,62 @@ elf_i386_relocate_section (bfd *output_bfd,
              base_got = htab->sgot;
              off = h->got.offset;
 
-             if (base_got == NULL
-                 || off != (bfd_vma) -1)
+             if (base_got == NULL)
                abort ();
 
-             /* We can't use h->got.offset here to save state, or
-                even just remember the offset, as finish_dynamic_symbol
-                would use that as offset into .got.  */
-                 
-             if (htab->splt != NULL)
-               {
-                 plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
-                 off = (plt_index + 3) * 4;
-                 base_got = htab->sgotplt;
-               }
-             else
+             if (off == (bfd_vma) -1)
                {
-                 plt_index = h->plt.offset / PLT_ENTRY_SIZE;
-                 off = plt_index * 4;
-                 base_got = htab->igotplt;
-               }
-
-             if (h->dynindx == -1
-                 || h->forced_local
-                 || info->symbolic)
-               {
-                 /* This references the local defitionion.  We must 
-                    initialize this entry in the global offset table.
-                    Since the offset must always be a multiple of 8, we
-                    use the least significant bit to record whether we
-                    have initialized it already.
-
-                    When doing a dynamic link, we create a .rela.got
-                    relocation entry to initialize the value.  This is
-                    done in the finish_dynamic_symbol routine.  */
-                 if ((off & 1) != 0)
-                   off &= ~1;
+                 /* We can't use h->got.offset here to save state, or
+                    even just remember the offset, as finish_dynamic_symbol
+                    would use that as offset into .got.  */
+                 
+                 if (htab->splt != NULL)
+                   {
+                     plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
+                     off = (plt_index + 3) * 4;
+                     base_got = htab->sgotplt;
+                   }
                  else
                    {
-                     bfd_put_32 (output_bfd, relocation,
-                                 base_got->contents + off);
-                     h->got.offset |= 1;
+                     plt_index = h->plt.offset / PLT_ENTRY_SIZE;
+                     off = plt_index * 4;
+                     base_got = htab->igotplt;
                    }
-               }
 
-             relocation = off;
+                 if (h->dynindx == -1
+                     || h->forced_local
+                     || info->symbolic)
+                   {
+                     /* This references the local defitionion.  We must
+                        initialize this entry in the global offset table.
+                        Since the offset must always be a multiple of 8,
+                        we use the least significant bit to record
+                        whether we have initialized it already.
+
+                        When doing a dynamic link, we create a .rela.got
+                        relocation entry to initialize the value.  This
+                        is done in the finish_dynamic_symbol routine.   */
+                     if ((off & 1) != 0)
+                       off &= ~1;
+                     else
+                       {
+                         bfd_put_32 (output_bfd, relocation,
+                                     base_got->contents + off);
+                         h->got.offset |= 1;
+                       }
+                   }
+
+                 relocation = off;
 
-             /* Adjust for static executables.  */
-             if (htab->splt == NULL)
-               relocation += gotplt->output_offset;
+                 /* Adjust for static executables.  */
+                 if (htab->splt == NULL)
+                   relocation += gotplt->output_offset;
+               }
+             else
+               relocation = (base_got->output_section->vma
+                             + base_got->output_offset + off
+                             - gotplt->output_section->vma
+                             - gotplt->output_offset);
             
              goto do_relocation;
 
index 86715865b6a166b6b0e1b01a04219ba24cf06df4..e85832519ea674d05b6813f473b37c8210532d6a 100644 (file)
@@ -1126,6 +1126,7 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
                case R_X86_64_GOTPCREL:
                case R_X86_64_GOTPCREL64:
+                 h->got.refcount += 1;
                  if (htab->sgot == NULL
                      && !elf64_x86_64_create_got_section (htab->elf.dynobj,
                                                           info))
@@ -1837,8 +1838,13 @@ elf64_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
       if (h->dynindx == -1 || h->forced_local)
        eh->dyn_relocs = NULL;
 
-      /* STT_GNU_IFUNC symbol uses .got.plt, not .got.  */
-      h->got.refcount = 0;
+      /* STT_GNU_IFUNC symbol uses .got.plt, not .got.  But for
+        shared library, we must go through GOT and we can't
+        use R_X86_64_IRELATIVE unless it is forced local.   */
+      if (!info->shared 
+         || info->symbolic
+         || h->forced_local)
+       h->got.refcount = 0;
     }
   else if (htab->elf.dynamic_sections_created
           && h->plt.refcount > 0)
@@ -2616,49 +2622,51 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              base_got = htab->sgot;
              off = h->got.offset;
 
-             if (base_got == NULL
-                 || off != (bfd_vma) -1)
+             if (base_got == NULL)
                abort ();
 
-             /* We can't use h->got.offset here to save state, or
-                even just remember the offset, as finish_dynamic_symbol
-                would use that as offset into .got.  */
-
-             if (htab->splt != NULL)
-               {
-                 plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
-                 off = (plt_index + 3) * GOT_ENTRY_SIZE;
-                 base_got = htab->sgotplt;
-               }
-             else
-               {
-                 plt_index = h->plt.offset / PLT_ENTRY_SIZE;
-                 off = plt_index * GOT_ENTRY_SIZE;
-                 base_got = htab->igotplt;
-               }
-
-             if (h->dynindx == -1
-                 || h->forced_local
-                 || info->symbolic)
+             if (off == (bfd_vma) -1)
                {
-                 /* This references the local defitionion.  We must 
-                    initialize this entry in the global offset table.
-                    Since the offset must always be a multiple of 8, we
-                    use the least significant bit to record whether we
-                    have initialized it already.
+                 /* We can't use h->got.offset here to save state, or
+                    even just remember the offset, as finish_dynamic_symbol
+                    would use that as offset into .got.  */
 
-                    When doing a dynamic link, we create a .rela.got
-                    relocation entry to initialize the value.  This is
-                    done in the finish_dynamic_symbol routine.  */
-                 if ((off & 1) != 0)
-                   off &= ~1;
+                 if (htab->splt != NULL)
+                   {
+                     plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1;
+                     off = (plt_index + 3) * GOT_ENTRY_SIZE;
+                     base_got = htab->sgotplt;
+                   }
                  else
                    {
-                     bfd_put_64 (output_bfd, relocation,
-                                 base_got->contents + off);
-                     /* Note that this is harmless for the GOTPLT64 case,
-                        as -1 | 1 still is -1.  */
-                     h->got.offset |= 1;
+                     plt_index = h->plt.offset / PLT_ENTRY_SIZE;
+                     off = plt_index * GOT_ENTRY_SIZE;
+                     base_got = htab->igotplt;
+                   }
+
+                 if (h->dynindx == -1
+                     || h->forced_local
+                     || info->symbolic)
+                   {
+                     /* This references the local defitionion.  We must 
+                        initialize this entry in the global offset table.
+                        Since the offset must always be a multiple of 8, 
+                        we use the least significant bit to record
+                        whether we have initialized it already.
+
+                        When doing a dynamic link, we create a .rela.got
+                        relocation entry to initialize the value.  This
+                        is done in the finish_dynamic_symbol routine.   */
+                     if ((off & 1) != 0)
+                       off &= ~1;
+                     else
+                       {
+                         bfd_put_64 (output_bfd, relocation,
+                                     base_got->contents + off);
+                         /* Note that this is harmless for the GOTPLT64
+                            case, as -1 | 1 still is -1.  */
+                         h->got.offset |= 1;
+                       }
                    }
                }
 
index 03fb645a0cd3218106e68c34328e96725fbbb41b..6c73acfe214a60f78bcd0e7d967cc0b0751c55cb 100644 (file)
@@ -1,3 +1,26 @@
+2009-06-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * ld-ifunc/ifunc-5-i386.d: Renamed to ...
+       * ld-ifunc/ifunc-5a-i386.d: This.
+
+       * ld-ifunc/ifunc-5-x86-64.d: Renamed to ...
+       * ld-ifunc/ifunc-5a-x86-64.d: This.
+
+       * ld-ifunc/ifunc-5b-i386.d: New.
+       * ld-ifunc/ifunc-5b-x86-64.d: Likewise.
+       * ld-ifunc/ifunc-6a-i386.d: Likewise.
+       * ld-ifunc/ifunc-6a-x86-64.d: Likewise.
+       * ld-ifunc/ifunc-6b-i386.d: Likewise.
+       * ld-ifunc/ifunc-6b-x86-64.d: Likewise.
+       * ld-ifunc/ifunc-6-i386.s: Likewise.
+       * ld-ifunc/ifunc-6-x86-64.s: Likewise.
+       * ld-ifunc/ifunc-7a-i386.d: Likewise.
+       * ld-ifunc/ifunc-7a-x86-64.d: Likewise.
+       * ld-ifunc/ifunc-7b-i386.d: Likewise.
+       * ld-ifunc/ifunc-7b-x86-64.d: Likewise.
+       * ld-ifunc/ifunc-7-i386.s: Likewise.
+       * ld-ifunc/ifunc-7-x86-64.s: Likewise.
+
 2009-06-01  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/10205
diff --git a/ld/testsuite/ld-ifunc/ifunc-5-i386.d b/ld/testsuite/ld-ifunc/ifunc-5-i386.d
deleted file mode 100644 (file)
index eb3fc01..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ld: -m elf_i386
-#as: --32
-#readelf: -r --wide
-#target: x86_64-*-* i?86-*-*
-
-#...
-[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_IRELATIVE[ ]*
-#pass
diff --git a/ld/testsuite/ld-ifunc/ifunc-5-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-5-x86-64.d
deleted file mode 100644 (file)
index 84347cc..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#ld:
-#readelf: -r --wide
-#target: x86_64-*-*
-
-#...
-[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_IRELATIVE[ ]+[0-9a-f]*
-#pass
diff --git a/ld/testsuite/ld-ifunc/ifunc-5a-i386.d b/ld/testsuite/ld-ifunc/ifunc-5a-i386.d
new file mode 100644 (file)
index 0000000..8fba080
--- /dev/null
@@ -0,0 +1,9 @@
+#source: ifunc-5-i386.s
+#ld: -m elf_i386
+#as: --32
+#readelf: -r --wide
+#target: x86_64-*-* i?86-*-*
+
+Relocation section '.rel.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_IRELATIVE[ ]*
diff --git a/ld/testsuite/ld-ifunc/ifunc-5a-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-5a-x86-64.d
new file mode 100644 (file)
index 0000000..b635099
--- /dev/null
@@ -0,0 +1,8 @@
+#source: ifunc-5-x86-64.s
+#ld:
+#readelf: -r --wide
+#target: x86_64-*-*
+
+Relocation section '.rela.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_IRELATIVE[ ]+[0-9a-f]*
diff --git a/ld/testsuite/ld-ifunc/ifunc-5b-i386.d b/ld/testsuite/ld-ifunc/ifunc-5b-i386.d
new file mode 100644 (file)
index 0000000..e00401b
--- /dev/null
@@ -0,0 +1,13 @@
+#source: ifunc-5-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[ ]+foo\(\)[ ]+foo
+#...
+Relocation section '.rel.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_JUMP_SLOT[ ]+foo\(\)[ ]+foo
diff --git a/ld/testsuite/ld-ifunc/ifunc-5b-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-5b-x86-64.d
new file mode 100644 (file)
index 0000000..d8b2e91
--- /dev/null
@@ -0,0 +1,12 @@
+#source: ifunc-5-x86-64.s
+#ld: -shared -z nocombreloc
+#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[ ]+foo\(\)[ ]+foo \+ 0
+#...
+Relocation section '.rela.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_JUMP_SLOT[ ]+foo\(\)[ ]+foo \+ 0
diff --git a/ld/testsuite/ld-ifunc/ifunc-6-i386.s b/ld/testsuite/ld-ifunc/ifunc-6-i386.s
new file mode 100644 (file)
index 0000000..bc632c9
--- /dev/null
@@ -0,0 +1,24 @@
+       .text
+       .type foo, %gnu_indirect_function
+.globl foo
+       .type   foo, @function
+foo:
+       ret
+       .size   foo, .-foo
+       .protected foo
+       .type start,"function"
+       .global start
+start:
+       .type _start,"function"
+       .global _start
+_start:
+       .type __start,"function"
+       .global __start
+__start:
+       .type __start,"function"
+       call    .L6
+.L6:
+       popl    %ebx
+       addl    $_GLOBAL_OFFSET_TABLE_+[.-.L6], %ebx
+       call    foo@PLT
+       leal    foo@GOT(%ebx), %eax
diff --git a/ld/testsuite/ld-ifunc/ifunc-6-x86-64.s b/ld/testsuite/ld-ifunc/ifunc-6-x86-64.s
new file mode 100644 (file)
index 0000000..954d67d
--- /dev/null
@@ -0,0 +1,20 @@
+       .text
+       .type foo, %gnu_indirect_function
+.globl foo
+       .type   foo, @function
+foo:
+       ret
+       .size   foo, .-foo
+       .protected foo
+       .type start,"function"
+       .global start
+start:
+       .type _start,"function"
+       .global _start
+_start:
+       .type __start,"function"
+       .global __start
+__start:
+       .type __start,"function"
+       call    foo@PLT
+       movq    foo@GOTPCREL(%rip), %rax
diff --git a/ld/testsuite/ld-ifunc/ifunc-6a-i386.d b/ld/testsuite/ld-ifunc/ifunc-6a-i386.d
new file mode 100644 (file)
index 0000000..a83e62b
--- /dev/null
@@ -0,0 +1,9 @@
+#source: ifunc-6-i386.s
+#ld: -m elf_i386
+#as: --32
+#readelf: -r --wide
+#target: x86_64-*-* i?86-*-*
+
+Relocation section '.rel.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_IRELATIVE[ ]*
diff --git a/ld/testsuite/ld-ifunc/ifunc-6a-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-6a-x86-64.d
new file mode 100644 (file)
index 0000000..169cf1c
--- /dev/null
@@ -0,0 +1,8 @@
+#source: ifunc-6-x86-64.s
+#ld:
+#readelf: -r --wide
+#target: x86_64-*-*
+
+Relocation section '.rela.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_IRELATIVE[ ]+[0-9a-f]*
diff --git a/ld/testsuite/ld-ifunc/ifunc-6b-i386.d b/ld/testsuite/ld-ifunc/ifunc-6b-i386.d
new file mode 100644 (file)
index 0000000..e53fc72
--- /dev/null
@@ -0,0 +1,13 @@
+#source: ifunc-6-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[ ]+foo\(\)[ ]+foo
+#...
+Relocation section '.rel.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_IRELATIVE[ ]*
diff --git a/ld/testsuite/ld-ifunc/ifunc-6b-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-6b-x86-64.d
new file mode 100644 (file)
index 0000000..5a948e9
--- /dev/null
@@ -0,0 +1,12 @@
+#source: ifunc-6-x86-64.s
+#ld: -shared -z nocombreloc
+#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[ ]+foo\(\)[ ]+foo \+ 0
+#...
+Relocation section '.rela.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_IRELATIVE[ ]+[0-9a-f]*
diff --git a/ld/testsuite/ld-ifunc/ifunc-7-i386.s b/ld/testsuite/ld-ifunc/ifunc-7-i386.s
new file mode 100644 (file)
index 0000000..8616c4e
--- /dev/null
@@ -0,0 +1,24 @@
+       .text
+       .type foo, %gnu_indirect_function
+.globl foo
+       .type   foo, @function
+foo:
+       ret
+       .size   foo, .-foo
+       .hidden foo
+       .type start,"function"
+       .global start
+start:
+       .type _start,"function"
+       .global _start
+_start:
+       .type __start,"function"
+       .global __start
+__start:
+       .type __start,"function"
+       call    .L6
+.L6:
+       popl    %ebx
+       addl    $_GLOBAL_OFFSET_TABLE_+[.-.L6], %ebx
+       call    foo@PLT
+       leal    foo@GOT(%ebx), %eax
diff --git a/ld/testsuite/ld-ifunc/ifunc-7-x86-64.s b/ld/testsuite/ld-ifunc/ifunc-7-x86-64.s
new file mode 100644 (file)
index 0000000..24fce11
--- /dev/null
@@ -0,0 +1,20 @@
+       .text
+       .type foo, %gnu_indirect_function
+.globl foo
+       .type   foo, @function
+foo:
+       ret
+       .size   foo, .-foo
+       .hidden foo
+       .type start,"function"
+       .global start
+start:
+       .type _start,"function"
+       .global _start
+_start:
+       .type __start,"function"
+       .global __start
+__start:
+       .type __start,"function"
+       call    foo@PLT
+       movq    foo@GOTPCREL(%rip), %rax
diff --git a/ld/testsuite/ld-ifunc/ifunc-7a-i386.d b/ld/testsuite/ld-ifunc/ifunc-7a-i386.d
new file mode 100644 (file)
index 0000000..6b4afe1
--- /dev/null
@@ -0,0 +1,9 @@
+#source: ifunc-7-i386.s
+#ld: -m elf_i386
+#as: --32
+#readelf: -r --wide
+#target: x86_64-*-* i?86-*-*
+
+Relocation section '.rel.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_IRELATIVE[ ]*
diff --git a/ld/testsuite/ld-ifunc/ifunc-7a-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-7a-x86-64.d
new file mode 100644 (file)
index 0000000..350614a
--- /dev/null
@@ -0,0 +1,8 @@
+#source: ifunc-7-x86-64.s
+#ld:
+#readelf: -r --wide
+#target: x86_64-*-*
+
+Relocation section '.rela.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_IRELATIVE[ ]+[0-9a-f]*
diff --git a/ld/testsuite/ld-ifunc/ifunc-7b-i386.d b/ld/testsuite/ld-ifunc/ifunc-7b-i386.d
new file mode 100644 (file)
index 0000000..31cdd97
--- /dev/null
@@ -0,0 +1,9 @@
+#source: ifunc-7-i386.s
+#ld: -shared -m elf_i386
+#as: --32
+#readelf: -r --wide
+#target: x86_64-*-* i?86-*-*
+
+Relocation section '.rel.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_IRELATIVE[ ]*
diff --git a/ld/testsuite/ld-ifunc/ifunc-7b-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-7b-x86-64.d
new file mode 100644 (file)
index 0000000..cd66d58
--- /dev/null
@@ -0,0 +1,8 @@
+#source: ifunc-7-x86-64.s
+#ld: -shared
+#readelf: -r --wide
+#target: x86_64-*-*
+
+Relocation section '.rela.plt' at .*
+[ ]+Offset[ ]+Info[ ]+Type[ ]+.*
+[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_IRELATIVE[ ]+[0-9a-f]*