authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-10-20 17:29:04+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-21 21:38:41-04:00
log3d7c6c803b788138aa08f51cf4ee8cf7892e315d
treecd6f81b82b20532d40e0944e6a814519ebf7cb41
parentc4fcf0e22a0a0bab19ac9d1335b10decbfb2f137

dwarf: fix false assumption that ptr-deref requires GOT-indirection


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

src/link/Dwarf.zig+19-14
......@@ -87,15 +87,6 @@ pub const DeclState = struct {
8787 self.exprloc_relocs.deinit(self.gpa);
8888 }
8989
90 fn addExprlocReloc(self: *DeclState, target: u32, offset: u32, is_ptr: bool) !void {
91 log.debug("{x}: target sym %{d}, via GOT {}", .{ offset, target, is_ptr });
92 try self.exprloc_relocs.append(self.gpa, .{
93 .type = if (is_ptr) .got_load else .direct_load,
94 .target = target,
95 .offset = offset,
96 });
97 }
98
9990 /// Adds local type relocation of the form: @offset => @this + addend
10091 /// @this signifies the offset within the .debug_abbrev section of the containing atom.
10192 fn addTypeRelocLocal(self: *DeclState, atom_index: Atom.Index, offset: u32, addend: u32) !void {
......@@ -807,11 +798,25 @@ pub const DeclState = struct {
807798 try dbg_info.append(DW.OP.deref);
808799 }
809800 switch (loc) {
810 .linker_load => |load_struct| try self.addExprlocReloc(
811 load_struct.sym_index,
812 offset,
813 is_ptr,
814 ),
801 .linker_load => |load_struct| switch (load_struct.type) {
802 .direct => {
803 log.debug("{x}: target sym %{d}", .{ offset, load_struct.sym_index });
804 try self.exprloc_relocs.append(self.gpa, .{
805 .type = .direct_load,
806 .target = load_struct.sym_index,
807 .offset = offset,
808 });
809 },
810 .got => {
811 log.debug("{x}: target sym %{d} via GOT", .{ offset, load_struct.sym_index });
812 try self.exprloc_relocs.append(self.gpa, .{
813 .type = .got_load,
814 .target = load_struct.sym_index,
815 .offset = offset,
816 });
817 },
818 else => {}, // TODO
819 },
815820 else => {},
816821 }
817822 },