Rizin
unix-like reverse engineering framework and cli tools
rz_bin.h File Reference
#include <rz_util.h>
#include <rz_types.h>
#include <rz_io.h>
#include <rz_cons.h>
#include <rz_list.h>
#include <ht_pu.h>
#include <rz_demangler.h>
#include <rz_hash.h>
#include <rz_bin_dwarf.h>
#include <rz_pdb.h>

Go to the source code of this file.

Classes

struct  rz_bin_addr_t
 
struct  rz_bin_hash_t
 
struct  rz_bin_file_hash_t
 
struct  rz_bin_info_t
 
struct  rz_bin_file_load_options_t
 
struct  rz_bin_object_t
 
struct  rz_bin_file_t
 XX curplugin == o->plugin. More...
 
struct  rz_bin_file_options_t
 
struct  rz_bin_t
 
struct  rz_bin_xtr_metadata_t
 
struct  rz_bin_xtr_extract_t
 
struct  rz_bin_xtr_plugin_t
 
struct  rz_bin_arch_options_t
 
struct  rz_bin_trycatch_t
 
struct  rz_bin_source_line_sample_t
 A single sample of source line info for a specific address. More...
 
struct  rz_bin_source_line_info_t
 
struct  rz_bin_source_line_info_builder_t
 
struct  rz_bin_plugin_t
 
struct  rz_bin_virtual_file_t
 
struct  rz_bin_map_t
 Description of a single memory mapping into virtual memory from a binary. More...
 
struct  rz_bin_section_t
 
struct  rz_bin_section_map_t
 
struct  rz_bin_class_t
 
struct  rz_bin_symbol_t
 
struct  rz_bin_import_t
 
struct  rz_bin_reloc_t
 
struct  rz_bin_reloc_storage_t
 Efficient storage of relocations to query by address. More...
 
struct  rz_bin_string_t
 
struct  rz_bin_field_t
 
struct  rz_bin_mem_t
 
struct  rz_bin_resource_t
 
struct  rz_bin_bind_t
 

Macros

#define RZ_BIN_DBG_STRIPPED   0x01
 
#define RZ_BIN_DBG_STATIC   0x02
 
#define RZ_BIN_DBG_LINENUMS   0x04
 
#define RZ_BIN_DBG_SYMS   0x08
 
#define RZ_BIN_DBG_RELOCS   0x10
 
#define RZ_BIN_ENTRY_TYPE_PROGRAM   0
 
#define RZ_BIN_ENTRY_TYPE_MAIN   1
 
#define RZ_BIN_ENTRY_TYPE_INIT   2
 
#define RZ_BIN_ENTRY_TYPE_FINI   3
 
#define RZ_BIN_ENTRY_TYPE_TLS   4
 
#define RZ_BIN_ENTRY_TYPE_PREINIT   5
 
#define RZ_BIN_SIZEOF_STRINGS   512
 
#define RZ_BIN_MAX_ARCH   1024
 
#define RZ_BIN_REQ_ALL   UT64_MAX
 
#define RZ_BIN_REQ_UNK   0x000000
 
#define RZ_BIN_REQ_ENTRIES   0x000001
 
#define RZ_BIN_REQ_IMPORTS   0x000002
 
#define RZ_BIN_REQ_SYMBOLS   0x000004
 
#define RZ_BIN_REQ_SECTIONS   0x000008
 
#define RZ_BIN_REQ_INFO   0x000010
 
#define RZ_BIN_REQ_OPERATION   0x000020
 
#define RZ_BIN_REQ_HELP   0x000040
 
#define RZ_BIN_REQ_STRINGS   0x000080
 
#define RZ_BIN_REQ_FIELDS   0x000100
 
#define RZ_BIN_REQ_LIBS   0x000200
 
#define RZ_BIN_REQ_SRCLINE   0x000400
 
#define RZ_BIN_REQ_MAIN   0x000800
 
#define RZ_BIN_REQ_EXTRACT   0x001000
 
#define RZ_BIN_REQ_RELOCS   0x002000
 
#define RZ_BIN_REQ_LISTARCHS   0x004000
 
#define RZ_BIN_REQ_CREATE   0x008000
 
#define RZ_BIN_REQ_CLASSES   0x010000
 
#define RZ_BIN_REQ_DWARF   0x020000
 
#define RZ_BIN_REQ_SIZE   0x040000
 
#define RZ_BIN_REQ_PDB   0x080000
 
#define RZ_BIN_REQ_PDB_DWNLD   0x100000
 
#define RZ_BIN_REQ_DLOPEN   0x200000
 
#define RZ_BIN_REQ_EXPORTS   0x400000
 
#define RZ_BIN_REQ_VERSIONINFO   0x800000
 
#define RZ_BIN_REQ_PACKAGE   0x1000000
 
#define RZ_BIN_REQ_HEADER   0x2000000
 
#define RZ_BIN_REQ_LISTPLUGINS   0x4000000
 
#define RZ_BIN_REQ_RESOURCES   0x8000000
 
#define RZ_BIN_REQ_INITFINI   0x10000000
 
#define RZ_BIN_REQ_SEGMENTS   0x20000000
 
#define RZ_BIN_REQ_HASHES   0x40000000
 
#define RZ_BIN_REQ_SIGNATURE   0x80000000
 
#define RZ_BIN_REQ_TRYCATCH   0x100000000
 
#define RZ_BIN_REQ_SECTIONS_MAPPING   0x200000000
 
#define RZ_BIN_REQ_CLASSES_SOURCES   0x400000000
 
#define RZ_BIN_REQ_BASEFIND   0x800000000
 
#define RZ_BIN_METH_CLASS   0x0000000000000001L
 
#define RZ_BIN_METH_STATIC   0x0000000000000002L
 
#define RZ_BIN_METH_PUBLIC   0x0000000000000004L
 
#define RZ_BIN_METH_PRIVATE   0x0000000000000008L
 
#define RZ_BIN_METH_PROTECTED   0x0000000000000010L
 
#define RZ_BIN_METH_INTERNAL   0x0000000000000020L
 
#define RZ_BIN_METH_OPEN   0x0000000000000040L
 
#define RZ_BIN_METH_FILEPRIVATE   0x0000000000000080L
 
#define RZ_BIN_METH_FINAL   0x0000000000000100L
 
#define RZ_BIN_METH_VIRTUAL   0x0000000000000200L
 
#define RZ_BIN_METH_CONST   0x0000000000000400L
 
#define RZ_BIN_METH_MUTATING   0x0000000000000800L
 
#define RZ_BIN_METH_ABSTRACT   0x0000000000001000L
 
#define RZ_BIN_METH_SYNCHRONIZED   0x0000000000002000L
 
#define RZ_BIN_METH_NATIVE   0x0000000000004000L
 
#define RZ_BIN_METH_BRIDGE   0x0000000000008000L
 
#define RZ_BIN_METH_VARARGS   0x0000000000010000L
 
#define RZ_BIN_METH_SYNTHETIC   0x0000000000020000L
 
#define RZ_BIN_METH_STRICT   0x0000000000040000L
 
#define RZ_BIN_METH_MIRANDA   0x0000000000080000L
 
#define RZ_BIN_METH_CONSTRUCTOR   0x0000000000100000L
 
#define RZ_BIN_METH_DECLARED_SYNCHRONIZED   0x0000000000200000L
 
#define RZ_BIN_BIND_LOCAL_STR   "LOCAL"
 
#define RZ_BIN_BIND_GLOBAL_STR   "GLOBAL"
 
#define RZ_BIN_BIND_WEAK_STR   "WEAK"
 
#define RZ_BIN_BIND_NUM_STR   "NUM"
 
#define RZ_BIN_BIND_LOOS_STR   "LOOS"
 
#define RZ_BIN_BIND_HIOS_STR   "HIOS"
 
#define RZ_BIN_BIND_LOPROC_STR   "LOPROC"
 
#define RZ_BIN_BIND_HIPROC_STR   "HIPROC"
 
#define RZ_BIN_BIND_IMPORT_STR   "IMPORT"
 
#define RZ_BIN_BIND_UNKNOWN_STR   "UNKNOWN"
 
#define RZ_BIN_TYPE_NOTYPE_STR   "NOTYPE"
 
#define RZ_BIN_TYPE_OBJECT_STR   "OBJ"
 
#define RZ_BIN_TYPE_FUNC_STR   "FUNC"
 
#define RZ_BIN_TYPE_FIELD_STR   "FIELD"
 
#define RZ_BIN_TYPE_IFACE_STR   "IFACE"
 
#define RZ_BIN_TYPE_METH_STR   "METH"
 
#define RZ_BIN_TYPE_STATIC_STR   "STATIC"
 
#define RZ_BIN_TYPE_SECTION_STR   "SECT"
 
#define RZ_BIN_TYPE_FILE_STR   "FILE"
 
#define RZ_BIN_TYPE_COMMON_STR   "COMMON"
 
#define RZ_BIN_TYPE_TLS_STR   "TLS"
 
#define RZ_BIN_TYPE_NUM_STR   "NUM"
 
#define RZ_BIN_TYPE_LOOS_STR   "LOOS"
 
#define RZ_BIN_TYPE_HIOS_STR   "HIOS"
 
#define RZ_BIN_TYPE_LOPROC_STR   "LOPROC"
 
#define RZ_BIN_TYPE_HIPROC_STR   "HIPROC"
 
#define RZ_BIN_TYPE_SPECIAL_SYM_STR   "SPCL"
 
#define RZ_BIN_TYPE_UNKNOWN_STR   "UNK"
 
#define RZ_BIN_LANGUAGE_MASK(x)   ((x) & ~RZ_BIN_LANGUAGE_BLOCKS)
 
#define RZ_BIN_LANGUAGE_HAS_BLOCKS(x)   ((x)&RZ_BIN_LANGUAGE_BLOCKS)
 
#define RzBinSectionName   rz_offsetof(RzBinSection, name)
 
#define RzBinSectionOffset   rz_offsetof(RzBinSection, offset)
 
#define REBASE_PADDR(o, l, type_t)
 

Typedefs

typedef struct rz_bin_t RzBin
 
typedef struct rz_bin_file_t RzBinFile
 
typedef struct rz_bin_source_line_info_t RzBinSourceLineInfo
 
typedef struct rz_bin_reloc_storage_t RzBinRelocStorage
 
typedef struct rz_bin_addr_t RzBinAddr
 
typedef struct rz_bin_hash_t RzBinHash
 
typedef struct rz_bin_file_hash_t RzBinFileHash
 
typedef struct rz_bin_info_t RzBinInfo
 
typedef struct rz_bin_file_load_options_t RzBinObjectLoadOptions
 
typedef struct rz_bin_string_database_t RzBinStrDb
 
typedef struct rz_bin_object_t RzBinObject
 
typedef struct rz_bin_file_options_t RzBinFileOptions
 
typedef struct rz_bin_xtr_metadata_t RzBinXtrMetadata
 
typedef int(* FREE_XTR) (void *xtr_obj)
 
typedef struct rz_bin_xtr_extract_t RzBinXtrData
 
typedef struct rz_bin_xtr_plugin_t RzBinXtrPlugin
 
typedef struct rz_bin_arch_options_t RzBinArchOptions
 
typedef struct rz_bin_trycatch_t RzBinTrycatch
 
typedef struct rz_bin_source_line_sample_t RzBinSourceLineSample
 A single sample of source line info for a specific address. More...
 
typedef struct rz_bin_source_line_info_builder_t RzBinSourceLineInfoBuilder
 
typedef struct rz_bin_plugin_t RzBinPlugin
 
typedef void(* RzBinSymbollCallback) (RzBinObject *obj, void *symbol)
 
typedef struct rz_bin_virtual_file_t RzBinVirtualFile
 
typedef struct rz_bin_map_t RzBinMap
 Description of a single memory mapping into virtual memory from a binary. More...
 
typedef struct rz_bin_section_t RzBinSection
 
typedef struct rz_bin_section_map_t RzBinSectionMap
 
typedef struct rz_bin_class_t RzBinClass
 
typedef struct rz_bin_symbol_t RzBinSymbol
 
typedef struct rz_bin_import_t RzBinImport
 
typedef struct rz_bin_reloc_t RzBinReloc
 
typedef struct rz_bin_string_t RzBinString
 
typedef struct rz_bin_field_t RzBinField
 
typedef struct rz_bin_mem_t RzBinMem
 
typedef struct rz_bin_resource_t RzBinResource
 
typedef ut64(* RzBinGetOffset) (RzBin *bin, int type, int idx)
 
typedef char *(* RzBinGetName) (RzBin *bin, int type, int idx)
 
typedef RzList *(* RzBinGetSections) (RzBin *bin)
 
typedef RzBinSection *(* RzBinGetSectionAt) (RzBin *bin, ut64 addr)
 
typedef char *(* RzBinDemangle) (RzBinFile *bf, const char *def, const char *str, ut64 vaddr, bool libs)
 
typedef struct rz_bin_bind_t RzBinBind
 

Enumerations

enum  RzBinSpecialSymbol {
  RZ_BIN_SPECIAL_SYMBOL_ENTRY , RZ_BIN_SPECIAL_SYMBOL_INIT , RZ_BIN_SPECIAL_SYMBOL_MAIN , RZ_BIN_SPECIAL_SYMBOL_FINI ,
  RZ_BIN_SPECIAL_SYMBOL_LAST
}
 
enum  RzBinLanguage {
  RZ_BIN_LANGUAGE_UNKNOWN = 0 , RZ_BIN_LANGUAGE_JAVA = 1 , RZ_BIN_LANGUAGE_C = 1 << 1 , RZ_BIN_LANGUAGE_GO = 1 << 2 ,
  RZ_BIN_LANGUAGE_CXX = 1 << 3 , RZ_BIN_LANGUAGE_OBJC = 1 << 4 , RZ_BIN_LANGUAGE_SWIFT = 1 << 5 , RZ_BIN_LANGUAGE_DLANG = 1 << 6 ,
  RZ_BIN_LANGUAGE_MSVC = 1 << 7 , RZ_BIN_LANGUAGE_RUST = 1 << 8 , RZ_BIN_LANGUAGE_KOTLIN = 1 << 9 , RZ_BIN_LANGUAGE_GROOVY = 1 << 10 ,
  RZ_BIN_LANGUAGE_DART = 1 << 11 , RZ_BIN_LANGUAGE_BLOCKS = 1 << 31
}
 
enum  { RZ_BIN_CLASS_PRIVATE , RZ_BIN_CLASS_PUBLIC , RZ_BIN_CLASS_FRIENDLY , RZ_BIN_CLASS_PROTECTED }
 
enum  RzBinRelocType {
  RZ_BIN_RELOC_8 = 8 , RZ_BIN_RELOC_16 = 16 , RZ_BIN_RELOC_24 = 24 , RZ_BIN_RELOC_32 = 32 ,
  RZ_BIN_RELOC_64 = 64
}
 
enum  { RZ_BIN_TYPE_DEFAULT = 0 , RZ_BIN_TYPE_CORE = 1 }
 

Functions

 RZ_LIB_VERSION_HEADER (rz_bin)
 
RZ_API RzBinXtrDatarz_bin_xtrdata_new (RzBuffer *buf, ut64 offset, ut64 size, ut32 file_count, RzBinXtrMetadata *metadata)
 
RZ_API void rz_bin_xtrdata_free (void *data)
 
RZ_API RzBinTrycatchrz_bin_trycatch_new (ut64 source, ut64 from, ut64 to, ut64 handler, ut64 filter)
 
RZ_API void rz_bin_trycatch_free (RzBinTrycatch *tc)
 
static bool rz_bin_source_line_sample_is_closing (const RzBinSourceLineSample *s)
 
RZ_API void rz_bin_source_line_info_builder_init (RzBinSourceLineInfoBuilder *builder)
 
RZ_API void rz_bin_source_line_info_builder_fini (RzBinSourceLineInfoBuilder *builder)
 
RZ_API void rz_bin_source_line_info_builder_push_sample (RzBinSourceLineInfoBuilder *builder, ut64 address, ut32 line, ut32 column, const char *file)
 Push a new sample into the builder. More...
 
RZ_API RzBinSourceLineInforz_bin_source_line_info_builder_build_and_fini (RzBinSourceLineInfoBuilder *builder)
 
RZ_API void rz_bin_source_line_info_free (RzBinSourceLineInfo *sli)
 
RZ_API const RzBinSourceLineSamplerz_bin_source_line_info_get_first_at (const RzBinSourceLineInfo *sli, ut64 addr)
 Find the first sample that affects the given address. i.e. find the first sample with the highest address less or equal to addr. There may be more which can be retrieved by repeatedly calling rz_bin_source_line_info_get_next() until it returns NULL. More...
 
RZ_API const RzBinSourceLineSamplerz_bin_source_line_info_get_next (const RzBinSourceLineInfo *sli, RZ_NONNULL const RzBinSourceLineSample *cur)
 
RZ_API ut64 rz_bin_reloc_size (RzBinReloc *reloc)
 size of the reloc (where it is supposed to be patched) in bits More...
 
RZ_API RzBinRelocStoragerz_bin_reloc_storage_new (RZ_OWN RzList *relocs)
 
RZ_API void rz_bin_reloc_storage_free (RzBinRelocStorage *storage)
 
RZ_API RzBinRelocrz_bin_reloc_storage_get_reloc_in (RzBinRelocStorage *storage, ut64 vaddr, ut64 size)
 Get the reloc with the lowest vaddr that starts inside the given interval. More...
 
static bool rz_bin_reloc_storage_targets_available (RzBinRelocStorage *storage)
 return true iff there is at least one reloc in the storage with a target address More...
 
RZ_API RzBinRelocrz_bin_reloc_storage_get_reloc_to (RzBinRelocStorage *storage, ut64 vaddr)
 Get a reloc that points exactly to vaddr or NULL. More...
 
RZ_API RzBinFieldrz_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_field_free (RzBinField *field)
 
RZ_API void rz_bin_virtual_file_free (RzBinVirtualFile *vfile)
 
RZ_API void rz_bin_map_free (RzBinMap *map)
 
RZ_API RZ_OWN RzListrz_bin_maps_of_file_sections (RZ_NONNULL RzBinFile *binfile)
 Create a list of RzBinMap from RzBinSections queried from the given file. More...
 
RZ_API RzListrz_bin_sections_of_maps (RzList *maps)
 Create a list of RzBinSection from RzBinMaps. More...
 
RZ_API RzBinSectionrz_bin_section_new (const char *name)
 
RZ_API void rz_bin_section_free (RzBinSection *bs)
 
RZ_API RZ_OWN char * rz_bin_section_type_to_string (RzBin *bin, int type)
 Converts the RzBinSection type to the string representation. More...
 
RZ_API RZ_OWN RzListrz_bin_section_flag_to_list (RzBin *bin, ut64 flag)
 Converts the RzBinSection flags to a list of string representations. More...
 
RZ_API void rz_bin_info_free (RzBinInfo *rb)
 
RZ_API void rz_bin_import_free (RzBinImport *imp)
 
RZ_API void rz_bin_resource_free (RzBinResource *res)
 
RZ_API void rz_bin_symbol_free (RzBinSymbol *sym)
 
static bool rz_bin_reloc_has_target (RzBinReloc *reloc)
 
RZ_API void rz_bin_reloc_free (RzBinReloc *reloc)
 
RZ_API RzBinSymbolrz_bin_symbol_new (const char *name, ut64 paddr, ut64 vaddr)
 
RZ_API void rz_bin_string_free (void *_str)
 

Macro Definition Documentation

◆ REBASE_PADDR

#define REBASE_PADDR (   o,
  l,
  type_t 
)
Value:
do { \
if ((o)->opts.loadaddr) { \
RzListIter *_it; \
type_t *_el; \
rz_list_foreach ((l), _it, _el) { \
_el->paddr += (o)->opts.loadaddr; \
} \
} \
} while (0)

Definition at line 662 of file rz_bin.h.

◆ RZ_BIN_BIND_GLOBAL_STR

#define RZ_BIN_BIND_GLOBAL_STR   "GLOBAL"

Definition at line 107 of file rz_bin.h.

◆ RZ_BIN_BIND_HIOS_STR

#define RZ_BIN_BIND_HIOS_STR   "HIOS"

Definition at line 111 of file rz_bin.h.

◆ RZ_BIN_BIND_HIPROC_STR

#define RZ_BIN_BIND_HIPROC_STR   "HIPROC"

Definition at line 113 of file rz_bin.h.

◆ RZ_BIN_BIND_IMPORT_STR

#define RZ_BIN_BIND_IMPORT_STR   "IMPORT"

Definition at line 114 of file rz_bin.h.

◆ RZ_BIN_BIND_LOCAL_STR

#define RZ_BIN_BIND_LOCAL_STR   "LOCAL"

Definition at line 106 of file rz_bin.h.

◆ RZ_BIN_BIND_LOOS_STR

#define RZ_BIN_BIND_LOOS_STR   "LOOS"

Definition at line 110 of file rz_bin.h.

◆ RZ_BIN_BIND_LOPROC_STR

#define RZ_BIN_BIND_LOPROC_STR   "LOPROC"

Definition at line 112 of file rz_bin.h.

◆ RZ_BIN_BIND_NUM_STR

#define RZ_BIN_BIND_NUM_STR   "NUM"

Definition at line 109 of file rz_bin.h.

◆ RZ_BIN_BIND_UNKNOWN_STR

#define RZ_BIN_BIND_UNKNOWN_STR   "UNKNOWN"

Definition at line 115 of file rz_bin.h.

◆ RZ_BIN_BIND_WEAK_STR

#define RZ_BIN_BIND_WEAK_STR   "WEAK"

Definition at line 108 of file rz_bin.h.

◆ RZ_BIN_DBG_LINENUMS

#define RZ_BIN_DBG_LINENUMS   0x04

Definition at line 29 of file rz_bin.h.

◆ RZ_BIN_DBG_RELOCS

#define RZ_BIN_DBG_RELOCS   0x10

Definition at line 31 of file rz_bin.h.

◆ RZ_BIN_DBG_STATIC

#define RZ_BIN_DBG_STATIC   0x02

Definition at line 28 of file rz_bin.h.

◆ RZ_BIN_DBG_STRIPPED

#define RZ_BIN_DBG_STRIPPED   0x01

Definition at line 27 of file rz_bin.h.

◆ RZ_BIN_DBG_SYMS

#define RZ_BIN_DBG_SYMS   0x08

Definition at line 30 of file rz_bin.h.

◆ RZ_BIN_ENTRY_TYPE_FINI

#define RZ_BIN_ENTRY_TYPE_FINI   3

Definition at line 36 of file rz_bin.h.

◆ RZ_BIN_ENTRY_TYPE_INIT

#define RZ_BIN_ENTRY_TYPE_INIT   2

Definition at line 35 of file rz_bin.h.

◆ RZ_BIN_ENTRY_TYPE_MAIN

#define RZ_BIN_ENTRY_TYPE_MAIN   1

Definition at line 34 of file rz_bin.h.

◆ RZ_BIN_ENTRY_TYPE_PREINIT

#define RZ_BIN_ENTRY_TYPE_PREINIT   5

Definition at line 38 of file rz_bin.h.

◆ RZ_BIN_ENTRY_TYPE_PROGRAM

#define RZ_BIN_ENTRY_TYPE_PROGRAM   0

Definition at line 33 of file rz_bin.h.

◆ RZ_BIN_ENTRY_TYPE_TLS

#define RZ_BIN_ENTRY_TYPE_TLS   4

Definition at line 37 of file rz_bin.h.

◆ RZ_BIN_LANGUAGE_HAS_BLOCKS

#define RZ_BIN_LANGUAGE_HAS_BLOCKS (   x)    ((x)&RZ_BIN_LANGUAGE_BLOCKS)

Definition at line 163 of file rz_bin.h.

◆ RZ_BIN_LANGUAGE_MASK

#define RZ_BIN_LANGUAGE_MASK (   x)    ((x) & ~RZ_BIN_LANGUAGE_BLOCKS)

Definition at line 162 of file rz_bin.h.

◆ RZ_BIN_MAX_ARCH

#define RZ_BIN_MAX_ARCH   1024

Definition at line 41 of file rz_bin.h.

◆ RZ_BIN_METH_ABSTRACT

#define RZ_BIN_METH_ABSTRACT   0x0000000000001000L

Definition at line 95 of file rz_bin.h.

◆ RZ_BIN_METH_BRIDGE

#define RZ_BIN_METH_BRIDGE   0x0000000000008000L

Definition at line 98 of file rz_bin.h.

◆ RZ_BIN_METH_CLASS

#define RZ_BIN_METH_CLASS   0x0000000000000001L

Definition at line 83 of file rz_bin.h.

◆ RZ_BIN_METH_CONST

#define RZ_BIN_METH_CONST   0x0000000000000400L

Definition at line 93 of file rz_bin.h.

◆ RZ_BIN_METH_CONSTRUCTOR

#define RZ_BIN_METH_CONSTRUCTOR   0x0000000000100000L

Definition at line 103 of file rz_bin.h.

◆ RZ_BIN_METH_DECLARED_SYNCHRONIZED

#define RZ_BIN_METH_DECLARED_SYNCHRONIZED   0x0000000000200000L

Definition at line 104 of file rz_bin.h.

◆ RZ_BIN_METH_FILEPRIVATE

#define RZ_BIN_METH_FILEPRIVATE   0x0000000000000080L

Definition at line 90 of file rz_bin.h.

◆ RZ_BIN_METH_FINAL

#define RZ_BIN_METH_FINAL   0x0000000000000100L

Definition at line 91 of file rz_bin.h.

◆ RZ_BIN_METH_INTERNAL

#define RZ_BIN_METH_INTERNAL   0x0000000000000020L

Definition at line 88 of file rz_bin.h.

◆ RZ_BIN_METH_MIRANDA

#define RZ_BIN_METH_MIRANDA   0x0000000000080000L

Definition at line 102 of file rz_bin.h.

◆ RZ_BIN_METH_MUTATING

#define RZ_BIN_METH_MUTATING   0x0000000000000800L

Definition at line 94 of file rz_bin.h.

◆ RZ_BIN_METH_NATIVE

#define RZ_BIN_METH_NATIVE   0x0000000000004000L

Definition at line 97 of file rz_bin.h.

◆ RZ_BIN_METH_OPEN

#define RZ_BIN_METH_OPEN   0x0000000000000040L

Definition at line 89 of file rz_bin.h.

◆ RZ_BIN_METH_PRIVATE

#define RZ_BIN_METH_PRIVATE   0x0000000000000008L

Definition at line 86 of file rz_bin.h.

◆ RZ_BIN_METH_PROTECTED

#define RZ_BIN_METH_PROTECTED   0x0000000000000010L

Definition at line 87 of file rz_bin.h.

◆ RZ_BIN_METH_PUBLIC

#define RZ_BIN_METH_PUBLIC   0x0000000000000004L

Definition at line 85 of file rz_bin.h.

◆ RZ_BIN_METH_STATIC

#define RZ_BIN_METH_STATIC   0x0000000000000002L

Definition at line 84 of file rz_bin.h.

◆ RZ_BIN_METH_STRICT

#define RZ_BIN_METH_STRICT   0x0000000000040000L

Definition at line 101 of file rz_bin.h.

◆ RZ_BIN_METH_SYNCHRONIZED

#define RZ_BIN_METH_SYNCHRONIZED   0x0000000000002000L

Definition at line 96 of file rz_bin.h.

◆ RZ_BIN_METH_SYNTHETIC

#define RZ_BIN_METH_SYNTHETIC   0x0000000000020000L

Definition at line 100 of file rz_bin.h.

◆ RZ_BIN_METH_VARARGS

#define RZ_BIN_METH_VARARGS   0x0000000000010000L

Definition at line 99 of file rz_bin.h.

◆ RZ_BIN_METH_VIRTUAL

#define RZ_BIN_METH_VIRTUAL   0x0000000000000200L

Definition at line 92 of file rz_bin.h.

◆ RZ_BIN_REQ_ALL

#define RZ_BIN_REQ_ALL   UT64_MAX

Definition at line 43 of file rz_bin.h.

◆ RZ_BIN_REQ_BASEFIND

#define RZ_BIN_REQ_BASEFIND   0x800000000

Definition at line 80 of file rz_bin.h.

◆ RZ_BIN_REQ_CLASSES

#define RZ_BIN_REQ_CLASSES   0x010000

Definition at line 61 of file rz_bin.h.

◆ RZ_BIN_REQ_CLASSES_SOURCES

#define RZ_BIN_REQ_CLASSES_SOURCES   0x400000000

Definition at line 79 of file rz_bin.h.

◆ RZ_BIN_REQ_CREATE

#define RZ_BIN_REQ_CREATE   0x008000

Definition at line 60 of file rz_bin.h.

◆ RZ_BIN_REQ_DLOPEN

#define RZ_BIN_REQ_DLOPEN   0x200000

Definition at line 66 of file rz_bin.h.

◆ RZ_BIN_REQ_DWARF

#define RZ_BIN_REQ_DWARF   0x020000

Definition at line 62 of file rz_bin.h.

◆ RZ_BIN_REQ_ENTRIES

#define RZ_BIN_REQ_ENTRIES   0x000001

Definition at line 45 of file rz_bin.h.

◆ RZ_BIN_REQ_EXPORTS

#define RZ_BIN_REQ_EXPORTS   0x400000

Definition at line 67 of file rz_bin.h.

◆ RZ_BIN_REQ_EXTRACT

#define RZ_BIN_REQ_EXTRACT   0x001000

Definition at line 57 of file rz_bin.h.

◆ RZ_BIN_REQ_FIELDS

#define RZ_BIN_REQ_FIELDS   0x000100

Definition at line 53 of file rz_bin.h.

◆ RZ_BIN_REQ_HASHES

#define RZ_BIN_REQ_HASHES   0x40000000

Definition at line 75 of file rz_bin.h.

◆ RZ_BIN_REQ_HEADER

#define RZ_BIN_REQ_HEADER   0x2000000

Definition at line 70 of file rz_bin.h.

◆ RZ_BIN_REQ_HELP

#define RZ_BIN_REQ_HELP   0x000040

Definition at line 51 of file rz_bin.h.

◆ RZ_BIN_REQ_IMPORTS

#define RZ_BIN_REQ_IMPORTS   0x000002

Definition at line 46 of file rz_bin.h.

◆ RZ_BIN_REQ_INFO

#define RZ_BIN_REQ_INFO   0x000010

Definition at line 49 of file rz_bin.h.

◆ RZ_BIN_REQ_INITFINI

#define RZ_BIN_REQ_INITFINI   0x10000000

Definition at line 73 of file rz_bin.h.

◆ RZ_BIN_REQ_LIBS

#define RZ_BIN_REQ_LIBS   0x000200

Definition at line 54 of file rz_bin.h.

◆ RZ_BIN_REQ_LISTARCHS

#define RZ_BIN_REQ_LISTARCHS   0x004000

Definition at line 59 of file rz_bin.h.

◆ RZ_BIN_REQ_LISTPLUGINS

#define RZ_BIN_REQ_LISTPLUGINS   0x4000000

Definition at line 71 of file rz_bin.h.

◆ RZ_BIN_REQ_MAIN

#define RZ_BIN_REQ_MAIN   0x000800

Definition at line 56 of file rz_bin.h.

◆ RZ_BIN_REQ_OPERATION

#define RZ_BIN_REQ_OPERATION   0x000020

Definition at line 50 of file rz_bin.h.

◆ RZ_BIN_REQ_PACKAGE

#define RZ_BIN_REQ_PACKAGE   0x1000000

Definition at line 69 of file rz_bin.h.

◆ RZ_BIN_REQ_PDB

#define RZ_BIN_REQ_PDB   0x080000

Definition at line 64 of file rz_bin.h.

◆ RZ_BIN_REQ_PDB_DWNLD

#define RZ_BIN_REQ_PDB_DWNLD   0x100000

Definition at line 65 of file rz_bin.h.

◆ RZ_BIN_REQ_RELOCS

#define RZ_BIN_REQ_RELOCS   0x002000

Definition at line 58 of file rz_bin.h.

◆ RZ_BIN_REQ_RESOURCES

#define RZ_BIN_REQ_RESOURCES   0x8000000

Definition at line 72 of file rz_bin.h.

◆ RZ_BIN_REQ_SECTIONS

#define RZ_BIN_REQ_SECTIONS   0x000008

Definition at line 48 of file rz_bin.h.

◆ RZ_BIN_REQ_SECTIONS_MAPPING

#define RZ_BIN_REQ_SECTIONS_MAPPING   0x200000000

Definition at line 78 of file rz_bin.h.

◆ RZ_BIN_REQ_SEGMENTS

#define RZ_BIN_REQ_SEGMENTS   0x20000000

Definition at line 74 of file rz_bin.h.

◆ RZ_BIN_REQ_SIGNATURE

#define RZ_BIN_REQ_SIGNATURE   0x80000000

Definition at line 76 of file rz_bin.h.

◆ RZ_BIN_REQ_SIZE

#define RZ_BIN_REQ_SIZE   0x040000

Definition at line 63 of file rz_bin.h.

◆ RZ_BIN_REQ_SRCLINE

#define RZ_BIN_REQ_SRCLINE   0x000400

Definition at line 55 of file rz_bin.h.

◆ RZ_BIN_REQ_STRINGS

#define RZ_BIN_REQ_STRINGS   0x000080

Definition at line 52 of file rz_bin.h.

◆ RZ_BIN_REQ_SYMBOLS

#define RZ_BIN_REQ_SYMBOLS   0x000004

Definition at line 47 of file rz_bin.h.

◆ RZ_BIN_REQ_TRYCATCH

#define RZ_BIN_REQ_TRYCATCH   0x100000000

Definition at line 77 of file rz_bin.h.

◆ RZ_BIN_REQ_UNK

#define RZ_BIN_REQ_UNK   0x000000

Definition at line 44 of file rz_bin.h.

◆ RZ_BIN_REQ_VERSIONINFO

#define RZ_BIN_REQ_VERSIONINFO   0x800000

Definition at line 68 of file rz_bin.h.

◆ RZ_BIN_SIZEOF_STRINGS

#define RZ_BIN_SIZEOF_STRINGS   512

Definition at line 40 of file rz_bin.h.

◆ RZ_BIN_TYPE_COMMON_STR

#define RZ_BIN_TYPE_COMMON_STR   "COMMON"

Definition at line 126 of file rz_bin.h.

◆ RZ_BIN_TYPE_FIELD_STR

#define RZ_BIN_TYPE_FIELD_STR   "FIELD"

Definition at line 120 of file rz_bin.h.

◆ RZ_BIN_TYPE_FILE_STR

#define RZ_BIN_TYPE_FILE_STR   "FILE"

Definition at line 125 of file rz_bin.h.

◆ RZ_BIN_TYPE_FUNC_STR

#define RZ_BIN_TYPE_FUNC_STR   "FUNC"

Definition at line 119 of file rz_bin.h.

◆ RZ_BIN_TYPE_HIOS_STR

#define RZ_BIN_TYPE_HIOS_STR   "HIOS"

Definition at line 130 of file rz_bin.h.

◆ RZ_BIN_TYPE_HIPROC_STR

#define RZ_BIN_TYPE_HIPROC_STR   "HIPROC"

Definition at line 132 of file rz_bin.h.

◆ RZ_BIN_TYPE_IFACE_STR

#define RZ_BIN_TYPE_IFACE_STR   "IFACE"

Definition at line 121 of file rz_bin.h.

◆ RZ_BIN_TYPE_LOOS_STR

#define RZ_BIN_TYPE_LOOS_STR   "LOOS"

Definition at line 129 of file rz_bin.h.

◆ RZ_BIN_TYPE_LOPROC_STR

#define RZ_BIN_TYPE_LOPROC_STR   "LOPROC"

Definition at line 131 of file rz_bin.h.

◆ RZ_BIN_TYPE_METH_STR

#define RZ_BIN_TYPE_METH_STR   "METH"

Definition at line 122 of file rz_bin.h.

◆ RZ_BIN_TYPE_NOTYPE_STR

#define RZ_BIN_TYPE_NOTYPE_STR   "NOTYPE"

Definition at line 117 of file rz_bin.h.

◆ RZ_BIN_TYPE_NUM_STR

#define RZ_BIN_TYPE_NUM_STR   "NUM"

Definition at line 128 of file rz_bin.h.

◆ RZ_BIN_TYPE_OBJECT_STR

#define RZ_BIN_TYPE_OBJECT_STR   "OBJ"

Definition at line 118 of file rz_bin.h.

◆ RZ_BIN_TYPE_SECTION_STR

#define RZ_BIN_TYPE_SECTION_STR   "SECT"

Definition at line 124 of file rz_bin.h.

◆ RZ_BIN_TYPE_SPECIAL_SYM_STR

#define RZ_BIN_TYPE_SPECIAL_SYM_STR   "SPCL"

Definition at line 133 of file rz_bin.h.

◆ RZ_BIN_TYPE_STATIC_STR

#define RZ_BIN_TYPE_STATIC_STR   "STATIC"

Definition at line 123 of file rz_bin.h.

◆ RZ_BIN_TYPE_TLS_STR

#define RZ_BIN_TYPE_TLS_STR   "TLS"

Definition at line 127 of file rz_bin.h.

◆ RZ_BIN_TYPE_UNKNOWN_STR

#define RZ_BIN_TYPE_UNKNOWN_STR   "UNK"

Definition at line 134 of file rz_bin.h.

◆ RzBinSectionName

#define RzBinSectionName   rz_offsetof(RzBinSection, name)

Definition at line 659 of file rz_bin.h.

◆ RzBinSectionOffset

#define RzBinSectionOffset   rz_offsetof(RzBinSection, offset)

Definition at line 660 of file rz_bin.h.

Typedef Documentation

◆ FREE_XTR

typedef int(* FREE_XTR) (void *xtr_obj)

Definition at line 377 of file rz_bin.h.

◆ RzBin

typedef struct rz_bin_t RzBin

Definition at line 1 of file rz_bin.h.

◆ RzBinAddr

typedef struct rz_bin_addr_t RzBinAddr

◆ RzBinArchOptions

◆ RzBinBind

typedef struct rz_bin_bind_t RzBinBind

◆ RzBinClass

typedef struct rz_bin_class_t RzBinClass

◆ RzBinDemangle

typedef char*(* RzBinDemangle) (RzBinFile *bf, const char *def, const char *str, ut64 vaddr, bool libs)

Definition at line 804 of file rz_bin.h.

◆ RzBinField

typedef struct rz_bin_field_t RzBinField

◆ RzBinFile

typedef struct rz_bin_file_t RzBinFile

Definition at line 1 of file rz_bin.h.

◆ RzBinFileHash

◆ RzBinFileOptions

◆ RzBinGetName

typedef char*(* RzBinGetName) (RzBin *bin, int type, int idx)

Definition at line 801 of file rz_bin.h.

◆ RzBinGetOffset

typedef ut64(* RzBinGetOffset) (RzBin *bin, int type, int idx)

Definition at line 800 of file rz_bin.h.

◆ RzBinGetSectionAt

typedef RzBinSection*(* RzBinGetSectionAt) (RzBin *bin, ut64 addr)

Definition at line 803 of file rz_bin.h.

◆ RzBinGetSections

typedef RzList*(* RzBinGetSections) (RzBin *bin)

Definition at line 802 of file rz_bin.h.

◆ RzBinHash

typedef struct rz_bin_hash_t RzBinHash

◆ RzBinImport

typedef struct rz_bin_import_t RzBinImport

◆ RzBinInfo

typedef struct rz_bin_info_t RzBinInfo

◆ RzBinMap

typedef struct rz_bin_map_t RzBinMap

Description of a single memory mapping into virtual memory from a binary.

◆ RzBinMem

typedef struct rz_bin_mem_t RzBinMem

◆ RzBinObject

typedef struct rz_bin_object_t RzBinObject

◆ RzBinObjectLoadOptions

◆ RzBinPlugin

typedef struct rz_bin_plugin_t RzBinPlugin

◆ RzBinReloc

typedef struct rz_bin_reloc_t RzBinReloc

◆ RzBinRelocStorage

Definition at line 1 of file rz_bin.h.

◆ RzBinResource

◆ RzBinSection

◆ RzBinSectionMap

Structure to associate a segment with the list of sections that fall in that segment.

◆ RzBinSourceLineInfo

Definition at line 1 of file rz_bin.h.

◆ RzBinSourceLineInfoBuilder

Temporary data structure for building an RzBinSourceLineInfo.

◆ RzBinSourceLineSample

A single sample of source line info for a specific address.

If at least one of the line, column and file members is not 0/NULL, such a sample specifies the line info for all addresses greater or equal to address until the next address that has another sample.

If all the members line, column and file are 0/NULL, then this is a closing sample, indicating that the previous entry stops here. The address is the first address not contained by the previous record. Such a case corresponds for example to what DW_LNE_end_sequence emits in Dwarf. Use rz_bin_source_line_sample_is_closing() for checking if a sample is closing.

◆ RzBinStrDb

Definition at line 25 of file rz_bin.h.

◆ RzBinString

typedef struct rz_bin_string_t RzBinString

◆ RzBinSymbol

typedef struct rz_bin_symbol_t RzBinSymbol

◆ RzBinSymbollCallback

typedef void(* RzBinSymbollCallback) (RzBinObject *obj, void *symbol)

Definition at line 561 of file rz_bin.h.

◆ RzBinTrycatch

◆ RzBinVirtualFile

A virtual file is a binary buffer, exposed by a bin plugin for a loaded file. These virtual files can be used whenever data that is related to the file but not directly represented-as is in the raw file should be mapped into the virtual address space. Common examples for this include compressed segments or patching relocations. The idea is that the bin plugin exposes virtual files and then refers to them in the RzBinMap it returns.

For example, when there is a binary format that contains a compressed segment called "text", the bin plugin would create a virtual file:

   RzBinVirtualFile {
     .name = "text_decompressed",
     .buf = rz_buf_new_with_bytes(<decompressed bytes>, <decompressed size>),
     ...
   }

which it can then use for mapping by referring to its exact name:

RzBinMap {
  .vsize = <decompressed size>,
  .name = "text",
  .vfile_name = "text_decompressed",
  ...
}

When RzBin is used as part of RzCore, these virtual files can be opened as RzIO files using an URI like vfile://<binfile id>/<filename>. By default, RzCore sets everything up automatically though so it is rather rare that one has to manually work with these URIs.

◆ RzBinXtrData

◆ RzBinXtrMetadata

◆ RzBinXtrPlugin

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
RZ_BIN_CLASS_PRIVATE 
RZ_BIN_CLASS_PUBLIC 
RZ_BIN_CLASS_FRIENDLY 
RZ_BIN_CLASS_PROTECTED 

Definition at line 165 of file rz_bin.h.

165  {
170 };
@ RZ_BIN_CLASS_PUBLIC
Definition: rz_bin.h:167
@ RZ_BIN_CLASS_FRIENDLY
Definition: rz_bin.h:168
@ RZ_BIN_CLASS_PROTECTED
Definition: rz_bin.h:169
@ RZ_BIN_CLASS_PRIVATE
Definition: rz_bin.h:166

◆ anonymous enum

anonymous enum
Enumerator
RZ_BIN_TYPE_DEFAULT 
RZ_BIN_TYPE_CORE 

Definition at line 180 of file rz_bin.h.

180  {
182  RZ_BIN_TYPE_CORE = 1
183 };
@ RZ_BIN_TYPE_DEFAULT
Definition: rz_bin.h:181
@ RZ_BIN_TYPE_CORE
Definition: rz_bin.h:182

◆ RzBinLanguage

Enumerator
RZ_BIN_LANGUAGE_UNKNOWN 
RZ_BIN_LANGUAGE_JAVA 
RZ_BIN_LANGUAGE_C 
RZ_BIN_LANGUAGE_GO 
RZ_BIN_LANGUAGE_CXX 
RZ_BIN_LANGUAGE_OBJC 
RZ_BIN_LANGUAGE_SWIFT 
RZ_BIN_LANGUAGE_DLANG 
RZ_BIN_LANGUAGE_MSVC 
RZ_BIN_LANGUAGE_RUST 
RZ_BIN_LANGUAGE_KOTLIN 
RZ_BIN_LANGUAGE_GROOVY 
RZ_BIN_LANGUAGE_DART 
RZ_BIN_LANGUAGE_BLOCKS 

Definition at line 145 of file rz_bin.h.

145  {
148  RZ_BIN_LANGUAGE_C = 1 << 1,
149  RZ_BIN_LANGUAGE_GO = 1 << 2,
150  RZ_BIN_LANGUAGE_CXX = 1 << 3,
151  RZ_BIN_LANGUAGE_OBJC = 1 << 4,
152  RZ_BIN_LANGUAGE_SWIFT = 1 << 5,
153  RZ_BIN_LANGUAGE_DLANG = 1 << 6,
154  RZ_BIN_LANGUAGE_MSVC = 1 << 7,
155  RZ_BIN_LANGUAGE_RUST = 1 << 8,
156  RZ_BIN_LANGUAGE_KOTLIN = 1 << 9,
157  RZ_BIN_LANGUAGE_GROOVY = 1 << 10,
158  RZ_BIN_LANGUAGE_DART = 1 << 11,
159  RZ_BIN_LANGUAGE_BLOCKS = 1 << 31,
160 } RzBinLanguage;
RzBinLanguage
Definition: rz_bin.h:145
@ RZ_BIN_LANGUAGE_UNKNOWN
Definition: rz_bin.h:146
@ RZ_BIN_LANGUAGE_GROOVY
Definition: rz_bin.h:157
@ RZ_BIN_LANGUAGE_OBJC
Definition: rz_bin.h:151
@ RZ_BIN_LANGUAGE_KOTLIN
Definition: rz_bin.h:156
@ RZ_BIN_LANGUAGE_RUST
Definition: rz_bin.h:155
@ RZ_BIN_LANGUAGE_DLANG
Definition: rz_bin.h:153
@ RZ_BIN_LANGUAGE_C
Definition: rz_bin.h:148
@ RZ_BIN_LANGUAGE_JAVA
Definition: rz_bin.h:147
@ RZ_BIN_LANGUAGE_DART
Definition: rz_bin.h:158
@ RZ_BIN_LANGUAGE_CXX
Definition: rz_bin.h:150
@ RZ_BIN_LANGUAGE_SWIFT
Definition: rz_bin.h:152
@ RZ_BIN_LANGUAGE_MSVC
Definition: rz_bin.h:154
@ RZ_BIN_LANGUAGE_GO
Definition: rz_bin.h:149
@ RZ_BIN_LANGUAGE_BLOCKS
Definition: rz_bin.h:159

◆ RzBinRelocType

Enumerator
RZ_BIN_RELOC_8 
RZ_BIN_RELOC_16 
RZ_BIN_RELOC_24 
RZ_BIN_RELOC_32 
RZ_BIN_RELOC_64 

Definition at line 172 of file rz_bin.h.

172  {
173  RZ_BIN_RELOC_8 = 8,
174  RZ_BIN_RELOC_16 = 16,
175  RZ_BIN_RELOC_24 = 24,
176  RZ_BIN_RELOC_32 = 32,
177  RZ_BIN_RELOC_64 = 64
RzBinRelocType
Definition: rz_bin.h:172
@ RZ_BIN_RELOC_32
Definition: rz_bin.h:176
@ RZ_BIN_RELOC_24
Definition: rz_bin.h:175
@ RZ_BIN_RELOC_16
Definition: rz_bin.h:174
@ RZ_BIN_RELOC_64
Definition: rz_bin.h:177
@ RZ_BIN_RELOC_8
Definition: rz_bin.h:173

◆ RzBinSpecialSymbol

Enumerator
RZ_BIN_SPECIAL_SYMBOL_ENTRY 
RZ_BIN_SPECIAL_SYMBOL_INIT 
RZ_BIN_SPECIAL_SYMBOL_MAIN 
RZ_BIN_SPECIAL_SYMBOL_FINI 
RZ_BIN_SPECIAL_SYMBOL_LAST 

Definition at line 136 of file rz_bin.h.

136  {
RzBinSpecialSymbol
Definition: rz_bin.h:136
@ RZ_BIN_SPECIAL_SYMBOL_FINI
Definition: rz_bin.h:140
@ RZ_BIN_SPECIAL_SYMBOL_ENTRY
Definition: rz_bin.h:137
@ RZ_BIN_SPECIAL_SYMBOL_LAST
Definition: rz_bin.h:141
@ RZ_BIN_SPECIAL_SYMBOL_INIT
Definition: rz_bin.h:138
@ RZ_BIN_SPECIAL_SYMBOL_MAIN
Definition: rz_bin.h:139

Function Documentation

◆ rz_bin_field_free()

RZ_API void rz_bin_field_free ( RzBinField field)

Definition at line 950 of file bin.c.

950  {
951  if (field) {
952  free(field->name);
953  free(field->visibility_str);
954  free(field->type);
955  free(field->comment);
956  free(field->format);
957  free(field);
958  }
959 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
char * comment
Definition: rz_bin.h:770
char * format
Definition: rz_bin.h:771
char * name
Definition: rz_bin.h:767
char * type
Definition: rz_bin.h:768
char * visibility_str
Definition: rz_bin.h:769

References rz_bin_field_t::comment, rz_bin_field_t::format, free(), rz_bin_field_t::name, rz_bin_field_t::type, and rz_bin_field_t::visibility_str.

Referenced by dex_resolve_fields_in_class(), fields(), get_ivar_list_t(), MACH0_(), rz_bin_dex_fields(), and rz_bin_java_class_fields_as_binfields().

◆ rz_bin_field_new()

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 
)

Definition at line 935 of file bin.c.

935  {
936  RzBinField *ptr = RZ_NEW0(RzBinField);
937  if (ptr) {
938  ptr->name = strdup(name);
939  ptr->comment = (comment && *comment) ? strdup(comment) : NULL;
940  ptr->format = (format && *format) ? strdup(format) : NULL;
941  ptr->format_named = format_named;
942  ptr->paddr = paddr;
943  ptr->size = size;
944  // ptr->visibility = any default visibility?
945  ptr->vaddr = vaddr;
946  }
947  return ptr;
948 }
#define NULL
Definition: cris-opc.c:27
voidpf void uLong size
Definition: ioapi.h:138
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_NEW0(x)
Definition: rz_types.h:284
Definition: z80asm.h:102
ut64 vaddr
Definition: rz_bin.h:762
ut64 paddr
Definition: rz_bin.h:763
bool format_named
Definition: rz_bin.h:772

References rz_bin_field_t::comment, rz_bin_field_t::format, rz_bin_field_t::format_named, rz_bin_field_t::name, NULL, rz_bin_field_t::paddr, RZ_NEW0, rz_bin_field_t::size, strdup(), and rz_bin_field_t::vaddr.

Referenced by classes_from_symbols(), fields(), MACH0_(), and rz_bin_java_class_fields_as_binfields().

◆ rz_bin_import_free()

RZ_API void rz_bin_import_free ( RzBinImport imp)

Definition at line 137 of file bin.c.

137  {
138  if (imp) {
139  RZ_FREE(imp->name);
140  RZ_FREE(imp->libname);
141  RZ_FREE(imp->classname);
142  RZ_FREE(imp->descriptor);
143  free(imp);
144  }
145 }
#define RZ_FREE(x)
Definition: rz_types.h:369
char * libname
Definition: rz_bin.h:702
char * descriptor
Definition: rz_bin.h:706
char * name
Definition: rz_bin.h:701
char * classname
Definition: rz_bin.h:705

References rz_bin_import_t::classname, rz_bin_import_t::descriptor, free(), rz_bin_import_t::libname, rz_bin_import_t::name, and RZ_FREE.

Referenced by imports(), load_buffer(), rz_bin_dex_imports(), rz_bin_java_class_const_pool_as_imports(), rz_bin_le_get_imports(), rz_bin_le_get_relocs(), and rz_bin_ne_get_imports().

◆ rz_bin_info_free()

RZ_API void rz_bin_info_free ( RzBinInfo rb)

Definition at line 97 of file bin.c.

97  {
98  if (!rb) {
99  return;
100  }
101 
103  free(rb->intrp);
104  free(rb->file);
105  free(rb->type);
106  free(rb->bclass);
107  free(rb->rclass);
108  free(rb->arch);
109  free(rb->cpu);
110  free(rb->machine);
111  free(rb->os);
112  free(rb->features);
113  free(rb->subsystem);
114  free(rb->default_cc);
115  free(rb->rpath);
116  free(rb->guid);
117  free(rb->debug_file_name);
118  free(rb->actual_checksum);
119  free(rb->claimed_checksum);
120  free(rb->compiler);
121  free(rb->head_flag);
122  free(rb);
123 }
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
char * claimed_checksum
Definition: rz_bin.h:237
char * type
Definition: rz_bin.h:211
RzList * file_hashes
Definition: rz_bin.h:226
char * intrp
Definition: rz_bin.h:243
char * default_cc
Definition: rz_bin.h:225
char * os
Definition: rz_bin.h:219
char * head_flag
Definition: rz_bin.h:217
char * subsystem
Definition: rz_bin.h:220
char * machine
Definition: rz_bin.h:216
char * bclass
Definition: rz_bin.h:212
char * guid
Definition: rz_bin.h:222
char * file
Definition: rz_bin.h:210
char * debug_file_name
Definition: rz_bin.h:223
char * features
Definition: rz_bin.h:218
char * rpath
Definition: rz_bin.h:221
char * cpu
Definition: rz_bin.h:215
char * actual_checksum
Definition: rz_bin.h:236
char * rclass
Definition: rz_bin.h:213
char * arch
Definition: rz_bin.h:214
char * compiler
Definition: rz_bin.h:244

References rz_bin_info_t::actual_checksum, rz_bin_info_t::arch, rz_bin_info_t::bclass, rz_bin_info_t::claimed_checksum, rz_bin_info_t::compiler, rz_bin_info_t::cpu, rz_bin_info_t::debug_file_name, rz_bin_info_t::default_cc, rz_bin_info_t::features, rz_bin_info_t::file, rz_bin_info_t::file_hashes, free(), rz_bin_info_t::guid, rz_bin_info_t::head_flag, rz_bin_info_t::intrp, rz_bin_info_t::machine, rz_bin_info_t::os, rz_bin_info_t::rclass, rz_bin_info_t::rpath, rz_list_free(), rz_bin_info_t::subsystem, and rz_bin_info_t::type.

Referenced by load_buffer(), rz_bin_object_free(), and rz_core_bin_load().

◆ rz_bin_map_free()

RZ_API void rz_bin_map_free ( RzBinMap map)

Definition at line 1023 of file bin.c.

1023  {
1024  if (!map) {
1025  return;
1026  }
1027  free(map->vfile_name);
1028  free(map->name);
1029  free(map);
1030 }
size_t map(int syms, int left, int len)
Definition: enough.c:237

References free(), and map().

Referenced by get_maps_unpatched(), load_buffer(), maps(), and rz_bin_maps_of_file_sections().

◆ rz_bin_maps_of_file_sections()

RZ_API RZ_OWN RzList* rz_bin_maps_of_file_sections ( RZ_NONNULL RzBinFile binfile)

Create a list of RzBinMap from RzBinSections queried from the given file.

Some binary formats have a 1:1 correspondence of mapping and their RzBinSections. This is not always the case (e.g. ELF) but if it is, plugins can use this function as their maps callback, which will generate mappings for sections.

Definition at line 1040 of file bin.c.

1040  {
1041  rz_return_val_if_fail(binfile, NULL);
1042  if (!binfile->o || !binfile->o->plugin || !binfile->o->plugin->sections) {
1043  return NULL;
1044  }
1045  RzList *sections = binfile->o->plugin->sections(binfile);
1046  if (!sections) {
1047  return NULL;
1048  }
1050  if (!r) {
1051  goto hcf;
1052  }
1053  RzBinSection *sec;
1054  RzListIter *it;
1055  rz_list_foreach (sections, it, sec) {
1057  if (!map) {
1058  goto hcf;
1059  }
1060  map->name = sec->name ? strdup(sec->name) : NULL;
1061  map->paddr = sec->paddr;
1062  map->psize = sec->size;
1063  map->vaddr = sec->vaddr;
1064  map->vsize = sec->vsize;
1065  map->perm = sec->perm;
1066  rz_list_push(r, map);
1067  }
1068 hcf:
1070  return r;
1071 }
RZ_API void rz_bin_map_free(RzBinMap *map)
Definition: bin.c:1023
RzList * sections(RzBinFile *bf)
Definition: bin_ne.c:110
#define r
Definition: crypto_rc6.c:12
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
Definition: list.c:60
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
Description of a single memory mapping into virtual memory from a binary.
Definition: rz_bin.h:602
char * name
Definition: rz_bin.h:619

References map(), rz_bin_section_t::name, NULL, rz_bin_section_t::paddr, rz_bin_section_t::perm, r, rz_bin_map_free(), rz_list_free(), rz_list_newf(), rz_list_push(), RZ_NEW0, rz_return_val_if_fail, sections(), rz_bin_section_t::size, strdup(), rz_bin_section_t::vaddr, and rz_bin_section_t::vsize.

Referenced by maps().

◆ rz_bin_reloc_free()

RZ_API void rz_bin_reloc_free ( RzBinReloc reloc)

Definition at line 188 of file bin.c.

188  {
189  free(reloc);
190 }

References free().

Referenced by rz_bin_le_get_relocs(), and rz_bin_reloc_storage_free().

◆ rz_bin_reloc_has_target()

static bool rz_bin_reloc_has_target ( RzBinReloc reloc)
inlinestatic

Definition at line 828 of file rz_bin.h.

828  {
829  return reloc->target_vaddr && reloc->target_vaddr != UT64_MAX;
830 }
#define UT64_MAX
Definition: rz_types_base.h:86
ut64 target_vaddr
the target address that the patched reloc points to
Definition: rz_bin.h:718

References rz_bin_reloc_t::target_vaddr, and UT64_MAX.

Referenced by rz_bin_reloc_storage_new(), rz_core_bin_apply_relocs(), rz_core_bin_relocs_print(), and set_bin_relocs().

◆ rz_bin_reloc_size()

RZ_API ut64 rz_bin_reloc_size ( RzBinReloc reloc)

size of the reloc (where it is supposed to be patched) in bits

Definition at line 60 of file bobj.c.

60  {
61  switch (reloc->type) {
62  case RZ_BIN_RELOC_8:
63  return 8;
64  case RZ_BIN_RELOC_16:
65  return 16;
66  case RZ_BIN_RELOC_24:
67  return 24;
68  case RZ_BIN_RELOC_32:
69  return 32;
70  case RZ_BIN_RELOC_64:
71  return 64;
72  }
73  return 0;
74 }
RzBinRelocType type
Definition: rz_bin.h:712

References RZ_BIN_RELOC_16, RZ_BIN_RELOC_24, RZ_BIN_RELOC_32, RZ_BIN_RELOC_64, RZ_BIN_RELOC_8, and rz_bin_reloc_t::type.

Referenced by meta_for_reloc().

◆ rz_bin_reloc_storage_free()

RZ_API void rz_bin_reloc_storage_free ( RzBinRelocStorage storage)

Definition at line 137 of file bobj.c.

137  {
138  if (!storage) {
139  return;
140  }
141  for (size_t i = 0; i < storage->relocs_count; i++) {
142  rz_bin_reloc_free(storage->relocs[i]);
143  }
144  free(storage->relocs);
145  free(storage->target_relocs);
146  free(storage);
147 }
lzma_index ** i
Definition: index.h:629
RZ_API void rz_bin_reloc_free(RzBinReloc *reloc)
Definition: bin.c:188
RzBinReloc ** target_relocs
all relocs that have a valid target_vaddr, ordered by their target_vaddr. size is target_relocs_count...
Definition: rz_bin.h:735
RzBinReloc ** relocs
all relocs, ordered by their vaddr
Definition: rz_bin.h:733

References free(), i, rz_bin_reloc_storage_t::relocs, rz_bin_reloc_storage_t::relocs_count, rz_bin_reloc_free(), and rz_bin_reloc_storage_t::target_relocs.

Referenced by rz_bin_object_free(), and rz_bin_object_patch_relocs().

◆ rz_bin_reloc_storage_get_reloc_in()

RZ_API RzBinReloc* rz_bin_reloc_storage_get_reloc_in ( RzBinRelocStorage storage,
ut64  vaddr,
ut64  size 
)

Get the reloc with the lowest vaddr that starts inside the given interval.

Definition at line 154 of file bobj.c.

154  {
155  rz_return_val_if_fail(storage && size >= 1, NULL);
156  if (!storage->relocs) {
157  return NULL;
158  }
159  size_t i;
160  rz_array_lower_bound(storage->relocs, storage->relocs_count, vaddr, i, reloc_vaddr_cmp);
161  if (i >= storage->relocs_count) {
162  return NULL;
163  }
164  RzBinReloc *r = storage->relocs[i];
165  return r->vaddr >= vaddr && r->vaddr < vaddr + size ? r : NULL;
166 }
static int reloc_vaddr_cmp(ut64 ref, RzBinReloc *reloc)
Definition: bobj.c:149
#define rz_array_lower_bound(array, len, x, i, cmp)
Definition: rz_vector.h:351

References i, NULL, r, reloc_vaddr_cmp(), rz_bin_reloc_storage_t::relocs, rz_bin_reloc_storage_t::relocs_count, rz_array_lower_bound, and rz_return_val_if_fail.

Referenced by rz_core_getreloc().

◆ rz_bin_reloc_storage_get_reloc_to()

RZ_API RzBinReloc* rz_bin_reloc_storage_get_reloc_to ( RzBinRelocStorage storage,
ut64  vaddr 
)

Get a reloc that points exactly to vaddr or NULL.

Definition at line 173 of file bobj.c.

173  {
174  rz_return_val_if_fail(storage, NULL);
175  if (!storage->target_relocs) {
176  return NULL;
177  }
178  size_t i;
180  if (!i) {
181  return NULL;
182  }
183  i--;
184  RzBinReloc *r = storage->target_relocs[i];
185  return r->target_vaddr == vaddr ? r : NULL;
186 }
static int reloc_target_vaddr_cmp(ut64 ref, RzBinReloc *reloc)
Definition: bobj.c:168
#define rz_array_upper_bound(array, len, x, i, cmp)
Definition: rz_vector.h:374
size_t target_relocs_count
Definition: rz_bin.h:736

References i, NULL, r, reloc_target_vaddr_cmp(), rz_array_upper_bound, rz_return_val_if_fail, rz_bin_reloc_storage_t::target_relocs, and rz_bin_reloc_storage_t::target_relocs_count.

Referenced by rz_core_get_reloc_to().

◆ rz_bin_reloc_storage_new()

RZ_API RzBinRelocStorage* rz_bin_reloc_storage_new ( RZ_OWN RzList relocs)

Definition at line 105 of file bobj.c.

105  {
107  if (!ret) {
108  return NULL;
109  }
110  RzPVector sorter;
111  rz_pvector_init(&sorter, NULL);
113  RzPVector target_sorter;
114  rz_pvector_init(&target_sorter, NULL);
115  rz_pvector_reserve(&target_sorter, rz_list_length(relocs));
116  RzListIter *it;
117  RzBinReloc *reloc;
118  rz_list_foreach (relocs, it, reloc) {
119  rz_pvector_push(&sorter, reloc);
120  if (rz_bin_reloc_has_target(reloc)) {
121  rz_pvector_push(&target_sorter, reloc);
122  }
123  }
124  relocs->free = NULL; // ownership of relocs transferred
126  rz_pvector_sort(&sorter, reloc_cmp);
127  ret->relocs_count = rz_pvector_len(&sorter);
128  ret->relocs = (RzBinReloc **)rz_pvector_flush(&sorter);
129  rz_pvector_fini(&sorter);
130  rz_pvector_sort(&target_sorter, reloc_target_cmp);
131  ret->target_relocs_count = rz_pvector_len(&target_sorter);
132  ret->target_relocs = (RzBinReloc **)rz_pvector_flush(&target_sorter);
133  rz_pvector_fini(&target_sorter);
134  return ret;
135 }
RzList * relocs(RzBinFile *bf)
Definition: bin_ne.c:114
static int reloc_cmp(const void *a, const void *b)
Definition: bobj.c:83
static int reloc_target_cmp(const void *a, const void *b)
Definition: bobj.c:93
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
Definition: list.c:109
static bool rz_bin_reloc_has_target(RzBinReloc *reloc)
Definition: rz_bin.h:828
static void ** rz_pvector_reserve(RzPVector *vec, size_t capacity)
Definition: rz_vector.h:312
RZ_API void rz_pvector_sort(RzPVector *vec, RzPVectorComparator cmp)
Definition: vector.c:408
RZ_API void rz_pvector_init(RzPVector *vec, RzPVectorFree free)
Definition: vector.c:298
RZ_API void rz_pvector_fini(RzPVector *vec)
Definition: vector.c:331
static size_t rz_pvector_len(const RzPVector *vec)
Definition: rz_vector.h:231
static void ** rz_pvector_push(RzPVector *vec, void *x)
Definition: rz_vector.h:300
static void ** rz_pvector_flush(RzPVector *vec)
Definition: rz_vector.h:320
Efficient storage of relocations to query by address.
Definition: rz_bin.h:732
RzListFree free
Definition: rz_list.h:21

References rz_list_t::free, NULL, reloc_cmp(), reloc_target_cmp(), relocs(), rz_bin_reloc_storage_t::relocs, rz_bin_reloc_storage_t::relocs_count, rz_bin_reloc_has_target(), rz_list_free(), rz_list_length(), RZ_NEW0, rz_pvector_fini(), rz_pvector_flush(), rz_pvector_init(), rz_pvector_len(), rz_pvector_push(), rz_pvector_reserve(), rz_pvector_sort(), rz_bin_reloc_storage_t::target_relocs, and rz_bin_reloc_storage_t::target_relocs_count.

Referenced by rz_bin_object_patch_relocs(), and rz_bin_object_set_items().

◆ rz_bin_reloc_storage_targets_available()

static bool rz_bin_reloc_storage_targets_available ( RzBinRelocStorage storage)
inlinestatic

return true iff there is at least one reloc in the storage with a target address

Definition at line 744 of file rz_bin.h.

744  {
745  return storage->target_relocs_count != 0;
746 }

References rz_bin_reloc_storage_t::target_relocs_count.

Referenced by rz_core_bin_relocs_print().

◆ rz_bin_resource_free()

RZ_API void rz_bin_resource_free ( RzBinResource res)

Definition at line 147 of file bin.c.

147  {
148  if (!res) {
149  return;
150  }
151  RZ_FREE(res->name);
152  RZ_FREE(res->time);
153  RZ_FREE(res->type);
154  RZ_FREE(res->language);
155  free(res);
156 }
char * language
Definition: rz_bin.h:794

References free(), rz_bin_resource_t::language, rz_bin_resource_t::name, RZ_FREE, rz_bin_resource_t::time, and rz_bin_resource_t::type.

◆ rz_bin_section_flag_to_list()

RZ_API RZ_OWN RzList* rz_bin_section_flag_to_list ( RzBin bin,
ut64  flag 
)

Converts the RzBinSection flags to a list of string representations.

Some binary formats have a function interface called "section_flag_to_rzlist" The returned string flag names are different between formats

Parameters
binRzBin instance
flagA flag field of the RzBinSection (differs between formats)

Definition at line 1151 of file bin.c.

1151  {
1152  RzBinFile *a = rz_bin_cur(bin);
1154  if (plugin && plugin->section_flag_to_rzlist) {
1155  return plugin->section_flag_to_rzlist(flag);
1156  }
1157  return NULL;
1158 }
RZ_API RzBinPlugin * rz_bin_file_cur_plugin(RzBinFile *bf)
Definition: bfile.c:348
RZ_API RzBinFile * rz_bin_cur(RzBin *bin)
Definition: bin.c:895
#define a(i)
Definition: sha256.c:41
Definition: malloc.c:26
XX curplugin == o->plugin.
Definition: rz_bin.h:298
RzList *(* section_flag_to_rzlist)(ut64 flag)
Definition: rz_bin.h:550

References a, NULL, rz_bin_cur(), rz_bin_file_cur_plugin(), and rz_bin_plugin_t::section_flag_to_rzlist.

Referenced by sections_print_json(), and sections_print_table().

◆ rz_bin_section_free()

RZ_API void rz_bin_section_free ( RzBinSection bs)

Definition at line 1116 of file bin.c.

1116  {
1117  if (bs) {
1118  free(bs->name);
1119  free(bs->format);
1120  free(bs);
1121  }
1122 }
char * format
Definition: rz_bin.h:630

References rz_bin_section_t::format, free(), and rz_bin_section_t::name.

Referenced by get_segments(), load_buffer(), rz_bin_dex_sections(), rz_bin_le_get_sections(), rz_bin_mz_get_segments(), rz_bin_ne_get_segments(), rz_bin_sections_of_maps(), section_free(), and sections().

◆ rz_bin_section_new()

RZ_API RzBinSection* rz_bin_section_new ( const char *  name)

Definition at line 1108 of file bin.c.

1108  {
1110  if (s) {
1111  s->name = name ? strdup(name) : NULL;
1112  }
1113  return s;
1114 }
static RzSocket * s
Definition: rtr.c:28

References NULL, RZ_NEW0, s, and strdup().

Referenced by get_segments().

◆ rz_bin_section_type_to_string()

RZ_API RZ_OWN char* rz_bin_section_type_to_string ( RzBin bin,
int  type 
)

Converts the RzBinSection type to the string representation.

Some binary formats have a function interface called "section_type_to_string" The returned string type name is different between formats

Parameters
binRzBin instance
typeA type field of the RzBinSection (differs between formats)

Definition at line 1133 of file bin.c.

1133  {
1134  RzBinFile *a = rz_bin_cur(bin);
1136  if (plugin && plugin->section_type_to_string) {
1137  return plugin->section_type_to_string(type);
1138  }
1139  return NULL;
1140 }
int type
Definition: mipsasm.c:17
char *(* section_type_to_string)(ut64 type)
Definition: rz_bin.h:549

References a, NULL, rz_bin_cur(), rz_bin_file_cur_plugin(), rz_bin_plugin_t::section_type_to_string, and type.

Referenced by sections_print_json(), and sections_print_table().

◆ rz_bin_sections_of_maps()

RZ_API RzList* rz_bin_sections_of_maps ( RzList maps)

Create a list of RzBinSection from RzBinMaps.

Some binary formats have a 1:1 correspondence of mapping and some of their RzBinSections, but also want to add some unmapped sections. In this case, they can implement their mapped sections in their maps callback, then in their sections callback use this function to create sections from them and add some additional ones. See also rz_bin_maps_of_file_sections() for the inverse, when no additional sections should be added.

Definition at line 1084 of file bin.c.

1084  {
1087  if (!ret) {
1088  return NULL;
1089  }
1090  RzListIter *it;
1091  RzBinMap *map;
1092  rz_list_foreach (maps, it, map) {
1094  if (!sec) {
1095  break;
1096  }
1097  sec->name = map->name ? strdup(map->name) : NULL;
1098  sec->paddr = map->paddr;
1099  sec->size = map->psize;
1100  sec->vaddr = map->vaddr;
1101  sec->vsize = map->vsize;
1102  sec->perm = map->perm;
1103  rz_list_append(ret, sec);
1104  }
1105  return ret;
1106 }
RZ_API void rz_bin_section_free(RzBinSection *bs)
Definition: bin.c:1116
static RzList * maps(RzBinFile *bf)
Definition: bin_bf.c:116
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288

References map(), maps(), rz_bin_section_t::name, NULL, rz_bin_section_t::paddr, rz_bin_section_t::perm, rz_bin_section_free(), rz_list_append(), rz_list_newf(), RZ_NEW0, rz_return_val_if_fail, rz_bin_section_t::size, strdup(), rz_bin_section_t::vaddr, and rz_bin_section_t::vsize.

Referenced by sections().

◆ rz_bin_source_line_info_builder_build_and_fini()

RZ_API RzBinSourceLineInfo* rz_bin_source_line_info_builder_build_and_fini ( RzBinSourceLineInfoBuilder builder)

Definition at line 87 of file dbginfo.c.

87  {
89  if (!r) {
90  goto err;
91  }
92  size_t initial_samples_count = rz_vector_len(&builder->samples); // final count may be less after removing unnecessary closing samples
93  if (initial_samples_count) {
94  r->samples = RZ_NEWS0(RzBinSourceLineSample, initial_samples_count);
95  if (!r->samples) {
96  goto err_r;
97  }
98 
99  // samples should be built in flat RzVector to avoid excessive small mallocs,
100  // for sorting we use a pvector with references into our flat vectors (after flushing them).
101 
102  RzPVector sorter;
103  rz_pvector_init(&sorter, NULL);
104  RzBinSourceLineSample *initial_samples = rz_vector_flush(&builder->samples);
105  rz_pvector_reserve(&sorter, initial_samples_count);
106  for (size_t i = 0; i < initial_samples_count; i++) {
107  rz_pvector_push(&sorter, &initial_samples[i]);
108  }
110 
111  r->samples_count = 0;
112  for (size_t i = 0; i < initial_samples_count; i++) {
113  RzBinSourceLineSample *new_sample = rz_pvector_at(&sorter, i);
114  if (r->samples_count) {
115  RzBinSourceLineSample *prev = &r->samples[r->samples_count - 1];
116  if (prev->address == new_sample->address && rz_bin_source_line_sample_is_closing(new_sample)) {
117  // closing sample but there are others that are not closing so this is dropped
118  continue;
119  }
120  }
121  r->samples[r->samples_count++] = *new_sample;
122  }
123  free(initial_samples); // all inner strings are moved already
124  rz_pvector_fini(&sorter);
125  }
126  r->filename_pool = builder->filename_pool;
127  // don't call regular fini on the builder because we moved its string pool!
128  rz_vector_fini(&builder->samples);
129  return r;
130 err_r:
131  free(r);
132 err:
134  return NULL;
135 }
static bool err
Definition: armass.c:435
static int line_sample_cmp(const void *a, const void *b)
Definition: dbginfo.c:39
RZ_API void rz_bin_source_line_info_builder_fini(RzBinSourceLineInfoBuilder *builder)
Definition: dbginfo.c:14
static bool rz_bin_source_line_sample_is_closing(const RzBinSourceLineSample *s)
Definition: rz_bin.h:474
#define RZ_NEWS0(x, y)
Definition: rz_types.h:282
RZ_API void * rz_vector_flush(RzVector *vec)
Turn the vector into a fixed-size array. This will clear the vector and return an array of its origin...
Definition: vector.c:230
RZ_API void rz_vector_fini(RzVector *vec)
Definition: vector.c:61
static size_t rz_vector_len(const RzVector *vec)
Definition: rz_vector.h:82
static void * rz_pvector_at(const RzPVector *vec, size_t index)
Definition: rz_vector.h:236
RzStrConstPool filename_pool
Definition: rz_bin.h:496
A single sample of source line info for a specific address.
Definition: rz_bin.h:441

References rz_bin_source_line_sample_t::address, err, rz_bin_source_line_info_builder_t::filename_pool, free(), i, line_sample_cmp(), NULL, r, rz_bin_source_line_info_builder_fini(), rz_bin_source_line_sample_is_closing(), RZ_NEW0, RZ_NEWS0, rz_pvector_at(), rz_pvector_fini(), rz_pvector_init(), rz_pvector_push(), rz_pvector_reserve(), rz_pvector_sort(), rz_vector_fini(), rz_vector_flush(), rz_vector_len(), and rz_bin_source_line_info_builder_t::samples.

Referenced by lines(), and parse_line_raw().

◆ rz_bin_source_line_info_builder_fini()

RZ_API void rz_bin_source_line_info_builder_fini ( RzBinSourceLineInfoBuilder builder)

Definition at line 14 of file dbginfo.c.

14  {
15  rz_vector_fini(&builder->samples);
17 }
RZ_API void rz_str_constpool_fini(RzStrConstPool *pool)
Definition: str_constpool.c:15

References rz_bin_source_line_info_builder_t::filename_pool, rz_str_constpool_fini(), rz_vector_fini(), and rz_bin_source_line_info_builder_t::samples.

Referenced by rz_bin_source_line_info_builder_build_and_fini().

◆ rz_bin_source_line_info_builder_init()

RZ_API void rz_bin_source_line_info_builder_init ( RzBinSourceLineInfoBuilder builder)

Definition at line 9 of file dbginfo.c.

9  {
12 }
RZ_API bool rz_str_constpool_init(RzStrConstPool *pool)
Definition: str_constpool.c:10
RZ_API void rz_vector_init(RzVector *vec, size_t elem_size, RzVectorFree free, void *free_user)
Definition: vector.c:33

References rz_bin_source_line_info_builder_t::filename_pool, NULL, rz_str_constpool_init(), rz_vector_init(), and rz_bin_source_line_info_builder_t::samples.

Referenced by lines(), and parse_line_raw().

◆ rz_bin_source_line_info_builder_push_sample()

RZ_API void rz_bin_source_line_info_builder_push_sample ( RzBinSourceLineInfoBuilder builder,
ut64  address,
ut32  line,
ut32  column,
const char *  file 
)

Push a new sample into the builder.

This function is used to continuously fill the builder with concrete samples of line info for a specific address, usually during parsing of debug info from a file. The samples may be pushed in any order and the builder will later take care of generating a valid RzBinSourceLineInfo from it.

Parameters
linemay be 0 or a positive line number, where 0 means that this entry closes the one before it. see also RzBinSourceLine.

Definition at line 28 of file dbginfo.c.

28  {
29  RzBinSourceLineSample *sample = rz_vector_push(&builder->samples, NULL);
30  if (!sample) {
31  return;
32  }
33  sample->address = address;
34  sample->line = line;
35  sample->column = column;
36  sample->file = file ? rz_str_constpool_get(&builder->filename_pool, file) : NULL;
37 }
line
Definition: setup.py:34
RZ_API const char * rz_str_constpool_get(RzStrConstPool *pool, const char *str)
Definition: str_constpool.c:19
RZ_API void * rz_vector_push(RzVector *vec, void *x)
Definition: vector.c:197
Definition: gzappend.c:170

References rz_bin_source_line_sample_t::address, rz_bin_source_line_sample_t::column, rz_bin_source_line_sample_t::file, rz_bin_source_line_info_builder_t::filename_pool, rz_bin_source_line_sample_t::line, setup::line, NULL, rz_str_constpool_get(), rz_vector_push(), and rz_bin_source_line_info_builder_t::samples.

Referenced by lines(), rz_bin_dwarf_line_op_run(), and store_line_sample().

◆ rz_bin_source_line_info_free()

RZ_API void rz_bin_source_line_info_free ( RzBinSourceLineInfo sli)

Definition at line 137 of file dbginfo.c.

137  {
138  if (!sli) {
139  return;
140  }
141  free(sli->samples);
143  free(sli);
144 }
RzStrConstPool filename_pool
Definition: rz_bin.h:488
RzBinSourceLineSample * samples
All source line references for given adresses.
Definition: rz_bin.h:486

References rz_bin_source_line_info_t::filename_pool, free(), rz_str_constpool_fini(), and rz_bin_source_line_info_t::samples.

Referenced by rz_bin_dwarf_line_info_free(), and rz_bin_object_free().

◆ rz_bin_source_line_info_get_first_at()

RZ_API const RzBinSourceLineSample* rz_bin_source_line_info_get_first_at ( const RzBinSourceLineInfo sli,
ut64  addr 
)

Find the first sample that affects the given address. i.e. find the first sample with the highest address less or equal to addr. There may be more which can be retrieved by repeatedly calling rz_bin_source_line_info_get_next() until it returns NULL.

Definition at line 151 of file dbginfo.c.

151  {
152  if (!sli->samples_count) {
153  return NULL;
154  }
155  size_t l;
156 #define CMP(x, y) (x > y.address ? 1 : (x < y.address ? -1 : 0))
158 #undef CMP
159  if (!l) {
160  return NULL;
161  }
162  l--;
163  RzBinSourceLineSample *r = &sli->samples[l];
164  if (r->address > addr || rz_bin_source_line_sample_is_closing(r)) {
165  return NULL;
166  }
167  // walk back to the very first entry with this addr
168  while (r > sli->samples) {
169  if ((r - 1)->address == r->address) {
170  r--;
171  } else {
172  break;
173  }
174  }
175  return r;
176 }
#define CMP(x, y)
static int addr
Definition: z80asm.c:58

References addr, CMP, NULL, r, rz_array_upper_bound, rz_bin_source_line_sample_is_closing(), rz_bin_source_line_info_t::samples, and rz_bin_source_line_info_t::samples_count.

Referenced by print_source_info(), rz_bin_addr2line(), and rz_bin_addr2text().

◆ rz_bin_source_line_info_get_next()

RZ_API const RzBinSourceLineSample* rz_bin_source_line_info_get_next ( const RzBinSourceLineInfo sli,
RZ_NONNULL const RzBinSourceLineSample cur 
)
Parameters
curMUST be a pointer returned by either rz_bin_source_line_info_get_first_at() or rz_bin_source_line_info_get_next().
Returns
The next sample at the same address as cur or NULL if there is none.

Definition at line 182 of file dbginfo.c.

182  {
183  rz_return_val_if_fail(sli && cur && cur >= sli->samples && cur < sli->samples + sli->samples_count, NULL);
184  if (cur == sli->samples + sli->samples_count - 1) {
185  return NULL;
186  }
187  const RzBinSourceLineSample *next = cur + 1;
188  if (next->address != cur->address) {
189  return NULL;
190  }
191  return next;
192 }

References rz_bin_source_line_sample_t::address, NULL, rz_return_val_if_fail, rz_bin_source_line_info_t::samples, and rz_bin_source_line_info_t::samples_count.

Referenced by print_source_info(), and rz_bin_addr2text().

◆ rz_bin_source_line_sample_is_closing()

static bool rz_bin_source_line_sample_is_closing ( const RzBinSourceLineSample s)
inlinestatic

Definition at line 474 of file rz_bin.h.

474  {
475  return !s->line && !s->column && !s->file;
476 }

References s.

Referenced by line_sample_cmp(), rz_bin_source_line_info_builder_build_and_fini(), and rz_bin_source_line_info_get_first_at().

◆ rz_bin_string_free()

RZ_API void rz_bin_string_free ( void *  _str)

◆ rz_bin_symbol_free()

◆ rz_bin_symbol_new()

RZ_API RzBinSymbol* rz_bin_symbol_new ( const char *  name,
ut64  paddr,
ut64  vaddr 
)

Definition at line 165 of file bin.c.

165  {
167  if (sym) {
168  sym->name = name ? strdup(name) : NULL;
169  sym->paddr = paddr;
170  sym->vaddr = vaddr;
171  }
172  return sym;
173 }

References rz_bin_symbol_t::name, NULL, rz_bin_symbol_t::paddr, RZ_NEW0, strdup(), and rz_bin_symbol_t::vaddr.

Referenced by add_new_func_symbol(), rz_bin_java_class_const_pool_as_symbols(), rz_bin_java_class_fields_as_symbols(), and rz_bin_java_class_methods_as_symbols().

◆ rz_bin_trycatch_free()

RZ_API void rz_bin_trycatch_free ( RzBinTrycatch tc)

Definition at line 1190 of file bin.c.

1190  {
1191  free(tc);
1192 }

References free().

Referenced by trycatch().

◆ rz_bin_trycatch_new()

RZ_API RzBinTrycatch* rz_bin_trycatch_new ( ut64  source,
ut64  from,
ut64  to,
ut64  handler,
ut64  filter 
)

Definition at line 1178 of file bin.c.

1178  {
1180  if (tc) {
1181  tc->source = source;
1182  tc->from = from;
1183  tc->to = to;
1184  tc->handler = handler;
1185  tc->filter = filter;
1186  }
1187  return tc;
1188 }
const char * source
Definition: lz4.h:699
static bool filter(RzParse *p, ut64 addr, RzFlag *f, RzAnalysisHint *hint, char *data, char *str, int len, bool big_endian)
Definition: filter.c:185
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
Definition: sfsocketcall.h:123
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Definition: sfsocketcall.h:125

References rz_bin_trycatch_t::filter, filter(), rz_bin_trycatch_t::from, from, rz_bin_trycatch_t::handler, RZ_NEW0, rz_bin_trycatch_t::source, source, rz_bin_trycatch_t::to, and to.

Referenced by trycatch().

◆ rz_bin_virtual_file_free()

RZ_API void rz_bin_virtual_file_free ( RzBinVirtualFile vfile)

Definition at line 1012 of file bin.c.

1012  {
1013  if (!vfile) {
1014  return;
1015  }
1016  if (vfile->buf_owned) {
1017  rz_buf_free(vfile->buf);
1018  }
1019  free(vfile->name);
1020  free(vfile);
1021 }
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
Definition: buf.c:1253
RZ_NONNULL RzBuffer * buf
Definition: rz_bin.h:597
bool buf_owned
whether buf is owned and freed by this RzBinVirtualFile
Definition: rz_bin.h:598
RZ_OWN RZ_NONNULL char * name
Definition: rz_bin.h:596

References rz_bin_virtual_file_t::buf, rz_bin_virtual_file_t::buf_owned, free(), rz_bin_virtual_file_t::name, and rz_buf_free().

Referenced by get_virtual_files(), and virtual_files().

◆ rz_bin_xtrdata_free()

RZ_API void rz_bin_xtrdata_free ( void *  data)

Definition at line 61 of file bin.c.

61  {
62  RzBinXtrData *data = data_;
63  rz_return_if_fail(data);
64  if (data->metadata) {
65  free(data->metadata->libname);
66  free(data->metadata->arch);
67  free(data->metadata->machine);
68  free(data->metadata);
69  }
70  free(data->file);
71  rz_buf_free(data->buf);
72  free(data);
73 }
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
RzBuffer * buf
Definition: rz_bin.h:380
RzBinXtrMetadata * metadata
Definition: rz_bin.h:386

References rz_bin_xtr_metadata_t::arch, rz_bin_xtr_extract_t::buf, rz_bin_xtr_extract_t::file, free(), rz_bin_xtr_metadata_t::libname, rz_bin_xtr_metadata_t::machine, rz_bin_xtr_extract_t::metadata, rz_buf_free(), and rz_return_if_fail.

Referenced by oneshotall(), oneshotall_buffer(), and rz_bin_file_new().

◆ rz_bin_xtrdata_new()

RZ_API RzBinXtrData* rz_bin_xtrdata_new ( RzBuffer buf,
ut64  offset,
ut64  size,
ut32  file_count,
RzBinXtrMetadata metadata 
)

Definition at line 47 of file bin.c.

47  {
49  if (data) {
50  data->offset = offset;
51  data->size = size;
52  data->file_count = file_count;
53  data->metadata = metadata;
54  data->loaded = 0;
55  // don't slice twice TODO. review this
56  data->buf = rz_buf_ref(buf); // rz_buf_new_slice (buf, offset, size);
57  }
58  return data;
59 }
voidpf uLong offset
Definition: ioapi.h:144
voidpf void * buf
Definition: ioapi.h:138
RZ_API RzBuffer * rz_buf_ref(RzBuffer *b)
Increment the reference count of the buffer.
Definition: buf.c:668

References rz_bin_xtr_extract_t::buf, rz_bin_xtr_extract_t::file_count, rz_bin_xtr_extract_t::loaded, rz_bin_xtr_extract_t::metadata, rz_bin_xtr_extract_t::offset, rz_buf_ref(), RZ_NEW0, and rz_bin_xtr_extract_t::size.

Referenced by extract(), oneshot(), and oneshot_buffer().

◆ RZ_LIB_VERSION_HEADER()

RZ_LIB_VERSION_HEADER ( rz_bin  )