authorgravatar for jacoblevgw@gmail.comJacob G-W <jacoblevgw@gmail.com> 2021-06-13 16:35:25-04:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2021-06-13 23:42:57+03:00
logdf4f11f42f44b4ee2a06e43095bc160277ceed42
tree43b63421bce3441b0bb1a405c575d389c81489b0
parentff79b87fa062d602722a6ec17f74550cda42a624

link/Elf: don't use \n in log.debug calls

It already inserts a \n so it produces 2 \n which is harder to read.

1 files changed, 23 insertions(+), 23 deletions(-)

src/link/Elf.zig+23-23
...@@ -451,7 +451,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {...@@ -451,7 +451,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
451 const file_size = self.base.options.program_code_size_hint;451 const file_size = self.base.options.program_code_size_hint;
452 const p_align = 0x1000;452 const p_align = 0x1000;
453 const off = self.findFreeSpace(file_size, p_align);453 const off = self.findFreeSpace(file_size, p_align);
454 log.debug("found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });454 log.debug("found PT_LOAD free space 0x{x} to 0x{x}", .{ off, off + file_size });
455 const entry_addr: u64 = self.entry_addr orelse if (self.base.options.target.cpu.arch == .spu_2) @as(u64, 0) else default_entry_addr;455 const entry_addr: u64 = self.entry_addr orelse if (self.base.options.target.cpu.arch == .spu_2) @as(u64, 0) else default_entry_addr;
456 try self.program_headers.append(self.base.allocator, .{456 try self.program_headers.append(self.base.allocator, .{
457 .p_type = elf.PT_LOAD,457 .p_type = elf.PT_LOAD,
...@@ -473,7 +473,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {...@@ -473,7 +473,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
473 // page align.473 // page align.
474 const p_align = if (self.base.options.target.os.tag == .linux) 0x1000 else @as(u16, ptr_size);474 const p_align = if (self.base.options.target.os.tag == .linux) 0x1000 else @as(u16, ptr_size);
475 const off = self.findFreeSpace(file_size, p_align);475 const off = self.findFreeSpace(file_size, p_align);
476 log.debug("found PT_LOAD free space 0x{x} to 0x{x}\n", .{ off, off + file_size });476 log.debug("found PT_LOAD free space 0x{x} to 0x{x}", .{ off, off + file_size });
477 // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at.477 // TODO instead of hard coding the vaddr, make a function to find a vaddr to put things at.
478 // we'll need to re-use that function anyway, in case the GOT grows and overlaps something478 // we'll need to re-use that function anyway, in case the GOT grows and overlaps something
479 // else in virtual memory.479 // else in virtual memory.
...@@ -495,7 +495,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {...@@ -495,7 +495,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
495 assert(self.shstrtab.items.len == 0);495 assert(self.shstrtab.items.len == 0);
496 try self.shstrtab.append(self.base.allocator, 0); // need a 0 at position 0496 try self.shstrtab.append(self.base.allocator, 0); // need a 0 at position 0
497 const off = self.findFreeSpace(self.shstrtab.items.len, 1);497 const off = self.findFreeSpace(self.shstrtab.items.len, 1);
498 log.debug("found shstrtab free space 0x{x} to 0x{x}\n", .{ off, off + self.shstrtab.items.len });498 log.debug("found shstrtab free space 0x{x} to 0x{x}", .{ off, off + self.shstrtab.items.len });
499 try self.sections.append(self.base.allocator, .{499 try self.sections.append(self.base.allocator, .{
500 .sh_name = try self.makeString(".shstrtab"),500 .sh_name = try self.makeString(".shstrtab"),
501 .sh_type = elf.SHT_STRTAB,501 .sh_type = elf.SHT_STRTAB,
...@@ -553,7 +553,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {...@@ -553,7 +553,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
553 const each_size: u64 = if (small_ptr) @sizeOf(elf.Elf32_Sym) else @sizeOf(elf.Elf64_Sym);553 const each_size: u64 = if (small_ptr) @sizeOf(elf.Elf32_Sym) else @sizeOf(elf.Elf64_Sym);
554 const file_size = self.base.options.symbol_count_hint * each_size;554 const file_size = self.base.options.symbol_count_hint * each_size;
555 const off = self.findFreeSpace(file_size, min_align);555 const off = self.findFreeSpace(file_size, min_align);
556 log.debug("found symtab free space 0x{x} to 0x{x}\n", .{ off, off + file_size });556 log.debug("found symtab free space 0x{x} to 0x{x}", .{ off, off + file_size });
557557
558 try self.sections.append(self.base.allocator, .{558 try self.sections.append(self.base.allocator, .{
559 .sh_name = try self.makeString(".symtab"),559 .sh_name = try self.makeString(".symtab"),
...@@ -595,7 +595,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {...@@ -595,7 +595,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
595 const file_size_hint = 200;595 const file_size_hint = 200;
596 const p_align = 1;596 const p_align = 1;
597 const off = self.findFreeSpace(file_size_hint, p_align);597 const off = self.findFreeSpace(file_size_hint, p_align);
598 log.debug("found .debug_info free space 0x{x} to 0x{x}\n", .{598 log.debug("found .debug_info free space 0x{x} to 0x{x}", .{
599 off,599 off,
600 off + file_size_hint,600 off + file_size_hint,
601 });601 });
...@@ -620,7 +620,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {...@@ -620,7 +620,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
620 const file_size_hint = 128;620 const file_size_hint = 128;
621 const p_align = 1;621 const p_align = 1;
622 const off = self.findFreeSpace(file_size_hint, p_align);622 const off = self.findFreeSpace(file_size_hint, p_align);
623 log.debug("found .debug_abbrev free space 0x{x} to 0x{x}\n", .{623 log.debug("found .debug_abbrev free space 0x{x} to 0x{x}", .{
624 off,624 off,
625 off + file_size_hint,625 off + file_size_hint,
626 });626 });
...@@ -645,7 +645,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {...@@ -645,7 +645,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
645 const file_size_hint = 160;645 const file_size_hint = 160;
646 const p_align = 16;646 const p_align = 16;
647 const off = self.findFreeSpace(file_size_hint, p_align);647 const off = self.findFreeSpace(file_size_hint, p_align);
648 log.debug("found .debug_aranges free space 0x{x} to 0x{x}\n", .{648 log.debug("found .debug_aranges free space 0x{x} to 0x{x}", .{
649 off,649 off,
650 off + file_size_hint,650 off + file_size_hint,
651 });651 });
...@@ -670,7 +670,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {...@@ -670,7 +670,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
670 const file_size_hint = 250;670 const file_size_hint = 250;
671 const p_align = 1;671 const p_align = 1;
672 const off = self.findFreeSpace(file_size_hint, p_align);672 const off = self.findFreeSpace(file_size_hint, p_align);
673 log.debug("found .debug_line free space 0x{x} to 0x{x}\n", .{673 log.debug("found .debug_line free space 0x{x} to 0x{x}", .{
674 off,674 off,
675 off + file_size_hint,675 off + file_size_hint,
676 });676 });
...@@ -826,7 +826,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {...@@ -826,7 +826,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
826 debug_abbrev_sect.sh_offset = self.findFreeSpace(needed_size, 1);826 debug_abbrev_sect.sh_offset = self.findFreeSpace(needed_size, 1);
827 }827 }
828 debug_abbrev_sect.sh_size = needed_size;828 debug_abbrev_sect.sh_size = needed_size;
829 log.debug(".debug_abbrev start=0x{x} end=0x{x}\n", .{829 log.debug(".debug_abbrev start=0x{x} end=0x{x}", .{
830 debug_abbrev_sect.sh_offset,830 debug_abbrev_sect.sh_offset,
831 debug_abbrev_sect.sh_offset + needed_size,831 debug_abbrev_sect.sh_offset + needed_size,
832 });832 });
...@@ -973,7 +973,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {...@@ -973,7 +973,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
973 debug_aranges_sect.sh_offset = self.findFreeSpace(needed_size, 16);973 debug_aranges_sect.sh_offset = self.findFreeSpace(needed_size, 16);
974 }974 }
975 debug_aranges_sect.sh_size = needed_size;975 debug_aranges_sect.sh_size = needed_size;
976 log.debug(".debug_aranges start=0x{x} end=0x{x}\n", .{976 log.debug(".debug_aranges start=0x{x} end=0x{x}", .{
977 debug_aranges_sect.sh_offset,977 debug_aranges_sect.sh_offset,
978 debug_aranges_sect.sh_offset + needed_size,978 debug_aranges_sect.sh_offset + needed_size,
979 });979 });
...@@ -1140,7 +1140,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {...@@ -1140,7 +1140,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
1140 shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);1140 shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);
1141 }1141 }
1142 shstrtab_sect.sh_size = needed_size;1142 shstrtab_sect.sh_size = needed_size;
1143 log.debug("writing shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size });1143 log.debug("writing shstrtab start=0x{x} end=0x{x}", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size });
11441144
1145 try self.base.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset);1145 try self.base.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset);
1146 if (!self.shdr_table_dirty) {1146 if (!self.shdr_table_dirty) {
...@@ -1161,7 +1161,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {...@@ -1161,7 +1161,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
1161 debug_strtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);1161 debug_strtab_sect.sh_offset = self.findFreeSpace(needed_size, 1);
1162 }1162 }
1163 debug_strtab_sect.sh_size = needed_size;1163 debug_strtab_sect.sh_size = needed_size;
1164 log.debug("debug_strtab start=0x{x} end=0x{x}\n", .{ debug_strtab_sect.sh_offset, debug_strtab_sect.sh_offset + needed_size });1164 log.debug("debug_strtab start=0x{x} end=0x{x}", .{ debug_strtab_sect.sh_offset, debug_strtab_sect.sh_offset + needed_size });
11651165
1166 try self.base.file.?.pwriteAll(self.debug_strtab.items, debug_strtab_sect.sh_offset);1166 try self.base.file.?.pwriteAll(self.debug_strtab.items, debug_strtab_sect.sh_offset);
1167 if (!self.shdr_table_dirty) {1167 if (!self.shdr_table_dirty) {
...@@ -1195,7 +1195,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {...@@ -1195,7 +1195,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
11951195
1196 for (buf) |*shdr, i| {1196 for (buf) |*shdr, i| {
1197 shdr.* = sectHeaderTo32(self.sections.items[i]);1197 shdr.* = sectHeaderTo32(self.sections.items[i]);
1198 log.debug("writing section {}\n", .{shdr.*});1198 log.debug("writing section {}", .{shdr.*});
1199 if (foreign_endian) {1199 if (foreign_endian) {
1200 std.elf.bswapAllFields(elf.Elf32_Shdr, shdr);1200 std.elf.bswapAllFields(elf.Elf32_Shdr, shdr);
1201 }1201 }
...@@ -1208,7 +1208,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {...@@ -1208,7 +1208,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
12081208
1209 for (buf) |*shdr, i| {1209 for (buf) |*shdr, i| {
1210 shdr.* = self.sections.items[i];1210 shdr.* = self.sections.items[i];
1211 log.debug("writing section {}\n", .{shdr.*});1211 log.debug("writing section {}", .{shdr.*});
1212 if (foreign_endian) {1212 if (foreign_endian) {
1213 std.elf.bswapAllFields(elf.Elf64_Shdr, shdr);1213 std.elf.bswapAllFields(elf.Elf64_Shdr, shdr);
1214 }1214 }
...@@ -1219,10 +1219,10 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {...@@ -1219,10 +1219,10 @@ pub fn flushModule(self: *Elf, comp: *Compilation) !void {
1219 self.shdr_table_dirty = false;1219 self.shdr_table_dirty = false;
1220 }1220 }
1221 if (self.entry_addr == null and self.base.options.effectiveOutputMode() == .Exe) {1221 if (self.entry_addr == null and self.base.options.effectiveOutputMode() == .Exe) {
1222 log.debug("flushing. no_entry_point_found = true\n", .{});1222 log.debug("flushing. no_entry_point_found = true", .{});
1223 self.error_flags.no_entry_point_found = true;1223 self.error_flags.no_entry_point_found = true;
1224 } else {1224 } else {
1225 log.debug("flushing. no_entry_point_found = false\n", .{});1225 log.debug("flushing. no_entry_point_found = false", .{});
1226 self.error_flags.no_entry_point_found = false;1226 self.error_flags.no_entry_point_found = false;
1227 try self.writeElfHeader();1227 try self.writeElfHeader();
1228 }1228 }
...@@ -2073,10 +2073,10 @@ pub fn allocateDeclIndexes(self: *Elf, decl: *Module.Decl) !void {...@@ -2073,10 +2073,10 @@ pub fn allocateDeclIndexes(self: *Elf, decl: *Module.Decl) !void {
2073 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);2073 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);
20742074
2075 if (self.local_symbol_free_list.popOrNull()) |i| {2075 if (self.local_symbol_free_list.popOrNull()) |i| {
2076 log.debug("reusing symbol index {d} for {s}\n", .{ i, decl.name });2076 log.debug("reusing symbol index {d} for {s}", .{ i, decl.name });
2077 decl.link.elf.local_sym_index = i;2077 decl.link.elf.local_sym_index = i;
2078 } else {2078 } else {
2079 log.debug("allocating symbol index {d} for {s}\n", .{ self.local_symbols.items.len, decl.name });2079 log.debug("allocating symbol index {d} for {s}", .{ self.local_symbols.items.len, decl.name });
2080 decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len);2080 decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len);
2081 _ = self.local_symbols.addOneAssumeCapacity();2081 _ = self.local_symbols.addOneAssumeCapacity();
2082 }2082 }
...@@ -2278,11 +2278,11 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {...@@ -2278,11 +2278,11 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
2278 !mem.isAlignedGeneric(u64, local_sym.st_value, required_alignment);2278 !mem.isAlignedGeneric(u64, local_sym.st_value, required_alignment);
2279 if (need_realloc) {2279 if (need_realloc) {
2280 const vaddr = try self.growTextBlock(&decl.link.elf, code.len, required_alignment);2280 const vaddr = try self.growTextBlock(&decl.link.elf, code.len, required_alignment);
2281 log.debug("growing {s} from 0x{x} to 0x{x}\n", .{ decl.name, local_sym.st_value, vaddr });2281 log.debug("growing {s} from 0x{x} to 0x{x}", .{ decl.name, local_sym.st_value, vaddr });
2282 if (vaddr != local_sym.st_value) {2282 if (vaddr != local_sym.st_value) {
2283 local_sym.st_value = vaddr;2283 local_sym.st_value = vaddr;
22842284
2285 log.debug(" (writing new offset table entry)\n", .{});2285 log.debug(" (writing new offset table entry)", .{});
2286 self.offset_table.items[decl.link.elf.offset_table_index] = vaddr;2286 self.offset_table.items[decl.link.elf.offset_table_index] = vaddr;
2287 try self.writeOffsetTableEntry(decl.link.elf.offset_table_index);2287 try self.writeOffsetTableEntry(decl.link.elf.offset_table_index);
2288 }2288 }
...@@ -2300,7 +2300,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {...@@ -2300,7 +2300,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
2300 const decl_name = mem.spanZ(decl.name);2300 const decl_name = mem.spanZ(decl.name);
2301 const name_str_index = try self.makeString(decl_name);2301 const name_str_index = try self.makeString(decl_name);
2302 const vaddr = try self.allocateTextBlock(&decl.link.elf, code.len, required_alignment);2302 const vaddr = try self.allocateTextBlock(&decl.link.elf, code.len, required_alignment);
2303 log.debug("allocated text block for {s} at 0x{x}\n", .{ decl_name, vaddr });2303 log.debug("allocated text block for {s} at 0x{x}", .{ decl_name, vaddr });
2304 errdefer self.freeTextBlock(&decl.link.elf);2304 errdefer self.freeTextBlock(&decl.link.elf);
23052305
2306 local_sym.* = .{2306 local_sym.* = .{
...@@ -2418,7 +2418,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {...@@ -2418,7 +2418,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
2418 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {2418 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {
2419 const new_offset = self.findFreeSpace(needed_size, 1);2419 const new_offset = self.findFreeSpace(needed_size, 1);
2420 const existing_size = last_src_fn.off;2420 const existing_size = last_src_fn.off;
2421 log.debug("moving .debug_line section: {d} bytes from 0x{x} to 0x{x}\n", .{2421 log.debug("moving .debug_line section: {d} bytes from 0x{x} to 0x{x}", .{
2422 existing_size,2422 existing_size,
2423 debug_line_sect.sh_offset,2423 debug_line_sect.sh_offset,
2424 new_offset,2424 new_offset,
...@@ -2589,7 +2589,7 @@ fn writeDeclDebugInfo(self: *Elf, text_block: *TextBlock, dbg_info_buf: []const...@@ -2589,7 +2589,7 @@ fn writeDeclDebugInfo(self: *Elf, text_block: *TextBlock, dbg_info_buf: []const
2589 if (needed_size > self.allocatedSize(debug_info_sect.sh_offset)) {2589 if (needed_size > self.allocatedSize(debug_info_sect.sh_offset)) {
2590 const new_offset = self.findFreeSpace(needed_size, 1);2590 const new_offset = self.findFreeSpace(needed_size, 1);
2591 const existing_size = last_decl.dbg_info_off;2591 const existing_size = last_decl.dbg_info_off;
2592 log.debug("moving .debug_info section: {} bytes from 0x{x} to 0x{x}\n", .{2592 log.debug("moving .debug_info section: {} bytes from 0x{x} to 0x{x}", .{
2593 existing_size,2593 existing_size,
2594 debug_info_sect.sh_offset,2594 debug_info_sect.sh_offset,
2595 new_offset,2595 new_offset,