mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibELF: Fix relocation support for 'static __thread' variables
This commit is contained in:
parent
5f6ee4c539
commit
251eaad8f0
Notes:
sideshowbarker
2024-07-18 10:31:43 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/251eaad8f01 Pull-request: https://github.com/SerenityOS/serenity/pull/8414
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: {
|
||||
#endif
|
||||
auto symbol = relocation.symbol();
|
||||
// For some reason, LibC has a R_386_TLS_TPOFF that refers to the undefined symbol.. huh
|
||||
if (relocation.symbol_index() == 0)
|
||||
break;
|
||||
auto res = lookup_symbol(symbol);
|
||||
if (!res.has_value())
|
||||
break;
|
||||
auto* dynamic_object_of_symbol = res.value().dynamic_object;
|
||||
FlatPtr symbol_value;
|
||||
DynamicObject const* dynamic_object_of_symbol;
|
||||
if (relocation.symbol_index() != 0) {
|
||||
auto res = lookup_symbol(symbol);
|
||||
if (!res.has_value())
|
||||
break;
|
||||
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);
|
||||
*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;
|
||||
}
|
||||
#ifndef __LP64__
|
||||
|
|
Loading…
Add table
Reference in a new issue