13 #define VFILE_NAME_RELOC_TARGETS "reloc-targets"
14 #define VFILE_NAME_PATCHED "patched"
51 #define DTYPE_IS_FUNCTION(type) (COFF_SYM_GET_DTYPE(type) == COFF_SYM_DTYPE_FUNCTION)
59 struct coff_symbol *
s =
NULL;
60 struct coff_scn_hdr *sc_hdr =
NULL;
61 if (idx < 0 || idx >
bin->hdr.f_nsyms) {
79 if (
s->n_scnum <
bin->hdr.f_nscns + 1 &&
s->n_scnum > 0) {
81 sc_hdr = &
bin->scn_hdrs[
s->n_scnum - 1];
82 ptr->
paddr = sc_hdr->s_scnptr +
s->n_value;
84 ptr->
vaddr =
bin->scn_va[
s->n_scnum - 1] +
s->n_value;
97 switch (
s->n_sclass) {
122 char *newname =
rz_str_newf(
"%s-0x%08x", coffname,
s->n_value);
127 }
else if (sc_hdr && !memcmp(sc_hdr->s_name,
s->n_name, 8)) {
148 if (!ptr || idx < 0 || idx >
bin->hdr.f_nsyms) {
152 struct coff_symbol *
s = &
bin->symbols[
idx];
162 ptr->
name = coffname;
235 for (
size_t i = 0;
i < obj->
hdr.f_nscns;
i++) {
240 struct coff_scn_hdr *hdr = &obj->
scn_hdrs[
i];
242 ptr->
psize = hdr->s_size;
243 ptr->
vsize = hdr->s_size;
244 ptr->
paddr = hdr->s_scnptr;
282 for (
size_t i = 0;
i < obj->
hdr.f_nscns;
i++) {
288 if (strstr(ptr->
name,
"data")) {
309 for (
size_t i = 0;
i < obj->
hdr.f_nsyms;
i++) {
326 for (
size_t i = 0;
i < obj->
hdr.f_nsyms;
i++) {
348 for (
size_t i = 0;
i < obj->
hdr.f_nsyms;
i++) {
368 for (
i = 0;
i < obj->
hdr.f_nsyms;
i++) {
416 switch (obj->
hdr.f_magic) {
525 .desc =
"COFF format rz_bin plugin",
546 #ifndef RZ_PLUGIN_INCORE
RZ_API void rz_bin_symbol_free(RzBinSymbol *sym)
RZ_API void rz_bin_map_free(RzBinMap *map)
RZ_API void rz_bin_import_free(RzBinImport *imp)
RZ_API void rz_bin_section_free(RzBinSection *bs)
RZ_API void rz_bin_virtual_file_free(RzBinVirtualFile *vfile)
static RzBinAddr * binsym(RzBinFile *bf, RzBinSpecialSymbol sym)
static Sdb * get_sdb(RzBinFile *bf)
static bool check_buffer(RzBuffer *buf)
static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb)
static RzList * symbols(RzBinFile *bf)
static void populate_imports(struct rz_bin_coff_obj *obj)
static ut64 size(RzBinFile *bf)
static RzList * libs(RzBinFile *bf)
static void populate_symbols(RzBinFile *bf)
static bool _fill_bin_symbol(RzBin *rbin, struct rz_bin_coff_obj *bin, int idx, RzBinSymbol **sym)
static RzList * fields(RzBinFile *bf)
static void destroy(RzBinFile *bf)
RZ_API RzLibStruct rizin_plugin
static RzBinImport * _fill_bin_import(struct rz_bin_coff_obj *bin, int idx)
#define VFILE_NAME_PATCHED
static RzList * virtual_files(RzBinFile *bf)
static RzBinInfo * info(RzBinFile *bf)
static ut64 baddr(RzBinFile *bf)
static RzList * entries(RzBinFile *bf)
#define VFILE_NAME_RELOC_TARGETS
static bool rz_coff_is_stripped(struct rz_bin_coff_obj *obj)
static RzList * maps(RzBinFile *bf)
static bool is_imported_symbol(struct coff_symbol *s)
static RzList * sections(RzBinFile *bf)
#define DTYPE_IS_FUNCTION(type)
static RzList * imports(RzBinFile *bf)
static RzList * relocs(RzBinFile *bf)
RzBinPlugin rz_bin_plugin_coff
RZ_API struct rz_bin_coff_obj * rz_bin_coff_new_buf(RzBuffer *buf, bool verbose)
RZ_API void rz_bin_coff_free(struct rz_bin_coff_obj *obj)
RZ_API ut64 rz_coff_perms_from_section_flags(ut32 flags)
RZ_API RzBinAddr * rz_coff_get_entry(struct rz_bin_coff_obj *obj)
RZ_API bool rz_coff_supported_arch(const ut8 *buf)
RZ_API char * rz_coff_symbol_name(struct rz_bin_coff_obj *obj, void *ptr)
RZ_API ut64 rz_coff_get_reloc_targets_vfile_size(struct rz_bin_coff_obj *obj)
size of the artificial reloc target vfile
RZ_API ut64 rz_coff_get_reloc_targets_map_base(struct rz_bin_coff_obj *obj)
base vaddr where to map the artificial reloc target vfile
RZ_API RZ_BORROW RzBuffer * rz_coff_get_patched_buf(struct rz_bin_coff_obj *bin)
RZ_API RzList * rz_coff_get_relocs(struct rz_bin_coff_obj *bin)
RZ_API ut64 rz_coff_import_index_addr(struct rz_bin_coff_obj *obj, ut64 imp_index)
#define COFF_FILE_MACHINE_TMS320C55PLUS
#define COFF_FILE_MACHINE_SH3DSP
#define COFF_FILE_MACHINE_SH4
#define COFF_SYM_CLASS_FILE
#define COFF_FILE_MACHINE_AMD29KBE
#define COFF_FILE_MACHINE_ARM64
#define COFF_FILE_MACHINE_AMD64
#define COFF_FILE_MACHINE_ARM
#define COFF_FILE_MACHINE_TMS320C54
#define COFF_FILE_TI_COFF
#define COFF_FLAGS_TI_F_EXEC
#define COFF_FLAGS_TI_F_LNNO
#define COFF_FILE_MACHINE_MIPSFPU
#define COFF_FILE_MACHINE_SH3
#define COFF_FILE_MACHINE_MIPS16
#define COFF_FLAGS_TI_F_RELFLG
#define COFF_FILE_MACHINE_MIPSFPU16
#define COFF_SYM_CLASS_LABEL
#define COFF_FILE_MACHINE_I386
#define COFF_SYM_CLASS_EXTERNAL
#define COFF_SYM_SCNUM_UNDEF
#define COFF_FILE_MACHINE_TMS320C55
#define COFF_FILE_MACHINE_SH5
#define COFF_SYM_CLASS_STATIC
#define COFF_FILE_MACHINE_AMD29KLE
#define COFF_FILE_MACHINE_THUMB
#define COFF_FILE_MACHINE_R4000
#define COFF_FILE_MACHINE_H8300
#define COFF_SYM_CLASS_FUNCTION
#define COFF_FILE_MACHINE_ARMNT
#define COFF_SYM_SCNUM_ABS
#define COFF_FLAGS_TI_F_LSYMS
#define COFF_SYM_CLASS_SECTION
size_t map(int syms, int left, int len)
RZ_API char * sdb_fmt(const char *fmt,...)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API const KEY_TYPE bool * found
RZ_API RZ_BORROW RzListIter * rz_list_prepend(RZ_NONNULL RzList *list, void *data)
Appends at the beginning of the list a new element.
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.
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")
#define RZ_BIN_DBG_RELOCS
#define RZ_BIN_DBG_STRIPPED
#define RZ_BIN_BIND_LOCAL_STR
#define RZ_BIN_BIND_GLOBAL_STR
#define RZ_BIN_TYPE_FILE_STR
#define RZ_BIN_TYPE_FUNC_STR
#define RZ_BIN_TYPE_UNKNOWN_STR
#define RZ_BIN_TYPE_SECTION_STR
#define RZ_BIN_DBG_LINENUMS
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_API RZ_OWN RzBuffer * rz_buf_new_empty(ut64 len)
Creates a new empty buffer with a predefined size;.
void(* RzListFree)(void *ptr)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API const char * rz_str_constpool_get(RzStrConstPool *pool, const char *str)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
RzBuffer * buf_patched
overlay over the original file with relocs patched
struct coff_symbol * symbols
struct coff_scn_hdr * scn_hdrs
HtUU * imp_index
locally-generated indices for imports, in particular for deterministically assigning reloc targets
XX curplugin == o->plugin.
Description of a single memory mapping into virtual memory from a binary.
ut64 vsize
size to map in the destination address space. If vsize > psize, excessive bytes are meant to be fille...
ut64 paddr
address of the map inside the file
ut64 psize
size of the data inside the file
ut64 vaddr
address in the destination address space to map to
RZ_NULLABLE char * vfile_name
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)()