LibELF: Implement TLS relocation support for x86_64

This commit is contained in:
Gunnar Beutner 2021-07-03 00:50:03 +02:00 committed by Andreas Kling
parent c51b49a8cb
commit a0a38e1e84
Notes: sideshowbarker 2024-07-18 10:31:50 +09:00

View file

@ -478,6 +478,9 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
#ifndef __LP64__
case R_386_TLS_TPOFF32:
case R_386_TLS_TPOFF: {
#else
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)
@ -490,12 +493,6 @@ DynamicLoader::RelocationResult DynamicLoader::do_relocation(const ELF::DynamicO
*patch_ptr = negative_offset_from_tls_block_end(res.value().value, dynamic_object_of_symbol->tls_offset().value(), res.value().size);
break;
}
#else
case R_X86_64_TPOFF64:
dbgln("FIXME: Patched R_X86_64_TPOFF64 relocation with invalid ptr.");
*patch_ptr = 0xaaaaaaaaaaaaaaaa;
break;
#endif
#ifndef __LP64__
case R_386_JMP_SLOT: {
#else