| ... | ... | @@ -345,7 +345,7 @@ fn mapAndUpdateSections( |
| 345 | 345 | .target_sect_id = target_sect_id, |
| 346 | 346 | .offset = @intCast(u32, offset), |
| 347 | 347 | }); |
| 348 | | log.warn("{s}: {s},{s} mapped to {s},{s} from 0x{x} to 0x{x}", .{ |
| 348 | log.debug("{s}: {s},{s} mapped to {s},{s} from 0x{x} to 0x{x}", .{ |
| 349 | 349 | object.name, |
| 350 | 350 | parseName(&source_sect.segname), |
| 351 | 351 | parseName(&source_sect.sectname), |
| ... | ... | @@ -513,7 +513,7 @@ fn updateMetadata(self: *Zld, object_id: u16) !void { |
| 513 | 513 | }); |
| 514 | 514 | }, |
| 515 | 515 | else => { |
| 516 | | log.warn("unhandled section type 0x{x} for '{s}/{s}'", .{ flags, segname, sectname }); |
| 516 | log.debug("unhandled section type 0x{x} for '{s}/{s}'", .{ flags, segname, sectname }); |
| 517 | 517 | }, |
| 518 | 518 | } |
| 519 | 519 | } |
| ... | ... | @@ -537,7 +537,7 @@ fn updateMetadata(self: *Zld, object_id: u16) !void { |
| 537 | 537 | |
| 538 | 538 | const segname = parseName(&source_sect.segname); |
| 539 | 539 | const sectname = parseName(&source_sect.sectname); |
| 540 | | log.warn("section '{s}/{s}' will be unmapped", .{ segname, sectname }); |
| 540 | log.debug("section '{s}/{s}' will be unmapped", .{ segname, sectname }); |
| 541 | 541 | try self.unhandled_sections.putNoClobber(self.allocator, .{ |
| 542 | 542 | .object_id = object_id, |
| 543 | 543 | .source_sect_id = source_sect_id, |
| ... | ... | @@ -780,7 +780,7 @@ fn resolveImports(self: *Zld) !void { |
| 780 | 780 | mem.eql(u8, sym_name, "___stack_chk_guard") or |
| 781 | 781 | mem.eql(u8, sym_name, "_environ")) |
| 782 | 782 | { |
| 783 | | log.warn("writing nonlazy symbol '{s}'", .{sym_name}); |
| 783 | log.debug("writing nonlazy symbol '{s}'", .{sym_name}); |
| 784 | 784 | const index = @intCast(u32, self.nonlazy_imports.items().len); |
| 785 | 785 | try self.nonlazy_imports.putNoClobber(self.allocator, key, .{ |
| 786 | 786 | .symbol = new_sym, |
| ... | ... | @@ -788,7 +788,7 @@ fn resolveImports(self: *Zld) !void { |
| 788 | 788 | .index = index, |
| 789 | 789 | }); |
| 790 | 790 | } else if (mem.eql(u8, sym_name, "__tlv_bootstrap")) { |
| 791 | | log.warn("writing threadlocal symbol '{s}'", .{sym_name}); |
| 791 | log.debug("writing threadlocal symbol '{s}'", .{sym_name}); |
| 792 | 792 | const index = @intCast(u32, self.threadlocal_imports.items().len); |
| 793 | 793 | try self.threadlocal_imports.putNoClobber(self.allocator, key, .{ |
| 794 | 794 | .symbol = new_sym, |
| ... | ... | @@ -796,7 +796,7 @@ fn resolveImports(self: *Zld) !void { |
| 796 | 796 | .index = index, |
| 797 | 797 | }); |
| 798 | 798 | } else { |
| 799 | | log.warn("writing lazy symbol '{s}'", .{sym_name}); |
| 799 | log.debug("writing lazy symbol '{s}'", .{sym_name}); |
| 800 | 800 | const index = @intCast(u32, self.lazy_imports.items().len); |
| 801 | 801 | try self.lazy_imports.putNoClobber(self.allocator, key, .{ |
| 802 | 802 | .symbol = new_sym, |
| ... | ... | @@ -808,7 +808,7 @@ fn resolveImports(self: *Zld) !void { |
| 808 | 808 | |
| 809 | 809 | const n_strx = try self.makeString("dyld_stub_binder"); |
| 810 | 810 | const name = try self.allocator.dupe(u8, "dyld_stub_binder"); |
| 811 | | log.warn("writing nonlazy symbol 'dyld_stub_binder'", .{}); |
| 811 | log.debug("writing nonlazy symbol 'dyld_stub_binder'", .{}); |
| 812 | 812 | const index = @intCast(u32, self.nonlazy_imports.items().len); |
| 813 | 813 | try self.nonlazy_imports.putNoClobber(self.allocator, name, .{ |
| 814 | 814 | .symbol = .{ |
| ... | ... | @@ -1012,7 +1012,7 @@ fn writeStubHelperCommon(self: *Zld) !void { |
| 1012 | 1012 | const new_this_addr = this_addr + @sizeOf(u32); |
| 1013 | 1013 | const displacement = math.divExact(u64, target_addr - new_this_addr, 4) catch |_| break :binder_blk; |
| 1014 | 1014 | const literal = math.cast(u18, displacement) catch |_| break :binder_blk; |
| 1015 | | log.warn("2: disp=0x{x}, literal=0x{x}", .{ displacement, literal }); |
| 1015 | log.debug("2: disp=0x{x}, literal=0x{x}", .{ displacement, literal }); |
| 1016 | 1016 | // Pad with nop to please division. |
| 1017 | 1017 | // nop |
| 1018 | 1018 | mem.writeIntLittle(u32, code[12..16], Arm64.nop().toU32()); |
| ... | ... | @@ -1065,7 +1065,7 @@ fn writeLazySymbolPointer(self: *Zld, index: u32) !void { |
| 1065 | 1065 | var buf: [@sizeOf(u64)]u8 = undefined; |
| 1066 | 1066 | mem.writeIntLittle(u64, &buf, end); |
| 1067 | 1067 | const off = la_symbol_ptr.offset + index * @sizeOf(u64); |
| 1068 | | log.warn("writing lazy symbol pointer entry 0x{x} at 0x{x}", .{ end, off }); |
| 1068 | log.debug("writing lazy symbol pointer entry 0x{x} at 0x{x}", .{ end, off }); |
| 1069 | 1069 | try self.file.?.pwriteAll(&buf, off); |
| 1070 | 1070 | } |
| 1071 | 1071 | |
| ... | ... | @@ -1078,7 +1078,7 @@ fn writeStub(self: *Zld, index: u32) !void { |
| 1078 | 1078 | const stub_off = stubs.offset + index * stubs.reserved2; |
| 1079 | 1079 | const stub_addr = stubs.addr + index * stubs.reserved2; |
| 1080 | 1080 | const la_ptr_addr = la_symbol_ptr.addr + index * @sizeOf(u64); |
| 1081 | | log.warn("writing stub at 0x{x}", .{stub_off}); |
| 1081 | log.debug("writing stub at 0x{x}", .{stub_off}); |
| 1082 | 1082 | var code = try self.allocator.alloc(u8, stubs.reserved2); |
| 1083 | 1083 | defer self.allocator.free(code); |
| 1084 | 1084 | switch (self.arch.?) { |
| ... | ... | @@ -1225,7 +1225,7 @@ fn resolveSymbols(self: *Zld) !void { |
| 1225 | 1225 | const target_addr = target_sect.addr + target_mapping.offset; |
| 1226 | 1226 | const n_value = sym.n_value - source_sect.addr + target_addr; |
| 1227 | 1227 | |
| 1228 | | log.warn("resolving '{s}':{} as {s} symbol at 0x{x}", .{ sym_name, sym, tt, n_value }); |
| 1228 | log.debug("resolving '{s}':{} as {s} symbol at 0x{x}", .{ sym_name, sym, tt, n_value }); |
| 1229 | 1229 | |
| 1230 | 1230 | // TODO this assumes only two symbol-filled segments. Also, there might be a more |
| 1231 | 1231 | // generic way of doing this. |
| ... | ... | @@ -1255,8 +1255,8 @@ fn resolveSymbols(self: *Zld) !void { |
| 1255 | 1255 | |
| 1256 | 1256 | fn doRelocs(self: *Zld) !void { |
| 1257 | 1257 | for (self.objects.items) |object, object_id| { |
| 1258 | | log.warn("\n\n", .{}); |
| 1259 | | log.warn("relocating object {s}", .{object.name}); |
| 1258 | log.debug("\n\n", .{}); |
| 1259 | log.debug("relocating object {s}", .{object.name}); |
| 1260 | 1260 | |
| 1261 | 1261 | const seg = object.load_commands.items[object.segment_cmd_index.?].Segment; |
| 1262 | 1262 | |
| ... | ... | @@ -1279,7 +1279,7 @@ fn doRelocs(self: *Zld) !void { |
| 1279 | 1279 | .object_id = @intCast(u16, object_id), |
| 1280 | 1280 | .source_sect_id = @intCast(u16, source_sect_id), |
| 1281 | 1281 | }) orelse { |
| 1282 | | log.warn("no mapping for {s},{s}; skipping", .{ segname, sectname }); |
| 1282 | log.debug("no mapping for {s},{s}; skipping", .{ segname, sectname }); |
| 1283 | 1283 | continue; |
| 1284 | 1284 | }; |
| 1285 | 1285 | const target_seg = self.load_commands.items[target_mapping.target_seg_id].Segment; |
| ... | ... | @@ -1297,34 +1297,34 @@ fn doRelocs(self: *Zld) !void { |
| 1297 | 1297 | switch (self.arch.?) { |
| 1298 | 1298 | .aarch64 => { |
| 1299 | 1299 | const rel_type = @intToEnum(macho.reloc_type_arm64, rel.r_type); |
| 1300 | | log.warn("{s}", .{rel_type}); |
| 1301 | | log.warn(" | source address 0x{x}", .{this_addr}); |
| 1302 | | log.warn(" | offset 0x{x}", .{off}); |
| 1300 | log.debug("{s}", .{rel_type}); |
| 1301 | log.debug(" | source address 0x{x}", .{this_addr}); |
| 1302 | log.debug(" | offset 0x{x}", .{off}); |
| 1303 | 1303 | |
| 1304 | 1304 | if (rel_type == .ARM64_RELOC_ADDEND) { |
| 1305 | 1305 | addend = rel.r_symbolnum; |
| 1306 | | log.warn(" | calculated addend = 0x{x}", .{addend}); |
| 1306 | log.debug(" | calculated addend = 0x{x}", .{addend}); |
| 1307 | 1307 | // TODO followed by either PAGE21 or PAGEOFF12 only. |
| 1308 | 1308 | continue; |
| 1309 | 1309 | } |
| 1310 | 1310 | }, |
| 1311 | 1311 | .x86_64 => { |
| 1312 | 1312 | const rel_type = @intToEnum(macho.reloc_type_x86_64, rel.r_type); |
| 1313 | | log.warn("{s}", .{rel_type}); |
| 1314 | | log.warn(" | source address 0x{x}", .{this_addr}); |
| 1315 | | log.warn(" | offset 0x{x}", .{off}); |
| 1313 | log.debug("{s}", .{rel_type}); |
| 1314 | log.debug(" | source address 0x{x}", .{this_addr}); |
| 1315 | log.debug(" | offset 0x{x}", .{off}); |
| 1316 | 1316 | }, |
| 1317 | 1317 | else => {}, |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | const target_addr = try self.relocTargetAddr(@intCast(u16, object_id), rel); |
| 1321 | | log.warn(" | target address 0x{x}", .{target_addr}); |
| 1321 | log.debug(" | target address 0x{x}", .{target_addr}); |
| 1322 | 1322 | if (rel.r_extern == 1) { |
| 1323 | 1323 | const target_symname = object.getString(object.symtab.items[rel.r_symbolnum].n_strx); |
| 1324 | | log.warn(" | target symbol '{s}'", .{target_symname}); |
| 1324 | log.debug(" | target symbol '{s}'", .{target_symname}); |
| 1325 | 1325 | } else { |
| 1326 | 1326 | const target_sectname = seg.sections.items[rel.r_symbolnum - 1].sectname; |
| 1327 | | log.warn(" | target section '{s}'", .{parseName(&target_sectname)}); |
| 1327 | log.debug(" | target section '{s}'", .{parseName(&target_sectname)}); |
| 1328 | 1328 | } |
| 1329 | 1329 | |
| 1330 | 1330 | switch (self.arch.?) { |
| ... | ... | @@ -1358,7 +1358,7 @@ fn doRelocs(self: *Zld) !void { |
| 1358 | 1358 | assert(rel.r_length == 2); |
| 1359 | 1359 | const inst = code[off..][0..4]; |
| 1360 | 1360 | const offset = @intCast(i64, mem.readIntLittle(i32, inst)); |
| 1361 | | log.warn(" | calculated addend 0x{x}", .{offset}); |
| 1361 | log.debug(" | calculated addend 0x{x}", .{offset}); |
| 1362 | 1362 | const actual_target_addr = blk: { |
| 1363 | 1363 | if (rel.r_extern == 1) { |
| 1364 | 1364 | break :blk @intCast(i64, target_addr) + offset; |
| ... | ... | @@ -1370,7 +1370,7 @@ fn doRelocs(self: *Zld) !void { |
| 1370 | 1370 | .X86_64_RELOC_SIGNED_4 => 4, |
| 1371 | 1371 | else => unreachable, |
| 1372 | 1372 | }; |
| 1373 | | log.warn(" | calculated correction 0x{x}", .{correction}); |
| 1373 | log.debug(" | calculated correction 0x{x}", .{correction}); |
| 1374 | 1374 | |
| 1375 | 1375 | // The value encoded in the instruction is a displacement - 4 - correction. |
| 1376 | 1376 | // To obtain the adjusted target address in the final binary, we need |
| ... | ... | @@ -1385,9 +1385,9 @@ fn doRelocs(self: *Zld) !void { |
| 1385 | 1385 | const orig_seg = object.load_commands.items[object.segment_cmd_index.?].Segment; |
| 1386 | 1386 | const orig_sect = orig_seg.sections.items[orig_sect_id]; |
| 1387 | 1387 | const orig_offset = off + offset + 4 + correction - @intCast(i64, orig_sect.addr); |
| 1388 | | log.warn(" | original offset 0x{x}", .{orig_offset}); |
| 1388 | log.debug(" | original offset 0x{x}", .{orig_offset}); |
| 1389 | 1389 | const adjusted = @intCast(i64, target_addr) + orig_offset; |
| 1390 | | log.warn(" | adjusted target address 0x{x}", .{adjusted}); |
| 1390 | log.debug(" | adjusted target address 0x{x}", .{adjusted}); |
| 1391 | 1391 | break :blk adjusted - correction; |
| 1392 | 1392 | } |
| 1393 | 1393 | }; |
| ... | ... | @@ -1406,7 +1406,7 @@ fn doRelocs(self: *Zld) !void { |
| 1406 | 1406 | |
| 1407 | 1407 | const result = outer: { |
| 1408 | 1408 | if (rel.r_extern == 1) { |
| 1409 | | log.warn(" | calculated addend 0x{x}", .{offset}); |
| 1409 | log.debug(" | calculated addend 0x{x}", .{offset}); |
| 1410 | 1410 | if (sub) |s| { |
| 1411 | 1411 | break :outer @intCast(i64, target_addr) - s + offset; |
| 1412 | 1412 | } else { |
| ... | ... | @@ -1433,7 +1433,7 @@ fn doRelocs(self: *Zld) !void { |
| 1433 | 1433 | break :inner @intCast(i64, target_addr) + orig_offset; |
| 1434 | 1434 | } |
| 1435 | 1435 | }; |
| 1436 | | log.warn(" | adjusted target address 0x{x}", .{actual_target_addr}); |
| 1436 | log.debug(" | adjusted target address 0x{x}", .{actual_target_addr}); |
| 1437 | 1437 | break :outer actual_target_addr; |
| 1438 | 1438 | } |
| 1439 | 1439 | }; |
| ... | ... | @@ -1463,7 +1463,7 @@ fn doRelocs(self: *Zld) !void { |
| 1463 | 1463 | 2 => { |
| 1464 | 1464 | const inst = code[off..][0..4]; |
| 1465 | 1465 | const offset = mem.readIntLittle(i32, inst); |
| 1466 | | log.warn(" | calculated addend 0x{x}", .{offset}); |
| 1466 | log.debug(" | calculated addend 0x{x}", .{offset}); |
| 1467 | 1467 | const result = if (sub) |s| |
| 1468 | 1468 | @intCast(i64, target_addr) - s + offset |
| 1469 | 1469 | else |
| ... | ... | @@ -1500,7 +1500,7 @@ fn doRelocs(self: *Zld) !void { |
| 1500 | 1500 | const this_page = @intCast(i32, this_addr >> 12); |
| 1501 | 1501 | const target_page = @intCast(i32, ta >> 12); |
| 1502 | 1502 | const pages = @bitCast(u21, @intCast(i21, target_page - this_page)); |
| 1503 | | log.warn(" | moving by {} pages", .{pages}); |
| 1503 | log.debug(" | moving by {} pages", .{pages}); |
| 1504 | 1504 | var parsed = mem.bytesAsValue(meta.TagPayload(Arm64, Arm64.Address), inst); |
| 1505 | 1505 | parsed.immhi = @truncate(u19, pages >> 2); |
| 1506 | 1506 | parsed.immlo = @truncate(u2, pages); |
| ... | ... | @@ -1511,14 +1511,14 @@ fn doRelocs(self: *Zld) !void { |
| 1511 | 1511 | => { |
| 1512 | 1512 | const inst = code[off..][0..4]; |
| 1513 | 1513 | if (Arm64.isArithmetic(inst)) { |
| 1514 | | log.warn(" | detected ADD opcode", .{}); |
| 1514 | log.debug(" | detected ADD opcode", .{}); |
| 1515 | 1515 | // add |
| 1516 | 1516 | var parsed = mem.bytesAsValue(meta.TagPayload(Arm64, Arm64.Add), inst); |
| 1517 | 1517 | const ta = if (addend) |a| target_addr + a else target_addr; |
| 1518 | 1518 | const narrowed = @truncate(u12, ta); |
| 1519 | 1519 | parsed.offset = narrowed; |
| 1520 | 1520 | } else { |
| 1521 | | log.warn(" | detected LDR/STR opcode", .{}); |
| 1521 | log.debug(" | detected LDR/STR opcode", .{}); |
| 1522 | 1522 | // ldr/str |
| 1523 | 1523 | var parsed = mem.bytesAsValue(meta.TagPayload(Arm64, Arm64.LoadRegister), inst); |
| 1524 | 1524 | const ta = if (addend) |a| target_addr + a else target_addr; |
| ... | ... | @@ -1559,7 +1559,7 @@ fn doRelocs(self: *Zld) !void { |
| 1559 | 1559 | }; |
| 1560 | 1560 | const ta = if (addend) |a| target_addr + a else target_addr; |
| 1561 | 1561 | const narrowed = @truncate(u12, ta); |
| 1562 | | log.warn(" | rewriting TLV access to ADD opcode", .{}); |
| 1562 | log.debug(" | rewriting TLV access to ADD opcode", .{}); |
| 1563 | 1563 | // For TLV, we always generate an add instruction. |
| 1564 | 1564 | mem.writeIntLittle(u32, inst, Arm64.add(parsed.rt, parsed.rn, narrowed, parsed.size).toU32()); |
| 1565 | 1565 | }, |
| ... | ... | @@ -1571,7 +1571,7 @@ fn doRelocs(self: *Zld) !void { |
| 1571 | 1571 | 3 => { |
| 1572 | 1572 | const inst = code[off..][0..8]; |
| 1573 | 1573 | const offset = mem.readIntLittle(i64, inst); |
| 1574 | | log.warn(" | calculated addend 0x{x}", .{offset}); |
| 1574 | log.debug(" | calculated addend 0x{x}", .{offset}); |
| 1575 | 1575 | const result = if (sub) |s| |
| 1576 | 1576 | @intCast(i64, target_addr) - s + offset |
| 1577 | 1577 | else |
| ... | ... | @@ -1602,7 +1602,7 @@ fn doRelocs(self: *Zld) !void { |
| 1602 | 1602 | 2 => { |
| 1603 | 1603 | const inst = code[off..][0..4]; |
| 1604 | 1604 | const offset = mem.readIntLittle(i32, inst); |
| 1605 | | log.warn(" | calculated addend 0x{x}", .{offset}); |
| 1605 | log.debug(" | calculated addend 0x{x}", .{offset}); |
| 1606 | 1606 | const result = if (sub) |s| |
| 1607 | 1607 | @intCast(i64, target_addr) - s + offset |
| 1608 | 1608 | else |
| ... | ... | @@ -1624,7 +1624,7 @@ fn doRelocs(self: *Zld) !void { |
| 1624 | 1624 | } |
| 1625 | 1625 | } |
| 1626 | 1626 | |
| 1627 | | log.warn("writing contents of '{s},{s}' section from '{s}' from 0x{x} to 0x{x}", .{ |
| 1627 | log.debug("writing contents of '{s},{s}' section from '{s}' from 0x{x} to 0x{x}", .{ |
| 1628 | 1628 | segname, |
| 1629 | 1629 | sectname, |
| 1630 | 1630 | object.name, |
| ... | ... | @@ -1636,7 +1636,7 @@ fn doRelocs(self: *Zld) !void { |
| 1636 | 1636 | target_sect.flags == macho.S_THREAD_LOCAL_ZEROFILL or |
| 1637 | 1637 | target_sect.flags == macho.S_THREAD_LOCAL_VARIABLES) |
| 1638 | 1638 | { |
| 1639 | | log.warn("zeroing out '{s},{s}' from 0x{x} to 0x{x}", .{ |
| 1639 | log.debug("zeroing out '{s},{s}' from 0x{x} to 0x{x}", .{ |
| 1640 | 1640 | parseName(&target_sect.segname), |
| 1641 | 1641 | parseName(&target_sect.sectname), |
| 1642 | 1642 | target_sect_off, |
| ... | ... | @@ -1670,7 +1670,7 @@ fn relocTargetAddr(self: *Zld, object_id: u16, rel: macho.relocation_info) !u64 |
| 1670 | 1670 | const target_seg = self.load_commands.items[target_mapping.target_seg_id].Segment; |
| 1671 | 1671 | const target_sect = target_seg.sections.items[target_mapping.target_sect_id]; |
| 1672 | 1672 | const target_sect_addr = target_sect.addr + target_mapping.offset; |
| 1673 | | log.warn(" | symbol local to object", .{}); |
| 1673 | log.debug(" | symbol local to object", .{}); |
| 1674 | 1674 | break :blk target_sect_addr + sym.n_value - source_sect.addr; |
| 1675 | 1675 | } else if (isImport(&sym)) { |
| 1676 | 1676 | // Relocate to either the artifact's local symbol, or an import from |
| ... | ... | @@ -2275,7 +2275,7 @@ fn writeRebaseInfoTable(self: *Zld) !void { |
| 2275 | 2275 | dyld_info.rebase_size = @intCast(u32, mem.alignForwardGeneric(u64, buffer.len, @sizeOf(u64))); |
| 2276 | 2276 | seg.inner.filesize += dyld_info.rebase_size; |
| 2277 | 2277 | |
| 2278 | | log.warn("writing rebase info from 0x{x} to 0x{x}", .{ dyld_info.rebase_off, dyld_info.rebase_off + dyld_info.rebase_size }); |
| 2278 | log.debug("writing rebase info from 0x{x} to 0x{x}", .{ dyld_info.rebase_off, dyld_info.rebase_off + dyld_info.rebase_size }); |
| 2279 | 2279 | |
| 2280 | 2280 | try self.file.?.pwriteAll(buffer, dyld_info.rebase_off); |
| 2281 | 2281 | } |
| ... | ... | @@ -2336,7 +2336,7 @@ fn writeBindInfoTable(self: *Zld) !void { |
| 2336 | 2336 | dyld_info.bind_size = @intCast(u32, mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64))); |
| 2337 | 2337 | seg.inner.filesize += dyld_info.bind_size; |
| 2338 | 2338 | |
| 2339 | | log.warn("writing binding info from 0x{x} to 0x{x}", .{ dyld_info.bind_off, dyld_info.bind_off + dyld_info.bind_size }); |
| 2339 | log.debug("writing binding info from 0x{x} to 0x{x}", .{ dyld_info.bind_off, dyld_info.bind_off + dyld_info.bind_size }); |
| 2340 | 2340 | |
| 2341 | 2341 | try self.file.?.pwriteAll(buffer, dyld_info.bind_off); |
| 2342 | 2342 | } |
| ... | ... | @@ -2375,7 +2375,7 @@ fn writeLazyBindInfoTable(self: *Zld) !void { |
| 2375 | 2375 | dyld_info.lazy_bind_size = @intCast(u32, mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64))); |
| 2376 | 2376 | seg.inner.filesize += dyld_info.lazy_bind_size; |
| 2377 | 2377 | |
| 2378 | | log.warn("writing lazy binding info from 0x{x} to 0x{x}", .{ dyld_info.lazy_bind_off, dyld_info.lazy_bind_off + dyld_info.lazy_bind_size }); |
| 2378 | log.debug("writing lazy binding info from 0x{x} to 0x{x}", .{ dyld_info.lazy_bind_off, dyld_info.lazy_bind_off + dyld_info.lazy_bind_size }); |
| 2379 | 2379 | |
| 2380 | 2380 | try self.file.?.pwriteAll(buffer, dyld_info.lazy_bind_off); |
| 2381 | 2381 | try self.populateLazyBindOffsetsInStubHelper(buffer); |
| ... | ... | @@ -2477,7 +2477,7 @@ fn writeExportInfo(self: *Zld) !void { |
| 2477 | 2477 | dyld_info.export_size = @intCast(u32, mem.alignForwardGeneric(u64, buffer.len, @alignOf(u64))); |
| 2478 | 2478 | seg.inner.filesize += dyld_info.export_size; |
| 2479 | 2479 | |
| 2480 | | log.warn("writing export info from 0x{x} to 0x{x}", .{ dyld_info.export_off, dyld_info.export_off + dyld_info.export_size }); |
| 2480 | log.debug("writing export info from 0x{x} to 0x{x}", .{ dyld_info.export_off, dyld_info.export_off + dyld_info.export_size }); |
| 2481 | 2481 | |
| 2482 | 2482 | try self.file.?.pwriteAll(buffer, dyld_info.export_off); |
| 2483 | 2483 | } |
| ... | ... | @@ -2611,7 +2611,7 @@ fn writeDebugInfo(self: *Zld) !void { |
| 2611 | 2611 | |
| 2612 | 2612 | const stabs_off = symtab.symoff; |
| 2613 | 2613 | const stabs_size = symtab.nsyms * @sizeOf(macho.nlist_64); |
| 2614 | | log.warn("writing symbol stabs from 0x{x} to 0x{x}", .{ stabs_off, stabs_size + stabs_off }); |
| 2614 | log.debug("writing symbol stabs from 0x{x} to 0x{x}", .{ stabs_off, stabs_size + stabs_off }); |
| 2615 | 2615 | try self.file.?.pwriteAll(mem.sliceAsBytes(stabs.items), stabs_off); |
| 2616 | 2616 | |
| 2617 | 2617 | linkedit.inner.filesize += stabs_size; |
| ... | ... | @@ -2629,12 +2629,12 @@ fn writeSymbolTable(self: *Zld) !void { |
| 2629 | 2629 | defer locals.deinit(); |
| 2630 | 2630 | |
| 2631 | 2631 | for (self.locals.items()) |entries| { |
| 2632 | | log.warn("'{s}': {} entries", .{ entries.key, entries.value.items.len }); |
| 2632 | log.debug("'{s}': {} entries", .{ entries.key, entries.value.items.len }); |
| 2633 | 2633 | // var symbol: ?macho.nlist_64 = null; |
| 2634 | 2634 | for (entries.value.items) |entry| { |
| 2635 | | log.warn(" | {}", .{entry.inner}); |
| 2636 | | log.warn(" | {}", .{entry.tt}); |
| 2637 | | log.warn(" | {s}", .{self.objects.items[entry.object_id].name}); |
| 2635 | log.debug(" | {}", .{entry.inner}); |
| 2636 | log.debug(" | {}", .{entry.tt}); |
| 2637 | log.debug(" | {s}", .{self.objects.items[entry.object_id].name}); |
| 2638 | 2638 | // switch (entry.tt) { |
| 2639 | 2639 | // .Global => { |
| 2640 | 2640 | // symbol = entry.inner; |
| ... | ... | @@ -2679,17 +2679,17 @@ fn writeSymbolTable(self: *Zld) !void { |
| 2679 | 2679 | |
| 2680 | 2680 | const locals_off = symtab.symoff + symtab.nsyms * @sizeOf(macho.nlist_64); |
| 2681 | 2681 | const locals_size = nlocals * @sizeOf(macho.nlist_64); |
| 2682 | | log.warn("writing local symbols from 0x{x} to 0x{x}", .{ locals_off, locals_size + locals_off }); |
| 2682 | log.debug("writing local symbols from 0x{x} to 0x{x}", .{ locals_off, locals_size + locals_off }); |
| 2683 | 2683 | try self.file.?.pwriteAll(mem.sliceAsBytes(locals.items), locals_off); |
| 2684 | 2684 | |
| 2685 | 2685 | const exports_off = locals_off + locals_size; |
| 2686 | 2686 | const exports_size = nexports * @sizeOf(macho.nlist_64); |
| 2687 | | log.warn("writing exported symbols from 0x{x} to 0x{x}", .{ exports_off, exports_size + exports_off }); |
| 2687 | log.debug("writing exported symbols from 0x{x} to 0x{x}", .{ exports_off, exports_size + exports_off }); |
| 2688 | 2688 | try self.file.?.pwriteAll(mem.sliceAsBytes(exports.items), exports_off); |
| 2689 | 2689 | |
| 2690 | 2690 | const undefs_off = exports_off + exports_size; |
| 2691 | 2691 | const undefs_size = nundefs * @sizeOf(macho.nlist_64); |
| 2692 | | log.warn("writing undefined symbols from 0x{x} to 0x{x}", .{ undefs_off, undefs_size + undefs_off }); |
| 2692 | log.debug("writing undefined symbols from 0x{x} to 0x{x}", .{ undefs_off, undefs_size + undefs_off }); |
| 2693 | 2693 | try self.file.?.pwriteAll(mem.sliceAsBytes(undefs.items), undefs_off); |
| 2694 | 2694 | |
| 2695 | 2695 | symtab.nsyms += @intCast(u32, nlocals + nexports + nundefs); |
| ... | ... | @@ -2720,7 +2720,7 @@ fn writeDynamicSymbolTable(self: *Zld) !void { |
| 2720 | 2720 | const needed_size = dysymtab.nindirectsyms * @sizeOf(u32); |
| 2721 | 2721 | seg.inner.filesize += needed_size; |
| 2722 | 2722 | |
| 2723 | | log.warn("writing indirect symbol table from 0x{x} to 0x{x}", .{ |
| 2723 | log.debug("writing indirect symbol table from 0x{x} to 0x{x}", .{ |
| 2724 | 2724 | dysymtab.indirectsymoff, |
| 2725 | 2725 | dysymtab.indirectsymoff + needed_size, |
| 2726 | 2726 | }); |
| ... | ... | @@ -2759,7 +2759,7 @@ fn writeStringTable(self: *Zld) !void { |
| 2759 | 2759 | symtab.strsize = @intCast(u32, mem.alignForwardGeneric(u64, self.strtab.items.len, @alignOf(u64))); |
| 2760 | 2760 | seg.inner.filesize += symtab.strsize; |
| 2761 | 2761 | |
| 2762 | | log.warn("writing string table from 0x{x} to 0x{x}", .{ symtab.stroff, symtab.stroff + symtab.strsize }); |
| 2762 | log.debug("writing string table from 0x{x} to 0x{x}", .{ symtab.stroff, symtab.stroff + symtab.strsize }); |
| 2763 | 2763 | |
| 2764 | 2764 | try self.file.?.pwriteAll(self.strtab.items, symtab.stroff); |
| 2765 | 2765 | |
| ... | ... | @@ -2806,7 +2806,7 @@ fn writeDataInCode(self: *Zld) !void { |
| 2806 | 2806 | dice_cmd.datasize = datasize; |
| 2807 | 2807 | seg.inner.filesize += datasize; |
| 2808 | 2808 | |
| 2809 | | log.warn("writing data-in-code from 0x{x} to 0x{x}", .{ fileoff, fileoff + datasize }); |
| 2809 | log.debug("writing data-in-code from 0x{x} to 0x{x}", .{ fileoff, fileoff + datasize }); |
| 2810 | 2810 | |
| 2811 | 2811 | try self.file.?.pwriteAll(buf.items, fileoff); |
| 2812 | 2812 | } |
| ... | ... | @@ -2827,7 +2827,7 @@ fn writeCodeSignaturePadding(self: *Zld) !void { |
| 2827 | 2827 | seg.inner.filesize += needed_size; |
| 2828 | 2828 | seg.inner.vmsize = mem.alignForwardGeneric(u64, seg.inner.filesize, self.page_size.?); |
| 2829 | 2829 | |
| 2830 | | log.warn("writing code signature padding from 0x{x} to 0x{x}", .{ fileoff, fileoff + needed_size }); |
| 2830 | log.debug("writing code signature padding from 0x{x} to 0x{x}", .{ fileoff, fileoff + needed_size }); |
| 2831 | 2831 | |
| 2832 | 2832 | // Pad out the space. We need to do this to calculate valid hashes for everything in the file |
| 2833 | 2833 | // except for code signature data. |
| ... | ... | @@ -2853,7 +2853,7 @@ fn writeCodeSignature(self: *Zld) !void { |
| 2853 | 2853 | var stream = std.io.fixedBufferStream(buffer); |
| 2854 | 2854 | try code_sig.write(stream.writer()); |
| 2855 | 2855 | |
| 2856 | | log.warn("writing code signature from 0x{x} to 0x{x}", .{ code_sig_cmd.dataoff, code_sig_cmd.dataoff + buffer.len }); |
| 2856 | log.debug("writing code signature from 0x{x} to 0x{x}", .{ code_sig_cmd.dataoff, code_sig_cmd.dataoff + buffer.len }); |
| 2857 | 2857 | |
| 2858 | 2858 | try self.file.?.pwriteAll(buffer, code_sig_cmd.dataoff); |
| 2859 | 2859 | } |
| ... | ... | @@ -2872,7 +2872,7 @@ fn writeLoadCommands(self: *Zld) !void { |
| 2872 | 2872 | } |
| 2873 | 2873 | |
| 2874 | 2874 | const off = @sizeOf(macho.mach_header_64); |
| 2875 | | log.warn("writing {} load commands from 0x{x} to 0x{x}", .{ self.load_commands.items.len, off, off + sizeofcmds }); |
| 2875 | log.debug("writing {} load commands from 0x{x} to 0x{x}", .{ self.load_commands.items.len, off, off + sizeofcmds }); |
| 2876 | 2876 | try self.file.?.pwriteAll(buffer, off); |
| 2877 | 2877 | } |
| 2878 | 2878 | |
| ... | ... | @@ -2910,7 +2910,7 @@ fn writeHeader(self: *Zld) !void { |
| 2910 | 2910 | for (self.load_commands.items) |cmd| { |
| 2911 | 2911 | header.sizeofcmds += cmd.cmdsize(); |
| 2912 | 2912 | } |
| 2913 | | log.warn("writing Mach-O header {}", .{header}); |
| 2913 | log.debug("writing Mach-O header {}", .{header}); |
| 2914 | 2914 | try self.file.?.pwriteAll(mem.asBytes(&header), 0); |
| 2915 | 2915 | } |
| 2916 | 2916 | |
| ... | ... | @@ -2924,7 +2924,7 @@ pub fn makeStaticString(bytes: []const u8) [16]u8 { |
| 2924 | 2924 | fn makeString(self: *Zld, bytes: []const u8) !u32 { |
| 2925 | 2925 | try self.strtab.ensureCapacity(self.allocator, self.strtab.items.len + bytes.len + 1); |
| 2926 | 2926 | const offset = @intCast(u32, self.strtab.items.len); |
| 2927 | | log.warn("writing new string '{s}' into string table at offset 0x{x}", .{ bytes, offset }); |
| 2927 | log.debug("writing new string '{s}' into string table at offset 0x{x}", .{ bytes, offset }); |
| 2928 | 2928 | self.strtab.appendSliceAssumeCapacity(bytes); |
| 2929 | 2929 | self.strtab.appendAssumeCapacity(0); |
| 2930 | 2930 | return offset; |