mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:07:35 +00:00
LibELF: Add support for IFUNCs
IFUNC is a GNU extension to the ELF standard that allows a function to have multiple implementations. A resolver function has to be called at load time to choose the right one to use. The PLT will contain the entry to the resolved function, so branching and more indirect jumps can be avoided at run-time. This mechanism is usually used when a routine can be made faster using CPU features that are available in only some models, and a fallback implementation has to exist for others. We will use this feature to have two separate memset implementations for CPUs with and without ERMS (Enhanced REP MOVSB/STOSB) support.
This commit is contained in:
parent
4d5965bd2c
commit
08c459e495
6 changed files with 56 additions and 10 deletions
|
@ -255,6 +255,7 @@ public:
|
|||
Symbol symbol(unsigned) const;
|
||||
|
||||
typedef void (*InitializationFunction)();
|
||||
typedef ElfW(Addr) (*IfuncResolver)();
|
||||
|
||||
bool has_init_section() const { return m_init_offset != 0; }
|
||||
bool has_init_array_section() const { return m_init_array_offset != 0; }
|
||||
|
@ -322,6 +323,7 @@ public:
|
|||
size_t size { 0 };
|
||||
VirtualAddress address;
|
||||
unsigned bind { STB_LOCAL };
|
||||
unsigned type { STT_FUNC };
|
||||
const ELF::DynamicObject* dynamic_object { nullptr }; // The object in which the symbol is defined
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue