authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-07-17 18:33:47+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-07-17 18:33:47+02:00
log9f20a51555169dfcc531b06390001d3dbd78094d
tree47ae420955c05643de8dcfa556f48585df3fc1fd
parentfccac48a55f91abfa6f04dc7274639a9faf5ab53

zld: demote logging back to debug from warn


3 files changed, 56 insertions(+), 55 deletions(-)

src/link/MachO/Object.zig+4-4
...@@ -486,7 +486,7 @@ const TextBlockParser = struct {...@@ -486,7 +486,7 @@ const TextBlockParser = struct {
486pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {486pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
487 const seg = self.load_commands.items[self.segment_cmd_index.?].Segment;487 const seg = self.load_commands.items[self.segment_cmd_index.?].Segment;
488488
489 log.warn("analysing {s}", .{self.name.?});489 log.debug("analysing {s}", .{self.name.?});
490490
491 const dysymtab = self.load_commands.items[self.dysymtab_cmd_index.?].Dysymtab;491 const dysymtab = self.load_commands.items[self.dysymtab_cmd_index.?].Dysymtab;
492 // We only care about defined symbols, so filter every other out.492 // We only care about defined symbols, so filter every other out.
...@@ -507,14 +507,14 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {...@@ -507,14 +507,14 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
507507
508 for (seg.sections.items) |sect, id| {508 for (seg.sections.items) |sect, id| {
509 const sect_id = @intCast(u8, id);509 const sect_id = @intCast(u8, id);
510 log.warn("putting section '{s},{s}' as a TextBlock", .{510 log.debug("putting section '{s},{s}' as a TextBlock", .{
511 segmentName(sect),511 segmentName(sect),
512 sectionName(sect),512 sectionName(sect),
513 });513 });
514514
515 // Get matching segment/section in the final artifact.515 // Get matching segment/section in the final artifact.
516 const match = (try zld.getMatchingSection(sect)) orelse {516 const match = (try zld.getMatchingSection(sect)) orelse {
517 log.warn("unhandled section", .{});517 log.debug("unhandled section", .{});
518 continue;518 continue;
519 };519 };
520520
...@@ -533,7 +533,7 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {...@@ -533,7 +533,7 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
533 const filtered_nlists = NlistWithIndex.filterInSection(sorted_nlists.items, sect);533 const filtered_nlists = NlistWithIndex.filterInSection(sorted_nlists.items, sect);
534534
535 // Is there any padding between symbols within the section?535 // Is there any padding between symbols within the section?
536 const is_splittable = self.header.?.flags & macho.MH_SUBSECTIONS_VIA_SYMBOLS != 0;536 // const is_splittable = self.header.?.flags & macho.MH_SUBSECTIONS_VIA_SYMBOLS != 0;
537 // TODO is it perhaps worth skip parsing subsections in Debug mode and not worry about537 // TODO is it perhaps worth skip parsing subsections in Debug mode and not worry about
538 // duplicates at all? Need some benchmarks!538 // duplicates at all? Need some benchmarks!
539 // const is_splittable = false;539 // const is_splittable = false;
src/link/MachO/TextBlock.zig+6-5
...@@ -695,7 +695,7 @@ pub fn parseRelocsFromObject(...@@ -695,7 +695,7 @@ pub fn parseRelocsFromObject(
695 .ARM64_RELOC_GOT_LOAD_PAGEOFF12,695 .ARM64_RELOC_GOT_LOAD_PAGEOFF12,
696 .ARM64_RELOC_TLVP_LOAD_PAGEOFF12,696 .ARM64_RELOC_TLVP_LOAD_PAGEOFF12,
697 => {697 => {
698 self.parsePageOff(rel, &parsed_rel, addend, ctx);698 self.parsePageOff(rel, &parsed_rel, addend);
699 if (rel_type == .ARM64_RELOC_PAGEOFF12)699 if (rel_type == .ARM64_RELOC_PAGEOFF12)
700 addend = 0;700 addend = 0;
701 },701 },
...@@ -866,6 +866,7 @@ fn parseUnsigned(...@@ -866,6 +866,7 @@ fn parseUnsigned(
866}866}
867867
868fn parseBranch(self: TextBlock, rel: macho.relocation_info, out: *Relocation, ctx: RelocContext) void {868fn parseBranch(self: TextBlock, rel: macho.relocation_info, out: *Relocation, ctx: RelocContext) void {
869 _ = self;
869 assert(rel.r_pcrel == 1);870 assert(rel.r_pcrel == 1);
870 assert(rel.r_length == 2);871 assert(rel.r_length == 2);
871872
...@@ -894,7 +895,7 @@ fn parsePage(self: TextBlock, rel: macho.relocation_info, out: *Relocation, adde...@@ -894,7 +895,7 @@ fn parsePage(self: TextBlock, rel: macho.relocation_info, out: *Relocation, adde
894 };895 };
895}896}
896897
897fn parsePageOff(self: TextBlock, rel: macho.relocation_info, out: *Relocation, addend: u32, ctx: RelocContext) void {898fn parsePageOff(self: TextBlock, rel: macho.relocation_info, out: *Relocation, addend: u32) void {
898 assert(rel.r_pcrel == 0);899 assert(rel.r_pcrel == 0);
899 assert(rel.r_length == 2);900 assert(rel.r_length == 2);
900901
...@@ -987,7 +988,7 @@ fn parseLoad(self: TextBlock, rel: macho.relocation_info, out: *Relocation) void...@@ -987,7 +988,7 @@ fn parseLoad(self: TextBlock, rel: macho.relocation_info, out: *Relocation) void
987988
988pub fn resolveRelocs(self: *TextBlock, zld: *Zld) !void {989pub fn resolveRelocs(self: *TextBlock, zld: *Zld) !void {
989 for (self.relocs.items) |rel| {990 for (self.relocs.items) |rel| {
990 log.warn("relocating {}", .{rel});991 log.debug("relocating {}", .{rel});
991992
992 const source_addr = blk: {993 const source_addr = blk: {
993 const sym = zld.locals.items[self.local_sym_index];994 const sym = zld.locals.items[self.local_sym_index];
...@@ -1073,8 +1074,8 @@ pub fn resolveRelocs(self: *TextBlock, zld: *Zld) !void {...@@ -1073,8 +1074,8 @@ pub fn resolveRelocs(self: *TextBlock, zld: *Zld) !void {
1073 }1074 }
1074 };1075 };
10751076
1076 log.warn(" | source_addr = 0x{x}", .{source_addr});1077 log.debug(" | source_addr = 0x{x}", .{source_addr});
1077 log.warn(" | target_addr = 0x{x}", .{target_addr});1078 log.debug(" | target_addr = 0x{x}", .{target_addr});
10781079
1079 try rel.resolve(.{1080 try rel.resolve(.{
1080 .block = self,1081 .block = self,
src/link/MachO/Zld.zig+46-46
...@@ -253,58 +253,58 @@ pub fn link(self: *Zld, files: []const []const u8, output: Output, args: LinkArg...@@ -253,58 +253,58 @@ pub fn link(self: *Zld, files: []const []const u8, output: Output, args: LinkArg
253 self.allocateLinkeditSegment();253 self.allocateLinkeditSegment();
254 try self.allocateTextBlocks();254 try self.allocateTextBlocks();
255255
256 log.warn("locals", .{});256 // log.warn("locals", .{});
257 for (self.locals.items) |sym, id| {257 // for (self.locals.items) |sym, id| {
258 log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });258 // log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
259 }259 // }
260260
261 log.warn("globals", .{});261 // log.warn("globals", .{});
262 for (self.globals.items) |sym, id| {262 // for (self.globals.items) |sym, id| {
263 log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });263 // log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
264 }264 // }
265265
266 log.warn("tentatives", .{});266 // log.warn("tentatives", .{});
267 for (self.tentatives.items) |sym, id| {267 // for (self.tentatives.items) |sym, id| {
268 log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });268 // log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
269 }269 // }
270270
271 log.warn("undefines", .{});271 // log.warn("undefines", .{});
272 for (self.undefs.items) |sym, id| {272 // for (self.undefs.items) |sym, id| {
273 log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });273 // log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
274 }274 // }
275275
276 log.warn("imports", .{});276 // log.warn("imports", .{});
277 for (self.imports.items) |sym, id| {277 // for (self.imports.items) |sym, id| {
278 log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });278 // log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
279 }279 // }
280280
281 log.warn("symbol resolver", .{});281 // log.warn("symbol resolver", .{});
282 for (self.symbol_resolver.keys()) |key| {282 // for (self.symbol_resolver.keys()) |key| {
283 log.warn(" {s} => {}", .{ key, self.symbol_resolver.get(key).? });283 // log.warn(" {s} => {}", .{ key, self.symbol_resolver.get(key).? });
284 }284 // }
285
286 log.warn("mappings", .{});
287 for (self.objects.items) |object, id| {
288 const object_id = @intCast(u16, id);
289 log.warn(" in object {s}", .{object.name.?});
290 for (object.symtab.items) |sym, sym_id| {
291 if (object.symbol_mapping.get(@intCast(u32, sym_id))) |local_id| {
292 log.warn(" | {d} => {d}", .{ sym_id, local_id });
293 } else {
294 log.warn(" | {d} no local mapping for {s}", .{ sym_id, object.getString(sym.n_strx) });
295 }
296 }
297 }
298285
299 var it = self.blocks.iterator();286 // log.warn("mappings", .{});
300 while (it.next()) |entry| {287 // for (self.objects.items) |object, id| {
301 const seg = self.load_commands.items[entry.key_ptr.seg].Segment;288 // const object_id = @intCast(u16, id);
302 const sect = seg.sections.items[entry.key_ptr.sect];289 // log.warn(" in object {s}", .{object.name.?});
290 // for (object.symtab.items) |sym, sym_id| {
291 // if (object.symbol_mapping.get(@intCast(u32, sym_id))) |local_id| {
292 // log.warn(" | {d} => {d}", .{ sym_id, local_id });
293 // } else {
294 // log.warn(" | {d} no local mapping for {s}", .{ sym_id, object.getString(sym.n_strx) });
295 // }
296 // }
297 // }
303298
304 log.warn("\n\n{s},{s} contents:", .{ segmentName(sect), sectionName(sect) });299 // var it = self.blocks.iterator();
305 log.warn(" {}", .{sect});300 // while (it.next()) |entry| {
306 entry.value_ptr.*.print(self);301 // const seg = self.load_commands.items[entry.key_ptr.seg].Segment;
307 }302 // const sect = seg.sections.items[entry.key_ptr.sect];
303
304 // log.warn("\n\n{s},{s} contents:", .{ segmentName(sect), sectionName(sect) });
305 // log.warn(" {}", .{sect});
306 // entry.value_ptr.*.print(self);
307 // }
308308
309 try self.flush();309 try self.flush();
310}310}
...@@ -1411,7 +1411,7 @@ fn writeStubInStubHelper(self: *Zld, index: u32) !void {...@@ -1411,7 +1411,7 @@ fn writeStubInStubHelper(self: *Zld, index: u32) !void {
1411fn resolveSymbolsInObject(self: *Zld, object_id: u16) !void {1411fn resolveSymbolsInObject(self: *Zld, object_id: u16) !void {
1412 const object = self.objects.items[object_id];1412 const object = self.objects.items[object_id];
14131413
1414 log.warn("resolving symbols in '{s}'", .{object.name});1414 log.debug("resolving symbols in '{s}'", .{object.name});
14151415
1416 for (object.symtab.items) |sym, id| {1416 for (object.symtab.items) |sym, id| {
1417 const sym_id = @intCast(u32, id);1417 const sym_id = @intCast(u32, id);