macho: unify Atom concept between drivers

This commit is contained in:
Jakub Konka 2023-08-22 14:03:45 +02:00
parent 85f2df5050
commit da9e7e498a
10 changed files with 980 additions and 1034 deletions

View File

@ -588,7 +588,6 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/src/link/MachO/Relocation.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/Trie.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/UnwindInfo.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/ZldAtom.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/dyld_info/bind.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/dyld_info/Rebase.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/dead_strip.zig"

View File

@ -1597,8 +1597,11 @@ pub fn createAtom(self: *MachO) !Atom.Index {
try self.atom_by_index_table.putNoClobber(gpa, sym_index, atom_index);
atom.* = .{
.sym_index = sym_index,
.inner_sym_index = 0,
.inner_nsyms_trailing = 0,
.file = 0,
.size = 0,
.alignment = 0,
.prev_index = null,
.next_index = null,
};

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ const sort = std.sort;
const trace = @import("../../tracy.zig").trace;
const Allocator = mem.Allocator;
const Atom = @import("ZldAtom.zig");
const Atom = @import("Atom.zig");
const AtomIndex = @import("zld.zig").AtomIndex;
const DwarfInfo = @import("DwarfInfo.zig");
const LoadCommandIterator = macho.LoadCommandIterator;

View File

@ -12,7 +12,7 @@ const mem = std.mem;
const trace = @import("../../tracy.zig").trace;
const Allocator = mem.Allocator;
const Atom = @import("ZldAtom.zig");
const Atom = @import("Atom.zig");
const AtomIndex = @import("zld.zig").AtomIndex;
const EhFrameRecord = eh_frame.EhFrameRecord;
const MachO = @import("../MachO.zig");

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@ const mem = std.mem;
const Allocator = mem.Allocator;
const AtomIndex = @import("zld.zig").AtomIndex;
const Atom = @import("ZldAtom.zig");
const Atom = @import("Atom.zig");
const MachO = @import("../MachO.zig");
const SymbolWithLoc = MachO.SymbolWithLoc;
const SymbolResolver = MachO.SymbolResolver;

View File

@ -8,7 +8,7 @@ const log = std.log.scoped(.eh_frame);
const Allocator = mem.Allocator;
const AtomIndex = @import("zld.zig").AtomIndex;
const Atom = @import("ZldAtom.zig");
const Atom = @import("Atom.zig");
const MachO = @import("../MachO.zig");
const Relocation = @import("Relocation.zig");
const SymbolWithLoc = MachO.SymbolWithLoc;

View File

@ -15,7 +15,7 @@ const mem = std.mem;
const aarch64 = @import("../../arch/aarch64/bits.zig");
const Allocator = mem.Allocator;
const Atom = @import("ZldAtom.zig");
const Atom = @import("Atom.zig");
const AtomIndex = @import("zld.zig").AtomIndex;
const MachO = @import("../MachO.zig");
const Relocation = @import("Relocation.zig");

View File

@ -21,7 +21,7 @@ const trace = @import("../../tracy.zig").trace;
const Allocator = mem.Allocator;
const Archive = @import("Archive.zig");
const Atom = @import("ZldAtom.zig");
const Atom = @import("Atom.zig");
const Cache = std.Build.Cache;
const CodeSignature = @import("CodeSignature.zig");
const Compilation = @import("../../Compilation.zig");
@ -247,7 +247,16 @@ pub const Zld = struct {
const gpa = self.gpa;
const index = @as(AtomIndex, @intCast(self.atoms.items.len));
const atom = try self.atoms.addOne(gpa);
atom.* = Atom.empty;
atom.* = .{
.sym_index = 0,
.inner_sym_index = 0,
.inner_nsyms_trailing = 0,
.file = 0,
.size = 0,
.alignment = 0,
.prev_index = null,
.next_index = null,
};
atom.sym_index = sym_index;
atom.size = size;
atom.alignment = alignment;
@ -3169,6 +3178,14 @@ pub fn linkWithZld(macho_file: *MachO, comp: *Compilation, prog_node: *std.Progr
};
defer zld.deinit();
// Index 0 is always a null symbol.
try zld.locals.append(gpa, .{
.n_strx = 0,
.n_type = 0,
.n_sect = 0,
.n_desc = 0,
.n_value = 0,
});
try zld.strtab.buffer.append(gpa, 0);
// Positional arguments to the linker such as object files and static archives.