diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-12-15 15:54:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-15 15:54:48 +0100 |
| commit | 87b843ef08426e1b14b2128987dfb52bb7de6788 (patch) | |
| tree | 463e9a1c77ad8cf0d9dce57ee4dbb47b9c62c0d8 /src | |
| parent | ff93486d0cbf032cbbf8b7953a072d448400ba2a (diff) | |
| parent | bd926e5ea0f9b27677a270a4e8253b6a6f77379c (diff) | |
| download | zig-87b843ef08426e1b14b2128987dfb52bb7de6788.tar.gz zig-87b843ef08426e1b14b2128987dfb52bb7de6788.zip | |
Merge pull request #10338 from ziglang/macho-missing-feats
macho: refactor consts in std.macho, and fix two bugs in MachO linker backend
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/MachO.zig | 128 | ||||
| -rw-r--r-- | src/link/MachO/Atom.zig | 93 | ||||
| -rw-r--r-- | src/link/MachO/DebugSymbols.zig | 1 | ||||
| -rw-r--r-- | src/link/MachO/Dylib.zig | 8 | ||||
| -rw-r--r-- | src/link/MachO/Object.zig | 10 |
5 files changed, 188 insertions, 52 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 43d6733132..d7457ec549 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -130,6 +130,7 @@ objc_imageinfo_section_index: ?u16 = null, tlv_section_index: ?u16 = null, tlv_data_section_index: ?u16 = null, tlv_bss_section_index: ?u16 = null, +tlv_ptrs_section_index: ?u16 = null, la_symbol_ptr_section_index: ?u16 = null, data_section_index: ?u16 = null, bss_section_index: ?u16 = null, @@ -164,6 +165,9 @@ stub_helper_preamble_atom: ?*Atom = null, strtab: std.ArrayListUnmanaged(u8) = .{}, strtab_dir: std.HashMapUnmanaged(u32, void, StringIndexContext, std.hash_map.default_max_load_percentage) = .{}, +tlv_ptr_entries_map: std.AutoArrayHashMapUnmanaged(Atom.Relocation.Target, *Atom) = .{}, +tlv_ptr_entries_map_free_list: std.ArrayListUnmanaged(u32) = .{}, + got_entries_map: std.AutoArrayHashMapUnmanaged(Atom.Relocation.Target, *Atom) = .{}, got_entries_map_free_list: std.ArrayListUnmanaged(u32) = .{}, @@ -783,7 +787,6 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { @sizeOf(u64), )); var rpath_cmd = macho.emptyGenericCommandWithData(macho.rpath_command{ - .cmd = macho.LC_RPATH, .cmdsize = cmdsize, .path = @sizeOf(macho.rpath_command), }); @@ -1526,6 +1529,24 @@ pub fn getMatchingSection(self: *MachO, sect: macho.section_64) !?MatchingSectio .sect = self.tlv_section_index.?, }; }, + macho.S_THREAD_LOCAL_VARIABLE_POINTERS => { + if (self.tlv_ptrs_section_index == null) { + self.tlv_ptrs_section_index = try self.initSection( + self.data_segment_cmd_index.?, + "__thread_ptrs", + sect.size, + sect.@"align", + .{ + .flags = macho.S_THREAD_LOCAL_VARIABLE_POINTERS, + }, + ); + } + + break :blk .{ + .seg = self.data_segment_cmd_index.?, + .sect = self.tlv_ptrs_section_index.?, + }; + }, macho.S_THREAD_LOCAL_REGULAR => { if (self.tlv_data_section_index == null) { self.tlv_data_section_index = try self.initSection( @@ -2143,6 +2164,24 @@ pub fn createGotAtom(self: *MachO, target: Atom.Relocation.Target) !*Atom { return atom; } +pub fn createTlvPtrAtom(self: *MachO, target: Atom.Relocation.Target) !*Atom { + const local_sym_index = @intCast(u32, self.locals.items.len); + try self.locals.append(self.base.allocator, .{ + .n_strx = 0, + .n_type = macho.N_SECT, + .n_sect = 0, + .n_desc = 0, + .n_value = 0, + }); + const atom = try self.createEmptyAtom(local_sym_index, @sizeOf(u64), 3); + assert(target == .global); + try atom.bindings.append(self.base.allocator, .{ + .n_strx = target.global, + .offset = 0, + }); + return atom; +} + fn createDyldPrivateAtom(self: *MachO) !void { if (self.dyld_private_atom != null) return; const local_sym_index = @intCast(u32, self.locals.items.len); @@ -2164,7 +2203,7 @@ fn createDyldPrivateAtom(self: *MachO) !void { const vaddr = try self.allocateAtom(atom, @sizeOf(u64), 8, match); log.debug("allocated {s} atom at 0x{x}", .{ self.getString(sym.n_strx), vaddr }); sym.n_value = vaddr; - } else try self.addAtomAndBumpSectionSize(atom, match); + } else try self.addAtomToSection(atom, match); sym.n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1); } @@ -2298,7 +2337,7 @@ fn createStubHelperPreambleAtom(self: *MachO) !void { const vaddr = try self.allocateAtom(atom, atom.size, alignment_pow_2, match); log.debug("allocated {s} atom at 0x{x}", .{ self.getString(sym.n_strx), vaddr }); sym.n_value = vaddr; - } else try self.addAtomAndBumpSectionSize(atom, match); + } else try self.addAtomToSection(atom, match); sym.n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1); } @@ -2514,7 +2553,7 @@ fn createTentativeDefAtoms(self: *MachO) !void { const vaddr = try self.allocateAtom(atom, size, alignment_pow_2, match); local_sym.n_value = vaddr; global_sym.n_value = vaddr; - } else try self.addAtomAndBumpSectionSize(atom, match); + } else try self.addAtomToSection(atom, match); } } @@ -2567,7 +2606,7 @@ fn createDsoHandleAtom(self: *MachO) !void { const sym = &self.locals.items[local_sym_index]; const vaddr = try self.allocateAtom(atom, 0, 1, match); sym.n_value = vaddr; - } else try self.addAtomAndBumpSectionSize(atom, match); + } else try self.addAtomToSection(atom, match); } } @@ -2913,7 +2952,7 @@ fn createMhExecuteHeaderAtom(self: *MachO) !void { const sym = &self.locals.items[local_sym_index]; const vaddr = try self.allocateAtom(atom, 0, 1, match); sym.n_value = vaddr; - } else try self.addAtomAndBumpSectionSize(atom, match); + } else try self.addAtomToSection(atom, match); self.mh_execute_header_index = local_sym_index; } @@ -2973,7 +3012,7 @@ fn resolveDyldStubBinder(self: *MachO) !void { const vaddr = try self.allocateAtom(atom, @sizeOf(u64), 8, match); log.debug("allocated {s} atom at 0x{x}", .{ self.getString(sym.n_strx), vaddr }); atom_sym.n_value = vaddr; - } else try self.addAtomAndBumpSectionSize(atom, match); + } else try self.addAtomToSection(atom, match); atom_sym.n_sect = @intCast(u8, self.section_ordinals.getIndex(match).? + 1); } @@ -3174,7 +3213,7 @@ fn addCodeSignatureLC(self: *MachO) !void { self.code_signature_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.base.allocator, .{ .linkedit_data = .{ - .cmd = macho.LC_CODE_SIGNATURE, + .cmd = .CODE_SIGNATURE, .cmdsize = @sizeOf(macho.linkedit_data_command), .dataoff = 0, .datasize = 0, @@ -3215,6 +3254,8 @@ pub fn deinit(self: *MachO) void { } self.section_ordinals.deinit(self.base.allocator); + self.tlv_ptr_entries_map.deinit(self.base.allocator); + self.tlv_ptr_entries_map_free_list.deinit(self.base.allocator); self.got_entries_map.deinit(self.base.allocator); self.got_entries_map_free_list.deinit(self.base.allocator); self.stubs_map.deinit(self.base.allocator); @@ -4203,7 +4244,7 @@ fn populateMissingMetadata(self: *MachO) !void { self.dyld_info_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.base.allocator, .{ .dyld_info_only = .{ - .cmd = macho.LC_DYLD_INFO_ONLY, + .cmd = .DYLD_INFO_ONLY, .cmdsize = @sizeOf(macho.dyld_info_command), .rebase_off = 0, .rebase_size = 0, @@ -4224,7 +4265,6 @@ fn populateMissingMetadata(self: *MachO) !void { self.symtab_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.base.allocator, .{ .symtab = .{ - .cmd = macho.LC_SYMTAB, .cmdsize = @sizeOf(macho.symtab_command), .symoff = 0, .nsyms = 0, @@ -4239,7 +4279,6 @@ fn populateMissingMetadata(self: *MachO) !void { self.dysymtab_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.base.allocator, .{ .dysymtab = .{ - .cmd = macho.LC_DYSYMTAB, .cmdsize = @sizeOf(macho.dysymtab_command), .ilocalsym = 0, .nlocalsym = 0, @@ -4272,7 +4311,7 @@ fn populateMissingMetadata(self: *MachO) !void { @sizeOf(u64), )); var dylinker_cmd = macho.emptyGenericCommandWithData(macho.dylinker_command{ - .cmd = macho.LC_LOAD_DYLINKER, + .cmd = .LOAD_DYLINKER, .cmdsize = cmdsize, .name = @sizeOf(macho.dylinker_command), }); @@ -4287,7 +4326,6 @@ fn populateMissingMetadata(self: *MachO) !void { self.main_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.base.allocator, .{ .main = .{ - .cmd = macho.LC_MAIN, .cmdsize = @sizeOf(macho.entry_point_command), .entryoff = 0x0, .stacksize = 0, @@ -4314,7 +4352,7 @@ fn populateMissingMetadata(self: *MachO) !void { compat_version.major << 16 | compat_version.minor << 8 | compat_version.patch, ); errdefer dylib_cmd.deinit(self.base.allocator); - dylib_cmd.inner.cmd = macho.LC_ID_DYLIB; + dylib_cmd.inner.cmd = .ID_DYLIB; try self.load_commands.append(self.base.allocator, .{ .dylib = dylib_cmd }); self.load_commands_dirty = true; } @@ -4323,7 +4361,6 @@ fn populateMissingMetadata(self: *MachO) !void { self.source_version_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.base.allocator, .{ .source_version = .{ - .cmd = macho.LC_SOURCE_VERSION, .cmdsize = @sizeOf(macho.source_version_command), .version = 0x0, }, @@ -4350,13 +4387,12 @@ fn populateMissingMetadata(self: *MachO) !void { } else platform_version; const is_simulator_abi = self.base.options.target.abi == .simulator; var cmd = macho.emptyGenericCommandWithData(macho.build_version_command{ - .cmd = macho.LC_BUILD_VERSION, .cmdsize = cmdsize, .platform = switch (self.base.options.target.os.tag) { - .macos => macho.PLATFORM_MACOS, - .ios => if (is_simulator_abi) macho.PLATFORM_IOSSIMULATOR else macho.PLATFORM_IOS, - .watchos => if (is_simulator_abi) macho.PLATFORM_WATCHOSSIMULATOR else macho.PLATFORM_WATCHOS, - .tvos => if (is_simulator_abi) macho.PLATFORM_TVOSSIMULATOR else macho.PLATFORM_TVOS, + .macos => .MACOS, + .ios => if (is_simulator_abi) macho.PLATFORM.IOSSIMULATOR else macho.PLATFORM.IOS, + .watchos => if (is_simulator_abi) macho.PLATFORM.WATCHOSSIMULATOR else macho.PLATFORM.WATCHOS, + .tvos => if (is_simulator_abi) macho.PLATFORM.TVOSSIMULATOR else macho.PLATFORM.TVOS, else => unreachable, }, .minos = platform_version, @@ -4364,7 +4400,7 @@ fn populateMissingMetadata(self: *MachO) !void { .ntools = 1, }); const ld_ver = macho.build_tool_version{ - .tool = macho.TOOL_LD, + .tool = .LD, .version = 0x0, }; cmd.data = try self.base.allocator.alloc(u8, cmdsize - @sizeOf(macho.build_version_command)); @@ -4377,7 +4413,6 @@ fn populateMissingMetadata(self: *MachO) !void { if (self.uuid_cmd_index == null) { self.uuid_cmd_index = @intCast(u16, self.load_commands.items.len); var uuid_cmd: macho.uuid_command = .{ - .cmd = macho.LC_UUID, .cmdsize = @sizeOf(macho.uuid_command), .uuid = undefined, }; @@ -4390,7 +4425,7 @@ fn populateMissingMetadata(self: *MachO) !void { self.function_starts_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.base.allocator, .{ .linkedit_data = .{ - .cmd = macho.LC_FUNCTION_STARTS, + .cmd = .FUNCTION_STARTS, .cmdsize = @sizeOf(macho.linkedit_data_command), .dataoff = 0, .datasize = 0, @@ -4403,7 +4438,7 @@ fn populateMissingMetadata(self: *MachO) !void { self.data_in_code_cmd_index = @intCast(u16, self.load_commands.items.len); try self.load_commands.append(self.base.allocator, .{ .linkedit_data = .{ - .cmd = macho.LC_DATA_IN_CODE, + .cmd = .DATA_IN_CODE, .cmdsize = @sizeOf(macho.linkedit_data_command), .dataoff = 0, .datasize = 0, @@ -4480,13 +4515,36 @@ fn allocateSegment(self: *MachO, index: u16, offset: u64) !void { // Allocate the sections according to their alignment at the beginning of the segment. var start: u64 = offset; - for (seg.sections.items) |*sect| { + for (seg.sections.items) |*sect, sect_id| { const alignment = try math.powi(u32, 2, sect.@"align"); const start_aligned = mem.alignForwardGeneric(u64, start, alignment); - const end = start_aligned + sect.size; sect.offset = @intCast(u32, seg.inner.fileoff + start_aligned); sect.addr = seg.inner.vmaddr + start_aligned; - start = end; + + // Recalculate section size given the allocated start address + sect.size = if (self.atoms.get(.{ + .seg = index, + .sect = @intCast(u16, sect_id), + })) |last_atom| blk: { + var atom = last_atom; + while (atom.prev) |prev| { + atom = prev; + } + + var base_addr = sect.addr; + + while (true) { + const atom_alignment = try math.powi(u32, 2, atom.alignment); + base_addr = mem.alignForwardGeneric(u64, base_addr, atom_alignment) + atom.size; + if (atom.next) |next| { + atom = next; + } else break; + } + + break :blk base_addr - sect.addr; + } else 0; + + start = start_aligned + sect.size; } const seg_size_aligned = mem.alignForwardGeneric(u64, start, self.page_size); @@ -4834,12 +4892,7 @@ fn allocateAtom(self: *MachO, atom: *Atom, new_atom_size: u64, alignment: u64, m return vaddr; } -fn addAtomAndBumpSectionSize(self: *MachO, atom: *Atom, match: MatchingSection) !void { - const seg = &self.load_commands.items[match.seg].segment; - const sect = &seg.sections.items[match.sect]; - const alignment = try math.powi(u32, 2, atom.alignment); - sect.size = mem.alignForwardGeneric(u64, sect.size, alignment) + atom.size; - +fn addAtomToSection(self: *MachO, atom: *Atom, match: MatchingSection) !void { if (self.atoms.getPtr(match)) |last| { last.*.next = atom; atom.prev = last.*; @@ -4978,6 +5031,7 @@ fn sortSections(self: *MachO) !void { &self.objc_data_section_index, &self.data_section_index, &self.tlv_section_index, + &self.tlv_ptrs_section_index, &self.tlv_data_section_index, &self.tlv_bss_section_index, &self.bss_section_index, @@ -6205,6 +6259,14 @@ fn logSymtab(self: MachO) void { } } + log.debug("__thread_ptrs entries:", .{}); + for (self.tlv_ptr_entries_map.keys()) |key| { + switch (key) { + .local => unreachable, + .global => |n_strx| log.debug(" {} => {s}", .{ key, self.getString(n_strx) }), + } + } + log.debug("stubs:", .{}); for (self.stubs_map.keys()) |key| { log.debug(" {} => {s}", .{ key, self.getString(key) }); diff --git a/src/link/MachO/Atom.zig b/src/link/MachO/Atom.zig index 71183f4157..a2f1b385dc 100644 --- a/src/link/MachO/Atom.zig +++ b/src/link/MachO/Atom.zig @@ -403,6 +403,13 @@ pub fn parseRelocs(self: *Atom, relocs: []macho.relocation_info, context: RelocC } try self.addPtrBindingOrRebase(rel, target, context); }, + .ARM64_RELOC_TLVP_LOAD_PAGE21, + .ARM64_RELOC_TLVP_LOAD_PAGEOFF12, + => { + if (target == .global) { + try addTlvPtrEntry(target, context); + } + }, else => {}, } }, @@ -452,6 +459,11 @@ pub fn parseRelocs(self: *Atom, relocs: []macho.relocation_info, context: RelocC @intCast(i64, target_sect_base_addr); } }, + .X86_64_RELOC_TLV => { + if (target == .global) { + try addTlvPtrEntry(target, context); + } + }, else => {}, } }, @@ -531,6 +543,47 @@ fn addPtrBindingOrRebase( } } +fn addTlvPtrEntry(target: Relocation.Target, context: RelocContext) !void { + if (context.macho_file.tlv_ptr_entries_map.contains(target)) return; + + const value_ptr = blk: { + if (context.macho_file.tlv_ptr_entries_map_free_list.popOrNull()) |i| { + log.debug("reusing __thread_ptrs entry index {d} for {}", .{ i, target }); + context.macho_file.tlv_ptr_entries_map.keys()[i] = target; + const value_ptr = context.macho_file.tlv_ptr_entries_map.getPtr(target).?; + break :blk value_ptr; + } else { + const res = try context.macho_file.tlv_ptr_entries_map.getOrPut( + context.macho_file.base.allocator, + target, + ); + log.debug("creating new __thread_ptrs entry at index {d} for {}", .{ + context.macho_file.tlv_ptr_entries_map.getIndex(target).?, + target, + }); + break :blk res.value_ptr; + } + }; + const atom = try context.macho_file.createTlvPtrAtom(target); + value_ptr.* = atom; + + const match = (try context.macho_file.getMatchingSection(.{ + .segname = MachO.makeStaticString("__DATA"), + .sectname = MachO.makeStaticString("__thread_ptrs"), + .flags = macho.S_THREAD_LOCAL_VARIABLE_POINTERS, + })).?; + if (!context.object.start_atoms.contains(match)) { + try context.object.start_atoms.putNoClobber(context.allocator, match, atom); + } + if (context.object.end_atoms.getPtr(match)) |last| { + last.*.next = atom; + atom.prev = last.*; + last.* = atom; + } else { + try context.object.end_atoms.putNoClobber(context.allocator, match, atom); + } +} + fn addGotEntry(target: Relocation.Target, context: RelocContext) !void { if (context.macho_file.got_entries_map.contains(target)) return; @@ -667,6 +720,7 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void { const sym = macho_file.locals.items[self.local_sym_index]; break :blk sym.n_value + rel.offset; }; + var is_via_thread_ptrs: bool = false; const target_addr = blk: { const is_via_got = got: { switch (arch) { @@ -742,8 +796,13 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void { .undef => { break :blk if (macho_file.stubs_map.get(n_strx)) |atom| macho_file.locals.items[atom.local_sym_index].n_value - else - 0; + else inner: { + if (macho_file.tlv_ptr_entries_map.get(rel.target)) |atom| { + is_via_thread_ptrs = true; + break :inner macho_file.locals.items[atom.local_sym_index].n_value; + } + break :inner 0; + }; }, } }, @@ -854,10 +913,12 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void { }, .ARM64_RELOC_TLVP_LOAD_PAGEOFF12 => { const code = self.code.items[rel.offset..][0..4]; + const actual_target_addr = @intCast(i64, target_addr) + rel.addend; + const RegInfo = struct { rd: u5, rn: u5, - size: u1, + size: u2, }; const reg_info: RegInfo = blk: { if (isArithmeticOp(code)) { @@ -878,13 +939,25 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void { break :blk .{ .rd = inst.rt, .rn = inst.rn, - .size = @truncate(u1, inst.size), + .size = inst.size, }; } }; - const actual_target_addr = @intCast(i64, target_addr) + rel.addend; const narrowed = @truncate(u12, @intCast(u64, actual_target_addr)); - var inst = aarch64.Instruction{ + var inst = if (is_via_thread_ptrs) blk: { + const offset = try math.divExact(u12, narrowed, 8); + break :blk aarch64.Instruction{ + .load_store_register = .{ + .rt = reg_info.rd, + .rn = reg_info.rn, + .offset = offset, + .opc = 0b01, + .op1 = 0b01, + .v = 0, + .size = reg_info.size, + }, + }; + } else aarch64.Instruction{ .add_subtract_immediate = .{ .rd = reg_info.rd, .rn = reg_info.rn, @@ -892,7 +965,7 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void { .sh = 0, .s = 0, .op = 0, - .sf = reg_info.size, + .sf = @truncate(u1, reg_info.size), }, }; mem.writeIntLittle(u32, code, inst.toU32()); @@ -942,8 +1015,10 @@ pub fn resolveRelocs(self: *Atom, macho_file: *MachO) !void { mem.writeIntLittle(u32, self.code.items[rel.offset..][0..4], @bitCast(u32, displacement)); }, .X86_64_RELOC_TLV => { - // We need to rewrite the opcode from movq to leaq. - self.code.items[rel.offset - 2] = 0x8d; + if (!is_via_thread_ptrs) { + // We need to rewrite the opcode from movq to leaq. + self.code.items[rel.offset - 2] = 0x8d; + } const displacement = try math.cast( i32, @intCast(i64, target_addr) - @intCast(i64, source_addr) - 4 + rel.addend, diff --git a/src/link/MachO/DebugSymbols.zig b/src/link/MachO/DebugSymbols.zig index 8babb5d647..cda5077528 100644 --- a/src/link/MachO/DebugSymbols.zig +++ b/src/link/MachO/DebugSymbols.zig @@ -122,7 +122,6 @@ pub fn populateMissingMetadata(self: *DebugSymbols, allocator: Allocator) !void try self.load_commands.append(allocator, .{ .symtab = .{ - .cmd = macho.LC_SYMTAB, .cmdsize = @sizeOf(macho.symtab_command), .symoff = @intCast(u32, symtab_off), .nsyms = base_cmd.nsyms, diff --git a/src/link/MachO/Dylib.zig b/src/link/MachO/Dylib.zig index 31a8b357c2..7593593cbc 100644 --- a/src/link/MachO/Dylib.zig +++ b/src/link/MachO/Dylib.zig @@ -177,16 +177,16 @@ fn readLoadCommands(self: *Dylib, allocator: Allocator, reader: anytype, depende while (i < self.header.?.ncmds) : (i += 1) { var cmd = try macho.LoadCommand.read(allocator, reader); switch (cmd.cmd()) { - macho.LC_SYMTAB => { + .SYMTAB => { self.symtab_cmd_index = i; }, - macho.LC_DYSYMTAB => { + .DYSYMTAB => { self.dysymtab_cmd_index = i; }, - macho.LC_ID_DYLIB => { + .ID_DYLIB => { self.id_cmd_index = i; }, - macho.LC_REEXPORT_DYLIB => { + .REEXPORT_DYLIB => { if (should_lookup_reexports) { // Parse install_name to dependent dylib. var id = try Id.fromLoadCommand(allocator, cmd.dylib); diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig index 7f4a49d0d5..12ca463760 100644 --- a/src/link/MachO/Object.zig +++ b/src/link/MachO/Object.zig @@ -269,7 +269,7 @@ pub fn readLoadCommands(self: *Object, allocator: Allocator, reader: anytype) !v while (i < header.ncmds) : (i += 1) { var cmd = try macho.LoadCommand.read(allocator, reader); switch (cmd.cmd()) { - macho.LC_SEGMENT_64 => { + .SEGMENT_64 => { self.segment_cmd_index = i; var seg = cmd.segment; for (seg.sections.items) |*sect, j| { @@ -302,18 +302,18 @@ pub fn readLoadCommands(self: *Object, allocator: Allocator, reader: anytype) !v seg.inner.fileoff += offset; }, - macho.LC_SYMTAB => { + .SYMTAB => { self.symtab_cmd_index = i; cmd.symtab.symoff += offset; cmd.symtab.stroff += offset; }, - macho.LC_DYSYMTAB => { + .DYSYMTAB => { self.dysymtab_cmd_index = i; }, - macho.LC_BUILD_VERSION => { + .BUILD_VERSION => { self.build_version_cmd_index = i; }, - macho.LC_DATA_IN_CODE => { + .DATA_IN_CODE => { self.data_in_code_cmd_index = i; cmd.linkedit_data.dataoff += offset; }, |
