| ... | ... | @@ -3786,7 +3786,13 @@ pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: Modu |
| 3786 | 3786 | atom.code.clearRetainingCapacity(); |
| 3787 | 3787 | try atom.code.appendSlice(self.base.allocator, code); |
| 3788 | 3788 | |
| 3789 | | const match = try self.getMatchingSectionAtom(atom, decl_name, typed_value.ty, typed_value.val); |
| 3789 | const match = try self.getMatchingSectionAtom( |
| 3790 | atom, |
| 3791 | decl_name, |
| 3792 | typed_value.ty, |
| 3793 | typed_value.val, |
| 3794 | required_alignment, |
| 3795 | ); |
| 3790 | 3796 | const addr = try self.allocateAtom(atom, code.len, required_alignment, match); |
| 3791 | 3797 | |
| 3792 | 3798 | log.debug("allocated atom for {s} at 0x{x}", .{ name, addr }); |
| ... | ... | @@ -3949,11 +3955,16 @@ fn needsPointerRebase(ty: Type, val: Value, mod: *Module) bool { |
| 3949 | 3955 | } |
| 3950 | 3956 | } |
| 3951 | 3957 | |
| 3952 | | fn getMatchingSectionAtom(self: *MachO, atom: *Atom, name: []const u8, ty: Type, val: Value) !MatchingSection { |
| 3958 | fn getMatchingSectionAtom( |
| 3959 | self: *MachO, |
| 3960 | atom: *Atom, |
| 3961 | name: []const u8, |
| 3962 | ty: Type, |
| 3963 | val: Value, |
| 3964 | alignment: u32, |
| 3965 | ) !MatchingSection { |
| 3953 | 3966 | const code = atom.code.items; |
| 3954 | | const target = self.base.options.target; |
| 3955 | 3967 | const mod = self.base.options.module.?; |
| 3956 | | const alignment = ty.abiAlignment(target); |
| 3957 | 3968 | const align_log_2 = math.log2(alignment); |
| 3958 | 3969 | const zig_ty = ty.zigTypeTag(); |
| 3959 | 3970 | const mode = self.base.options.optimize_mode; |
| ... | ... | @@ -4039,7 +4050,7 @@ fn getMatchingSectionAtom(self: *MachO, atom: *Atom, name: []const u8, ty: Type, |
| 4039 | 4050 | fn placeDecl(self: *MachO, decl_index: Module.Decl.Index, code_len: usize) !*macho.nlist_64 { |
| 4040 | 4051 | const module = self.base.options.module.?; |
| 4041 | 4052 | const decl = module.declPtr(decl_index); |
| 4042 | | const required_alignment = decl.ty.abiAlignment(self.base.options.target); |
| 4053 | const required_alignment = decl.getAlignment(self.base.options.target); |
| 4043 | 4054 | assert(decl.link.macho.local_sym_index != 0); // Caller forgot to call allocateDeclIndexes() |
| 4044 | 4055 | const symbol = &self.locals.items[decl.link.macho.local_sym_index]; |
| 4045 | 4056 | |
| ... | ... | @@ -4048,7 +4059,13 @@ fn placeDecl(self: *MachO, decl_index: Module.Decl.Index, code_len: usize) !*mac |
| 4048 | 4059 | |
| 4049 | 4060 | const decl_ptr = self.decls.getPtr(decl_index).?; |
| 4050 | 4061 | if (decl_ptr.* == null) { |
| 4051 | | decl_ptr.* = try self.getMatchingSectionAtom(&decl.link.macho, sym_name, decl.ty, decl.val); |
| 4062 | decl_ptr.* = try self.getMatchingSectionAtom( |
| 4063 | &decl.link.macho, |
| 4064 | sym_name, |
| 4065 | decl.ty, |
| 4066 | decl.val, |
| 4067 | required_alignment, |
| 4068 | ); |
| 4052 | 4069 | } |
| 4053 | 4070 | const match = decl_ptr.*.?; |
| 4054 | 4071 | |