9 #define MIPS_PLT_OFFSET 0x20
10 #define RISCV_PLT_ENTRY_SIZE 0x10
11 #define RISCV_PLT_OFFSET 0x20
12 #define SPARC_OFFSET_PLT_ENTRY_FROM_GOT_ADDR -0x6
13 #define X86_OFFSET_PLT_ENTRY_FROM_GOT_ADDR -0x6
14 #define X86_PLT_ENTRY_SIZE 0x10
16 #define COMPUTE_PLTGOT_POSITION(rel, pltgot_addr, n_initial_unused_entries) \
17 ((rel->vaddr - pltgot_addr - n_initial_unused_entries * sizeof(Elf_(Addr))) / sizeof(Elf_(Addr)))
46 ut64 plt_addr = jmprel_addr + dt_pltrelsz;
49 if (res !=
sizeof(
buf)) {
99 if (!rz_buf_read_ble32_at(
bin->b, p_plt_addr, &
tmp,
bin->big_endian)) {
108 if (
bin->big_endian) {
114 base -= (nrel * 12) + 20;
139 ut64 plt_addr =
s->offset;
140 Elf_(Word) plt_sym_addr;
142 while (plt_addr + 2 + 4 <
s->offset +
s->size) {
167 if ((plt_addr + 6 +
tmp) == rel->
vaddr) {
171 if (plt_sym_addr == rel->
vaddr) {
189 if (pltsec_section) {
219 plt_addr +=
pos * 12 + 20;
225 RZ_LOG_WARN(
"Unsupported relocation type for imports %d\n", rel->
type);
228 if (rel->
addend > plt_addr) {
229 return (plt_addr +
pos * 16 + 32) + rel->
addend;
232 return plt_addr +
pos * 16 + 32;
234 return plt_addr +
pos * 16 + 32;
236 RZ_LOG_WARN(
"Unsupported relocation type for imports %d\n", rel->
type);
243 switch (
bin->ehdr.e_machine) {
275 if (reloc->
sym != symbol) {
321 if (import->ordinal == ordinal) {
RzList * symbols(RzBinFile *bf)
ut64 Elf_() rz_bin_elf_v2p(RZ_NONNULL ELFOBJ *bin, ut64 vaddr)
Convert a virtual address to the physical address.
bool Elf_() rz_bin_elf_has_dt_dynamic(RZ_NONNULL ELFOBJ *bin)
#define rz_bin_elf_foreach_relocs(bin, reloc)
#define rz_bin_elf_foreach_imports(bin, import)
bool Elf_() rz_bin_elf_read_addr(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Addr) *result)
bool Elf_() rz_bin_elf_has_relocs(RZ_NONNULL ELFOBJ *bin)
bool Elf_() rz_bin_elf_is_thumb_addr(ut64 addr)
bool Elf_() rz_bin_elf_read_word(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Word) *result)
RZ_OWN RzVector *Elf_() rz_bin_elf_compute_symbols(ELFOBJ *bin, RzBinElfSymbolFilter filter)
RZ_BORROW RzBinElfSection *Elf_() rz_bin_elf_get_section_with_name(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL const char *name)
bool Elf_() rz_bin_elf_get_dt_info(RZ_NONNULL ELFOBJ *bin, ut64 key, RZ_OUT ut64 *info)
ut64 Elf_() rz_bin_elf_get_num_relocs_dynamic_plt(RZ_NONNULL ELFOBJ *bin)
#define RZ_BIN_ELF_PART_RELRO
bool Elf_() rz_bin_elf_is_relocatable(RZ_NONNULL ELFOBJ *bin)
Check if the elf binary is relocatable.
int Elf_() rz_bin_elf_has_relro(RZ_NONNULL ELFOBJ *bin)
Analyse if the elf binary has relro or partial relro.
#define X86_OFFSET_PLT_ENTRY_FROM_GOT_ADDR
static bool filter_import(ELFOBJ *bin, Elf_(Sym) *symbol, bool is_dynamic)
RZ_BORROW RzBinElfSymbol *Elf_() rz_bin_elf_get_import(RZ_NONNULL ELFOBJ *bin, ut32 ordinal)
#define COMPUTE_PLTGOT_POSITION(rel, pltgot_addr, n_initial_unused_entries)
static void convert_elf_symbols_to_elf_imports(ELFOBJ *bin, RzVector *symbols)
static void convert_elf_symbol_to_elf_import(ELFOBJ *bin, RzBinElfSymbol *symbol)
static ut64 get_import_offset(ELFOBJ *bin, RzBinElfSymbol *symbol)
static ut64 get_import_addr_ppc(ELFOBJ *bin, RzBinElfReloc *rel)
#define RISCV_PLT_ENTRY_SIZE
#define X86_PLT_ENTRY_SIZE
bool Elf_() rz_bin_elf_has_imports(RZ_NONNULL ELFOBJ *bin)
static ut64 get_import_addr(ELFOBJ *bin, ut64 symbol)
static ut64 get_import_addr_sparc(ELFOBJ *bin, RzBinElfReloc *rel)
static ut64 get_import_addr_x86(ELFOBJ *bin, RzBinElfReloc *rel)
static ut64 get_import_addr_x86_manual(ELFOBJ *bin, RzBinElfReloc *rel)
RZ_OWN RzVector *Elf_() rz_bin_elf_analyse_imports(RZ_NONNULL ELFOBJ *bin)
static ut64 get_import_addr_riscv(ELFOBJ *bin, RzBinElfReloc *rel)
static ut64 get_import_addr_mips(ELFOBJ *bin, RzBinElfReloc *rel)
static ut64 get_got_entry(ELFOBJ *bin, RzBinElfReloc *rel)
static ut64 get_import_addr_arm(ELFOBJ *bin, RzBinElfReloc *rel)
static ut64 get_import_addr_aux(ELFOBJ *bin, RzBinElfReloc *reloc)
#define SPARC_OFFSET_PLT_ENTRY_FROM_GOT_ADDR
#define RZ_SPARC_JMP_SLOT
#define RZ_AARCH64_RELATIVE
#define RZ_AARCH64_JUMP_SLOT
#define RZ_AARCH64_IRELATIVE
#define rz_return_val_if_fail(expr, val)
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
#define RZ_LOG_WARN(fmtstr,...)
RZ_API const ut8 * rz_mem_mem_aligned(const ut8 *haystack, int hlen, const ut8 *needle, int nlen, int align)
#define rz_vector_foreach(vec, it)
st64 addend
exact addend value taken from the ELF, meaning depends on type
ut64 vaddr
source vaddr of the reloc, calculated from offset
ut64 paddr
absolute paddr in the file, calculated from offset, or UT64_MAX if no such addr exists
ut64(WINAPI *w32_GetEnabledXStateFeatures)()