4 void* (*resolve_symbol)(
const char* name,
void*
data),
void*
data)
21 for (
uint64_t j = 0; j < relaCount; j++)
27 if (symIndex >= symCount)
39 *patchAddr = base + value + rela[j].
r_addend;
48 *patchAddr = base + value + rela[j].
r_addend;
59 *patchAddr = base + rela[j].
r_addend;
63 LOG_ERR(
"unsupported relocation type %llu for symbol '%s'\n", type, symName);
#define LOG_ERR(format,...)
const char * elf64_get_string(const Elf64_File *elf, Elf64_Xword strTabIndex, Elf64_Off offset)
Get a string from the string table section at the given offset.
#define ELF64_AT_OFFSET(elf, offset)
Get a pointer to a location in the ELF file at the given offset.
#define ELF64_R_TYPE(i)
Extract the type from r_info.
uint64_t Elf64_Xword
ELF64 Unsigned long integer.
uint64_t Elf64_Off
ELF64 Unsigned file offset.
uint64_t elf64_relocate(const Elf64_File *elf, Elf64_Addr base, Elf64_Off offset, void *(*resolve_symbol)(const char *name, void *data), void *data)
Perform relocations on an ELF file loaded into memory.
#define ELF64_R_SYM(i)
Extract the symbol index from r_info.
#define ELF64_GET_SHDR(elf, index)
Get the section header at the given index from an ELF file.
uint64_t Elf64_Addr
ELF64 Unsigned program address.
@ SHN_UNDEF
Undefined section.
@ R_X86_64_RELATIVE
word64 B + A
@ R_X86_64_GLOB_DAT
word64 S
@ R_X86_64_64
word64 S + A
@ R_X86_64_JUMP_SLOT
word64 S
@ R_X86_64_PC32
word32 S + A - P
@ SHT_RELA
Contains relocation entries with explicit addends.
#define ERR
Integer error value.
__UINTPTR_TYPE__ uintptr_t
ELF File Helper structure.
Elf64_Ehdr * header
The data in the file, pointed to the start of the ELF header.
ELF64 Rela Entry with addend.
Elf64_Word sh_type
Section type.
Elf64_Xword sh_size
Section size in bytes.
Elf64_Off sh_offset
Section's file offset in bytes.
ELF64 Symbol Table Entry.