mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +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:
parent
6bbd2ebf83
commit
101ac45c1a
5 changed files with 36 additions and 33 deletions
|
@ -54,13 +54,13 @@ public:
|
|||
// Note that the DynamicObject will not be linked yet. Callers are responsible for calling link() to finish it.
|
||||
RefPtr<DynamicObject> map();
|
||||
|
||||
bool link(unsigned flags, size_t total_tls_size);
|
||||
bool link(unsigned flags);
|
||||
|
||||
// Stage 2 of loading: dynamic object loading and primary relocations
|
||||
bool load_stage_2(unsigned flags, size_t total_tls_size);
|
||||
bool load_stage_2(unsigned flags);
|
||||
|
||||
// Stage 3 of loading: lazy relocations
|
||||
Result<NonnullRefPtr<DynamicObject>, DlErrorMessage> load_stage_3(unsigned flags, size_t total_tls_size);
|
||||
Result<NonnullRefPtr<DynamicObject>, DlErrorMessage> load_stage_3(unsigned flags);
|
||||
|
||||
// Stage 4 of loading: initializers
|
||||
void load_stage_4();
|
||||
|
@ -78,7 +78,7 @@ public:
|
|||
bool is_dynamic() const { return m_elf_image.is_dynamic(); }
|
||||
|
||||
static Optional<DynamicObject::SymbolLookupResult> lookup_symbol(const ELF::DynamicObject::Symbol&);
|
||||
void copy_initial_tls_data_into(ByteBuffer& buffer, size_t total_tls_size) const;
|
||||
void copy_initial_tls_data_into(ByteBuffer& buffer) const;
|
||||
|
||||
private:
|
||||
DynamicLoader(int fd, String filename, void* file_data, size_t file_size);
|
||||
|
@ -113,10 +113,10 @@ private:
|
|||
void load_program_headers();
|
||||
|
||||
// Stage 2
|
||||
void do_main_relocations(size_t total_tls_size);
|
||||
void do_main_relocations();
|
||||
|
||||
// Stage 3
|
||||
void do_lazy_relocations(size_t total_tls_size);
|
||||
void do_lazy_relocations();
|
||||
void setup_plt_trampoline();
|
||||
|
||||
// Stage 4
|
||||
|
@ -129,9 +129,9 @@ private:
|
|||
Success = 1,
|
||||
ResolveLater = 2,
|
||||
};
|
||||
RelocationResult do_relocation(size_t total_tls_size, const DynamicObject::Relocation&, ShouldInitializeWeak should_initialize_weak);
|
||||
RelocationResult do_relocation(const DynamicObject::Relocation&, ShouldInitializeWeak should_initialize_weak);
|
||||
size_t calculate_tls_size() const;
|
||||
ssize_t negative_offset_from_tls_block_end(size_t value_of_symbol, size_t tls_offset, size_t total_tls_size) const;
|
||||
ssize_t negative_offset_from_tls_block_end(size_t value_of_symbol, size_t tls_offset, size_t symbol_size) const;
|
||||
|
||||
String m_filename;
|
||||
String m_program_interpreter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue