mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00
LibELF: Support relocating weak symbols against global libraries
A strong symbol anywhere in an executable must override any weak symbol used in any library. This means that the weak symbol must be overridden by a strong symbol even if the strong symbol is in a dependent library. This means we need to perform relocations twice, and resolve weak symbols globally before attempting to resolve them locally. Consequentially we need to defer performing any initialisations until after we have performed the second round of relocations.
This commit is contained in:
parent
3e815ad5b1
commit
05345fc07d
4 changed files with 189 additions and 148 deletions
|
@ -449,6 +449,9 @@ Elf32_Addr DynamicObject::patch_plt_entry(u32 relocation_offset)
|
|||
DynamicObject::SymbolLookupResult DynamicObject::lookup_symbol(const ELF::DynamicObject::Symbol& symbol) const
|
||||
{
|
||||
VERBOSE("looking up symbol: %s\n", symbol.name());
|
||||
if (symbol.is_undefined() || symbol.bind() == STB_WEAK)
|
||||
return DynamicLinker::lookup_global_symbol(symbol.name());
|
||||
|
||||
if (!symbol.is_undefined()) {
|
||||
VERBOSE("symbol is defined in its object\n");
|
||||
return { true, symbol.value(), (FlatPtr)symbol.address().as_ptr(), symbol.bind(), &symbol.object() };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue