| ... | @@ -204,10 +204,10 @@ fn newSymbolWithAtom(self: *ZigObject, allocator: Allocator, name: u32, macho_fi | ... | @@ -204,10 +204,10 @@ fn newSymbolWithAtom(self: *ZigObject, allocator: Allocator, name: u32, macho_fi |
| 204 | pub fn getAtomData(self: ZigObject, macho_file: *MachO, atom: Atom, buffer: []u8) !void { | 204 | pub fn getAtomData(self: ZigObject, macho_file: *MachO, atom: Atom, buffer: []u8) !void { |
| 205 | assert(atom.file == self.index); | 205 | assert(atom.file == self.index); |
| 206 | assert(atom.size == buffer.len); | 206 | assert(atom.size == buffer.len); |
| 207 | const sect = macho_file.sections.items(.header)[atom.out_n_sect]; | 207 | const isec = atom.getInputSection(macho_file); |
| 208 | assert(!sect.isZerofill()); | 208 | assert(!isec.isZerofill()); |
| 209 | | 209 | |
| 210 | switch (sect.type()) { | 210 | switch (isec.type()) { |
| 211 | macho.S_THREAD_LOCAL_REGULAR => { | 211 | macho.S_THREAD_LOCAL_REGULAR => { |
| 212 | const tlv = self.tlv_initializers.get(atom.atom_index).?; | 212 | const tlv = self.tlv_initializers.get(atom.atom_index).?; |
| 213 | @memcpy(buffer, tlv.data); | 213 | @memcpy(buffer, tlv.data); |
| ... | @@ -216,6 +216,7 @@ pub fn getAtomData(self: ZigObject, macho_file: *MachO, atom: Atom, buffer: []u8 | ... | @@ -216,6 +216,7 @@ pub fn getAtomData(self: ZigObject, macho_file: *MachO, atom: Atom, buffer: []u8 |
| 216 | @memset(buffer, 0); | 216 | @memset(buffer, 0); |
| 217 | }, | 217 | }, |
| 218 | else => { | 218 | else => { |
| | 219 | const sect = macho_file.sections.items(.header)[atom.out_n_sect]; |
| 219 | const file_offset = sect.offset + atom.value; | 220 | const file_offset = sect.offset + atom.value; |
| 220 | const amt = try macho_file.base.file.?.preadAll(buffer, file_offset); | 221 | const amt = try macho_file.base.file.?.preadAll(buffer, file_offset); |
| 221 | if (amt != buffer.len) return error.InputOutput; | 222 | if (amt != buffer.len) return error.InputOutput; |