diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-09-10 16:24:41 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-09-18 10:00:04 +0200 |
| commit | e5da251635bb24d418dbec4385aa2319c7f75247 (patch) | |
| tree | 2200aa85546e4bdcae67a6f05e185796cf112503 /src/link/MachO/Object.zig | |
| parent | 05d0c42894b40c530819b1ac15f8133bfd34cf47 (diff) | |
| download | zig-e5da251635bb24d418dbec4385aa2319c7f75247.tar.gz zig-e5da251635bb24d418dbec4385aa2319c7f75247.zip | |
macho: clean up use of section ids
Diffstat (limited to 'src/link/MachO/Object.zig')
| -rw-r--r-- | src/link/MachO/Object.zig | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig index 7c7c83ab3e..28244c674f 100644 --- a/src/link/MachO/Object.zig +++ b/src/link/MachO/Object.zig @@ -220,15 +220,15 @@ fn filterRelocs( pub fn scanInputSections(self: Object, macho_file: *MachO) !void { for (self.sections.items) |sect| { - const match = (try macho_file.getOutputSection(sect)) orelse { + const sect_id = (try macho_file.getOutputSection(sect)) orelse { log.debug(" unhandled section", .{}); continue; }; - const output = macho_file.sections.items(.header)[match]; + const output = macho_file.sections.items(.header)[sect_id]; log.debug("mapping '{s},{s}' into output sect({d}, '{s},{s}')", .{ sect.segName(), sect.sectName(), - match + 1, + sect_id + 1, output.segName(), output.sectName(), }); @@ -335,15 +335,15 @@ pub fn splitIntoAtoms(self: *Object, macho_file: *MachO, object_id: u32) !void { log.debug("splitting section '{s},{s}' into atoms", .{ sect.segName(), sect.sectName() }); // Get matching segment/section in the final artifact. - const match = (try macho_file.getOutputSection(sect)) orelse { + const out_sect_id = (try macho_file.getOutputSection(sect)) orelse { log.debug(" unhandled section", .{}); continue; }; log.debug(" output sect({d}, '{s},{s}')", .{ - match + 1, - macho_file.sections.items(.header)[match].segName(), - macho_file.sections.items(.header)[match].sectName(), + out_sect_id + 1, + macho_file.sections.items(.header)[out_sect_id].segName(), + macho_file.sections.items(.header)[out_sect_id].sectName(), }); const cpu_arch = macho_file.base.options.target.cpu.arch; @@ -376,7 +376,7 @@ pub fn splitIntoAtoms(self: *Object, macho_file: *MachO, object_id: u32) !void { try self.symtab.append(gpa, .{ .n_strx = 0, .n_type = macho.N_SECT, - .n_sect = match + 1, + .n_sect = out_sect_id + 1, .n_desc = 0, .n_value = sect.addr, }); @@ -397,10 +397,10 @@ pub fn splitIntoAtoms(self: *Object, macho_file: *MachO, object_id: u32) !void { atom_code, relocs, &.{}, - match, + out_sect_id, sect, ); - try macho_file.addAtomToSection(atom, match); + try macho_file.addAtomToSection(atom); } var next_sym_count: usize = 0; @@ -452,7 +452,7 @@ pub fn splitIntoAtoms(self: *Object, macho_file: *MachO, object_id: u32) !void { atom_code, relocs, sorted_atom_syms.items[1..], - match, + out_sect_id, sect, ); @@ -465,7 +465,7 @@ pub fn splitIntoAtoms(self: *Object, macho_file: *MachO, object_id: u32) !void { try self.symtab.append(gpa, .{ .n_strx = 0, .n_type = macho.N_SECT, - .n_sect = match + 1, + .n_sect = out_sect_id + 1, .n_desc = 0, .n_value = addr, }); @@ -479,7 +479,7 @@ pub fn splitIntoAtoms(self: *Object, macho_file: *MachO, object_id: u32) !void { try self.atom_by_index_table.put(gpa, alias, atom); } - try macho_file.addAtomToSection(atom, match); + try macho_file.addAtomToSection(atom); } } else { // If there is no symbol to refer to this atom, we create @@ -490,7 +490,7 @@ pub fn splitIntoAtoms(self: *Object, macho_file: *MachO, object_id: u32) !void { try self.symtab.append(gpa, .{ .n_strx = 0, .n_type = macho.N_SECT, - .n_sect = match + 1, + .n_sect = out_sect_id + 1, .n_desc = 0, .n_value = sect.addr, }); @@ -506,10 +506,10 @@ pub fn splitIntoAtoms(self: *Object, macho_file: *MachO, object_id: u32) !void { code, relocs, filtered_syms, - match, + out_sect_id, sect, ); - try macho_file.addAtomToSection(atom, match); + try macho_file.addAtomToSection(atom); } } } @@ -524,21 +524,21 @@ fn createAtomFromSubsection( code: ?[]const u8, relocs: []align(1) const macho.relocation_info, indexes: []const SymbolAtIndex, - match: u8, + out_sect_id: u8, sect: macho.section_64, ) !*Atom { const gpa = macho_file.base.allocator; const sym = self.symtab.items[sym_index]; const atom = try MachO.createEmptyAtom(gpa, sym_index, size, alignment); atom.file = object_id; - self.symtab.items[sym_index].n_sect = match + 1; + self.symtab.items[sym_index].n_sect = out_sect_id + 1; log.debug("creating ATOM(%{d}, '{s}') in sect({d}, '{s},{s}') in object({d})", .{ sym_index, self.getString(sym.n_strx), - match + 1, - macho_file.sections.items(.header)[match].segName(), - macho_file.sections.items(.header)[match].sectName(), + out_sect_id + 1, + macho_file.sections.items(.header)[out_sect_id].segName(), + macho_file.sections.items(.header)[out_sect_id].sectName(), object_id, }); @@ -566,7 +566,7 @@ fn createAtomFromSubsection( try atom.contained.ensureTotalCapacity(gpa, indexes.len); for (indexes) |inner_sym_index| { const inner_sym = &self.symtab.items[inner_sym_index.index]; - inner_sym.n_sect = match + 1; + inner_sym.n_sect = out_sect_id + 1; atom.contained.appendAssumeCapacity(.{ .sym_index = inner_sym_index.index, .offset = inner_sym.n_value - sym.n_value, |
