about summary refs log tree commit diff
path: root/ports/sysdeps/aarch64/dl-irel.h
diff options
context:
space:
mode:
authorWill Newton <will.newton@linaro.org>2013-11-25 14:56:28 +0000
committerWill Newton <will.newton@linaro.org>2013-11-26 16:18:04 +0000
commit7520ff8c744a704ca39741c165a2360d63a4f47a (patch)
treeaf183d787aeee1f40d548358e4cbd72b2dab3ee9 /ports/sysdeps/aarch64/dl-irel.h
parent6f476861be660541eee229acfbc9ef4098af70ab (diff)
downloadglibc-7520ff8c744a704ca39741c165a2360d63a4f47a.tar.gz
glibc-7520ff8c744a704ca39741c165a2360d63a4f47a.tar.xz
glibc-7520ff8c744a704ca39741c165a2360d63a4f47a.zip
aarch64: Enable ifunc support.
Add support for handling the R_AARCH64_IRELATIVE relocation and
STT_GNU_IFUNC symbols to the aarch64 port.

ports/ChangeLog.aarch64:

2013-11-26  Will Newton  <will.newton@linaro.org>

	* sysdeps/aarch64/dl-irel.h: Include ldsodefs.h.
	(ELF_MACHINE_IRELA): Define.  (elf_ifunc_invoke): Pass
	hwcap to ifunc resolver function.  (elf_irela): New function.
	* sysdeps/aarch64/dl-machine.h: Include dl-irel.h.
	(elf_machine_rela) Handle STT_GNU_IFUNC symbols and
	R_AARCH64_IRELATIVE relocations.  (elf_machine_lazy_rel):
	Handle R_AARCH64_IRELATIVE relocations.
Diffstat (limited to 'ports/sysdeps/aarch64/dl-irel.h')
-rw-r--r--ports/sysdeps/aarch64/dl-irel.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/ports/sysdeps/aarch64/dl-irel.h b/ports/sysdeps/aarch64/dl-irel.h
index 1a3811e7bb..f37ee399c8 100644
--- a/ports/sysdeps/aarch64/dl-irel.h
+++ b/ports/sysdeps/aarch64/dl-irel.h
@@ -22,15 +22,31 @@
 
 #include <stdio.h>
 #include <unistd.h>
+#include <ldsodefs.h>
 
-/* AArch64 does not yet implement IFUNC support.  However since
-   2011-06-20 provision of a elf_ifunc_invoke has been mandatory.  */
+#define ELF_MACHINE_IRELA	1
 
 static inline ElfW(Addr)
 __attribute ((always_inline))
 elf_ifunc_invoke (ElfW(Addr) addr)
 {
-  return ((ElfW(Addr) (*) (void)) (addr)) ();
+  return ((ElfW(Addr) (*) (unsigned long int)) (addr)) (GLRO(dl_hwcap));
+}
+
+static inline void
+__attribute ((always_inline))
+elf_irela (const ElfW(Rela) *reloc)
+{
+  ElfW(Addr) *const reloc_addr = (void *) reloc->r_offset;
+  const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info);
+
+  if (__glibc_likely (r_type == R_AARCH64_IRELATIVE))
+    {
+      ElfW(Addr) value = elf_ifunc_invoke (reloc->r_addend);
+      *reloc_addr = value;
+    }
+  else
+    __libc_fatal ("unexpected reloc type in static binary");
 }
 
 #endif