kernel/inc/drivers/builtin/elf/relocation.h

38 lines
1.0 KiB
C
Raw Permalink Normal View History

// This file is part of noxos and licensed under the MIT open source license
#ifndef NOXOS_RELOCATION_H
#define NOXOS_RELOCATION_H
#include <utils/stdtypes.h>
#include <drivers/builtin/elf/elf.h>
#define ELF_RELOCATION_SYMBOL(i) ((i) >> 32)
#define ELF_RELOCATION_TYPE(i) ((i) & 0xFFFFFFFFL)
#define ELF_RELOCATION_INFO(s,t) (((s) << 32) + ((t) & 0xFFFFFFFFL))
#define ELF_RELOCATION_X86_64_PC32(s,a,p) (s + a - p)
#define ELF_RELOCATION_X86_64_PLT32(l,a,p) (l + a - p)
typedef enum {
ELF_REL_NONE,
ELF_REL_64,
ELF_REL_PC32,
ELF_REL_GOT32,
ELF_REL_PLT32,
ELF_REL_COPY,
ELF_REL_GLOB_DAT,
ELF_REL_JUMP_SLOT,
ELF_REL_RELATIVE
} elf_relocation_type_E;
typedef struct {
uint64_t offset;
uint64_t info;
int64_t addend;
} elf_relocation_a_T;
//void elf_relocate (elf_executable_T* executable, uint8_t* buffer, void* address);
bool elf_relocate_driver(elf_executable_T* executable, uint8_t* buffer, void* load_address);
#endif //NOXOS_RELOCATION_H