authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-27 19:22:57+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-09-27 19:22:57+02:00
log111349f83c456200c131c222d06cdf83fa62ac54
treeb7a41fed7d1765821d4ea7ce93bbd9a56b58cdd8
parent85132965f4163f211c3b04a6316f8dac46d1c260

elf: do not update globals not defined by the object


1 files changed, 4 insertions(+), 3 deletions(-)

src/link/Elf.zig+4-3
......@@ -790,7 +790,7 @@ pub fn populateMissingMetadata(self: *Elf) !void {
790790 }
791791
792792 if (self.base.options.module) |module| {
793 if (self.zig_module_index == null) {
793 if (self.zig_module_index == null and !self.base.options.use_llvm) {
794794 const index = @as(File.Index, @intCast(try self.files.addOne(gpa)));
795795 self.files.set(index, .{ .zig_module = .{
796796 .index = index,
......@@ -905,14 +905,15 @@ fn growSegment(self: *Elf, shndx: u16, needed_size: u64) !void {
905905 const sym = self.symbol(sym_index);
906906 const atom_ptr = sym.atom(self) orelse continue;
907907 if (!atom_ptr.flags.alive or !atom_ptr.flags.allocated) continue;
908 if (atom_ptr.value >= end_addr) sym.value += diff;
908 if (sym.value >= end_addr) sym.value += diff;
909909 }
910910
911911 for (file_ptr.globals()) |sym_index| {
912912 const sym = self.symbol(sym_index);
913 if (sym.file_index != index) continue;
913914 const atom_ptr = sym.atom(self) orelse continue;
914915 if (!atom_ptr.flags.alive or !atom_ptr.flags.allocated) continue;
915 if (atom_ptr.value >= end_addr) sym.value += diff;
916 if (sym.value >= end_addr) sym.value += diff;
916917 }
917918
918919 for (file_ptr.atoms()) |atom_index| {