authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-03-08 14:32:47+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-03-08 22:46:17+01:00
logb5642b4f85e7962ee7eb3d137e47fadf392a865b
tree73bfdff3bd2df798efd6f0f307279ba8a12c90ef
parentd9069cbe2cf88634eb556b3063ede5af4a5cced4

elf+aarch64: set _GLOBAL_OFFSET_TABLE_ to .got section


1 files changed, 14 insertions(+), 5 deletions(-)

src/link/Elf.zig+14-5
......@@ -3170,11 +3170,20 @@ fn allocateLinkerDefinedSymbols(self: *Elf) void {
31703170 }
31713171
31723172 // _GLOBAL_OFFSET_TABLE_
3173 if (self.got_plt_section_index) |shndx| {
3174 const shdr = &self.shdrs.items[shndx];
3175 const symbol_ptr = self.symbol(self.got_index.?);
3176 symbol_ptr.value = shdr.sh_addr;
3177 symbol_ptr.output_section_index = shndx;
3173 if (self.getTarget().cpu.arch == .x86_64) {
3174 if (self.got_plt_section_index) |shndx| {
3175 const shdr = self.shdrs.items[shndx];
3176 const sym = self.symbol(self.got_index.?);
3177 sym.value = shdr.sh_addr;
3178 sym.output_section_index = shndx;
3179 }
3180 } else {
3181 if (self.got_section_index) |shndx| {
3182 const shdr = self.shdrs.items[shndx];
3183 const sym = self.symbol(self.got_index.?);
3184 sym.value = shdr.sh_addr;
3185 sym.output_section_index = shndx;
3186 }
31783187 }
31793188
31803189 // _PROCEDURE_LINKAGE_TABLE_