mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
LibELF: Move AK/ELF/ into Libraries/LibELF/
Let's arrange things like this instead. It didn't feel right for all of the ELF handling code to live in AK.
This commit is contained in:
parent
31beff8afb
commit
49635e62fa
9 changed files with 11 additions and 11 deletions
61
Libraries/LibELF/ELFLoader.h
Normal file
61
Libraries/LibELF/ELFLoader.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibELF/ELFImage.h>
|
||||
|
||||
#ifdef KERNEL
|
||||
#include <Kernel/VM/VirtualAddress.h>
|
||||
class Region;
|
||||
#endif
|
||||
|
||||
class ELFLoader {
|
||||
public:
|
||||
explicit ELFLoader(const u8*);
|
||||
~ELFLoader();
|
||||
|
||||
bool load();
|
||||
#if defined(KERNEL)
|
||||
Function<void*(VirtualAddress, size_t, size_t, bool, bool, const String&)> alloc_section_hook;
|
||||
Function<void*(size_t, size_t)> tls_section_hook;
|
||||
Function<void*(VirtualAddress, size_t, size_t, size_t, bool r, bool w, bool x, const String&)> map_section_hook;
|
||||
VirtualAddress entry() const { return m_image.entry(); }
|
||||
#endif
|
||||
char* symbol_ptr(const char* name);
|
||||
|
||||
bool has_symbols() const { return m_image.symbol_count(); }
|
||||
|
||||
String symbolicate(u32 address) const;
|
||||
|
||||
private:
|
||||
bool layout();
|
||||
bool perform_relocations();
|
||||
void* lookup(const ELFImage::Symbol&);
|
||||
char* area_for_section(const ELFImage::Section&);
|
||||
char* area_for_section_name(const char*);
|
||||
|
||||
struct PtrAndSize {
|
||||
PtrAndSize() {}
|
||||
PtrAndSize(char* p, unsigned s)
|
||||
: ptr(p)
|
||||
, size(s)
|
||||
{
|
||||
}
|
||||
|
||||
char* ptr { nullptr };
|
||||
unsigned size { 0 };
|
||||
};
|
||||
ELFImage m_image;
|
||||
|
||||
struct SortedSymbol {
|
||||
u32 address;
|
||||
const char* name;
|
||||
};
|
||||
#ifdef KERNEL
|
||||
mutable OwnPtr<Region> m_sorted_symbols_region;
|
||||
#else
|
||||
mutable Vector<SortedSymbol> m_sorted_symbols;
|
||||
#endif
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue