| ... | ... | @@ -2310,11 +2310,11 @@ fn shiftLocalsByOffset(self: *MachO, match: MatchingSection, offset: i64) !void |
| 2310 | 2310 | var atom = self.atoms.get(match) orelse return; |
| 2311 | 2311 | |
| 2312 | 2312 | while (true) { |
| 2313 | | const atom_sym = &self.locals.items[atom.sym_index]; |
| 2313 | const atom_sym = atom.getSymbolPtr(self); |
| 2314 | 2314 | atom_sym.n_value = @intCast(u64, @intCast(i64, atom_sym.n_value) + offset); |
| 2315 | 2315 | |
| 2316 | 2316 | for (atom.contained.items) |sym_at_off| { |
| 2317 | | const contained_sym = &self.locals.items[sym_at_off.sym_index]; |
| 2317 | const contained_sym = self.getSymbolPtr(.{ .sym_index = sym_at_off.sym_index, .file = atom.file }); |
| 2318 | 2318 | contained_sym.n_value = @intCast(u64, @intCast(i64, contained_sym.n_value) + offset); |
| 2319 | 2319 | } |
| 2320 | 2320 | |
| ... | ... | @@ -3488,7 +3488,7 @@ fn shrinkAtom(self: *MachO, atom: *Atom, new_block_size: u64, match: MatchingSec |
| 3488 | 3488 | } |
| 3489 | 3489 | |
| 3490 | 3490 | fn growAtom(self: *MachO, atom: *Atom, new_atom_size: u64, alignment: u64, match: MatchingSection) !u64 { |
| 3491 | | const sym = self.locals.items[atom.sym_index]; |
| 3491 | const sym = atom.getSymbol(self); |
| 3492 | 3492 | const align_ok = mem.alignBackwardGeneric(u64, sym.n_value, alignment) == sym.n_value; |
| 3493 | 3493 | const need_realloc = !align_ok or new_atom_size > atom.capacity(self); |
| 3494 | 3494 | if (!need_realloc) return sym.n_value; |
| ... | ... | @@ -3643,14 +3643,14 @@ pub fn updateFunc(self: *MachO, module: *Module, func: *Module.Fn, air: Air, liv |
| 3643 | 3643 | }, |
| 3644 | 3644 | } |
| 3645 | 3645 | |
| 3646 | | const symbol = try self.placeDecl(decl_index, decl.link.macho.code.items.len); |
| 3646 | const addr = try self.placeDecl(decl_index, decl.link.macho.code.items.len); |
| 3647 | 3647 | |
| 3648 | 3648 | if (decl_state) |*ds| { |
| 3649 | 3649 | try self.d_sym.?.dwarf.commitDeclState( |
| 3650 | 3650 | &self.base, |
| 3651 | 3651 | module, |
| 3652 | 3652 | decl, |
| 3653 | | symbol.n_value, |
| 3653 | addr, |
| 3654 | 3654 | decl.link.macho.size, |
| 3655 | 3655 | ds, |
| 3656 | 3656 | ); |
| ... | ... | @@ -3731,7 +3731,7 @@ pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: Modu |
| 3731 | 3731 | |
| 3732 | 3732 | errdefer self.freeAtom(atom, match, true); |
| 3733 | 3733 | |
| 3734 | | const symbol = &self.locals.items[atom.sym_index]; |
| 3734 | const symbol = atom.getSymbolPtr(self); |
| 3735 | 3735 | symbol.* = .{ |
| 3736 | 3736 | .n_strx = name_str_index, |
| 3737 | 3737 | .n_type = macho.N_SECT, |
| ... | ... | @@ -3814,14 +3814,14 @@ pub fn updateDecl(self: *MachO, module: *Module, decl_index: Module.Decl.Index) |
| 3814 | 3814 | }, |
| 3815 | 3815 | } |
| 3816 | 3816 | }; |
| 3817 | | const symbol = try self.placeDecl(decl_index, code.len); |
| 3817 | const addr = try self.placeDecl(decl_index, code.len); |
| 3818 | 3818 | |
| 3819 | 3819 | if (decl_state) |*ds| { |
| 3820 | 3820 | try self.d_sym.?.dwarf.commitDeclState( |
| 3821 | 3821 | &self.base, |
| 3822 | 3822 | module, |
| 3823 | 3823 | decl, |
| 3824 | | symbol.n_value, |
| 3824 | addr, |
| 3825 | 3825 | decl.link.macho.size, |
| 3826 | 3826 | ds, |
| 3827 | 3827 | ); |
| ... | ... | @@ -3977,12 +3977,11 @@ fn getMatchingSectionAtom( |
| 3977 | 3977 | return match; |
| 3978 | 3978 | } |
| 3979 | 3979 | |
| 3980 | | fn placeDecl(self: *MachO, decl_index: Module.Decl.Index, code_len: usize) !*macho.nlist_64 { |
| 3980 | fn placeDecl(self: *MachO, decl_index: Module.Decl.Index, code_len: usize) !u64 { |
| 3981 | 3981 | const module = self.base.options.module.?; |
| 3982 | 3982 | const decl = module.declPtr(decl_index); |
| 3983 | 3983 | const required_alignment = decl.getAlignment(self.base.options.target); |
| 3984 | 3984 | assert(decl.link.macho.sym_index != 0); // Caller forgot to call allocateDeclIndexes() |
| 3985 | | const symbol = &self.locals.items[decl.link.macho.sym_index]; |
| 3986 | 3985 | |
| 3987 | 3986 | const sym_name = try decl.getFullyQualifiedName(module); |
| 3988 | 3987 | defer self.base.allocator.free(sym_name); |
| ... | ... | @@ -4000,6 +3999,7 @@ fn placeDecl(self: *MachO, decl_index: Module.Decl.Index, code_len: usize) !*mac |
| 4000 | 3999 | const match = decl_ptr.*.?; |
| 4001 | 4000 | |
| 4002 | 4001 | if (decl.link.macho.size != 0) { |
| 4002 | const symbol = decl.link.macho.getSymbolPtr(self); |
| 4003 | 4003 | const capacity = decl.link.macho.capacity(self); |
| 4004 | 4004 | const need_realloc = code_len > capacity or !mem.isAlignedGeneric(u64, symbol.n_value, required_alignment); |
| 4005 | 4005 | |
| ... | ... | @@ -4033,6 +4033,7 @@ fn placeDecl(self: *MachO, decl_index: Module.Decl.Index, code_len: usize) !*mac |
| 4033 | 4033 | |
| 4034 | 4034 | errdefer self.freeAtom(&decl.link.macho, match, false); |
| 4035 | 4035 | |
| 4036 | const symbol = decl.link.macho.getSymbolPtr(self); |
| 4036 | 4037 | symbol.* = .{ |
| 4037 | 4038 | .n_strx = name_str_index, |
| 4038 | 4039 | .n_type = macho.N_SECT, |
| ... | ... | @@ -4047,7 +4048,7 @@ fn placeDecl(self: *MachO, decl_index: Module.Decl.Index, code_len: usize) !*mac |
| 4047 | 4048 | self.got_entries.items[got_index].sym_index = got_atom.sym_index; |
| 4048 | 4049 | } |
| 4049 | 4050 | |
| 4050 | | return symbol; |
| 4051 | return decl.link.macho.getSymbol(self).n_value; |
| 4051 | 4052 | } |
| 4052 | 4053 | |
| 4053 | 4054 | pub fn updateDeclLineNumber(self: *MachO, module: *Module, decl: *const Module.Decl) !void { |
| ... | ... | @@ -5233,7 +5234,7 @@ fn allocateAtom( |
| 5233 | 5234 | const big_atom = free_list.items[i]; |
| 5234 | 5235 | // We now have a pointer to a live atom that has too much capacity. |
| 5235 | 5236 | // Is it enough that we could fit this new atom? |
| 5236 | | const sym = self.locals.items[big_atom.sym_index]; |
| 5237 | const sym = big_atom.getSymbol(self); |
| 5237 | 5238 | const capacity = big_atom.capacity(self); |
| 5238 | 5239 | const ideal_capacity = if (needs_padding) padToIdeal(capacity) else capacity; |
| 5239 | 5240 | const ideal_capacity_end_vaddr = math.add(u64, sym.n_value, ideal_capacity) catch ideal_capacity; |
| ... | ... | @@ -5264,7 +5265,7 @@ fn allocateAtom( |
| 5264 | 5265 | } |
| 5265 | 5266 | break :blk new_start_vaddr; |
| 5266 | 5267 | } else if (self.atoms.get(match)) |last| { |
| 5267 | | const last_symbol = self.locals.items[last.sym_index]; |
| 5268 | const last_symbol = last.getSymbol(self); |
| 5268 | 5269 | const ideal_capacity = if (needs_padding) padToIdeal(last.size) else last.size; |
| 5269 | 5270 | const ideal_capacity_end_vaddr = last_symbol.n_value + ideal_capacity; |
| 5270 | 5271 | const new_start_vaddr = mem.alignForwardGeneric(u64, ideal_capacity_end_vaddr, alignment); |