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 {...@@ -855,7 +855,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
855 }855 }
856 // Write the form for the compile unit, which must match the abbrev table above.856 // Write the form for the compile unit, which must match the abbrev table above.
857 const name_strp = try self.makeDebugString(module.root_pkg.root_src_path);857 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 ".");
859 const producer_strp = try self.makeDebugString(link.producer_string);859 const producer_strp = try self.makeDebugString(link.producer_string);
860 // Currently only one compilation unit is supported, so the address range is simply860 // Currently only one compilation unit is supported, so the address range is simply
861 // identical to the main program header virtual address and memory size.861 // identical to the main program header virtual address and memory size.
...@@ -2858,11 +2858,12 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 {...@@ -2858,11 +2858,12 @@ fn dbgLineNeededHeaderBytes(self: Elf) u32 {
2858 const file_name_entry_format_count = 1;2858 const file_name_entry_format_count = 1;
2859 const directory_count = 1;2859 const directory_count = 1;
2860 const file_name_count = 1;2860 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; // "."
2861 return @intCast(u32, 53 + directory_entry_format_count * 2 + file_name_entry_format_count * 2 +2862 return @intCast(u32, 53 + directory_entry_format_count * 2 + file_name_entry_format_count * 2 +
2862 directory_count * 8 + file_name_count * 8 +2863 directory_count * 8 + file_name_count * 8 +
2863 // These are encoded as DW.FORM_string rather than DW.FORM_strp as we would like2864 // These are encoded as DW.FORM_string rather than DW.FORM_strp as we would like
2864 // because of a workaround for readelf and gdb failing to understand DWARFv5 correctly.2865 // 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 +
2866 self.base.options.module.?.root_pkg.root_src_path.len);2867 self.base.options.module.?.root_pkg.root_src_path.len);
2867}2868}
28682869