mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:47:37 +00:00
Tests/LibELF: Test loading libraries with dynamic TLS
The setup is a bit peculiar: both the definition and the use site of these TLS variables have to be in a shared library, otherwise the linker might relax the global-dynamic access mode to something that doesn't require a `__tls_get_addr` call.
This commit is contained in:
parent
ad9e674fa0
commit
c63fe0e1f1
4 changed files with 106 additions and 6 deletions
21
Tests/LibELF/TLSDef.cpp
Normal file
21
Tests/LibELF/TLSDef.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Daniel Bertalan <dani@danielbertalan.dev>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibTest/Macros.h>
|
||||
|
||||
__thread int one = 1;
|
||||
__thread int two = 2;
|
||||
[[gnu::tls_model("initial-exec")]] __thread int three = 3;
|
||||
[[gnu::tls_model("initial-exec")]] __thread int four = 4;
|
||||
|
||||
void check_increment_worked();
|
||||
void check_increment_worked()
|
||||
{
|
||||
EXPECT_EQ(one, 2);
|
||||
EXPECT_EQ(two, 3);
|
||||
EXPECT_EQ(three, 4);
|
||||
EXPECT_EQ(four, 5);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue