LibELF: Add a small local-exec TLS test
Part 1 of this test uses a large array so we are more likely getting segfaults when using an incorrect TLS layout. The `volatile`s and `taint_for_optimiter`s should hopefully prevent the compiler from optimizing the tests out.
This commit is contained in:
parent
9437b29b43
commit
9881d10e38
Notes:
sideshowbarker
2024-07-17 16:23:06 +09:00
Author: https://github.com/spholz Commit: https://github.com/SerenityOS/serenity/commit/9881d10e38 Pull-request: https://github.com/SerenityOS/serenity/pull/24005 Reviewed-by: https://github.com/ADKaster ✅
1 changed files with 23 additions and 0 deletions
|
@ -14,3 +14,26 @@ TEST_CASE(basic)
|
|||
{
|
||||
run_test();
|
||||
}
|
||||
|
||||
TEST_CASE(local_exec)
|
||||
{
|
||||
[[gnu::tls_model("local-exec")]] static volatile __thread char test1[PAGE_SIZE * 4 + 10];
|
||||
|
||||
for (size_t i = 0; i < sizeof(test1); i++) {
|
||||
test1[i] = static_cast<char>(i);
|
||||
AK::taint_for_optimizer(test1[i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sizeof(test1); i++) {
|
||||
AK::taint_for_optimizer(test1[i]);
|
||||
EXPECT_EQ(test1[i], static_cast<char>(i));
|
||||
}
|
||||
|
||||
[[gnu::tls_model("local-exec")]] static volatile __thread u16 test2[] = { 0x1234, 0x5678, 0xabcd };
|
||||
AK::taint_for_optimizer(test2[0]);
|
||||
EXPECT_EQ(test2[0], 0x1234);
|
||||
AK::taint_for_optimizer(test2[1]);
|
||||
EXPECT_EQ(test2[1], 0x5678);
|
||||
AK::taint_for_optimizer(test2[2]);
|
||||
EXPECT_EQ(test2[2], 0xabcd);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue