10 #define HASH_NCHAIN_OFFSET(x) ((x) + 4)
66 static Elf_(Word) get_number_of_symbols_from_heuristic_aux(
ELFOBJ *
bin,
ut64 symtab_offset,
ut64 strtab_offset) {
67 if (symtab_offset > strtab_offset) {
71 ut64 symtab_size = strtab_offset - symtab_offset;
72 return symtab_size /
sizeof(
Elf_(Sym));
88 return get_number_of_symbols_from_heuristic_aux(
bin, symtab_offset, strtab_offset);
91 static Elf_(Word) get_number_of_symbols_from_section(
ELFOBJ *
bin) {
105 if (
name[0] !=
'$') {
110 return (
name[2] ==
'\0' ||
name[2] ==
'.') &&
120 switch (
bin->ehdr.e_machine) {
181 if (symbol->st_name != 0) {
190 if (symbol->st_shndx >=
bin->ehdr.e_shnum) {
200 return elf_symbol->
name;
208 if (!elf_symbol->
name) {
220 elf_symbol->
size = symbol->st_size;
222 if (symbol->st_size == 0 && symbol->st_shndx ==
SHN_UNDEF && symbol->st_value == 0) {
229 elf_symbol->
vaddr = symbol->st_value;
258 for (
size_t i = 1;
i < segment->
number;
i++) {
343 if (!strtab_section) {
371 if (!gnu_debugdata) {
392 .elf_load_sections =
true,
395 if (!debug_data_bin) {
400 if (!debug_symbols) {
404 HtPP *name_set = ht_pp_new0();
406 goto debug_symbols_err;
411 ht_pp_insert(name_set, sym->
name, sym);
424 debug_symbols->
len = 0;
427 ht_pp_free(name_set);
440 return symbol->st_shndx !=
SHT_NULL;
456 RZ_LOG_WARN(
"Neither hash nor gnu_hash exist. Falling back to heuristics for deducing the number of dynamic symbols...\n");
458 result = get_number_of_symbols_from_section(
bin);
463 result = get_number_of_symbols_from_heuristic(
bin);
468 RZ_LOG_ERROR(
"Failed to determine the number of dynamic symbols from heuristics.\n");
478 if (symbol->
ordinal == ordinal) {
492 HtUU *set = ht_uu_new0();
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(* RzBinElfSymbolFilter)(ELFOBJ *bin, Elf_(Sym) *entry, bool is_dynamic)
size_t Elf_() rz_bin_elf_get_number_of_symbols_from_hash_table(RZ_NONNULL ELFOBJ *bin)
#define rz_bin_elf_enumerate_sections(bin, section, i)
#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.
bool Elf_() rz_bin_elf_read_addr(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Addr) *result)
bool Elf_() rz_bin_elf_read_char(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT ut8 *result)
RZ_BORROW RzBinElfSection *Elf_() rz_bin_elf_get_section(RZ_NONNULL ELFOBJ *bin, Elf_(Half) index)
bool Elf_() rz_bin_elf_read_word(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Word) *result)
bool Elf_() rz_bin_elf_read_xword(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Xword) *result)
RZ_BORROW RzBinElfSection *Elf_() rz_bin_elf_get_section_with_name(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL const char *name)
RZ_OWN RzBinElfStrtab *Elf_() rz_bin_elf_strtab_new(RZ_NONNULL ELFOBJ *bin, ut64 offset, ut64 size)
void Elf_() rz_bin_elf_strtab_free(RzBinElfStrtab *ptr)
bool Elf_() rz_bin_elf_read_section(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RZ_INOUT ut64 *offset, RZ_NONNULL RZ_OUT Elf_(Section) *result)
bool Elf_() rz_bin_elf_get_dt_info(RZ_NONNULL ELFOBJ *bin, ut64 key, RZ_OUT ut64 *info)
bool Elf_() rz_bin_elf_is_relocatable(RZ_NONNULL ELFOBJ *bin)
Check if the elf binary is relocatable.
RZ_OWN char *Elf_() rz_bin_elf_strtab_get_dup(RZ_NONNULL RzBinElfStrtab *strtab, ut64 index)
size_t Elf_() rz_bin_elf_get_number_of_symbols_from_gnu_hash_table(RZ_NONNULL ELFOBJ *bin)
static bool convert_elf_symbol_entry(ELFOBJ *bin, struct symbols_segment *segment, RzBinElfSymbol *elf_symbol, Elf_(Sym) *symbol, size_t ordinal)
static const struct symbol_type_translation symbol_type_translation_table[]
static bool is_special_symbol(ELFOBJ *bin, Elf_(Sym) *sym, const char *name)
RZ_BORROW RzBinElfSymbol *Elf_() rz_bin_elf_get_symbol(RZ_NONNULL ELFOBJ *bin, ut32 ordinal)
static const char * symbol_bind_to_str(Elf_(Sym) *sym)
static bool filter_symbol(RZ_UNUSED ELFOBJ *bin, Elf_(Sym) *symbol, RZ_UNUSED bool is_dynamic)
static bool get_symbol_entry(ELFOBJ *bin, ut64 offset, Elf_(Sym) *result)
static bool has_already_been_processed(ELFOBJ *bin, ut64 offset, HtUU *set)
static bool get_section_elf_symbols(ELFOBJ *bin, RzVector *result, RzBinElfSymbolFilter filter, HtUU *set)
static bool get_gnu_debugdata_elf_symbols(ELFOBJ *bin, RzVector *result, RzBinElfSymbolFilter filter, HtUU *set)
static bool compute_symbols_from_segment(ELFOBJ *bin, RzVector *result, struct symbols_segment *segment, RzBinElfSymbolFilter filter, HtUU *set)
static struct symbols_segment symbols_segment_init(ut64 offset, ut64 number, ut64 entry_size, bool dynamic, RzBinElfStrtab *strtab)
RZ_OWN RzVector *Elf_() rz_bin_elf_compute_symbols(ELFOBJ *bin, RzBinElfSymbolFilter filter)
RZ_OWN RzVector *Elf_() rz_bin_elf_symbols_new(RZ_NONNULL ELFOBJ *bin)
static bool is_section_local_symbol(ELFOBJ *bin, Elf_(Sym) *symbol)
static struct symbol_bind_translation symbol_bind_translation_table[]
static void elf_symbol_fini(void *e, RZ_UNUSED void *user)
static const char * symbol_type_to_str(ELFOBJ *bin, RzBinElfSymbol *ret, Elf_(Sym) *sym)
static bool set_elf_symbol_name(ELFOBJ *bin, struct symbols_segment *segment, RzBinElfSymbol *elf_symbol, Elf_(Sym) *symbol, RzBinElfSection *section)
bool Elf_() rz_bin_elf_has_symbols(RZ_NONNULL ELFOBJ *bin)
static bool is_special_arm_symbol(ELFOBJ *bin, Elf_(Sym) *sym, const char *name)
static bool get_symbol_entry_aux(ELFOBJ *bin, ut64 offset, Elf_(Sym) *result)
static bool get_dynamic_elf_symbols(ELFOBJ *bin, RzVector *result, RzBinElfSymbolFilter filter, HtUU *set)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API const KEY_TYPE bool * found
#define ELF_ST_VISIBILITY(v)
static bool filter(RzParse *p, ut64 addr, RzFlag *f, RzAnalysisHint *hint, char *data, char *str, int len, bool big_endian)
int dynamic(struct state *s)
#define rz_return_val_if_fail(expr, val)
#define RZ_BIN_TYPE_HIOS_STR
#define RZ_BIN_TYPE_COMMON_STR
#define RZ_BIN_BIND_WEAK_STR
#define RZ_BIN_BIND_HIPROC_STR
#define RZ_BIN_TYPE_OBJECT_STR
#define RZ_BIN_BIND_LOPROC_STR
#define RZ_BIN_TYPE_TLS_STR
#define RZ_BIN_TYPE_NOTYPE_STR
#define RZ_BIN_TYPE_NUM_STR
#define RZ_BIN_TYPE_LOOS_STR
#define RZ_BIN_TYPE_LOPROC_STR
#define RZ_BIN_BIND_HIOS_STR
#define RZ_BIN_BIND_NUM_STR
#define RZ_BIN_BIND_LOCAL_STR
#define RZ_BIN_BIND_LOOS_STR
#define RZ_BIN_BIND_GLOBAL_STR
#define RZ_BIN_TYPE_FILE_STR
#define RZ_BIN_TYPE_FUNC_STR
#define RZ_BIN_TYPE_HIPROC_STR
#define RZ_BIN_TYPE_UNKNOWN_STR
#define RZ_BIN_TYPE_SECTION_STR
#define RZ_BIN_TYPE_SPECIAL_SYM_STR
#define RZ_BIN_BIND_UNKNOWN_STR
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_slice(RzBuffer *b, ut64 offset, ut64 size)
Creates a new buffer from a slice of another buffer.
RZ_API bool rz_lzma_dec_buf(RZ_NONNULL RzBuffer *src, RZ_NONNULL RzBuffer *dst, ut64 block_size, ut8 *src_consumed)
Decompress the src buffer with LZMA algorithm and put the decompressed data in dst.
#define RZ_LOG_WARN(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API char * rz_str_new(const char *str)
RZ_API void * rz_vector_push(RzVector *vec, void *x)
#define rz_vector_foreach(vec, it)
RZ_API void rz_vector_free(RzVector *vec)
RZ_API RzVector * rz_vector_new(size_t elem_size, RzVectorFree free, void *free_user)
static size_t rz_vector_len(const RzVector *vec)
ut64 baseaddr
where the linker maps the binary in memory
RZ_BORROW RzBinElfStrtab * strtab
ut64(WINAPI *w32_GetEnabledXStateFeatures)()