authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-07-15 22:53:52+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-07-18 09:13:09+02:00
log33388130775672df611091910e0cb1482a7eeb02
treeff401a3a6e578d248a66a24874eeabb13569cf79
parenta9e3088d9ce9edd61765e610e5d1a5ea8a5f6733

macho: use isec for working out getAtomData in ZigObject


1 files changed, 4 insertions(+), 3 deletions(-)

src/link/MachO/ZigObject.zig+4-3
......@@ -204,10 +204,10 @@ fn newSymbolWithAtom(self: *ZigObject, allocator: Allocator, name: u32, macho_fi
204204pub fn getAtomData(self: ZigObject, macho_file: *MachO, atom: Atom, buffer: []u8) !void {
205205 assert(atom.file == self.index);
206206 assert(atom.size == buffer.len);
207 const sect = macho_file.sections.items(.header)[atom.out_n_sect];
208 assert(!sect.isZerofill());
207 const isec = atom.getInputSection(macho_file);
208 assert(!isec.isZerofill());
209209
210 switch (sect.type()) {
210 switch (isec.type()) {
211211 macho.S_THREAD_LOCAL_REGULAR => {
212212 const tlv = self.tlv_initializers.get(atom.atom_index).?;
213213 @memcpy(buffer, tlv.data);
......@@ -216,6 +216,7 @@ pub fn getAtomData(self: ZigObject, macho_file: *MachO, atom: Atom, buffer: []u8
216216 @memset(buffer, 0);
217217 },
218218 else => {
219 const sect = macho_file.sections.items(.header)[atom.out_n_sect];
219220 const file_offset = sect.offset + atom.value;
220221 const amt = try macho_file.base.file.?.preadAll(buffer, file_offset);
221222 if (amt != buffer.len) return error.InputOutput;