summaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2013-12-19 16:11:19 +0100
committerMark Wielaard <mjw@redhat.com>2013-12-20 16:30:48 +0100
commitc2ba078eb5f54ea941f099b02c118f8aa7b04204 (patch)
tree12e9bca505e636f97adf9cf53ce257b27d54bc0b /backends
parent159ac52b061c60947a943c102298cd692223274f (diff)
downloadelfutils-c2ba078eb5f54ea941f099b02c118f8aa7b04204.tar.gz
backends: aarch64 always has _GLOBAL_OFFSET_TABLE_ point to .got[0].
Like some other architectures aarch64 has a special rule for the _GLOBAL_OFFSET_TABLE_ symbol. Even if there is a .plt.got section the symbol value still points to the start of the .got section. This is also what the dynamic linker expects. See https://sourceware.org/ml/libc-ports/2013-06/msg00057.html Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'backends')
-rw-r--r--backends/ChangeLog5
-rw-r--r--backends/aarch64_init.c1
-rw-r--r--backends/aarch64_symbol.c28
3 files changed, 34 insertions, 0 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index d5f6b53a..24cc63d9 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,8 @@
+2013-12-19 Mark Wielaard <mjw@redhat.com>
+
+ * aarch64_init.c (aarch64_init): Hook check_special_symbol.
+ * aarch64_symbol.c (aarch64_check_special_symbol): New function.
+
2013-12-18 Mark Wielaard <mjw@redhat.com>
* Makefile.am (ppc64_SRCS): Add ppc64_resolve_sym.c.
diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c
index 749af2aa..d663d402 100644
--- a/backends/aarch64_init.c
+++ b/backends/aarch64_init.c
@@ -56,6 +56,7 @@ aarch64_init (elf, machine, eh, ehlen)
HOOK (eh, core_note);
HOOK (eh, reloc_simple_type);
HOOK (eh, return_value_location);
+ HOOK (eh, check_special_symbol);
return MODVERSION;
}
diff --git a/backends/aarch64_symbol.c b/backends/aarch64_symbol.c
index b0f3377e..e41a7a7d 100644
--- a/backends/aarch64_symbol.c
+++ b/backends/aarch64_symbol.c
@@ -32,6 +32,7 @@
#include <elf.h>
#include <stddef.h>
+#include <string.h>
#define BACKEND aarch64_
#include "libebl_CPU.h"
@@ -54,3 +55,30 @@ aarch64_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
return ELF_T_NUM;
}
}
+
+/* If this is the _GLOBAL_OFFSET_TABLE_ symbol, then it should point to
+ .got[0] even if there is a .got.plt section. */
+bool
+aarch64_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr, const GElf_Sym *sym,
+ const char *name, const GElf_Shdr *destshdr)
+{
+ if (name != NULL
+ && strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
+ {
+ const char *sname = elf_strptr (elf, ehdr->e_shstrndx, destshdr->sh_name);
+ if (sname != NULL && strcmp (sname, ".got.plt") == 0)
+ {
+ Elf_Scn *scn = NULL;
+ while ((scn = elf_nextscn (elf, scn)) != NULL)
+ {
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
+ sname = elf_strptr (elf, ehdr->e_shstrndx, shdr->sh_name);
+ if (sname != NULL && strcmp (sname, ".got") == 0)
+ return sym->st_value == shdr->sh_addr;
+ }
+ }
+ }
+
+ return false;
+}