diff options
author | David S. Miller <davem@davemloft.net> | 2011-06-20 19:56:40 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-06-20 19:56:40 -0700 |
commit | 42675c6ff0e95346de8a2cbc066e14e0d6a856e4 (patch) | |
tree | 2350fafe239e6a63d30f480628cc1f1d86e0b5a4 /sysdeps | |
parent | 57912a71cc379f8582e3ea272782dc39c6c02e45 (diff) | |
download | glibc-42675c6ff0e95346de8a2cbc066e14e0d6a856e4.tar glibc-42675c6ff0e95346de8a2cbc066e14e0d6a856e4.tar.gz glibc-42675c6ff0e95346de8a2cbc066e14e0d6a856e4.tar.bz2 glibc-42675c6ff0e95346de8a2cbc066e14e0d6a856e4.zip |
Add an elf_ifunc_invoke interface so that architectures can implement
the ifunc resolver calls however they wish.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/i386/dl-irel.h | 9 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc32/dl-irel.h | 9 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc64/dl-irel.h | 11 | ||||
-rw-r--r-- | sysdeps/sparc/sparc32/dl-irel.h | 11 | ||||
-rw-r--r-- | sysdeps/sparc/sparc32/dl-plt.h | 5 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/dl-irel.h | 11 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/dl-plt.h | 5 | ||||
-rw-r--r-- | sysdeps/x86_64/dl-irel.h | 9 |
8 files changed, 61 insertions, 9 deletions
diff --git a/sysdeps/i386/dl-irel.h b/sysdeps/i386/dl-irel.h index 30385a1ef8..70cd6b04db 100644 --- a/sysdeps/i386/dl-irel.h +++ b/sysdeps/i386/dl-irel.h @@ -26,6 +26,13 @@ #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 diff --git a/sysdeps/powerpc/powerpc32/dl-irel.h b/sysdeps/powerpc/powerpc32/dl-irel.h index 3f204cd7ae..a31e1edd4a 100644 --- a/sysdeps/powerpc/powerpc32/dl-irel.h +++ b/sysdeps/powerpc/powerpc32/dl-irel.h @@ -26,6 +26,13 @@ #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 diff --git a/sysdeps/powerpc/powerpc64/dl-irel.h b/sysdeps/powerpc/powerpc64/dl-irel.h index 6cded5091d..3c2668fbb7 100644 --- a/sysdeps/powerpc/powerpc64/dl-irel.h +++ b/sysdeps/powerpc/powerpc64/dl-irel.h @@ -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 diff --git a/sysdeps/sparc/sparc32/dl-irel.h b/sysdeps/sparc/sparc32/dl-irel.h index 2753fb4ceb..4eaaa37d69 100644 --- a/sysdeps/sparc/sparc32/dl-irel.h +++ b/sysdeps/sparc/sparc32/dl-irel.h @@ -28,6 +28,13 @@ #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); } diff --git a/sysdeps/sparc/sparc32/dl-plt.h b/sysdeps/sparc/sparc32/dl-plt.h index bfb891fe69..0fbd95093b 100644 --- a/sysdeps/sparc/sparc32/dl-plt.h +++ b/sysdeps/sparc/sparc32/dl-plt.h @@ -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 */ diff --git a/sysdeps/sparc/sparc64/dl-irel.h b/sysdeps/sparc/sparc64/dl-irel.h index 0d70e2a448..e356ac6420 100644 --- a/sysdeps/sparc/sparc64/dl-irel.h +++ b/sysdeps/sparc/sparc64/dl-irel.h @@ -28,6 +28,13 @@ #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 diff --git a/sysdeps/sparc/sparc64/dl-plt.h b/sysdeps/sparc/sparc64/dl-plt.h index ca2fe3bbd8..ed8abfa115 100644 --- a/sysdeps/sparc/sparc64/dl-plt.h +++ b/sysdeps/sparc/sparc64/dl-plt.h @@ -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 */ diff --git a/sysdeps/x86_64/dl-irel.h b/sysdeps/x86_64/dl-irel.h index d2d5c0670e..19f94576b3 100644 --- a/sysdeps/x86_64/dl-irel.h +++ b/sysdeps/x86_64/dl-irel.h @@ -26,6 +26,13 @@ #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 |