diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-07-13 07:56:28 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-07-18 09:13:08 +0200 |
| commit | 129fe8668c8b4835c11c50360ee4ed36972ae773 (patch) | |
| tree | 10e2f7290b4e2fc9e23e6eee491a7a945862a497 /src | |
| parent | e5a66184eda96d8571ea5abaf7d5623d092bfac2 (diff) | |
| download | zig-129fe8668c8b4835c11c50360ee4ed36972ae773.tar.gz zig-129fe8668c8b4835c11c50360ee4ed36972ae773.zip | |
macho: write non-incremental atoms in ZigObject
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/MachO.zig | 3 | ||||
| -rw-r--r-- | src/link/MachO/ZigObject.zig | 17 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig index e99fd6bf58..3c02900589 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -2351,6 +2351,9 @@ fn writeSectionsAndUpdateLinkeditSizes(self: *MachO) !void { for (self.objects.items) |index| { try self.getFile(index).?.writeAtoms(self); } + if (self.getZigObject()) |zo| { + try zo.writeAtoms(self); + } if (self.getInternalObject()) |obj| { try obj.asFile().writeAtoms(self); } diff --git a/src/link/MachO/ZigObject.zig b/src/link/MachO/ZigObject.zig index a84a95da7e..160e67d3d5 100644 --- a/src/link/MachO/ZigObject.zig +++ b/src/link/MachO/ZigObject.zig @@ -508,9 +508,20 @@ pub fn writeAtomsRelocatable(self: *ZigObject, macho_file: *MachO) !void { // For example, TLS data gets written out via traditional route. // Is there any better way of handling this? pub fn writeAtoms(self: *ZigObject, macho_file: *MachO) !void { - const gpa = macho_file.base.comp.gpa; - _ = gpa; - _ = self; + const tracy = trace(@src()); + defer tracy.end(); + + for (self.getAtoms()) |atom_index| { + const atom = self.getAtom(atom_index) orelse continue; + if (!atom.flags.alive) continue; + const sect = atom.getInputSection(macho_file); + if (sect.isZerofill()) continue; + if (macho_file.isZigSection(atom.out_n_sect)) continue; + const off = atom.value; + const buffer = macho_file.sections.items(.out)[atom.out_n_sect].items; + try self.getAtomData(macho_file, atom.*, buffer[off..][0..atom.size]); + try atom.resolveRelocs(macho_file, buffer[off..][0..atom.size]); + } } pub fn calcSymtabSize(self: *ZigObject, macho_file: *MachO) void { |
