[PATCH] backends: aarch64 always has _GLOBAL_OFFSET_TABLE_ point to .got[0].
Mark Wielaard
mjw at redhat.com
Fri Dec 20 15:33:33 UTC 2013
Hi,
On Thu, 2013-12-19 at 16:17 +0100, Mark Wielaard wrote:
> 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
> +2013-12-19 Mark Wielaard <mjw at redhat.com>
> +
> + * aarch64_init.c (aarch64_init): Hook check_special_symbol.
> + * aarch64_symbol.c (aarch64_check_special_symbol): New function.
I pushed this to master, with one typo fixed, see below.
It worked nicely on the fedora aarch64 build:
http://arm.koji.fedoraproject.org/koji/buildinfo?buildID=182251
build logs show all tests passing.
> +/* 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 (name != NULL && strcmp (sname, ".got") == 0)
^
That should be sname of course.
> + return sym->st_value == shdr->sh_addr;
> + }
> + }
> + }
> +
> + return false;
> +}
More information about the elfutils-devel
mailing list