14 #include "../i/private.h"
18 #define rz_bin_file_get_elf(bf) ((ELFOBJ *)bf->o->bin_obj)
20 #define VFILE_NAME_RELOC_TARGETS "reloc-targets"
21 #define VFILE_NAME_PATCHED "patched"
24 #define rz_buf_append_word rz_buf_append_ut64
26 #define rz_buf_append_word rz_buf_append_ut32
38 static const HexagonRelocMask hex_rel6_x_masks[] = {
39 { 0x38000000, 0x0000201f }, { 0x39000000, 0x0000201f },
40 { 0x3e000000, 0x00001f80 }, { 0x3f000000, 0x00001f80 },
41 { 0x40000000, 0x000020f8 }, { 0x41000000, 0x000007e0 },
42 { 0x42000000, 0x000020f8 }, { 0x43000000, 0x000007e0 },
43 { 0x44000000, 0x000020f8 }, { 0x45000000, 0x000007e0 },
44 { 0x46000000, 0x000020f8 }, { 0x47000000, 0x000007e0 },
45 { 0x6a000000, 0x00001f80 }, { 0x7c000000, 0x001f2000 },
46 { 0x9a000000, 0x00000f60 }, { 0x9b000000, 0x00000f60 },
47 { 0x9c000000, 0x00000f60 }, { 0x9d000000, 0x00000f60 },
48 { 0x9f000000, 0x001f0100 }, { 0xab000000, 0x0000003f },
49 { 0xad000000, 0x0000003f }, { 0xaf000000, 0x00030078 },
50 { 0xd7000000, 0x006020e0 }, { 0xd8000000, 0x006020e0 },
51 { 0xdb000000, 0x006020e0 }, { 0xdf000000, 0x006020e0 }
61 static ut32 hexagon_get_bitmask_r6(
ut32 insn) {
62 if ((insn & 0xc000) == 0) {
66 for (
int i = 0;
i <
sizeof(hex_rel6_x_masks) /
sizeof(HexagonRelocMask); ++
i) {
67 if ((0xff000000 & insn) == hex_rel6_x_masks[
i].cmpMask) {
68 return hex_rel6_x_masks[
i].relocMask;
71 RZ_LOG_ERROR(
"Unrecognized instruction for 6_X relocation: 0x%x", insn);
82 static ut32 hexagon_get_bitmask_r8(
ut32 insn) {
83 if ((0xff000000 & insn) == 0xde000000) {
86 if ((0xff000000 & insn) == 0x3c000000) {
99 static ut32 hexagon_get_bitmask_r11(
ut32 insn) {
100 if ((0xff000000 & insn) == 0xa1000000) {
113 static ut32 hexagon_get_bitmask_r16(
ut32 insn) {
114 if ((0xff000000 & insn) == 0x48000000) {
117 if ((0xff000000 & insn) == 0x49000000) {
120 if ((0xff000000 & insn) == 0x78000000) {
123 if ((0xff000000 & insn) == 0xb0000000) {
126 if ((insn & 0xc000) == 0) {
130 for (
int i = 0;
i <
sizeof(hex_rel6_x_masks) /
sizeof(HexagonRelocMask); ++
i) {
131 if ((0xff000000 & insn) == hex_rel6_x_masks[
i].cmpMask) {
132 return hex_rel6_x_masks[
i].relocMask;
136 RZ_LOG_ERROR(
"Unrecognized instruction for 16_X relocation: 0x%x", insn);
140 typedef struct rz_bin_reloc_formular_symbols_t {
152 } RzBinRelocFormularSymbols;
158 struct special_symbol_translation {
163 static struct special_symbol_translation special_symbol_translation_table[] = {
222 for (
size_t i = 0;
i <
RZ_ARRAY_SIZE(special_symbol_translation_table);
i++) {
223 if (sym == special_symbol_translation_table[
i].symbol) {
224 return special_symbol_translation_table[
i].get_addr(
bin);
237 result->
paddr = paddr;
238 result->
vaddr = vaddr;
254 return rz_bin_addr_new_aux(
bin, paddr, vaddr);
260 return rz_bin_addr_new_aux(
bin, paddr, vaddr);
268 ut64 paddr = binsym_aux(
bin, sym);
273 return rz_bin_addr_new_from_paddr(
bin, paddr);
278 if (constructor_offset ==
UT64_MAX) {
302 tmp->hpaddr = constructor_offset +
pos;
372 add_entry_offset(
bin, result);
373 add_java_libraries(
bin, result);
374 add_constructors(
bin, result);
388 static bool create_set_e_ident(
RzBuffer *result) {
411 return create_set_e_ident(result) &&
413 create_set_e_machine(result,
is_arm) &&
415 rz_buf_append_word(result,
sizeof(
Elf_(Ehdr)) +
sizeof(
Elf_(Phdr))) &&
416 rz_buf_append_word(result,
sizeof(
Elf_(Ehdr))) &&
417 rz_buf_append_word(result, 0) &&
450 static Elf_(Word) create_get_baddr(
bool is_arm) {
470 if (!create_set_ehdr(result,
is_arm) ||
471 !create_set_phdr(result,
baddr, codelen) ||
477 if (data && datalen > 0) {
479 RZ_LOG_WARN(
"DATA section not support for ELF yet\n");
520 return convert_symbol(
bin, symbol);
543 return convert_import(symbol);
546 static int get_file_type(
RzBinFile *bf) {
547 struct Elf_(rz_bin_elf_obj_t) *obj = bf->
o->
bin_obj;
571 RZ_LOG_ERROR(
"Cannot retrieve regstate on: %s (not yet supported)\n", machine_name);
576 static char *setphname(
ut16 mach,
Elf_(Word) ptyp) {
584 return strdup(
"ABIFLAGS");
593 static bool is_wordable_section(
const char *
name) {
594 if (!strcmp(
name,
".init_array")) {
597 if (!strcmp(
name,
".fini_array")) {
600 if (!strcmp(
name,
".data.rel.ro")) {
603 if (!strcmp(
name,
".dynamic")) {
606 if (!strcmp(
name,
".got")) {
609 if (strstr(
name,
".rela.")) {
630 if (note->start_vaddr == phdr->p_vaddr) {
654 struct Elf_(rz_bin_elf_obj_t) *obj = (bf && bf->
o) ? bf->
o->
bin_obj :
NULL;
678 map->paddr =
iter->data.p_offset;
679 map->psize =
iter->data.p_filesz;
680 map->vsize =
iter->data.p_memsz;
681 map->vaddr =
iter->data.p_vaddr;
685 if (core_sp !=
UT64_MAX && core_sp >=
iter->data.p_vaddr && core_sp < iter->data.p_vaddr +
iter->data.p_memsz) {
689 if (nf && nf->file) {
720 if (rz_list_empty(ret)) {
728 map->vaddr = 0x10000;
734 if (obj->ehdr.e_type ==
ET_REL) {
739 ut64 ehdr_size =
sizeof(obj->ehdr);
740 if (bf->
size < ehdr_size) {
741 ehdr_size = bf->
size;
745 map->psize = ehdr_size;
746 map->vaddr = obj->baddr;
747 map->vsize = ehdr_size;
758 return obj->bits / 8;
789 result |= (valBit <<
bit);
825 static void patch_reloc_hexagon(
RZ_INOUT RzBuffer *buf_patched,
const ut64 patch_addr,
const int rel_type,
const RzBinRelocFormularSymbols *fs) {
833 RZ_LOG_WARN(
"Patching for reloc type %d not implemented.", rel_type);
842 val = (fs->S + fs->A);
845 val = (fs->B + fs->A);
849 val = (fs->S + fs->A - fs->P) >> 2;
853 val = (fs->S + fs->A - fs->P) >> 2;
857 val = (fs->S + fs->A - fs->P) >> 2;
861 val = (fs->S + fs->A);
865 val = (fs->S + fs->A) >> 16;
868 val = (fs->S + fs->A);
872 val = (fs->S + fs->A);
876 val = (fs->S + fs->A);
880 val = (fs->S + fs->A);
884 val = (fs->S + fs->A - fs->P) >> 2;
888 val = (fs->S + fs->A - fs->P) >> 2;
892 val = (fs->S + fs->A - fs->P) >> 6;
896 val = (fs->S + fs->A) >> 6;
900 val = (fs->S + fs->A - fs->P) & 0x3f;
904 val = (fs->S + fs->A - fs->P) & 0x3f;
908 val = (fs->S + fs->A - fs->P) & 0x3f;
912 val = (fs->S + fs->A - fs->P) & 0x3f;
916 val = (fs->S + fs->A - fs->P) & 0x3f;
920 val = (fs->S + fs->A);
923 val = (fs->S + fs->A - fs->P);
927 val = (fs->S + fs->A - fs->GOT);
931 val = (fs->S + fs->A - fs->GOT) >> 16;
934 val = (fs->S + fs->A - fs->GOT);
938 val = (fs->S + fs->A - fs->GOT) >> 6;
944 val = (fs->L + fs->A - fs->P) >> 2;
949 val = (fs->S + fs->A - fs->P) & 0x3f;
954 val = (fs->S + fs->A - fs->P) >> 6;
959 val = (fs->S + fs->A) & 0x3f;
964 val = (fs->S + fs->A) & 0x3f;
967 bitmask = 0x00203fe0;
968 val = (fs->S + fs->A) & 0x3f;
971 bitmask = 0x00003fe0;
972 val = (fs->S + fs->A) & 0x3f;
977 val = (fs->S + fs->A);
982 val = (fs->S + fs->A - fs->P);
987 val = (fs->S + fs->A);
992 val = (fs->S + fs->A - fs->GOT);
997 val = (fs->S + fs->A - fs->GOT);
1001 val = (fs->S + fs->A - fs->T) >> 6;
1006 val = (fs->S + fs->A - fs->T);
1011 val = (fs->S + fs->A - fs->T);
1016 patch_val_hexagon(buf_patched, patch_addr, bitmask,
val & 0xffffffff);
1017 patch_val_hexagon(buf_patched, patch_addr + 4, bitmask,
val >> 32);
1019 patch_val_hexagon(buf_patched, patch_addr, bitmask,
val);
1024 ut16 e_machine = obj->ehdr.e_machine;
1027 RzBinRelocFormularSymbols formular_sym = { .A =
A, .B =
B, .GOT = GOT, .L =
L, .S =
S, .P =
P, .MB = 0, .G = 0, .GP = 0, .T = 0, .TLS = 0 };
1030 bool big_endian = obj->big_endian;
1031 switch (e_machine) {
1033 patch_reloc_hexagon(obj->buf_patched, patch_addr, rel->
type, &formular_sym);
1041 rz_buf_write_ble32_at(obj->buf_patched, patch_addr,
val, obj->big_endian);
1049 int low = 0, word = 0;
1050 switch (rel->
type) {
1057 val = (
S +
A) >> 16;
1061 val = (
S +
A + 0x8000) >> 16;
1065 val = (
S +
A -
P + 0x8000) >> 16;
1069 val = (
S +
A) & 0xffff;
1073 val = (
S +
A -
P) & 0xffff;
1094 val &= (1 << 14) - 1;
1100 val &= (1 << 24) - 1;
1121 switch (rel->
type) {
1137 switch (rel->
type) {
1242 r->is_ifunc =
false;
1245 r->import = get_import(
bin, rel->
sym);
1247 r->symbol = get_symbol(
bin, rel->
sym);
1255 r->type = RZ_BIN_RELOC_##T; \
1259 r->type = RZ_BIN_RELOC_##T; \
1261 r->additive = rel->mode == DT_RELA; \
1264 switch (
bin->ehdr.e_machine) {
1266 switch (rel->
type) {
1285 switch (rel->
type) {
1307 switch (rel->
type) {
1342 default:
ADD(32, GOT);
break;
1346 switch (rel->
type) {
1350 default:
ADD(64, GOT);
break;
1354 switch (rel->
type) {
1365 switch (rel->
type) {
1397 bin->relocs_patched =
true;
1412 if (!
bin->buf_patched) {
1417 ut64 got_addr = get_got_addr(
bin);
1429 sym_addr = symbol->
vaddr;
1438 patch_reloc(
bin, reloc, sym_addr,
baddr, sym_addr, got_addr);
1452 struct Elf_(rz_bin_elf_obj_t) *obj = o ? o->
bin_obj :
NULL;
1475 if (obj->buf_patched) {
1480 vf->
buf = obj->buf_patched;
1488 struct Elf_(rz_bin_elf_obj_t) *obj = (bf && bf->
o) ? bf->
o->
bin_obj :
NULL;
1492 RzList *ret = maps_unpatched(bf);
1527 if (strstr(ptr->name,
"data") && !strstr(ptr->name,
"rel") && !strstr(ptr->name,
"pydata")) {
1528 ptr->is_data =
true;
1529 }
else if (!strcmp(ptr->name,
"C")) {
1530 ptr->is_data =
true;
1532 if (is_wordable_section(ptr->name)) {
1546 ut16 mach = obj->ehdr.e_machine;
1555 ptr->size =
iter->data.p_filesz;
1556 ptr->vsize =
iter->data.p_memsz;
1557 ptr->paddr =
iter->data.p_offset;
1558 ptr->vaddr =
iter->data.p_vaddr;
1559 ptr->perm =
iter->data.p_flags;
1560 ptr->align =
iter->data.p_align;
1561 ptr->is_segment =
true;
1563 switch (
iter->data.p_type) {
1565 ptr->name =
strdup(
"DYNAMIC");
1573 ptr->name =
strdup(
"INTERP");
1576 ptr->name =
strdup(
"GNU_STACK");
1579 ptr->name =
strdup(
"GNU_RELRO");
1582 ptr->name =
strdup(
"GNU_EH_FRAME");
1585 ptr->name =
strdup(
"PHDR");
1588 ptr->name =
strdup(
"TLS");
1591 ptr->name =
strdup(
"NOTE");
1594 ptr->name =
strdup(
"OPENBSD_RANDOMIZE");
1597 ptr->name =
strdup(
"OPENBSD_WXNEEDED");
1600 ptr->name =
strdup(
"OPENBSD_BOOTDATA");
1603 if (ptr->size == 0 && ptr->vsize == 0) {
1604 ptr->name =
strdup(
"NONE");
1606 ptr->name = setphname(mach,
iter->data.p_type);
1616 ut64 ehdr_size =
sizeof(obj->ehdr);
1617 if (bf->
size < ehdr_size) {
1618 ehdr_size = bf->
size;
1620 ptr->name =
strdup(
"ehdr");
1622 ptr->vaddr = obj->baddr;
1623 ptr->size = ehdr_size;
1624 ptr->vsize = ehdr_size;
1626 ptr->is_segment =
true;
1661 tmp->is_imported =
true;
1722 ut64 got_addr = get_got_addr(
bin);
1725 got_addr =
bin->reloc_targets_map_base;
1730 if (!(ptr = reloc_convert(
bin, reloc, got_addr))) {
1744 bool is_rust =
false;
1746 rz_list_foreach (symbols_list,
iter, symbol) {
1750 if (!strcmp(symbol->
name,
"_NSConcreteGlobalBlock")) {
1751 ret->
lang = (ret->
lang && !strcmp(ret->
lang,
"c++")) ?
"c++ blocks ext." :
"c blocks ext.";
1754 if (strstr(symbol->
name,
"__stack_chk_fail") || strstr(symbol->
name,
"__stack_smash_handler")) {
1758 if (!is_rust && !strcmp(symbol->
name,
"__rust_oom")) {
1776 #define RZ_BIN_RANDOMDATA_RETGUARD_SZ 48
1777 if (!strcmp(
section->name,
".openbsd.randomdata")) {
1786 static bool has_sanitizers(
RzBinFile *bf) {
1791 rz_list_foreach (imports_list,
iter,
import) {
1792 if (strstr(import->name,
"__sanitizer") ||
1793 strstr(import->name,
"__ubsan")) {
1824 ret->
has_pi = (strstr(
str,
"DYN")) ? 1 : 0;
1865 ret->
bits = obj->bits;
1866 if (!strcmp(ret->
arch,
"avr")) {
1883 lookup_sections(bf, ret);
1884 lookup_symbols(bf, ret);
1940 if (!add_fields(
bin, result)) {
const aarch64_field fields[]
static ut64 get_addr(RzAnalysis *analysis, const char *regname, int idx)
RZ_API RZ_OWN RzList * rz_bin_file_strings(RZ_NONNULL RzBinFile *bf, size_t min_length, bool raw_strings)
Generates a RzList struct containing RzBinString from a given RzBinFile.
RZ_API void rz_bin_symbol_free(RzBinSymbol *sym)
RZ_API void rz_bin_map_free(RzBinMap *map)
RZ_API void rz_bin_field_free(RzBinField *field)
RZ_API void rz_bin_import_free(RzBinImport *imp)
RZ_API void rz_bin_section_free(RzBinSection *bs)
RZ_API RzBinField * rz_bin_field_new(ut64 paddr, ut64 vaddr, int size, const char *name, const char *comment, const char *format, bool format_named)
RZ_API void rz_bin_virtual_file_free(RzBinVirtualFile *vfile)
static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb)
static void destroy(RzBinFile *bf)
static ut64 baddr(RzBinFile *bf)
static Sdb * get_sdb(RzBinFile *bf)
static RzList * maps(RzBinFile *bf)
#define VFILE_NAME_PATCHED
static RzList * virtual_files(RzBinFile *bf)
static RzBinAddr * binsym(RzBinFile *bf, RzBinSpecialSymbol sym)
static RzList * libs(RzBinFile *bf)
#define VFILE_NAME_RELOC_TARGETS
static char * regstate(RzBinFile *bf)
RzList * entries(RzBinFile *bf)
RzBinInfo * info(RzBinFile *bf)
RzList * symbols(RzBinFile *bf)
RzList * imports(RzBinFile *bf)
RzList * sections(RzBinFile *bf)
RzList * relocs(RzBinFile *bf)
static ut64 boffset(RzBinFile *bf)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
ut64 Elf_() rz_bin_elf_p2v(RZ_NONNULL ELFOBJ *bin, ut64 paddr)
Convert a physical address to the virtual address.
void Elf_() rz_bin_elf_free(RZ_NONNULL ELFOBJ *bin)
Free the elf binary.
RZ_OWN ELFOBJ *Elf_() rz_bin_elf_new_buf(RZ_NONNULL RzBuffer *buf, RZ_NONNULL RzBinObjectLoadOptions *options)
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_is_big_endian(RZ_NONNULL ELFOBJ *bin)
Check the binary endianness.
#define rz_bin_elf_foreach_segments(bin, segment)
RZ_OWN char *Elf_() rz_bin_elf_get_e_type_as_string(RZ_NONNULL ELFOBJ *bin)
size_t Elf_() rz_bin_elf_get_relocs_count(RZ_NONNULL ELFOBJ *bin)
#define rz_bin_elf_fix_arm_thumb_object_dispatch(object)
RZ_OWN char *Elf_() rz_bin_elf_get_e_ehsize_as_string(RZ_NONNULL ELFOBJ *bin)
#define rz_bin_elf_enumerate_sections(bin, section, i)
RZ_BORROW RzBinElfSymbol *Elf_() rz_bin_elf_get_symbol(RZ_NONNULL ELFOBJ *bin, ut32 ordinal)
bool Elf_() rz_bin_elf_is_static(RZ_NONNULL ELFOBJ *bin)
Check if the binary is statically-linked library.
bool Elf_() rz_bin_elf_is_stripped(RZ_NONNULL ELFOBJ *bin)
Check if the binary is stripped.
void Elf_() rz_bin_elf_fix_arm_thumb_symbol(RZ_NONNULL RzBinSymbol *symbol)
#define rz_bin_elf_foreach_sections(bin, section)
RZ_OWN char *Elf_() rz_bin_elf_get_file_type(RZ_NONNULL ELFOBJ *bin)
Return a string representing the file type.
#define RZ_BIN_ELF_SCN_IS_EXECUTABLE(x)
RZ_BORROW RzBinElfSymbol *Elf_() rz_bin_elf_get_import(RZ_NONNULL ELFOBJ *bin, ut32 ordinal)
#define rz_bin_elf_foreach_symbols(bin, symbol)
bool Elf_() rz_bin_elf_is_executable(RZ_NONNULL ELFOBJ *bin)
Check if the elf binary is executable.
RZ_OWN char *Elf_() rz_bin_elf_get_e_phnum_as_string(RZ_NONNULL ELFOBJ *bin)
RZ_OWN char *Elf_() rz_bin_elf_get_e_shstrndx_as_string(RZ_NONNULL ELFOBJ *bin)
#define rz_bin_elf_foreach_relocs(bin, reloc)
ut64 Elf_() rz_bin_elf_get_main_offset(RZ_NONNULL ELFOBJ *bin)
Compute the main offset of the binary.
#define rz_bin_elf_foreach_imports(bin, import)
bool Elf_() rz_bin_elf_has_va(ELFOBJ *bin)
Check if the elf use virtual address.
bool Elf_() rz_bin_elf_read_addr(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Addr) *result)
RZ_OWN char *Elf_() rz_bin_elf_get_elf_class(RZ_NONNULL ELFOBJ *bin)
Return a string representing the elf class.
bool Elf_() rz_bin_elf_has_relocs(RZ_NONNULL ELFOBJ *bin)
#define rz_bin_elf_foreach_notes_segment(bin, notes)
bool Elf_() rz_bin_elf_has_nx(RZ_NONNULL ELFOBJ *bin)
Check if the stack is not executable.
bool Elf_() rz_bin_elf_is_arm_binary_supporting_thumb(RZ_NONNULL ELFOBJ *bin)
RZ_OWN char *Elf_() rz_bin_elf_get_intrp(RZ_NONNULL ELFOBJ *bin)
Get the program interpreter.
RZ_OWN char *Elf_() rz_bin_elf_get_e_entry_as_string(RZ_NONNULL ELFOBJ *bin)
RZ_OWN char *Elf_() rz_bin_elf_get_abi(RZ_NONNULL ELFOBJ *bin)
Return a string representing the application binary interface.
void Elf_() rz_bin_elf_fix_arm_thumb_addr(ut64 *addr)
RZ_OWN char *Elf_() rz_bin_elf_get_e_shoff_as_string(RZ_NONNULL ELFOBJ *bin)
bool Elf_() rz_bin_elf_is_thumb_addr(ut64 addr)
ut64 Elf_() rz_bin_elf_get_baddr(RZ_NONNULL ELFOBJ *bin)
Compute the base address of the binary.
RZ_OWN char *Elf_() rz_bin_elf_get_machine_name(RZ_NONNULL ELFOBJ *bin)
Return a string representing the machine name.
RZ_OWN char *Elf_() rz_bin_elf_get_e_shentsize_as_string(RZ_NONNULL ELFOBJ *bin)
#define RZ_BIN_ELF_SCN_IS_READABLE(x)
RZ_OWN RzList *Elf_() rz_bin_elf_get_libs(RZ_NONNULL ELFOBJ *bin)
List all imported lib.
bool Elf_() rz_bin_elf_has_imports(RZ_NONNULL ELFOBJ *bin)
bool Elf_() rz_bin_elf_has_notes(RZ_NONNULL ELFOBJ *bin)
RZ_BORROW RzBinElfSection *Elf_() rz_bin_elf_get_section_with_name(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL const char *name)
RZ_OWN char *Elf_() rz_bin_elf_get_e_machine_as_string(RZ_NONNULL ELFOBJ *bin)
#define RZ_BIN_ELF_SCN_IS_WRITABLE(x)
bool Elf_() rz_bin_elf_get_dt_info(RZ_NONNULL ELFOBJ *bin, ut64 key, RZ_OUT ut64 *info)
RZ_OWN char *Elf_() rz_bin_elf_get_rpath(RZ_NONNULL ELFOBJ *bin)
Get the rpath.
RZ_OWN char *Elf_() rz_bin_elf_get_e_flags_as_string(RZ_NONNULL ELFOBJ *bin)
RZ_OWN char *Elf_() rz_bin_elf_get_arch(RZ_NONNULL ELFOBJ *bin)
Get the elf binary architecture.
RZ_OWN char *Elf_() rz_bin_elf_get_e_version_as_string(RZ_NONNULL ELFOBJ *bin)
bool Elf_() rz_bin_elf_has_segments(RZ_NONNULL ELFOBJ *bin)
bool Elf_() rz_bin_elf_has_sections(RZ_NONNULL ELFOBJ *bin)
RZ_OWN char *Elf_() rz_bin_elf_get_head_flag(RZ_NONNULL ELFOBJ *bin)
Return the head flag.
RZ_OWN char *Elf_() rz_bin_elf_get_e_phoff_as_string(RZ_NONNULL ELFOBJ *bin)
RZ_OWN char *Elf_() rz_bin_elf_get_osabi_name(RZ_NONNULL ELFOBJ *bin)
Return the os application binary interface name.
ut64 Elf_() rz_bin_elf_get_init_offset(RZ_NONNULL ELFOBJ *bin)
Compute the init offset of the binary.
ut64 Elf_() rz_bin_elf_get_entry_offset(RZ_NONNULL ELFOBJ *bin)
Get the entry offset.
ut64 Elf_() rz_bin_elf_get_boffset(RZ_NONNULL ELFOBJ *bin)
Compute the base offset of the binary.
RZ_OWN char *Elf_() rz_bin_elf_get_e_indent_as_string(RZ_NONNULL ELFOBJ *bin)
RZ_OWN char *Elf_() rz_bin_elf_get_cpu(RZ_NONNULL ELFOBJ *bin)
Return a string representing the cpu.
RZ_OWN char *Elf_() rz_bin_elf_get_e_shnum_as_string(RZ_NONNULL ELFOBJ *bin)
ut64 Elf_() rz_bin_elf_get_sp_val(RZ_NONNULL ELFOBJ *bin)
Get the stack pointer value.
RZ_OWN char *Elf_() rz_bin_elf_get_compiler(RZ_NONNULL ELFOBJ *bin)
Get the compiler info from the .comment section.
bool Elf_() rz_bin_elf_print_ehdr(ELFOBJ *bin, RZ_NONNULL PrintfCallback cb)
RZ_OWN char *Elf_() rz_bin_elf_get_e_phentsize_as_string(RZ_NONNULL ELFOBJ *bin)
ut64 Elf_() rz_bin_elf_get_fini_offset(RZ_NONNULL ELFOBJ *bin)
Compute the fini offset of the binary.
#define E_PHENTSIZE_OFFSET
#define PT_OPENBSD_BOOTDATA
#define PT_OPENBSD_WXNEEDED
#define PT_OPENBSD_RANDOMIZE
#define E_SHENTSIZE_OFFSET
#define E_ENTRYPOINT_OFFSET
#define E_SHSTRNDX_OFFSET
size_t map(int syms, int left, int len)
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type strings(--mime-type and\n"
" --mime-encoding)\n") OPT('s'
#define RZ_PPC64_ADDR16_HA
#define RZ_PPC64_ADDR16_LO
#define RZ_ARM_THM_JUMP24
#define RZ_X86_64_GLOB_DAT
#define R_HEX_BITMASK_WORD32
#define RZ_PPC64_ADDR16_HI
#define R_HEX_BITMASK_WORD32_X26
#define R_HEX_B22_PCREL_X
#define R_HEX_DTPREL_16_X
#define RZ_PPC64_REL16_HA
#define RZ_ARM_LDRS_PC_G2
#define RZ_RISCV_JUMP_SLOT
#define R_HEX_BITMASK_WORD32_B7
#define RZ_AARCH64_RELATIVE
#define RZ_ARM_THM_MOVW_PREL_NC
#define R_HEX_PLT_B22_PCREL
#define RZ_ARM_LDRS_PC_G0
#define RZ_ARM_MOVW_PREL_NC
#define RZ_X86_64_RELATIVE
#define RZ_X86_64_JUMP_SLOT
#define R_HEX_GD_PLT_B22_PCREL
#define R_HEX_LD_PLT_B22_PCREL
#define RZ_ARM_ALU_PC_G1_NC
#define RZ_ARM_LDRS_PC_G1
#define R_HEX_GOTREL_16_X
#define RZ_RISCV_RELATIVE
#define R_HEX_GD_PLT_B32_PCREL_X
#define RZ_PPC64_REL16_LO
#define RZ_AARCH64_JUMP_SLOT
#define R_HEX_B13_PCREL_X
#define R_HEX_GOTREL_32_6_X
#define R_HEX_GOTREL_LO16
#define R_HEX_BITMASK_WORD32_LO
#define R_HEX_LD_PLT_B32_PCREL_X
#define RZ_X86_64_IRELATIVE
#define R_HEX_B32_PCREL_X
#define R_HEX_B15_PCREL_X
#define RZ_X86_64_GOTPCREL
#define RZ_ARM_ALU_PC_G0_NC
#define R_HEX_DTPREL_11_X
#define R_HEX_GOTREL_HI16
#define R_HEX_BITMASK_WORD32_B15
#define R_HEX_BITMASK_WORD32_B13
#define R_HEX_BITMASK_WORD32_B22
#define R_HEX_GD_PLT_B22_PCREL_X
#define R_HEX_DTPREL_32_6_X
#define R_HEX_BITMASK_WORD16
#define R_HEX_LD_PLT_B22_PCREL_X
#define R_HEX_GOTREL_11_X
#define R_HEX_BITMASK_WORD32_B9
#define R_HEX_BITMASK_WORD32_R6
#define R_HEX_BITMASK_WORD8
#define R_HEX_BITMASK_WORD32_HL
#define RZ_AARCH64_GLOB_DAT
RZ_API void Ht_() free(HtName_(Ht) *ht)
#define DT_PREINIT_ARRAYSZ
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API ut64 MACH0_() reloc_targets_vfile_size(struct MACH0_(obj_t) *obj)
size of the artificial reloc target vfile
RZ_API void MACH0_() patch_relocs(RzBinFile *bf, struct MACH0_(obj_t) *obj)
Patching of external relocs in a sparse overlay buffer.
static ut64 reloc_target_size(struct MACH0_(obj_t) *obj)
static int is_arm(RzBinPEObj *bin)
RZ_API ut64 rz_bin_reloc_target_builder_get_target(RzBinRelocTargetBuilder *builder, ut64 sym)
obtain the address of the target for a given symbol
RZ_API void rz_bin_reloc_target_builder_free(RzBinRelocTargetBuilder *builder)
RZ_API void rz_bin_relocs_patch_maps(RZ_NONNULL RzList *maps, RZ_NULLABLE RzBuffer *buf_patched, ut64 buf_patched_offset, ut64 target_vfile_base, ut64 target_vfile_size, RZ_NONNULL const char *vfile_name_patched, RZ_NONNULL const char *vfile_name_reloc_targets)
Change file-mapped maps to the patched vfile if covered by the buffer and add the reloc target map.
RZ_API RzBinRelocTargetBuilder * rz_bin_reloc_target_builder_new(ut64 target_size, ut64 target_base)
#define rz_warn_if_reached()
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
#define RZ_BIN_DBG_STATIC
#define RZ_BIN_DBG_RELOCS
#define RZ_BIN_DBG_STRIPPED
#define RZ_BIN_ENTRY_TYPE_PREINIT
#define RZ_BIN_ENTRY_TYPE_FINI
@ RZ_BIN_SPECIAL_SYMBOL_FINI
@ RZ_BIN_SPECIAL_SYMBOL_ENTRY
@ RZ_BIN_SPECIAL_SYMBOL_INIT
@ RZ_BIN_SPECIAL_SYMBOL_MAIN
#define RZ_BIN_ENTRY_TYPE_INIT
#define RZ_BIN_DBG_LINENUMS
RZ_API void rz_buf_sparse_set_write_mode(RzBuffer *b, RzBufferSparseWriteMode mode)
Only for sparse RzBuffers.
RZ_API bool rz_buf_append_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len)
Append an array of bytes to the buffer.
RZ_API bool rz_buf_append_nbytes(RZ_NONNULL RzBuffer *b, ut64 len)
Extend the size of the buffer.
RZ_API bool rz_buf_append_ut32(RZ_NONNULL RzBuffer *b, ut32 n)
Add a ut32 number at the end of the buffer.
RZ_API bool rz_buf_append_ut64(RZ_NONNULL RzBuffer *b, ut64 n)
Add a ut64 number at the end of the buffer.
RZ_API st64 rz_buf_write_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len)
Write len bytes of the buffer at the specified address.
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.
@ RZ_BUF_SPARSE_WRITE_MODE_SPARSE
all writes are performed in the sparse overlay
@ RZ_BUF_SPARSE_WRITE_MODE_THROUGH
all writes are performed in the underlying base buffer
RZ_API bool rz_buf_append_ut16(RZ_NONNULL RzBuffer *b, ut16 n)
Add a ut16 number at the end of the buffer.
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_empty(ut64 len)
Creates a new empty buffer with a predefined size;.
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_bytes(RZ_NULLABLE RZ_BORROW const ut8 *bytes, ut64 len)
Creates a new buffer with a bytes array.
RZ_API RZ_OWN RzBuffer * rz_buf_new_sparse_overlay(RzBuffer *b, RzBufferSparseWriteMode write_mode)
Creates a sparse buffer from a already populated buffer.
static void rz_write_le32(void *dest, ut32 val)
static void rz_write_le16(void *dest, ut16 val)
static ut32 rz_read_le32(const void *src)
static ut32 rz_read_ble32(const void *src, bool big_endian)
static void rz_write_ble32(void *dest, ut32 val, bool big_endian)
static void rz_write_ble16(void *dest, ut16 val, bool big_endian)
static void rz_write_le64(void *dest, ut64 val)
static ut32 rz_read_be32(const void *src)
RZ_API char * rz_hex_bin2strdup(const ut8 *in, int len)
void(* RzListFree)(void *ptr)
#define RZ_LOG_WARN(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_str_new(const char *str)
RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case sensitive)
RZ_API bool rz_str_endswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string ends with a specifc sequence of characters (case sensitive)
#define RZ_BIT_MASK32(x, y)
#define rz_vector_foreach(vec, it)
static struct sockaddr static addrlen static backlog const void static flags void flags
Parsed PT_NOTE of type NT_PRSTATUS.
st64 addend
exact addend value taken from the ELF, meaning depends on type
ut64 target_vaddr
after patching, the target that this reloc points to
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
bool patch_relocs
ask the bin plugin to fill relocs with valid contents for analysis
ut64 baseaddr
where the linker maps the binary in memory
XX curplugin == o->plugin.
Description of a single memory mapping into virtual memory from a binary.
RzBinObjectLoadOptions opts
RZ_NONNULL RzBuffer * buf
bool buf_owned
whether buf is owned and freed by this RzBinVirtualFile
RZ_OWN RZ_NONNULL char * name
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()