| author | |
| committer | |
| log | ba710ec09dd3df4cd0ee8de9a5299aeaed53a847 |
| tree | 99e2e5aa645ea7d73c5beae28bdb3b7cf4947af3 |
| parent | 5144132320ae86320e9a6bf335bfbdccf52e2621 |
5 files changed, 9 insertions(+), 14 deletions(-)
src/link.zig-1| ... | @@ -700,7 +700,6 @@ pub const File = struct { | ... | @@ -700,7 +700,6 @@ pub const File = struct { |
| 700 | DllImportLibraryNotFound, | 700 | DllImportLibraryNotFound, |
| 701 | ExpectedFuncType, | 701 | ExpectedFuncType, |
| 702 | FailedToEmit, | 702 | FailedToEmit, |
| 703 | FailedToResolveRelocationTarget, | ||
| 704 | FileSystem, | 703 | FileSystem, |
| 705 | FilesOpenedWithWrongFlags, | 704 | FilesOpenedWithWrongFlags, |
| 706 | FlushFailure, | 705 | FlushFailure, |
src/link/MachO/Archive.zig+2-2| ... | @@ -128,7 +128,7 @@ fn parseTableOfContents(self: *Archive, allocator: Allocator, reader: anytype) ! | ... | @@ -128,7 +128,7 @@ fn parseTableOfContents(self: *Archive, allocator: Allocator, reader: anytype) ! |
| 128 | defer allocator.free(symtab); | 128 | defer allocator.free(symtab); |
| 129 | 129 | ||
| 130 | reader.readNoEof(symtab) catch { | 130 | reader.readNoEof(symtab) catch { |
| 131 | log.err("incomplete symbol table: expected symbol table of length 0x{x}", .{symtab_size}); | 131 | log.debug("incomplete symbol table: expected symbol table of length 0x{x}", .{symtab_size}); |
| 132 | return error.MalformedArchive; | 132 | return error.MalformedArchive; |
| 133 | }; | 133 | }; |
| 134 | 134 | ||
| ... | @@ -137,7 +137,7 @@ fn parseTableOfContents(self: *Archive, allocator: Allocator, reader: anytype) ! | ... | @@ -137,7 +137,7 @@ fn parseTableOfContents(self: *Archive, allocator: Allocator, reader: anytype) ! |
| 137 | defer allocator.free(strtab); | 137 | defer allocator.free(strtab); |
| 138 | 138 | ||
| 139 | reader.readNoEof(strtab) catch { | 139 | reader.readNoEof(strtab) catch { |
| 140 | log.err("incomplete symbol table: expected string table of length 0x{x}", .{strtab_size}); | 140 | log.debug("incomplete symbol table: expected string table of length 0x{x}", .{strtab_size}); |
| 141 | return error.MalformedArchive; | 141 | return error.MalformedArchive; |
| 142 | }; | 142 | }; |
| 143 | 143 |
src/link/MachO/Atom.zig+5-9| ... | @@ -615,7 +615,7 @@ pub fn resolveRelocs( | ... | @@ -615,7 +615,7 @@ pub fn resolveRelocs( |
| 615 | }; | 615 | }; |
| 616 | } | 616 | } |
| 617 | 617 | ||
| 618 | pub fn getRelocTargetAddress(macho_file: *MachO, target: SymbolWithLoc, is_tlv: bool) !u64 { | 618 | pub fn getRelocTargetAddress(macho_file: *MachO, target: SymbolWithLoc, is_tlv: bool) u64 { |
| 619 | const target_atom_index = getRelocTargetAtomIndex(macho_file, target) orelse { | 619 | const target_atom_index = getRelocTargetAtomIndex(macho_file, target) orelse { |
| 620 | // If there is no atom for target, we still need to check for special, atom-less | 620 | // If there is no atom for target, we still need to check for special, atom-less |
| 621 | // symbols such as `___dso_handle`. | 621 | // symbols such as `___dso_handle`. |
| ... | @@ -648,17 +648,13 @@ pub fn getRelocTargetAddress(macho_file: *MachO, target: SymbolWithLoc, is_tlv: | ... | @@ -648,17 +648,13 @@ pub fn getRelocTargetAddress(macho_file: *MachO, target: SymbolWithLoc, is_tlv: |
| 648 | // defined TLV template init section in the following order: | 648 | // defined TLV template init section in the following order: |
| 649 | // * wrt to __thread_data if defined, then | 649 | // * wrt to __thread_data if defined, then |
| 650 | // * wrt to __thread_bss | 650 | // * wrt to __thread_bss |
| 651 | // TODO remember to check what the mechanism was prior to HAS_TLV_INITIALIZERS in earlier versions of macOS | ||
| 651 | const sect_id: u16 = sect_id: { | 652 | const sect_id: u16 = sect_id: { |
| 652 | if (macho_file.thread_data_section_index) |i| { | 653 | if (macho_file.thread_data_section_index) |i| { |
| 653 | break :sect_id i; | 654 | break :sect_id i; |
| 654 | } else if (macho_file.thread_bss_section_index) |i| { | 655 | } else if (macho_file.thread_bss_section_index) |i| { |
| 655 | break :sect_id i; | 656 | break :sect_id i; |
| 656 | } else { | 657 | } else break :base_address 0; |
| 657 | log.err("threadlocal variables present but no initializer sections found", .{}); | ||
| 658 | log.err(" __thread_data not found", .{}); | ||
| 659 | log.err(" __thread_bss not found", .{}); | ||
| 660 | return error.FailedToResolveRelocationTarget; | ||
| 661 | } | ||
| 662 | }; | 658 | }; |
| 663 | break :base_address macho_file.sections.items(.header)[sect_id].addr; | 659 | break :base_address macho_file.sections.items(.header)[sect_id].addr; |
| 664 | } else 0; | 660 | } else 0; |
| ... | @@ -744,7 +740,7 @@ fn resolveRelocsArm64( | ... | @@ -744,7 +740,7 @@ fn resolveRelocsArm64( |
| 744 | const header = macho_file.sections.items(.header)[source_sym.n_sect - 1]; | 740 | const header = macho_file.sections.items(.header)[source_sym.n_sect - 1]; |
| 745 | break :is_tlv header.type() == macho.S_THREAD_LOCAL_VARIABLES; | 741 | break :is_tlv header.type() == macho.S_THREAD_LOCAL_VARIABLES; |
| 746 | }; | 742 | }; |
| 747 | break :blk try getRelocTargetAddress(macho_file, target, is_tlv); | 743 | break :blk getRelocTargetAddress(macho_file, target, is_tlv); |
| 748 | }; | 744 | }; |
| 749 | 745 | ||
| 750 | log.debug(" | source_addr = 0x{x}", .{source_addr}); | 746 | log.debug(" | source_addr = 0x{x}", .{source_addr}); |
| ... | @@ -1040,7 +1036,7 @@ fn resolveRelocsX86( | ... | @@ -1040,7 +1036,7 @@ fn resolveRelocsX86( |
| 1040 | const header = macho_file.sections.items(.header)[source_sym.n_sect - 1]; | 1036 | const header = macho_file.sections.items(.header)[source_sym.n_sect - 1]; |
| 1041 | break :is_tlv header.type() == macho.S_THREAD_LOCAL_VARIABLES; | 1037 | break :is_tlv header.type() == macho.S_THREAD_LOCAL_VARIABLES; |
| 1042 | }; | 1038 | }; |
| 1043 | break :blk try getRelocTargetAddress(macho_file, target, is_tlv); | 1039 | break :blk getRelocTargetAddress(macho_file, target, is_tlv); |
| 1044 | }; | 1040 | }; |
| 1045 | 1041 | ||
| 1046 | log.debug(" | source_addr = 0x{x}", .{source_addr}); | 1042 | log.debug(" | source_addr = 0x{x}", .{source_addr}); |
src/link/MachO/eh_frame.zig+1-1| ... | @@ -347,7 +347,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { | ... | @@ -347,7 +347,7 @@ pub fn EhFrameRecord(comptime is_mutable: bool) type { |
| 347 | }, | 347 | }, |
| 348 | .ARM64_RELOC_UNSIGNED => { | 348 | .ARM64_RELOC_UNSIGNED => { |
| 349 | assert(rel.r_extern == 1); | 349 | assert(rel.r_extern == 1); |
| 350 | const target_addr = try Atom.getRelocTargetAddress(macho_file, target, false); | 350 | const target_addr = Atom.getRelocTargetAddress(macho_file, target, false); |
| 351 | const result = @as(i64, @intCast(target_addr)) - @as(i64, @intCast(source_addr)); | 351 | const result = @as(i64, @intCast(target_addr)) - @as(i64, @intCast(source_addr)); |
| 352 | mem.writeIntLittle(i64, rec.data[rel_offset..][0..8], @as(i64, @intCast(result))); | 352 | mem.writeIntLittle(i64, rec.data[rel_offset..][0..8], @as(i64, @intCast(result))); |
| 353 | }, | 353 | }, |
src/link/MachO/thunks.zig+1-1| ... | @@ -317,7 +317,7 @@ fn isReachable( | ... | @@ -317,7 +317,7 @@ fn isReachable( |
| 317 | const target_addr = if (Atom.relocRequiresGot(macho_file, rel)) | 317 | const target_addr = if (Atom.relocRequiresGot(macho_file, rel)) |
| 318 | macho_file.getGotEntryAddress(target).? | 318 | macho_file.getGotEntryAddress(target).? |
| 319 | else | 319 | else |
| 320 | Atom.getRelocTargetAddress(macho_file, target, false) catch unreachable; | 320 | Atom.getRelocTargetAddress(macho_file, target, false); |
| 321 | _ = Relocation.calcPcRelativeDisplacementArm64(source_addr, target_addr) catch | 321 | _ = Relocation.calcPcRelativeDisplacementArm64(source_addr, target_addr) catch |
| 322 | return false; | 322 | return false; |
| 323 | 323 |