From b82746b81676737586289161eaa6ecb0f1eb7c0d Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 19 Dec 2013 16:24:12 +0100 Subject: [PATCH] 0.157-4 Add elfutils-0.157-aarch64-got-special-symbol.patch. --- ...ils-0.157-aarch64-got-special-symbol.patch | 70 +++++++++++++++++++ elfutils.spec | 7 +- 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 elfutils-0.157-aarch64-got-special-symbol.patch diff --git a/elfutils-0.157-aarch64-got-special-symbol.patch b/elfutils-0.157-aarch64-got-special-symbol.patch new file mode 100644 index 0000000..c7eacfa --- /dev/null +++ b/elfutils-0.157-aarch64-got-special-symbol.patch @@ -0,0 +1,70 @@ +commit 96d3b0aeddbb8c5557fdc5769e4d73eac81d74fd +Author: Mark Wielaard +Date: Thu Dec 19 16:11:19 2013 +0100 + + 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 + +diff --git a/backends/aarch64_init.c b/backends/aarch64_init.c +index 749af2a..d663d40 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 b0f3377..4e1dbd8 100644 +--- a/backends/aarch64_symbol.c ++++ b/backends/aarch64_symbol.c +@@ -32,6 +32,7 @@ + + #include + #include ++#include + + #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 (name != NULL && strcmp (sname, ".got") == 0) ++ return sym->st_value == shdr->sh_addr; ++ } ++ } ++ } ++ ++ return false; ++} diff --git a/elfutils.spec b/elfutils.spec index 05bcf9e..c41e98d 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,7 +1,7 @@ Name: elfutils Summary: A collection of utilities and DSOs to handle compiled objects Version: 0.157 -%global baserelease 3 +%global baserelease 4 URL: https://fedorahosted.org/elfutils/ %global source_url http://fedorahosted.org/releases/e/l/elfutils/%{version}/ License: GPLv3+ and (GPLv2+ or LGPLv3+) @@ -53,6 +53,7 @@ Patch3: elfutils-0.157-aarch64-elf.h.patch Patch4: elfutils-0.157-aarch64-hidden_format.patch Patch5: elfutils-0.157-aarch64-meat.patch Patch6: elfutils-0.157-aarch64-configury.patch +Patch7: elfutils-0.157-aarch64-got-special-symbol.patch %if !%{compat} Release: %{baserelease}%{?dist} @@ -221,6 +222,7 @@ sed -i.scanf-m -e 's/%m/%a/g' src/addr2line.c tests/line2addr.c %patch4 -p1 %patch5 -p1 %patch6 -p1 +%patch7 -p1 cp %{SOURCE2} %{SOURCE3} %{SOURCE4} tests/ find . -name \*.sh ! -perm -0100 -print | xargs chmod +x @@ -337,6 +339,9 @@ rm -rf ${RPM_BUILD_ROOT} %{_libdir}/libelf.a %changelog +* Thu Dec 19 2013 Mark Wielaard - 0.157-4 +- Add elfutils-0.157-aarch64-got-special-symbol.patch. + * Fri Dec 13 2013 Petr Machata - 0.157-3 - Add upstream support for aarch64