elf: populate symtab with symbols coming from DSOs

This commit is contained in:
Jakub Konka 2023-10-07 14:10:26 +02:00
parent c940735c4d
commit a748ca3725
3 changed files with 11 additions and 6 deletions

View File

@ -4877,6 +4877,12 @@ fn updateSymtabSize(self: *Elf) !void {
sizes.nglobals += object.output_symtab_size.nglobals;
}
for (self.shared_objects.items) |index| {
const shared_object = self.file(index).?.shared_object;
shared_object.updateSymtabSize(self);
sizes.nglobals += shared_object.output_symtab_size.nglobals;
}
if (self.got_section_index) |_| {
self.got.updateSymtabSize(self);
sizes.nlocals += self.got.output_symtab_size.nlocals;

View File

@ -479,9 +479,8 @@ fn scanReloc(
try self.reportNoPicError(symbol, rel, elf_file)
else
try self.reportPicError(symbol, rel, elf_file);
} else {
symbol.flags.needs_copy_rel = true;
}
symbol.flags.needs_copy_rel = true;
},
.dyn_copyrel => {

View File

@ -51,10 +51,10 @@ pub fn isIFunc(symbol: Symbol, elf_file: *Elf) bool {
}
pub fn @"type"(symbol: Symbol, elf_file: *Elf) u4 {
const s_sym = symbol.elfSym(elf_file);
const esym = symbol.elfSym(elf_file);
const file_ptr = symbol.file(elf_file).?;
if (s_sym.st_type() == elf.STT_GNU_IFUNC and file_ptr == .shared_object) return elf.STT_FUNC;
return s_sym.st_type();
if (esym.st_type() == elf.STT_GNU_IFUNC and file_ptr == .shared_object) return elf.STT_FUNC;
return esym.st_type();
}
pub fn name(symbol: Symbol, elf_file: *Elf) [:0]const u8 {
@ -111,7 +111,7 @@ pub fn gotAddress(symbol: Symbol, elf_file: *Elf) u64 {
}
pub fn pltGotAddress(symbol: Symbol, elf_file: *Elf) u64 {
if (!(symbol.flags.has_plt and symbol.flags.has_got and !symbol.flags.is_canonical)) return 0;
if (!(symbol.flags.has_plt and symbol.flags.has_got)) return 0;
const extras = symbol.extra(elf_file).?;
const shdr = elf_file.shdrs.items[elf_file.plt_got_section_index.?];
return shdr.sh_addr + extras.plt_got * 16;