authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-25 13:37:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-09-25 13:37:10-07:00
log812e482bef82450eb1010344a59c497feb12ee67
treeb39782dc464995ff148fe9ce7c2f80b92b140aa9
parent495d18a2056882d7edc7376751e7f3d4e10ef920

ELF linking supports root src directory to be cwd


1 files changed, 3 insertions(+), 2 deletions(-)

src/link/Elf.zig+3-2
......@@ -855,7 +855,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
855855 }
856856 // Write the form for the compile unit, which must match the abbrev table above.
857857 const name_strp = try self.makeDebugString(module.root_pkg.root_src_path);
858 const comp_dir_strp = try self.makeDebugString(module.root_pkg.root_src_directory.path.?);
858 const comp_dir_strp = try self.makeDebugString(module.root_pkg.root_src_directory.path orelse ".");
859859 const producer_strp = try self.makeDebugString(link.producer_string);
860860 // Currently only one compilation unit is supported, so the address range is simply
861861 // identical to the main program header virtual address and memory size.
......@@ -2858,11 +2858,12 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 {
28582858 const file_name_entry_format_count = 1;
28592859 const directory_count = 1;
28602860 const file_name_count = 1;
2861 const root_src_dir_path_len = if (self.base.options.module.?.root_pkg.root_src_directory.path) |p| p.len else 1; // "."
28612862 return @intCast(u32, 53 + directory_entry_format_count * 2 + file_name_entry_format_count * 2 +
28622863 directory_count * 8 + file_name_count * 8 +
28632864 // These are encoded as DW.FORM_string rather than DW.FORM_strp as we would like
28642865 // because of a workaround for readelf and gdb failing to understand DWARFv5 correctly.
2865 self.base.options.module.?.root_pkg.root_src_directory.path.?.len +
2866 root_src_dir_path_len +
28662867 self.base.options.module.?.root_pkg.root_src_path.len);
28672868}
28682869