4 void* (*resolve_symbol)(
const char* name,
void*
private),
void*
private)
19 for (
uint64_t j = 0; j < relaCount; j++)
33 *patchAddr = base + value + rela[j].
r_addend;
40 *patchAddr = (
uint64_t)resolve_symbol(symName,
private);
47 *patchAddr = base + rela[j].
r_addend;
51 LOG_ERR(
"unsupported relocation type %llu for symbol '%s'\n", type, symName);
#define LOG_ERR(format,...)
Elf64_Sym * elf64_get_dynamic_symbol_by_index(const Elf64_File *elf, Elf64_Xword symbolIndex)
Get a dynamic symbol by its index from the dynamic symbol table.
#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_relocate(const Elf64_File *elf, Elf64_Addr base, Elf64_Off offset, void *(*resolve_symbol)(const char *name, void *private), void *private)
Perform relocations on an ELF file loaded into memory.
uint64_t Elf64_Off
ELF64 Unsigned file offset.
const char * elf64_get_dynamic_symbol_name(const Elf64_File *elf, const Elf64_Sym *symbol)
Get the name of a dynamic symbol.
#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.
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_Word sh_info
Depends on section type.
Elf64_Xword sh_size
Section size in bytes.
Elf64_Addr sh_addr
If the section will appear in memory, this will be its virtual address, otherwise 0
Elf64_Off sh_offset
Section's file offset in bytes.
ELF64 Symbol Table Entry.