authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-07-13 07:56:28+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-07-18 09:13:08+02:00
log129fe8668c8b4835c11c50360ee4ed36972ae773
tree10e2f7290b4e2fc9e23e6eee491a7a945862a497
parente5a66184eda96d8571ea5abaf7d5623d092bfac2

macho: write non-incremental atoms in ZigObject


2 files changed, 17 insertions(+), 3 deletions(-)

src/link/MachO.zig+3
......@@ -2351,6 +2351,9 @@ fn writeSectionsAndUpdateLinkeditSizes(self: *MachO) !void {
23512351 for (self.objects.items) |index| {
23522352 try self.getFile(index).?.writeAtoms(self);
23532353 }
2354 if (self.getZigObject()) |zo| {
2355 try zo.writeAtoms(self);
2356 }
23542357 if (self.getInternalObject()) |obj| {
23552358 try obj.asFile().writeAtoms(self);
23562359 }
src/link/MachO/ZigObject.zig+14-3
......@@ -508,9 +508,20 @@ pub fn writeAtomsRelocatable(self: *ZigObject, macho_file: *MachO) !void {
508508// For example, TLS data gets written out via traditional route.
509509// Is there any better way of handling this?
510510pub fn writeAtoms(self: *ZigObject, macho_file: *MachO) !void {
511 const gpa = macho_file.base.comp.gpa;
512 _ = gpa;
513 _ = self;
511 const tracy = trace(@src());
512 defer tracy.end();
513
514 for (self.getAtoms()) |atom_index| {
515 const atom = self.getAtom(atom_index) orelse continue;
516 if (!atom.flags.alive) continue;
517 const sect = atom.getInputSection(macho_file);
518 if (sect.isZerofill()) continue;
519 if (macho_file.isZigSection(atom.out_n_sect)) continue;
520 const off = atom.value;
521 const buffer = macho_file.sections.items(.out)[atom.out_n_sect].items;
522 try self.getAtomData(macho_file, atom.*, buffer[off..][0..atom.size]);
523 try atom.resolveRelocs(macho_file, buffer[off..][0..atom.size]);
524 }
514525}
515526
516527pub fn calcSymtabSize(self: *ZigObject, macho_file: *MachO) void {