aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfnn-aarch64.c
diff options
context:
space:
mode:
authorJiong Wang <jiong.wang@arm.com>2016-03-07 15:40:50 +0000
committerJiong Wang <jiong.wang@arm.com>2016-03-07 15:40:50 +0000
commit18f822a08fd5cb8fed8b0b318e7945545c255081 (patch)
tree8a6ee313b3871291eaf8a34d79bd94ae75deac68 /bfd/elfnn-aarch64.c
parentf86f586366275bbb5ae77520eb990769f05a3030 (diff)
downloadgdb-18f822a08fd5cb8fed8b0b318e7945545c255081.zip
gdb-18f822a08fd5cb8fed8b0b318e7945545c255081.tar.gz
gdb-18f822a08fd5cb8fed8b0b318e7945545c255081.tar.bz2
[AArch64] Create .got section if _GLOBAL_OFFSET_TABLE_ referenced
2016-03-07 Jiong Wang <jiong.wang@arm.com> bfd/ * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Always create .got section if the symbol "_GLOBAL_OFFSET_TABLE_" referenced. ld/ * testsuite/ld-aarch64/implicit_got_section_1.s: New test source file. * testsuite/ld-aarch64/implicit_got_section_1.d: New test expected result. * testsuite/ld-aarch64/aarch64-elf.exp: Run new test.
Diffstat (limited to 'bfd/elfnn-aarch64.c')
-rw-r--r--bfd/elfnn-aarch64.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 599b5f8..d14b734 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -7080,6 +7080,22 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info,
if (h != NULL)
{
+ /* If a relocation refers to _GLOBAL_OFFSET_TABLE_, create the .got.
+ This shows up in particular in an R_AARCH64_PREL64 in large model
+ when calculating the pc-relative address to .got section which is
+ used to initialize the gp register. */
+ if (h->root.root.string
+ && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+ {
+ if (htab->root.dynobj == NULL)
+ htab->root.dynobj = abfd;
+
+ if (! aarch64_elf_create_got_section (htab->root.dynobj, info))
+ return FALSE;
+
+ BFD_ASSERT (h == htab->root.hgot);
+ }
+
/* Create the ifunc sections for static executables. If we
never see an indirect function symbol nor we are building
a static executable, those sections will be empty and