Skip to content

Commit

Permalink
elf: only allocate __dso_handle if not found in input object
Browse files Browse the repository at this point in the history
  • Loading branch information
kubkon committed Sep 20, 2024
1 parent 75b1acc commit cef1026
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Elf/InternalObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn newSymbolAssumeCapacity(self: *InternalObject, name_off: u32, elf_file: *Elf)
const esym = self.symtab.addOneAssumeCapacity();
esym.* = .{
.st_name = name_off,
.st_info = elf.STB_GLOBAL << 4,
.st_info = elf.STB_WEAK << 4,
.st_other = @intFromEnum(elf.STV.HIDDEN),
.st_shndx = elf.SHN_ABS,
.st_value = 0,
Expand Down Expand Up @@ -255,8 +255,10 @@ pub fn allocateSymbols(self: *InternalObject, elf_file: *Elf) void {

// __dso_handle
if (self.dso_handle_index) |index| {
const shdr = shdrs[1];
allocSymbol(self, index, shdr.sh_addr, 0, elf_file);
if (self.resolveSymbol(index, elf_file).file == self.index) {
const shdr = shdrs[1];
allocSymbol(self, index, shdr.sh_addr, 0, elf_file);
}
}

// __GNU_EH_FRAME_HDR
Expand Down

0 comments on commit cef1026

Please sign in to comment.