1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

LibELF: Change TLS offset calculation

This changes the TLS offset calculation logic to be based on the
symbol's size instead of the total size of the TLS.

Because of this change, we no longer need to pipe "m_tls_size" to so
many functions.

Also, After this patch, the TLS data of the main program exists at the
"end" of the TLS block (Highest addresses).

This fixes a part of #6609.
This commit is contained in:
Itamar 2021-04-30 13:31:42 +03:00 committed by Andreas Kling
parent 6bbd2ebf83
commit 101ac45c1a
5 changed files with 36 additions and 33 deletions

View file

@ -170,7 +170,7 @@ static void allocate_tls()
// Initialize TLS data
for (const auto& entry : s_loaders) {
entry.value->copy_initial_tls_data_into(initial_tls_data, s_total_tls_size);
entry.value->copy_initial_tls_data_into(initial_tls_data);
}
void* master_tls = ::allocate_tls((char*)initial_tls_data.data(), initial_tls_data.size());
@ -282,14 +282,14 @@ static Result<NonnullRefPtr<DynamicLoader>, DlErrorMessage> load_main_library(co
}
for (auto& loader : loaders) {
bool success = loader.link(flags, s_total_tls_size);
bool success = loader.link(flags);
if (!success) {
return DlErrorMessage { String::formatted("Failed to link library {}", loader.filename()) };
}
}
for (auto& loader : loaders) {
auto result = loader.load_stage_3(flags, s_total_tls_size);
auto result = loader.load_stage_3(flags);
VERIFY(!result.is_error());
auto& object = result.value();