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)
4747 const esym = self.symtab.addOneAssumeCapacity();
4848 esym.* = .{
4949 .st_name = name_off,
50 .st_info = elf.STB_GLOBAL << 4,
50 .st_info = elf.STB_WEAK << 4,
5151 .st_other = @intFromEnum(elf.STV.HIDDEN),
5252 .st_shndx = elf.SHN_ABS,
5353 .st_value = 0,
......@@ -255,8 +255,10 @@ pub fn allocateSymbols(self: *LinkerDefined, elf_file: *Elf) void {
255255
256256 // __dso_handle
257257 if (self.dso_handle_index) |index| {
258 const shdr = shdrs[1];
259 allocSymbol(self, index, shdr.sh_addr, 0, elf_file);
258 if (self.resolveSymbol(index, elf_file).file == self.index) {
259 const shdr = shdrs[1];
260 allocSymbol(self, index, shdr.sh_addr, 0, elf_file);
261 }
260262 }
261263
262264 // __GNU_EH_FRAME_HDR