authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-09-23 07:01:30+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-09-23 07:06:41+02:00
log7c2abff1e13f6172771c3fe36aa580cdaa56b11e
treeb6d6f74e28cc40b077fbd8831326c1bb46eb7709
parent6929a5f44026cec8162fe713668b02e0e02bdfcc

elf: only allocate __dso_handle symbol if not found in any object


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

src/link/Elf/LinkerDefined.zig+5-3
...@@ -47,7 +47,7 @@ fn newSymbolAssumeCapacity(self: *LinkerDefined, name_off: u32, elf_file: *Elf)...@@ -47,7 +47,7 @@ fn newSymbolAssumeCapacity(self: *LinkerDefined, name_off: u32, elf_file: *Elf)
47 const esym = self.symtab.addOneAssumeCapacity();47 const esym = self.symtab.addOneAssumeCapacity();
48 esym.* = .{48 esym.* = .{
49 .st_name = name_off,49 .st_name = name_off,
50 .st_info = elf.STB_GLOBAL << 4,50 .st_info = elf.STB_WEAK << 4,
51 .st_other = @intFromEnum(elf.STV.HIDDEN),51 .st_other = @intFromEnum(elf.STV.HIDDEN),
52 .st_shndx = elf.SHN_ABS,52 .st_shndx = elf.SHN_ABS,
53 .st_value = 0,53 .st_value = 0,
...@@ -255,8 +255,10 @@ pub fn allocateSymbols(self: *LinkerDefined, elf_file: *Elf) void {...@@ -255,8 +255,10 @@ pub fn allocateSymbols(self: *LinkerDefined, elf_file: *Elf) void {
255255
256 // __dso_handle256 // __dso_handle
257 if (self.dso_handle_index) |index| {257 if (self.dso_handle_index) |index| {
258 const shdr = shdrs[1];258 if (self.resolveSymbol(index, elf_file).file == self.index) {
259 allocSymbol(self, index, shdr.sh_addr, 0, elf_file);259 const shdr = shdrs[1];
260 allocSymbol(self, index, shdr.sh_addr, 0, elf_file);
261 }
260 }262 }
261263
262 // __GNU_EH_FRAME_HDR264 // __GNU_EH_FRAME_HDR