From b5642b4f85e7962ee7eb3d137e47fadf392a865b Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Fri, 8 Mar 2024 14:32:47 +0100 Subject: [PATCH] elf+aarch64: set _GLOBAL_OFFSET_TABLE_ to .got section --- src/link/Elf.zig | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 78cc434b2f..b18e97a556 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -3170,11 +3170,20 @@ fn allocateLinkerDefinedSymbols(self: *Elf) void { } // _GLOBAL_OFFSET_TABLE_ - if (self.got_plt_section_index) |shndx| { - const shdr = &self.shdrs.items[shndx]; - const symbol_ptr = self.symbol(self.got_index.?); - symbol_ptr.value = shdr.sh_addr; - symbol_ptr.output_section_index = shndx; + if (self.getTarget().cpu.arch == .x86_64) { + if (self.got_plt_section_index) |shndx| { + const shdr = self.shdrs.items[shndx]; + const sym = self.symbol(self.got_index.?); + sym.value = shdr.sh_addr; + sym.output_section_index = shndx; + } + } else { + if (self.got_section_index) |shndx| { + const shdr = self.shdrs.items[shndx]; + const sym = self.symbol(self.got_index.?); + sym.value = shdr.sh_addr; + sym.output_section_index = shndx; + } } // _PROCEDURE_LINKAGE_TABLE_