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 {
486486pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
487487 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
491491 const dysymtab = self.load_commands.items[self.dysymtab_cmd_index.?].Dysymtab;
492492 // We only care about defined symbols, so filter every other out.
......@@ -507,14 +507,14 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
507507
508508 for (seg.sections.items) |sect, id| {
509509 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", .{
511511 segmentName(sect),
512512 sectionName(sect),
513513 });
514514
515515 // Get matching segment/section in the final artifact.
516516 const match = (try zld.getMatchingSection(sect)) orelse {
517 log.warn("unhandled section", .{});
517 log.debug("unhandled section", .{});
518518 continue;
519519 };
520520
......@@ -533,7 +533,7 @@ pub fn parseTextBlocks(self: *Object, zld: *Zld) !void {
533533 const filtered_nlists = NlistWithIndex.filterInSection(sorted_nlists.items, sect);
534534
535535 // 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;
537537 // TODO is it perhaps worth skip parsing subsections in Debug mode and not worry about
538538 // duplicates at all? Need some benchmarks!
539539 // const is_splittable = false;
src/link/MachO/TextBlock.zig+6-5
......@@ -695,7 +695,7 @@ pub fn parseRelocsFromObject(
695695 .ARM64_RELOC_GOT_LOAD_PAGEOFF12,
696696 .ARM64_RELOC_TLVP_LOAD_PAGEOFF12,
697697 => {
698 self.parsePageOff(rel, &parsed_rel, addend, ctx);
698 self.parsePageOff(rel, &parsed_rel, addend);
699699 if (rel_type == .ARM64_RELOC_PAGEOFF12)
700700 addend = 0;
701701 },
......@@ -866,6 +866,7 @@ fn parseUnsigned(
866866}
867867
868868fn parseBranch(self: TextBlock, rel: macho.relocation_info, out: *Relocation, ctx: RelocContext) void {
869 _ = self;
869870 assert(rel.r_pcrel == 1);
870871 assert(rel.r_length == 2);
871872
......@@ -894,7 +895,7 @@ fn parsePage(self: TextBlock, rel: macho.relocation_info, out: *Relocation, adde
894895 };
895896}
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 {
898899 assert(rel.r_pcrel == 0);
899900 assert(rel.r_length == 2);
900901
......@@ -987,7 +988,7 @@ fn parseLoad(self: TextBlock, rel: macho.relocation_info, out: *Relocation) void
987988
988989pub fn resolveRelocs(self: *TextBlock, zld: *Zld) !void {
989990 for (self.relocs.items) |rel| {
990 log.warn("relocating {}", .{rel});
991 log.debug("relocating {}", .{rel});
991992
992993 const source_addr = blk: {
993994 const sym = zld.locals.items[self.local_sym_index];
......@@ -1073,8 +1074,8 @@ pub fn resolveRelocs(self: *TextBlock, zld: *Zld) !void {
10731074 }
10741075 };
10751076
1076 log.warn(" | source_addr = 0x{x}", .{source_addr});
1077 log.warn(" | target_addr = 0x{x}", .{target_addr});
1077 log.debug(" | source_addr = 0x{x}", .{source_addr});
1078 log.debug(" | target_addr = 0x{x}", .{target_addr});
10781079
10791080 try rel.resolve(.{
10801081 .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
253253 self.allocateLinkeditSegment();
254254 try self.allocateTextBlocks();
255255
256 log.warn("locals", .{});
257 for (self.locals.items) |sym, id| {
258 log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
259 }
256 // log.warn("locals", .{});
257 // for (self.locals.items) |sym, id| {
258 // log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
259 // }
260260
261 log.warn("globals", .{});
262 for (self.globals.items) |sym, id| {
263 log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
264 }
261 // log.warn("globals", .{});
262 // for (self.globals.items) |sym, id| {
263 // log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
264 // }
265265
266 log.warn("tentatives", .{});
267 for (self.tentatives.items) |sym, id| {
268 log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
269 }
266 // log.warn("tentatives", .{});
267 // for (self.tentatives.items) |sym, id| {
268 // log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
269 // }
270270
271 log.warn("undefines", .{});
272 for (self.undefs.items) |sym, id| {
273 log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
274 }
271 // log.warn("undefines", .{});
272 // for (self.undefs.items) |sym, id| {
273 // log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
274 // }
275275
276 log.warn("imports", .{});
277 for (self.imports.items) |sym, id| {
278 log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
279 }
276 // log.warn("imports", .{});
277 // for (self.imports.items) |sym, id| {
278 // log.warn(" {d}: {s}, {}", .{ id, self.getString(sym.n_strx), sym });
279 // }
280280
281 log.warn("symbol resolver", .{});
282 for (self.symbol_resolver.keys()) |key| {
283 log.warn(" {s} => {}", .{ key, self.symbol_resolver.get(key).? });
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 }
281 // log.warn("symbol resolver", .{});
282 // for (self.symbol_resolver.keys()) |key| {
283 // log.warn(" {s} => {}", .{ key, self.symbol_resolver.get(key).? });
284 // }
298285
299 var it = self.blocks.iterator();
300 while (it.next()) |entry| {
301 const seg = self.load_commands.items[entry.key_ptr.seg].Segment;
302 const sect = seg.sections.items[entry.key_ptr.sect];
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 // }
303298
304 log.warn("\n\n{s},{s} contents:", .{ segmentName(sect), sectionName(sect) });
305 log.warn(" {}", .{sect});
306 entry.value_ptr.*.print(self);
307 }
299 // var it = self.blocks.iterator();
300 // while (it.next()) |entry| {
301 // const seg = self.load_commands.items[entry.key_ptr.seg].Segment;
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
309309 try self.flush();
310310}
......@@ -1411,7 +1411,7 @@ fn writeStubInStubHelper(self: *Zld, index: u32) !void {
14111411fn resolveSymbolsInObject(self: *Zld, object_id: u16) !void {
14121412 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
14161416 for (object.symtab.items) |sym, id| {
14171417 const sym_id = @intCast(u32, id);