diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-04-05 08:23:46 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-04-13 11:47:51 +0200 |
| commit | eba280ce20d308ec0abb17719ab4cc43a27901eb (patch) | |
| tree | b9bbac734e4c82bb2487f0921e26fce627291578 /src/link/MachO/Atom.zig | |
| parent | 1795b8eb4e8db95cb639349c6c1bc4b0b82741bb (diff) | |
| download | zig-eba280ce20d308ec0abb17719ab4cc43a27901eb.tar.gz zig-eba280ce20d308ec0abb17719ab4cc43a27901eb.zip | |
macho: refactor relocation type in incremental linker
Diffstat (limited to 'src/link/MachO/Atom.zig')
| -rw-r--r-- | src/link/MachO/Atom.zig | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/link/MachO/Atom.zig b/src/link/MachO/Atom.zig index bd1a21a04f..5b17dc689d 100644 --- a/src/link/MachO/Atom.zig +++ b/src/link/MachO/Atom.zig @@ -14,7 +14,7 @@ const trace = @import("../../tracy.zig").trace; const Allocator = mem.Allocator; const Arch = std.Target.Cpu.Arch; const MachO = @import("../MachO.zig"); -const Relocation = @import("Relocation.zig"); +pub const Relocation = @import("Relocation.zig"); const SymbolWithLoc = MachO.SymbolWithLoc; /// Each decl always gets a local symbol with the fully qualified name. @@ -113,25 +113,19 @@ pub fn freeListEligible(self: Atom, macho_file: *MachO) bool { } pub fn addRelocation(macho_file: *MachO, atom_index: Index, reloc: Relocation) !void { - return addRelocations(macho_file, atom_index, 1, .{reloc}); + return addRelocations(macho_file, atom_index, &[_]Relocation{reloc}); } -pub fn addRelocations( - macho_file: *MachO, - atom_index: Index, - comptime count: comptime_int, - relocs: [count]Relocation, -) !void { +pub fn addRelocations(macho_file: *MachO, atom_index: Index, relocs: []Relocation) !void { const gpa = macho_file.base.allocator; - const target = macho_file.base.options.target; const gop = try macho_file.relocs.getOrPut(gpa, atom_index); if (!gop.found_existing) { gop.value_ptr.* = .{}; } - try gop.value_ptr.ensureUnusedCapacity(gpa, count); + try gop.value_ptr.ensureUnusedCapacity(gpa, relocs.len); for (relocs) |reloc| { log.debug(" (adding reloc of type {s} to target %{d})", .{ - reloc.fmtType(target), + @tagName(reloc.type), reloc.target.sym_index, }); gop.value_ptr.appendAssumeCapacity(reloc); |
