mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 18:47:39 +00:00
LibELF: Fix relocation support for 'static __thread' variables
This commit is contained in:
parent
5f6ee4c539
commit
251eaad8f0
1 changed files with 14 additions and 8 deletions
|
@ -482,15 +482,21 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
|
||||||
case R_X86_64_TPOFF64: {
|
case R_X86_64_TPOFF64: {
|
||||||
#endif
|
#endif
|
||||||
auto symbol = relocation.symbol();
|
auto symbol = relocation.symbol();
|
||||||
// For some reason, LibC has a R_386_TLS_TPOFF that refers to the undefined symbol.. huh
|
FlatPtr symbol_value;
|
||||||
if (relocation.symbol_index() == 0)
|
DynamicObject const* dynamic_object_of_symbol;
|
||||||
break;
|
if (relocation.symbol_index() != 0) {
|
||||||
auto res = lookup_symbol(symbol);
|
auto res = lookup_symbol(symbol);
|
||||||
if (!res.has_value())
|
if (!res.has_value())
|
||||||
break;
|
break;
|
||||||
auto* dynamic_object_of_symbol = res.value().dynamic_object;
|
symbol_value = res.value().value;
|
||||||
|
dynamic_object_of_symbol = res.value().dynamic_object;
|
||||||
|
} else {
|
||||||
|
symbol_value = 0;
|
||||||
|
dynamic_object_of_symbol = &relocation.dynamic_object();
|
||||||
|
}
|
||||||
VERIFY(dynamic_object_of_symbol);
|
VERIFY(dynamic_object_of_symbol);
|
||||||
*patch_ptr = negative_offset_from_tls_block_end(res.value().value, dynamic_object_of_symbol->tls_offset().value());
|
size_t addend = relocation.addend_used() ? relocation.addend() : *patch_ptr;
|
||||||
|
*patch_ptr = negative_offset_from_tls_block_end(symbol_value + addend, dynamic_object_of_symbol->tls_offset().value());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifndef __LP64__
|
#ifndef __LP64__
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue