authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-07 14:51:33+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-16 19:33:05+02:00
log1772dbb503429fcee453a3ee6db1eed4dfe7c5c9
treecf39909fb07fd3b7b7943f66e927d25eb60cc728
parent06f3b385c409a576b7c962f22c154edb307dd90b

elf: fix generating .plt.got indirection


2 files changed, 4 insertions(+), 0 deletions(-)

src/link/Elf/Atom.zig+2
...@@ -697,6 +697,8 @@ fn reportUndefined(...@@ -697,6 +697,8 @@ fn reportUndefined(
697}697}
698698
699pub fn resolveRelocsAlloc(self: Atom, elf_file: *Elf, code: []u8) !void {699pub fn resolveRelocsAlloc(self: Atom, elf_file: *Elf, code: []u8) !void {
700 relocs_log.debug("0x{x}: {s}", .{ self.value, self.name(elf_file) });
701
700 const file_ptr = self.file(elf_file).?;702 const file_ptr = self.file(elf_file).?;
701 var stream = std.io.fixedBufferStream(code);703 var stream = std.io.fixedBufferStream(code);
702 const cwriter = stream.writer();704 const cwriter = stream.writer();
src/link/Elf/synthetic_sections.zig+2
...@@ -795,6 +795,8 @@ pub const PltGotSection = struct {...@@ -795,6 +795,8 @@ pub const PltGotSection = struct {
795 pub fn addSymbol(plt_got: *PltGotSection, sym_index: Symbol.Index, elf_file: *Elf) !void {795 pub fn addSymbol(plt_got: *PltGotSection, sym_index: Symbol.Index, elf_file: *Elf) !void {
796 const index = @as(u32, @intCast(plt_got.symbols.items.len));796 const index = @as(u32, @intCast(plt_got.symbols.items.len));
797 const symbol = elf_file.symbol(sym_index);797 const symbol = elf_file.symbol(sym_index);
798 symbol.flags.has_plt = true;
799 symbol.flags.has_got = true;
798 if (symbol.extra(elf_file)) |extra| {800 if (symbol.extra(elf_file)) |extra| {
799 var new_extra = extra;801 var new_extra = extra;
800 new_extra.plt_got = index;802 new_extra.plt_got = index;