aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/Object.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2021-07-22 22:19:15 +0200
committerJakub Konka <kubkon@jakubkonka.com>2021-07-22 23:13:13 +0200
commita4feb97cdfb330207f3da05402983bf3a71de64e (patch)
treea2afbbb4567f128b4c1785c26d3a5bdb129dc9ce /src/link/MachO/Object.zig
parent4fd0cb7618ffb5428981672f6a21c411599f51b2 (diff)
downloadzig-a4feb97cdfb330207f3da05402983bf3a71de64e.tar.gz
zig-a4feb97cdfb330207f3da05402983bf3a71de64e.zip
macho: assign and cache section ordinals upon creation
then, when sorting sections within segments, clear and redo the ordinals since we re-apply them to symbols anyway. It is vital to have the ordinals consistent with parsing and resolving relocs however.
Diffstat (limited to 'src/link/MachO/Object.zig')
-rw-r--r--src/link/MachO/Object.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/link/MachO/Object.zig b/src/link/MachO/Object.zig
index c5ff19b9be..846b87a65a 100644
--- a/src/link/MachO/Object.zig
+++ b/src/link/MachO/Object.zig
@@ -733,7 +733,7 @@ pub fn parseTextBlocks(self: *Object, macho_file: *MachO) !void {
try macho_file.locals.append(macho_file.base.allocator, .{
.n_strx = try macho_file.makeString(sym_name),
.n_type = macho.N_SECT,
- .n_sect = macho_file.sectionId(match),
+ .n_sect = macho_file.section_to_ordinal.get(match) orelse unreachable,
.n_desc = 0,
.n_value = sect.addr,
});
@@ -779,7 +779,7 @@ pub fn parseTextBlocks(self: *Object, macho_file: *MachO) !void {
const nlist = nlist_with_index.nlist;
const local_sym_index = self.symbol_mapping.get(nlist_with_index.index) orelse unreachable;
const local = &macho_file.locals.items[local_sym_index];
- local.n_sect = macho_file.sectionId(match);
+ local.n_sect = macho_file.section_to_ordinal.get(match) orelse unreachable;
const stab: ?TextBlock.Stab = if (self.debug_info) |di| blk: {
// TODO there has to be a better to handle this.