]> sourceware.org Git - glibc.git/commitdiff
Add an elf_ifunc_invoke interface so that architectures can implement
authorDavid S. Miller <davem@davemloft.net>
Tue, 21 Jun 2011 02:56:40 +0000 (19:56 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Jun 2011 02:56:40 +0000 (19:56 -0700)
the ifunc resolver calls however they wish.

ChangeLog
elf/dl-runtime.c
elf/dl-sym.c
sysdeps/i386/dl-irel.h
sysdeps/powerpc/powerpc32/dl-irel.h
sysdeps/powerpc/powerpc64/dl-irel.h
sysdeps/sparc/sparc32/dl-irel.h
sysdeps/sparc/sparc32/dl-plt.h
sysdeps/sparc/sparc64/dl-irel.h
sysdeps/sparc/sparc64/dl-plt.h
sysdeps/x86_64/dl-irel.h

index 368c52a7a7adbd2e4933007b012fd364237fabfa..14700e772d3dd4696ca511cf699844e7a8bfb385 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2011-06-20  David S. Miller  <davem@davemloft.net>
+
+       * sysdeps/sparc/sparc32/dl-plt.h: Protect against multiple
+       inclusions.
+       * sysdeps/sparc/sparc64/dl-plt.h: Likewise.
+
+       * sysdeps/i386/dl-irel.h (elf_ifunc_invoke): New.
+       (elf_irel): Use it.
+       * sysdeps/powerpc/powerpc32/dl-irel.h: Likewise.
+       * sysdeps/powerpc/powerpc64/dl-irel.h: Likewise.
+       * sysdeps/sparc/sparc32/dl-irel.h: Likewise.
+       * sysdeps/sparc/sparc64/dl-irel.h: Likewise.
+       * sysdeps/x86_64/dl-irel.h: Likewise.
+
+       * elf/dl-runtime.c: Use elf_ifunc_invoke.
+       * elf/dl-sym.c: Likewise.
+
 2011-06-15  Ulrich Drepper  <drepper@gmail.com>
 
        * resolv/res_send.c (__libc_res_nsend): Fix typos in last patch.  We
index b27cfbf204d9b7fabb87f5fa4f6067cc8fd83830..8778e67f7cfa4146551de9a36ad83b6d7c59fd5c 100644 (file)
@@ -27,6 +27,7 @@
 #include <sysdep-cancel.h>
 #include "dynamic-link.h"
 #include <tls.h>
+#include <dl-irel.h>
 
 
 #if (!defined ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
@@ -146,7 +147,7 @@ _dl_fixup (
 
   if (sym != NULL
       && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0))
-    value = ((DL_FIXUP_VALUE_TYPE (*) (void)) DL_FIXUP_VALUE_ADDR (value)) ();
+    value = elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (value));
 
   /* Finally, fix up the plt itself.  */
   if (__builtin_expect (GLRO(dl_bind_not), 0))
@@ -235,8 +236,7 @@ _dl_profile_fixup (
          if (defsym != NULL
              && __builtin_expect (ELFW(ST_TYPE) (defsym->st_info)
                                   == STT_GNU_IFUNC, 0))
-           value = ((DL_FIXUP_VALUE_TYPE (*) (void))
-                    DL_FIXUP_VALUE_ADDR (value)) ();
+           value = elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (value));
        }
       else
        {
@@ -246,8 +246,7 @@ _dl_profile_fixup (
 
          if (__builtin_expect (ELFW(ST_TYPE) (refsym->st_info)
                                == STT_GNU_IFUNC, 0))
-           value = ((DL_FIXUP_VALUE_TYPE (*) (void))
-                    DL_FIXUP_VALUE_ADDR (value)) ();
+           value = elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (value));
 
          result = l;
        }
index 4faf05c00b8cae4de3cd7880dba52c840bd194bd..0af3e48d654b1cfc4a28e184836408a7d4b3cbea 100644 (file)
@@ -27,6 +27,7 @@
 #include <dl-hash.h>
 #include <sysdep-cancel.h>
 #include <dl-tls.h>
+#include <dl-irel.h>
 
 
 #ifdef SHARED
@@ -196,8 +197,7 @@ RTLD_NEXT used in code not dynamically loaded"));
        {
          DL_FIXUP_VALUE_TYPE fixup
            = DL_FIXUP_MAKE_VALUE (result, (ElfW(Addr)) value);
-         fixup =
-           ((DL_FIXUP_VALUE_TYPE (*) (void)) DL_FIXUP_VALUE_ADDR (fixup)) ();
+         fixup = elf_ifunc_invoke (DL_FIXUP_VALUE_ADDR (fixup));
          value = (void *) DL_FIXUP_VALUE_CODE_ADDR (fixup);
        }
 
index 30385a1ef88906c8997bd0f88d088d3c023d6b7f..70cd6b04dbe2d08af9d3b8bcc2109b1b4fadfb03 100644 (file)
 
 #define ELF_MACHINE_IREL       1
 
+static inline Elf32_Addr
+__attribute ((always_inline))
+elf_ifunc_invoke (Elf32_Addr addr)
+{
+  return ((Elf32_Addr (*) (void)) (addr)) ();
+}
+
 static inline void
 __attribute ((always_inline))
 elf_irel (const Elf32_Rel *reloc)
@@ -35,7 +42,7 @@ elf_irel (const Elf32_Rel *reloc)
 
   if (__builtin_expect (r_type == R_386_IRELATIVE, 1))
     {
-      Elf32_Addr value = ((Elf32_Addr (*) (void)) (*reloc_addr)) ();
+      Elf32_Addr value = elf_ifunc_invoke(*reloc_addr);
       *reloc_addr = value;
     }
   else
index 3f204cd7ae081b7c99c927a769090a49fcb35c5d..a31e1edd4af443a90a672cfc9026f3471398c2ba 100644 (file)
 
 #define ELF_MACHINE_IRELA      1
 
+static inline Elf32_Addr
+__attribute ((always_inline))
+elf_ifunc_invoke (Elf32_Addr addr)
+{
+  return ((Elf32_Addr (*) (void)) (addr)) ();
+}
+
 static inline void
 __attribute ((always_inline))
 elf_irela (const Elf32_Rela *reloc)
@@ -35,7 +42,7 @@ elf_irela (const Elf32_Rela *reloc)
   if (__builtin_expect (r_type == R_PPC_IRELATIVE, 1))
     {
       Elf32_Addr *const reloc_addr = (void *) reloc->r_offset;
-      Elf32_Addr value = ((Elf32_Addr (*) (void)) reloc->r_addend) ();
+      Elf32_Addr value = elf_ifunc_invoke(reloc->r_addend);
       *reloc_addr = value;
     }
   else
index 6cded5091dea6c13f2fcf849e48968c1b1fbc170..3c2668fbb77a05135674a63fa6245e2b931150f2 100644 (file)
@@ -33,6 +33,13 @@ typedef struct
   Elf64_Addr fd_aux;
 } Elf64_FuncDesc;
 
+static inline Elf64_Addr
+__attribute ((always_inline))
+elf_ifunc_invoke (Elf64_Addr addr)
+{
+  return ((Elf64_Addr (*) (void)) (addr)) ();
+}
+
 static inline void
 __attribute ((always_inline))
 elf_irela (const Elf64_Rela *reloc)
@@ -42,13 +49,13 @@ elf_irela (const Elf64_Rela *reloc)
   if (__builtin_expect (r_type == R_PPC64_IRELATIVE, 1))
     {
       Elf64_Addr *const reloc_addr = (void *) reloc->r_offset;
-      Elf64_Addr value = ((Elf64_Addr (*) (void)) reloc->r_addend) ();
+      Elf64_Addr value = elf_ifunc_invoke(reloc->r_addend);
       *reloc_addr = value;
     }
   else if (__builtin_expect (r_type == R_PPC64_JMP_IREL, 1))
     {
       Elf64_Addr *const reloc_addr = (void *) reloc->r_offset;
-      Elf64_Addr value = ((Elf64_Addr (*) (void)) reloc->r_addend) ();
+      Elf64_Addr value = elf_ifunc_invoke(reloc->r_addend);
       *(Elf64_FuncDesc *) reloc_addr = *(Elf64_FuncDesc *) value;
     }
   else
index 2753fb4ceb4670790732b5589aafeeef9644bbce..4eaaa37d69407dd3360bcbdc8c5f0de4fab950cf 100644 (file)
 
 #define ELF_MACHINE_IRELA      1
 
+static inline Elf32_Addr
+__attribute ((always_inline))
+elf_ifunc_invoke (Elf32_Addr addr)
+{
+  return ((Elf32_Addr (*) (int)) (addr)) (GLRO(dl_hwcap));
+}
+
 static inline void
 __attribute ((always_inline))
 elf_irela (const Elf32_Rela *reloc)
@@ -37,13 +44,13 @@ elf_irela (const Elf32_Rela *reloc)
   if (__builtin_expect (r_type == R_SPARC_IRELATIVE, 1))
     {
       Elf32_Addr *const reloc_addr = (void *) reloc->r_offset;
-      Elf32_Addr value = ((Elf32_Addr (*) (int)) reloc->r_addend) (GLRO(dl_hwcap));
+      Elf32_Addr value = elf_ifunc_invoke(reloc->r_addend);
       *reloc_addr = value;
     }
   else if (__builtin_expect (r_type == R_SPARC_JMP_IREL, 1))
     {
       Elf32_Addr *const reloc_addr = (void *) reloc->r_offset;
-      Elf32_Addr value = ((Elf32_Addr (*) (int)) reloc->r_addend) (GLRO(dl_hwcap));
+      Elf32_Addr value = elf_ifunc_invoke(reloc->r_addend);
 
       sparc_fixup_plt (reloc, reloc_addr, value, 0, 1);
     }
index bfb891fe692fef01fb70665d17f3bd7a89ee0ed7..0fbd95093bc2f1bc2a61f5b496c42eeb8ff90e5f 100644 (file)
@@ -18,6 +18,9 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#ifndef _DL_PLT_H
+#define _DL_PLT_H
+
 /* Some SPARC opcodes we need to use for self-modifying code.  */
 #define OPCODE_NOP     0x01000000 /* nop */
 #define OPCODE_CALL    0x40000000 /* call ?; add PC-rel word address */
@@ -95,3 +98,5 @@ sparc_fixup_plt (const Elf32_Rela *reloc, Elf32_Addr *reloc_addr,
 
   return value;
 }
+
+#endif /* dl-plt.h */
index 0d70e2a448f70f113492df9ad496247d94847247..e356ac64207222d1d1ac4fc9aa07a6f131b2bbd3 100644 (file)
 
 #define ELF_MACHINE_IRELA      1
 
+static inline Elf64_Addr
+__attribute ((always_inline))
+elf_ifunc_invoke (Elf64_Addr addr)
+{
+  return ((Elf64_Addr (*) (int)) (addr)) (GLRO(dl_hwcap));
+}
+
 static inline void
 __attribute ((always_inline))
 elf_irela (const Elf64_Rela *reloc)
@@ -37,13 +44,13 @@ elf_irela (const Elf64_Rela *reloc)
   if (__builtin_expect (r_type == R_SPARC_IRELATIVE, 1))
     {
       Elf64_Addr *const reloc_addr = (void *) reloc->r_offset;
-      Elf64_Addr value = ((Elf64_Addr (*) (int)) reloc->r_addend) (GLRO(dl_hwcap));
+      Elf64_Addr value = elf_ifunc_invoke(reloc->r_addend);
       *reloc_addr = value;
     }
   else if (__builtin_expect (r_type == R_SPARC_JMP_IREL, 1))
     {
       Elf64_Addr *const reloc_addr = (void *) reloc->r_offset;
-      Elf64_Addr value = ((Elf64_Addr (*) (int)) reloc->r_addend) (GLRO(dl_hwcap));
+      Elf64_Addr value = elf_ifunc_invoke(reloc->r_addend);
       struct link_map map = { .l_addr = 0 };
 
       /* 'high' is always zero, for large PLT entries the linker
index ca2fe3bbd866330373e5a00ec14f31b24be67902..ed8abfa1159cb4ac7133ffb6c08ceabea4b96361 100644 (file)
@@ -17,6 +17,9 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#ifndef _DL_PLT_H
+#define _DL_PLT_H
+
 /* We have 4 cases to handle.  And we code different code sequences
    for each one.  I love V9 code models...  */
 static inline void __attribute__ ((always_inline))
@@ -161,3 +164,5 @@ sparc64_fixup_plt (struct link_map *map, const Elf64_Rela *reloc,
       __asm __volatile ("flush %0" : : "r" (insns));
     }
 }
+
+#endif /* dl-plt.h */
index d2d5c0670ef769870c53d05b4b93ebb169b4e7b0..19f94576b3b392e0b1e59077f7d4e0426e1d11f3 100644 (file)
 
 #define ELF_MACHINE_IRELA      1
 
+static inline Elf64_Addr
+__attribute ((always_inline))
+elf_ifunc_invoke (Elf64_Addr addr)
+{
+  return ((Elf64_Addr (*) (void)) (addr)) ();
+}
+
 static inline void
 __attribute ((always_inline))
 elf_irela (const Elf64_Rela *reloc)
@@ -35,7 +42,7 @@ elf_irela (const Elf64_Rela *reloc)
 
   if (__builtin_expect (r_type == R_X86_64_IRELATIVE, 1))
     {
-      Elf64_Addr value = ((Elf64_Addr (*) (void)) reloc->r_addend) ();
+      Elf64_Addr value = elf_ifunc_invoke(reloc->r_addend);
       *reloc_addr = value;
     }
   else
This page took 0.055749 seconds and 5 git commands to generate.