mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibELF+LibC: Add support for Variant I of the TLS data structures
We currently only supported Variant II which is used by x86-64. Variant I is used by both AArch64 (when using the traditional non-TLSDESC model) and RISC-V, although with small differences. The TLS layout for Variant I is essentially flipped. The static TLS blocks are after the thread pointer for Variant I, while on Variant II they are before it. Some code using ELF TLS already worked on AArch64 and RISC-V even though we only support Variant II. This is because only the local-exec model directly uses TLS offsets, other models use relocations or __tls_get_addr().
This commit is contained in:
parent
3af793abfd
commit
9437b29b43
Notes:
sideshowbarker
2024-07-17 02:39:10 +09:00
Author: https://github.com/spholz
Commit: 9437b29b43
Pull-request: https://github.com/SerenityOS/serenity/pull/24005
Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 67 additions and 30 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <LibELF/Arch/tls.h>
|
||||
#include <sys/internals.h>
|
||||
|
||||
extern "C" {
|
||||
|
@ -21,6 +22,6 @@ extern "C" {
|
|||
// changed if we support dynamically allocated TLS blocks.
|
||||
void* __tls_get_addr(__tls_index* index)
|
||||
{
|
||||
return reinterpret_cast<void*>(reinterpret_cast<FlatPtr>(__builtin_thread_pointer()) + index->ti_module + index->ti_offset);
|
||||
return reinterpret_cast<void*>(reinterpret_cast<FlatPtr>(__builtin_thread_pointer()) + index->ti_module + index->ti_offset + ELF::TLS_DTV_OFFSET);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue