| ... | @@ -916,10 +916,7 @@ pub fn updateExports( | ... | @@ -916,10 +916,7 @@ pub fn updateExports( |
| 916 | continue; | 916 | continue; |
| 917 | } | 917 | } |
| 918 | | 918 | |
| 919 | const exp_name = try std.fmt.allocPrint(gpa, "_{}", .{exp.opts.name.fmt(&mod.intern_pool)}); | 919 | const exp_name = mod.intern_pool.stringToSlice(exp.opts.name); |
| 920 | defer gpa.free(exp_name); | | |
| 921 | | | |
| 922 | const name_off = try macho_file.strings.insert(gpa, exp_name); | | |
| 923 | const global_nlist_index = if (metadata.@"export"(self, macho_file, exp_name)) |exp_index| | 920 | const global_nlist_index = if (metadata.@"export"(self, macho_file, exp_name)) |exp_index| |
| 924 | exp_index.* | 921 | exp_index.* |
| 925 | else blk: { | 922 | else blk: { |
| ... | @@ -928,7 +925,6 @@ pub fn updateExports( | ... | @@ -928,7 +925,6 @@ pub fn updateExports( |
| 928 | break :blk global_nlist_index; | 925 | break :blk global_nlist_index; |
| 929 | }; | 926 | }; |
| 930 | const global_nlist = &self.symtab.items(.nlist)[global_nlist_index]; | 927 | const global_nlist = &self.symtab.items(.nlist)[global_nlist_index]; |
| 931 | global_nlist.n_strx = name_off; | | |
| 932 | global_nlist.n_value = nlist.n_value; | 928 | global_nlist.n_value = nlist.n_value; |
| 933 | global_nlist.n_sect = nlist.n_sect; | 929 | global_nlist.n_sect = nlist.n_sect; |
| 934 | global_nlist.n_type = macho.N_EXT | macho.N_SECT; | 930 | global_nlist.n_type = macho.N_EXT | macho.N_SECT; |
| ... | @@ -1053,13 +1049,11 @@ pub fn deleteDeclExport( | ... | @@ -1053,13 +1049,11 @@ pub fn deleteDeclExport( |
| 1053 | macho_file: *MachO, | 1049 | macho_file: *MachO, |
| 1054 | decl_index: InternPool.DeclIndex, | 1050 | decl_index: InternPool.DeclIndex, |
| 1055 | name: InternPool.NullTerminatedString, | 1051 | name: InternPool.NullTerminatedString, |
| 1056 | ) Allocator.Error!void { | 1052 | ) void { |
| 1057 | const metadata = self.decls.getPtr(decl_index) orelse return; | 1053 | const metadata = self.decls.getPtr(decl_index) orelse return; |
| 1058 | | 1054 | |
| 1059 | const gpa = macho_file.base.comp.gpa; | | |
| 1060 | const mod = macho_file.base.comp.module.?; | 1055 | const mod = macho_file.base.comp.module.?; |
| 1061 | const exp_name = try std.fmt.allocPrint(gpa, "_{s}", .{mod.intern_pool.stringToSlice(name)}); | 1056 | const exp_name = mod.intern_pool.stringToSlice(name); |
| 1062 | defer gpa.free(exp_name); | | |
| 1063 | const nlist_index = metadata.@"export"(self, macho_file, exp_name) orelse return; | 1057 | const nlist_index = metadata.@"export"(self, macho_file, exp_name) orelse return; |
| 1064 | | 1058 | |
| 1065 | log.debug("deleting export '{s}'", .{exp_name}); | 1059 | log.debug("deleting export '{s}'", .{exp_name}); |
| ... | @@ -1079,7 +1073,9 @@ pub fn deleteDeclExport( | ... | @@ -1079,7 +1073,9 @@ pub fn deleteDeclExport( |
| 1079 | pub fn getGlobalSymbol(self: *ZigObject, macho_file: *MachO, name: []const u8, lib_name: ?[]const u8) !u32 { | 1073 | pub fn getGlobalSymbol(self: *ZigObject, macho_file: *MachO, name: []const u8, lib_name: ?[]const u8) !u32 { |
| 1080 | _ = lib_name; | 1074 | _ = lib_name; |
| 1081 | const gpa = macho_file.base.comp.gpa; | 1075 | const gpa = macho_file.base.comp.gpa; |
| 1082 | const off = try macho_file.strings.insert(gpa, name); | 1076 | const sym_name = try std.fmt.allocPrint(gpa, "_{s}", .{name}); |
| | 1077 | defer gpa.free(sym_name); |
| | 1078 | const off = try macho_file.strings.insert(gpa, sym_name); |
| 1083 | const lookup_gop = try self.globals_lookup.getOrPut(gpa, off); | 1079 | const lookup_gop = try self.globals_lookup.getOrPut(gpa, off); |
| 1084 | if (!lookup_gop.found_existing) { | 1080 | if (!lookup_gop.found_existing) { |
| 1085 | const nlist_index = try self.addNlist(gpa); | 1081 | const nlist_index = try self.addNlist(gpa); |