aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-09-25 13:37:10 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-09-25 13:37:10 -0700
commit812e482bef82450eb1010344a59c497feb12ee67 (patch)
treeb39782dc464995ff148fe9ce7c2f80b92b140aa9 /src
parent495d18a2056882d7edc7376751e7f3d4e10ef920 (diff)
downloadzig-812e482bef82450eb1010344a59c497feb12ee67.tar.gz
zig-812e482bef82450eb1010344a59c497feb12ee67.zip
ELF linking supports root src directory to be cwd
Diffstat (limited to 'src')
-rw-r--r--src/link/Elf.zig5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 8035adcf0d..931c1bc9c0 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -855,7 +855,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
}
// Write the form for the compile unit, which must match the abbrev table above.
const name_strp = try self.makeDebugString(module.root_pkg.root_src_path);
- const comp_dir_strp = try self.makeDebugString(module.root_pkg.root_src_directory.path.?);
+ const comp_dir_strp = try self.makeDebugString(module.root_pkg.root_src_directory.path orelse ".");
const producer_strp = try self.makeDebugString(link.producer_string);
// Currently only one compilation unit is supported, so the address range is simply
// identical to the main program header virtual address and memory size.
@@ -2858,11 +2858,12 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 {
const file_name_entry_format_count = 1;
const directory_count = 1;
const file_name_count = 1;
+ const root_src_dir_path_len = if (self.base.options.module.?.root_pkg.root_src_directory.path) |p| p.len else 1; // "."
return @intCast(u32, 53 + directory_entry_format_count * 2 + file_name_entry_format_count * 2 +
directory_count * 8 + file_name_count * 8 +
// These are encoded as DW.FORM_string rather than DW.FORM_strp as we would like
// because of a workaround for readelf and gdb failing to understand DWARFv5 correctly.
- self.base.options.module.?.root_pkg.root_src_directory.path.?.len +
+ root_src_dir_path_len +
self.base.options.module.?.root_pkg.root_src_path.len);
}