mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:47:43 +00:00
LibELF: Re-organize ELFDynamicObject::load and add PLT trampoline
ELFDynamicObject::load looks a lot better with all the steps re-organized into helpers. Add plt_trampoline.S to handle PLT fixups for lazy loading. Add the needed trampoline-trampolines in ELFDynamicObject to get to the proper relocations and to return the symbol back to the assembly method to call into from the PLT once we return back to user code.
This commit is contained in:
parent
5fa0291a05
commit
331f37d1a8
4 changed files with 228 additions and 164 deletions
|
@ -28,6 +28,9 @@ public:
|
|||
|
||||
void dump();
|
||||
|
||||
// Will be called from _fixup_plt_entry, as part of the PLT trampoline
|
||||
Elf32_Addr patch_plt_entry(u32 relocation_offset);
|
||||
|
||||
private:
|
||||
class ProgramHeaderRegion {
|
||||
public:
|
||||
|
@ -68,6 +71,12 @@ private:
|
|||
|
||||
explicit ELFDynamicObject(const char* filename, int fd, size_t file_size);
|
||||
|
||||
void parse_dynamic_section();
|
||||
void load_program_headers();
|
||||
void do_relocations();
|
||||
void setup_plt_trampoline();
|
||||
void call_object_init_functions();
|
||||
|
||||
String m_filename;
|
||||
size_t m_file_size { 0 };
|
||||
int m_image_fd { -1 };
|
||||
|
@ -76,11 +85,6 @@ private:
|
|||
|
||||
OwnPtr<ELFImage> m_image;
|
||||
|
||||
void parse_dynamic_section();
|
||||
void do_relocations();
|
||||
|
||||
static void patch_plt_entry(u32 got_offset, void* dso_got_tag);
|
||||
|
||||
Vector<ProgramHeaderRegion> m_program_header_regions;
|
||||
ProgramHeaderRegion* m_text_region { nullptr };
|
||||
ProgramHeaderRegion* m_data_region { nullptr };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue