aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-10-20 17:29:04 +0200
committerAndrew Kelley <andrew@ziglang.org>2023-10-21 21:38:41 -0400
commit3d7c6c803b788138aa08f51cf4ee8cf7892e315d (patch)
treecd6f81b82b20532d40e0944e6a814519ebf7cb41 /src
parentc4fcf0e22a0a0bab19ac9d1335b10decbfb2f137 (diff)
downloadzig-3d7c6c803b788138aa08f51cf4ee8cf7892e315d.tar.gz
zig-3d7c6c803b788138aa08f51cf4ee8cf7892e315d.zip
dwarf: fix false assumption that ptr-deref requires GOT-indirection
Diffstat (limited to 'src')
-rw-r--r--src/link/Dwarf.zig33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
index b78243de74..ae08c059fd 100644
--- a/src/link/Dwarf.zig
+++ b/src/link/Dwarf.zig
@@ -87,15 +87,6 @@ pub const DeclState = struct {
self.exprloc_relocs.deinit(self.gpa);
}
- fn addExprlocReloc(self: *DeclState, target: u32, offset: u32, is_ptr: bool) !void {
- log.debug("{x}: target sym %{d}, via GOT {}", .{ offset, target, is_ptr });
- try self.exprloc_relocs.append(self.gpa, .{
- .type = if (is_ptr) .got_load else .direct_load,
- .target = target,
- .offset = offset,
- });
- }
-
/// Adds local type relocation of the form: @offset => @this + addend
/// @this signifies the offset within the .debug_abbrev section of the containing atom.
fn addTypeRelocLocal(self: *DeclState, atom_index: Atom.Index, offset: u32, addend: u32) !void {
@@ -807,11 +798,25 @@ pub const DeclState = struct {
try dbg_info.append(DW.OP.deref);
}
switch (loc) {
- .linker_load => |load_struct| try self.addExprlocReloc(
- load_struct.sym_index,
- offset,
- is_ptr,
- ),
+ .linker_load => |load_struct| switch (load_struct.type) {
+ .direct => {
+ log.debug("{x}: target sym %{d}", .{ offset, load_struct.sym_index });
+ try self.exprloc_relocs.append(self.gpa, .{
+ .type = .direct_load,
+ .target = load_struct.sym_index,
+ .offset = offset,
+ });
+ },
+ .got => {
+ log.debug("{x}: target sym %{d} via GOT", .{ offset, load_struct.sym_index });
+ try self.exprloc_relocs.append(self.gpa, .{
+ .type = .got_load,
+ .target = load_struct.sym_index,
+ .offset = offset,
+ });
+ },
+ else => {}, // TODO
+ },
else => {},
}
},