Refactor sections in RzBinPlugin from list to pvector (#4089)
This commit is contained in:
parent
7da17b80e2
commit
3a2148e1cd
92 changed files with 580 additions and 491 deletions
|
|
@ -30,10 +30,12 @@ static ut64 find_method(RzAnalysis *a, ut64 addr) {
|
|||
}
|
||||
|
||||
RzBinSection *sec;
|
||||
RzListIter *it;
|
||||
RzList *list = a->binb.get_sections(a->binb.bin);
|
||||
void **it;
|
||||
RzBinObject *obj = rz_bin_cur_object(a->binb.bin);
|
||||
const RzPVector *vec = obj ? a->binb.get_sections(obj) : NULL;
|
||||
|
||||
rz_list_foreach (list, it, sec) {
|
||||
rz_pvector_foreach (vec, it) {
|
||||
sec = *it;
|
||||
ut64 from = sec->vaddr;
|
||||
ut64 to = from + sec->vsize;
|
||||
if (!(sec->perm & RZ_PERM_X) || addr < from || addr > to) {
|
||||
|
|
|
|||
|
|
@ -227,7 +227,8 @@ RZ_API RzList /*<RVTableInfo *>*/ *rz_analysis_vtable_search(RVTableContext *con
|
|||
return NULL;
|
||||
}
|
||||
|
||||
RzList *sections = analysis->binb.get_sections(analysis->binb.bin);
|
||||
RzBinObject *obj = rz_bin_cur_object(analysis->binb.bin);
|
||||
const RzPVector *sections = obj ? analysis->binb.get_sections(obj) : NULL;
|
||||
if (!sections) {
|
||||
rz_list_free(vtables);
|
||||
return NULL;
|
||||
|
|
@ -235,9 +236,10 @@ RZ_API RzList /*<RVTableInfo *>*/ *rz_analysis_vtable_search(RVTableContext *con
|
|||
|
||||
rz_cons_break_push(NULL, NULL);
|
||||
|
||||
RzListIter *iter;
|
||||
void **iter;
|
||||
RzBinSection *section;
|
||||
rz_list_foreach (sections, iter, section) {
|
||||
rz_pvector_foreach (sections, iter) {
|
||||
section = *iter;
|
||||
if (rz_cons_is_breaked()) {
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,10 +35,12 @@ static ut64 find_method(RzAsm *a) {
|
|||
}
|
||||
|
||||
RzBinSection *sec;
|
||||
RzListIter *it;
|
||||
RzList *list = a->binb.get_sections(a->binb.bin);
|
||||
void **it;
|
||||
RzBinObject *obj = rz_bin_cur_object(a->binb.bin);
|
||||
const RzPVector *vec = obj ? a->binb.get_sections(obj) : NULL;
|
||||
|
||||
rz_list_foreach (list, it, sec) {
|
||||
rz_pvector_foreach (vec, it) {
|
||||
sec = *it;
|
||||
ut64 from = sec->vaddr;
|
||||
ut64 to = from + sec->vsize;
|
||||
if (!(sec->perm & RZ_PERM_X) || addr < from || addr > to) {
|
||||
|
|
|
|||
|
|
@ -300,13 +300,14 @@ static void string_scan_range_cfstring(RzBinFile *bf, HtUP *strings_db, RzPVecto
|
|||
}
|
||||
|
||||
static void scan_cfstring_table(RzBinFile *bf, HtUP *strings_db, RzPVector /*<RzBinString *>*/ *results, ut64 max_interval) {
|
||||
RzListIter *iter = NULL;
|
||||
void **iter = NULL;
|
||||
RzBinSection *section = NULL;
|
||||
RzBinObject *o = bf->o;
|
||||
if (!o) {
|
||||
return;
|
||||
}
|
||||
rz_list_foreach (o->sections, iter, section) {
|
||||
rz_pvector_foreach (o->sections, iter) {
|
||||
section = *iter;
|
||||
if (!section->name || section->paddr >= bf->size) {
|
||||
continue;
|
||||
} else if (max_interval && section->size > max_interval) {
|
||||
|
|
@ -412,12 +413,13 @@ RZ_API RZ_OWN RzPVector /*<RzBinString *>*/ *rz_bin_file_strings(RZ_NONNULL RzBi
|
|||
goto fail;
|
||||
}
|
||||
}
|
||||
} else if (bf->o && !rz_list_empty(bf->o->sections)) {
|
||||
} else if (bf->o && !rz_pvector_empty(bf->o->sections)) {
|
||||
// returns only the strings found on the RzBinFile but within the data section
|
||||
RzListIter *iter = NULL;
|
||||
void **iter = NULL;
|
||||
RzBinSection *section = NULL;
|
||||
RzBinObject *o = bf->o;
|
||||
rz_list_foreach (o->sections, iter, section) {
|
||||
rz_pvector_foreach (o->sections, iter) {
|
||||
section = *iter;
|
||||
if (section->paddr >= bf->size) {
|
||||
continue;
|
||||
} else if (max_interval && section->size > max_interval) {
|
||||
|
|
|
|||
|
|
@ -610,12 +610,6 @@ RZ_DEPRECATE RZ_API RZ_BORROW RzBinInfo *rz_bin_get_info(RzBin *bin) {
|
|||
return o ? (RzBinInfo *)rz_bin_object_get_info(o) : NULL;
|
||||
}
|
||||
|
||||
RZ_DEPRECATE RZ_API RZ_BORROW RzList /*<RzBinSection *>*/ *rz_bin_get_sections(RZ_NONNULL RzBin *bin) {
|
||||
rz_return_val_if_fail(bin, NULL);
|
||||
RzBinObject *o = rz_bin_cur_object(bin);
|
||||
return o ? (RzList *)rz_bin_object_get_sections_all(o) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Find the binary section at offset \p off.
|
||||
*
|
||||
|
|
@ -626,12 +620,13 @@ RZ_DEPRECATE RZ_API RZ_BORROW RzList /*<RzBinSection *>*/ *rz_bin_get_sections(R
|
|||
*/
|
||||
RZ_API RZ_BORROW RzBinSection *rz_bin_get_section_at(RzBinObject *o, ut64 off, int va) {
|
||||
RzBinSection *section;
|
||||
RzListIter *iter;
|
||||
void **iter;
|
||||
ut64 from, to;
|
||||
|
||||
rz_return_val_if_fail(o, NULL);
|
||||
// TODO: must be O(1) .. use sdb here
|
||||
rz_list_foreach (o->sections, iter, section) {
|
||||
rz_pvector_foreach (o->sections, iter) {
|
||||
section = *iter;
|
||||
if (section->is_segment) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -865,7 +860,7 @@ RZ_API void rz_bin_bind(RzBin *bin, RzBinBind *b) {
|
|||
b->bin = bin;
|
||||
b->get_offset = __getoffset;
|
||||
b->get_name = __getname;
|
||||
b->get_sections = rz_bin_get_sections;
|
||||
b->get_sections = rz_bin_object_get_sections_all;
|
||||
b->get_vsect_at = __get_vsection_at;
|
||||
b->demangle = rz_bin_demangle;
|
||||
}
|
||||
|
|
@ -1077,7 +1072,7 @@ RZ_API RZ_OWN RzPVector /*<RzBinMap *>*/ *rz_bin_maps_of_file_sections(RZ_NONNUL
|
|||
if (!binfile->o || !binfile->o->plugin || !binfile->o->plugin->sections) {
|
||||
return NULL;
|
||||
}
|
||||
RzList *sections = binfile->o->plugin->sections(binfile);
|
||||
RzPVector *sections = binfile->o->plugin->sections(binfile);
|
||||
if (!sections) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1086,8 +1081,9 @@ RZ_API RZ_OWN RzPVector /*<RzBinMap *>*/ *rz_bin_maps_of_file_sections(RZ_NONNUL
|
|||
goto hcf;
|
||||
}
|
||||
RzBinSection *sec;
|
||||
RzListIter *it;
|
||||
rz_list_foreach (sections, it, sec) {
|
||||
void **it;
|
||||
rz_pvector_foreach (sections, it) {
|
||||
sec = *it;
|
||||
RzBinMap *map = RZ_NEW0(RzBinMap);
|
||||
if (!map) {
|
||||
goto hcf;
|
||||
|
|
@ -1101,7 +1097,7 @@ RZ_API RZ_OWN RzPVector /*<RzBinMap *>*/ *rz_bin_maps_of_file_sections(RZ_NONNUL
|
|||
rz_pvector_push(r, map);
|
||||
}
|
||||
hcf:
|
||||
rz_list_free(sections);
|
||||
rz_pvector_free(sections);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ RZ_API RzBinLanguage rz_bin_language_detect(RzBinFile *binfile) {
|
|||
RzBinSymbol *sym;
|
||||
RzBinImport *imp;
|
||||
RzBinSection *section;
|
||||
RzListIter *iter;
|
||||
void **iter;
|
||||
|
||||
if (!info) {
|
||||
return RZ_BIN_LANGUAGE_UNKNOWN;
|
||||
|
|
@ -148,9 +148,8 @@ RZ_API RzBinLanguage rz_bin_language_detect(RzBinFile *binfile) {
|
|||
return language_apply_blocks_mask(RZ_BIN_LANGUAGE_OBJC, is_blocks);
|
||||
}
|
||||
|
||||
void **it;
|
||||
rz_pvector_foreach (o->symbols, it) {
|
||||
sym = *it;
|
||||
rz_pvector_foreach (o->symbols, iter) {
|
||||
sym = *iter;
|
||||
if (!sym->name) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -193,7 +192,8 @@ RZ_API RzBinLanguage rz_bin_language_detect(RzBinFile *binfile) {
|
|||
}
|
||||
|
||||
if (is_macho || is_elf) {
|
||||
rz_list_foreach (o->sections, iter, section) {
|
||||
rz_pvector_foreach (o->sections, iter) {
|
||||
section = *iter;
|
||||
if (!section->name) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ RZ_IPI void rz_bin_object_free(RzBinObject *o) {
|
|||
rz_pvector_free(o->libs);
|
||||
rz_pvector_free(o->maps);
|
||||
rz_pvector_free(o->mem);
|
||||
rz_list_free(o->sections);
|
||||
rz_pvector_free(o->sections);
|
||||
rz_pvector_free(o->symbols);
|
||||
rz_pvector_free(o->vfiles);
|
||||
rz_pvector_free(o->resources);
|
||||
|
|
@ -689,41 +689,42 @@ RZ_API const RzPVector /*<char *>*/ *rz_bin_object_get_libs(RZ_NONNULL RzBinObje
|
|||
}
|
||||
|
||||
/**
|
||||
* \brief Get list of \p RzBinSection representing both the sections and the segments of the binary object.
|
||||
* \brief Get pvector of \p RzBinSection representing both the sections and the segments of the binary object.
|
||||
*/
|
||||
RZ_API const RzList /*<RzBinSection *>*/ *rz_bin_object_get_sections_all(RZ_NONNULL RzBinObject *obj) {
|
||||
RZ_API const RzPVector /*<RzBinSection *>*/ *rz_bin_object_get_sections_all(RZ_NONNULL RzBinObject *obj) {
|
||||
rz_return_val_if_fail(obj, NULL);
|
||||
return obj->sections;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *get_sections_or_segment(RzBinObject *obj, bool is_segment) {
|
||||
RzList *res = rz_list_new();
|
||||
static RzPVector /*<RzBinSection *>*/ *get_sections_or_segment(RzBinObject *obj, bool is_segment) {
|
||||
RzPVector *res = rz_pvector_new(NULL);
|
||||
if (!res) {
|
||||
return NULL;
|
||||
}
|
||||
const RzList *all = rz_bin_object_get_sections_all(obj);
|
||||
RzListIter *it;
|
||||
const RzPVector *all = rz_bin_object_get_sections_all(obj);
|
||||
void **it;
|
||||
RzBinSection *sec;
|
||||
rz_list_foreach (all, it, sec) {
|
||||
rz_pvector_foreach (all, it) {
|
||||
sec = *it;
|
||||
if (sec->is_segment == is_segment) {
|
||||
rz_list_append(res, sec);
|
||||
rz_pvector_push(res, sec);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get list of \p RzBinSection representing only the sections of the binary object.
|
||||
* \brief Get pvector of \p RzBinSection representing only the sections of the binary object.
|
||||
*/
|
||||
RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_object_get_sections(RZ_NONNULL RzBinObject *obj) {
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinSection *>*/ *rz_bin_object_get_sections(RZ_NONNULL RzBinObject *obj) {
|
||||
rz_return_val_if_fail(obj, NULL);
|
||||
return get_sections_or_segment(obj, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get list of \p RzBinSection representing only the segments of the binary object.
|
||||
* \brief Get pvector of \p RzBinSection representing only the segments of the binary object.
|
||||
*/
|
||||
RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_object_get_segments(RZ_NONNULL RzBinObject *obj) {
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinSection *>*/ *rz_bin_object_get_segments(RZ_NONNULL RzBinObject *obj) {
|
||||
rz_return_val_if_fail(obj, NULL);
|
||||
return get_sections_or_segment(obj, true);
|
||||
}
|
||||
|
|
@ -826,7 +827,7 @@ static void bin_section_map_fini(void *e, void *user) {
|
|||
RZ_API RZ_OWN RzVector /*<RzBinSectionMap>*/ *rz_bin_object_sections_mapping_list(RZ_NONNULL RzBinObject *obj) {
|
||||
rz_return_val_if_fail(obj, NULL);
|
||||
|
||||
const RzList *all = rz_bin_object_get_sections_all(obj);
|
||||
const RzPVector *all = rz_bin_object_get_sections_all(obj);
|
||||
if (!all) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -836,7 +837,9 @@ RZ_API RZ_OWN RzVector /*<RzBinSectionMap>*/ *rz_bin_object_sections_mapping_lis
|
|||
RzBinSection *section, *segment;
|
||||
RzListIter *iter;
|
||||
|
||||
rz_list_foreach (all, iter, section) {
|
||||
void **it;
|
||||
rz_pvector_foreach (all, it) {
|
||||
section = *it;
|
||||
RzList *list = section->is_segment ? segments : sections;
|
||||
rz_list_append(list, section);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,16 +28,17 @@ RZ_IPI void rz_bin_set_and_process_sections(RzBinFile *bf, RzBinObject *o) {
|
|||
RzBin *bin = bf->rbin;
|
||||
RzBinPlugin *plugin = o->plugin;
|
||||
|
||||
rz_list_free(o->sections);
|
||||
rz_pvector_free(o->sections);
|
||||
if (!plugin->sections || !(o->sections = plugin->sections(bf))) {
|
||||
o->sections = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
o->sections = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
}
|
||||
|
||||
HtPP *filter_db = bin->filter ? ht_pp_new0() : NULL;
|
||||
|
||||
RzListIter *it;
|
||||
void **it;
|
||||
RzBinSection *element;
|
||||
rz_list_foreach (o->sections, it, element) {
|
||||
rz_pvector_foreach (o->sections, it) {
|
||||
element = *it;
|
||||
process_handle_section(element, o, filter_db);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
RZ_IPI RzBinSection *rz_bin_dwarf_section_by_name(RzBinFile *binfile, const char *sn, bool is_dwo) {
|
||||
rz_return_val_if_fail(binfile && sn, NULL);
|
||||
RzListIter *iter = NULL;
|
||||
void **iter = NULL;
|
||||
RzBinSection *section = NULL;
|
||||
RzBinSection *result_section = NULL;
|
||||
RzBinObject *o = binfile->o;
|
||||
|
|
@ -19,7 +19,8 @@ RZ_IPI RzBinSection *rz_bin_dwarf_section_by_name(RzBinFile *binfile, const char
|
|||
if (!name) {
|
||||
return NULL;
|
||||
}
|
||||
rz_list_foreach (o->sections, iter, section) {
|
||||
rz_pvector_foreach (o->sections, iter) {
|
||||
section = *iter;
|
||||
if (!section->name) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1211,30 +1211,30 @@ static RzBinSection *section_new(const char *name, ut32 perm, ut32 size, ut64 pa
|
|||
}
|
||||
|
||||
/**
|
||||
* \brief Returns a RzList<RzBinSection*> containing the dex sections
|
||||
* \brief Returns a RzPVector<RzBinSection*> containing the dex sections
|
||||
*/
|
||||
RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_dex_sections(RZ_NONNULL RzBinDex *dex) {
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinSection *>*/ *rz_bin_dex_sections(RZ_NONNULL RzBinDex *dex) {
|
||||
rz_return_val_if_fail(dex, NULL);
|
||||
|
||||
RzBinSection *section;
|
||||
RzList *sections = NULL;
|
||||
RzPVector *sections = NULL;
|
||||
|
||||
sections = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
sections = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
if (!sections) {
|
||||
return NULL;
|
||||
}
|
||||
section = section_new("data", RZ_PERM_RWX, dex->data_size, dex->data_offset, RZ_DEX_VIRT_ADDRESS + dex->data_offset);
|
||||
if (section && !rz_list_append(sections, section)) {
|
||||
if (section && !rz_pvector_push(sections, section)) {
|
||||
rz_bin_section_free(section);
|
||||
}
|
||||
section = section_new("file", RZ_PERM_R, dex->file_size, dex->header_offset, 0);
|
||||
if (section && !rz_list_append(sections, section)) {
|
||||
if (section && !rz_pvector_push(sections, section)) {
|
||||
rz_bin_section_free(section);
|
||||
}
|
||||
|
||||
if (dex->relocs_code) {
|
||||
section = section_new(RZ_DEX_RELOC_TARGETS, RZ_PERM_RWX, dex->relocs_size, 0, dex->relocs_offset);
|
||||
if (section && !rz_list_append(sections, section)) {
|
||||
if (section && !rz_pvector_push(sections, section)) {
|
||||
rz_bin_section_free(section);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ RZ_API ut64 rz_bin_dex_debug_info(RZ_NONNULL RzBinDex *dex);
|
|||
RZ_API RZ_OWN RzPVector /*<RzBinString *>*/ *rz_bin_dex_strings(RZ_NONNULL RzBinDex *dex);
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinClass *>*/ *rz_bin_dex_classes(RZ_NONNULL RzBinDex *dex);
|
||||
RZ_API RZ_OWN RzList /*<RzBinClassField *>*/ *rz_bin_dex_fields(RZ_NONNULL RzBinDex *dex);
|
||||
RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_dex_sections(RZ_NONNULL RzBinDex *dex);
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinSection *>*/ *rz_bin_dex_sections(RZ_NONNULL RzBinDex *dex);
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinSymbol *>*/ *rz_bin_dex_symbols(RZ_NONNULL RzBinDex *dex);
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinImport *>*/ *rz_bin_dex_imports(RZ_NONNULL RzBinDex *dex);
|
||||
RZ_API RZ_OWN RzPVector /*<char *>*/ *rz_bin_dex_libraries(RZ_NONNULL RzBinDex *dex);
|
||||
|
|
|
|||
|
|
@ -1761,12 +1761,12 @@ static int compare_section_names(const void *a, const void *b) {
|
|||
}
|
||||
|
||||
/**
|
||||
* \brief Returns a RzList<RzBinSection*> containing the class sections
|
||||
* \brief Returns a RzPVector<RzBinSection*> containing the class sections
|
||||
*/
|
||||
RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_java_class_as_sections(RZ_NONNULL RzBinJavaClass *bin) {
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinSection *>*/ *rz_bin_java_class_as_sections(RZ_NONNULL RzBinJavaClass *bin) {
|
||||
rz_return_val_if_fail(bin, NULL);
|
||||
|
||||
RzList *sections = rz_list_newf(section_free);
|
||||
RzPVector *sections = rz_pvector_new(section_free);
|
||||
if (!sections) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1775,14 +1775,14 @@ RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_java_class_as_sections(RZ_NONN
|
|||
char secname[512];
|
||||
ut64 end_offset;
|
||||
if (bin->constant_pool) {
|
||||
rz_list_append(sections,
|
||||
rz_pvector_push(sections,
|
||||
new_section("class.constant_pool",
|
||||
bin->constant_pool_offset,
|
||||
bin->interfaces_offset,
|
||||
RZ_PERM_R));
|
||||
}
|
||||
if (bin->interfaces) {
|
||||
rz_list_append(sections,
|
||||
rz_pvector_push(sections,
|
||||
new_section("class.interfaces",
|
||||
bin->interfaces_offset,
|
||||
bin->fields_offset,
|
||||
|
|
@ -1805,20 +1805,20 @@ RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_java_class_as_sections(RZ_NONN
|
|||
} else {
|
||||
end_offset = bin->methods_offset;
|
||||
}
|
||||
for (iname = 0; rz_list_find(sections, secname, compare_section_names); iname++) {
|
||||
for (iname = 0; rz_pvector_find(sections, secname, (RzPVectorComparator)compare_section_names, NULL); iname++) {
|
||||
snprintf(secname, sizeof(secname), "class.fields.%s_%d.attr", tmp, iname);
|
||||
}
|
||||
free(tmp);
|
||||
rz_list_append(sections, new_section(secname, field->offset, end_offset, RZ_PERM_R));
|
||||
rz_pvector_push(sections, new_section(secname, field->offset, end_offset, RZ_PERM_R));
|
||||
}
|
||||
rz_list_append(sections,
|
||||
rz_pvector_push(sections,
|
||||
new_section("class.fields",
|
||||
bin->fields_offset,
|
||||
bin->methods_offset,
|
||||
RZ_PERM_R));
|
||||
}
|
||||
if (bin->methods) {
|
||||
rz_list_append(sections,
|
||||
rz_pvector_push(sections,
|
||||
new_section("class.methods",
|
||||
bin->methods_offset,
|
||||
bin->attributes_offset,
|
||||
|
|
@ -1835,7 +1835,7 @@ RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_java_class_as_sections(RZ_NONN
|
|||
continue;
|
||||
}
|
||||
snprintf(secname, sizeof(secname), "class.methods.%s.attr", tmp);
|
||||
for (iname = 0; rz_list_find(sections, secname, compare_section_names); iname++) {
|
||||
for (iname = 0; rz_pvector_find(sections, secname, (RzPVectorComparator)compare_section_names, NULL); iname++) {
|
||||
snprintf(secname, sizeof(secname), "class.methods.%s_%d.attr", tmp, iname);
|
||||
}
|
||||
|
||||
|
|
@ -1849,7 +1849,7 @@ RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_java_class_as_sections(RZ_NONN
|
|||
} else {
|
||||
snprintf(secname, sizeof(secname), "class.methods.%s.attr", tmp);
|
||||
}
|
||||
rz_list_append(sections, new_section(secname, method->offset, end_offset, RZ_PERM_R));
|
||||
rz_pvector_push(sections, new_section(secname, method->offset, end_offset, RZ_PERM_R));
|
||||
|
||||
if (!method->attributes) {
|
||||
free(tmp);
|
||||
|
|
@ -1866,7 +1866,7 @@ RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_java_class_as_sections(RZ_NONN
|
|||
snprintf(secname, sizeof(secname), "class.methods.%s.attr.%d.code", tmp, k);
|
||||
}
|
||||
ut64 size = ac->code_offset + attr->attribute_length;
|
||||
rz_list_append(sections, new_section(secname, ac->code_offset, size, RZ_PERM_R | RZ_PERM_X));
|
||||
rz_pvector_push(sections, new_section(secname, ac->code_offset, size, RZ_PERM_R | RZ_PERM_X));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1874,7 +1874,7 @@ RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_java_class_as_sections(RZ_NONN
|
|||
}
|
||||
}
|
||||
if (bin->attributes) {
|
||||
rz_list_append(sections,
|
||||
rz_pvector_push(sections,
|
||||
new_section("class.attr",
|
||||
bin->attributes_offset,
|
||||
bin->class_end_offset,
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ RZ_API RZ_OWN RzList /*<RzBinSymbol *>*/ *rz_bin_java_class_const_pool_as_symbol
|
|||
RZ_API RZ_OWN RzPVector /*<RzBinImport *>*/ *rz_bin_java_class_const_pool_as_imports(RZ_NONNULL RzBinJavaClass *bin);
|
||||
RZ_API void rz_bin_java_class_const_pool_as_text(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb);
|
||||
RZ_API void rz_bin_java_class_const_pool_as_json(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL PJ *j);
|
||||
RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_java_class_as_sections(RZ_NONNULL RzBinJavaClass *bin);
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinSection *>*/ *rz_bin_java_class_as_sections(RZ_NONNULL RzBinJavaClass *bin);
|
||||
RZ_API RZ_OWN RzPVector /*<char *>*/ *rz_bin_java_class_as_libraries(RZ_NONNULL RzBinJavaClass *bin);
|
||||
RZ_API void rz_bin_java_class_interfaces_as_text(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL RzStrBuf *sb);
|
||||
RZ_API void rz_bin_java_class_interfaces_as_json(RZ_NONNULL RzBinJavaClass *bin, RZ_NONNULL PJ *j);
|
||||
|
|
|
|||
|
|
@ -1608,13 +1608,13 @@ RZ_OWN RzPVector /*<RzBinSymbol *>*/ *rz_bin_le_get_symbols(RzBinFile *bf) {
|
|||
return vec;
|
||||
}
|
||||
|
||||
RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_le_get_sections(RzBinFile *bf) {
|
||||
RZ_OWN RzPVector /*<RzBinSection *>*/ *rz_bin_le_get_sections(RzBinFile *bf) {
|
||||
rz_bin_le_obj_t *bin = bf->o->bin_obj;
|
||||
RzList *sections = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
RzPVector *sections = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
RzBinSection *sec = NULL;
|
||||
if (!sections) {
|
||||
fail_cleanup:
|
||||
rz_list_free(sections);
|
||||
rz_pvector_free(sections);
|
||||
rz_bin_section_free(sec);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1642,7 +1642,7 @@ RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_le_get_sections(RzBinFile *bf) {
|
|||
sec->bits = obj->flags & O_BIG_BIT ? RZ_SYS_BITS_32 : RZ_SYS_BITS_16;
|
||||
sec->is_data = obj->flags & O_RESOURCE || !(sec->perm & RZ_PERM_X);
|
||||
|
||||
CHECK(rz_list_append(sections, sec));
|
||||
CHECK(rz_pvector_push(sections, sec));
|
||||
sec = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ bool rz_bin_le_load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *
|
|||
void rz_bin_le_destroy(RzBinFile *bf);
|
||||
RZ_OWN RzPVector /*<RzBinMap *>*/ *rz_bin_le_get_maps(RzBinFile *bf);
|
||||
RZ_OWN RzList /*<RzBinAddr *>*/ *rz_bin_le_get_entry_points(RzBinFile *bf);
|
||||
RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_le_get_sections(RzBinFile *bf);
|
||||
RZ_OWN RzPVector /*<RzBinSection *>*/ *rz_bin_le_get_sections(RzBinFile *bf);
|
||||
RZ_OWN RzPVector /*<RzBinSymbol *>*/ *rz_bin_le_get_symbols(RzBinFile *bf);
|
||||
RZ_OWN RzPVector /*<RzBinImport *>*/ *rz_bin_le_get_imports(RzBinFile *bf);
|
||||
RZ_OWN RzPVector /*<char *>*/ *rz_bin_le_get_libs(RzBinFile *bf);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "luac_common.h"
|
||||
|
||||
void luac_add_section(RzList /*<RzBinSection *>*/ *section_list, char *name, ut64 offset, ut32 size, bool is_func) {
|
||||
void luac_add_section(RzPVector /*<RzBinSection *>*/ *section_vec, char *name, ut64 offset, ut32 size, bool is_func) {
|
||||
RzBinSection *bin_sec = RZ_NEW0(RzBinSection);
|
||||
if (!bin_sec || !name) {
|
||||
free(bin_sec);
|
||||
|
|
@ -25,7 +25,7 @@ void luac_add_section(RzList /*<RzBinSection *>*/ *section_list, char *name, ut6
|
|||
bin_sec->perm = RZ_PERM_R;
|
||||
}
|
||||
|
||||
if (!rz_list_append(section_list, bin_sec)) {
|
||||
if (!rz_pvector_push(section_vec, bin_sec)) {
|
||||
rz_bin_section_free(bin_sec);
|
||||
}
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ void luac_build_info_free(LuacBinInfo *bin_info) {
|
|||
}
|
||||
rz_list_free(bin_info->entry_list);
|
||||
rz_list_free(bin_info->symbol_list);
|
||||
rz_list_free(bin_info->section_list);
|
||||
rz_pvector_free(bin_info->section_vec);
|
||||
rz_list_free(bin_info->string_list);
|
||||
free(bin_info);
|
||||
}
|
||||
|
|
@ -132,13 +132,13 @@ LuacBinInfo *luac_build_info(LuaProto *proto) {
|
|||
|
||||
ret->entry_list = rz_list_newf((RzListFree)free_rz_addr);
|
||||
ret->symbol_list = rz_list_newf((RzListFree)rz_bin_symbol_free);
|
||||
ret->section_list = rz_list_newf((RzListFree)free_rz_section);
|
||||
ret->section_vec = rz_pvector_new((RzPVectorFree)free_rz_section);
|
||||
ret->string_list = rz_list_newf((RzListFree)free_rz_string);
|
||||
|
||||
if (!(ret->entry_list && ret->symbol_list && ret->section_list && ret->string_list)) {
|
||||
if (!(ret->entry_list && ret->symbol_list && ret->section_vec && ret->string_list)) {
|
||||
rz_list_free(ret->entry_list);
|
||||
rz_list_free(ret->symbol_list);
|
||||
rz_list_free(ret->section_list);
|
||||
rz_pvector_free(ret->section_vec);
|
||||
rz_list_free(ret->string_list);
|
||||
}
|
||||
|
||||
|
|
@ -254,42 +254,42 @@ void _luac_build_info(LuaProto *proto, LuacBinInfo *info) {
|
|||
current_offset = proto->offset;
|
||||
current_size = proto->size;
|
||||
section_name = rz_str_newf("%s.header", proto_name);
|
||||
luac_add_section(info->section_list, section_name, current_offset, current_size, false);
|
||||
luac_add_section(info->section_vec, section_name, current_offset, current_size, false);
|
||||
RZ_FREE(section_name);
|
||||
|
||||
// 1.2 set section name as function_name.code
|
||||
current_offset = proto->code_offset;
|
||||
current_size = proto->code_size;
|
||||
section_name = rz_str_newf("%s.code", proto_name);
|
||||
luac_add_section(info->section_list, section_name, current_offset, current_size, true);
|
||||
luac_add_section(info->section_vec, section_name, current_offset, current_size, true);
|
||||
RZ_FREE(section_name);
|
||||
|
||||
// 1.3 set const section
|
||||
current_offset = proto->const_offset;
|
||||
current_size = proto->const_size;
|
||||
section_name = rz_str_newf("%s.const", proto_name);
|
||||
luac_add_section(info->section_list, section_name, current_offset, current_size, false);
|
||||
luac_add_section(info->section_vec, section_name, current_offset, current_size, false);
|
||||
RZ_FREE(section_name);
|
||||
|
||||
// 1.4 upvalue section
|
||||
current_offset = proto->upvalue_offset;
|
||||
current_size = proto->upvalue_size;
|
||||
section_name = rz_str_newf("%s.upvalues", proto_name);
|
||||
luac_add_section(info->section_list, section_name, current_offset, current_size, false);
|
||||
luac_add_section(info->section_vec, section_name, current_offset, current_size, false);
|
||||
RZ_FREE(section_name);
|
||||
|
||||
// 1.5 inner protos section
|
||||
current_offset = proto->inner_proto_offset;
|
||||
current_size = proto->inner_proto_size;
|
||||
section_name = rz_str_newf("%s.protos", proto_name);
|
||||
luac_add_section(info->section_list, section_name, current_offset, current_size, false);
|
||||
luac_add_section(info->section_vec, section_name, current_offset, current_size, false);
|
||||
RZ_FREE(section_name);
|
||||
|
||||
// 1.6 debug section
|
||||
current_offset = proto->debug_offset;
|
||||
current_size = proto->debug_size;
|
||||
section_name = rz_str_newf("%s.debug", proto_name);
|
||||
luac_add_section(info->section_list, section_name, current_offset, current_size, false);
|
||||
luac_add_section(info->section_vec, section_name, current_offset, current_size, false);
|
||||
RZ_FREE(section_name);
|
||||
|
||||
// 2.1 parse local var info
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ typedef struct lua_dbg_upvalue_entry {
|
|||
typedef struct luac_bin_info {
|
||||
st32 major; ///< major version
|
||||
st32 minor; ///< minor version
|
||||
RzList /*<RzBinSection *>*/ *section_list; ///< list of sections
|
||||
RzPVector /*<RzBinSection *>*/ *section_vec; ///< list of sections
|
||||
RzList /*<RzBinSymbol *>*/ *symbol_list; ///< list of symbols
|
||||
RzList /*<RzBinAddr *>*/ *entry_list; ///< list of entries
|
||||
RzList /*<RzBinString *>*/ *string_list; ///< list of strings
|
||||
|
|
@ -187,7 +187,7 @@ void lua_free_proto_entry(LuaProto *);
|
|||
* Common Operation to RzBinInfo
|
||||
* Implemented in 'bin/format/luac/luac_bin.c'
|
||||
* ======================================================== */
|
||||
void luac_add_section(RzList /*<RzBinSection *>*/ *section_list, char *name, ut64 offset, ut32 size, bool is_func);
|
||||
void luac_add_section(RzPVector /*<RzBinSection *>*/ *section_list, char *name, ut64 offset, ut32 size, bool is_func);
|
||||
void luac_add_symbol(RzList /*<RzBinSymbol *>*/ *symbol_list, char *name, ut64 offset, ut64 size, const char *type);
|
||||
void luac_add_entry(RzList /*<RzBinAddr *>*/ *entry_list, ut64 offset, int entry_type);
|
||||
void luac_add_string(RzList /*<RzBinString *>*/ *string_list, char *string, ut64 offset, ut64 size);
|
||||
|
|
|
|||
|
|
@ -2020,12 +2020,12 @@ RzPVector /*<RzBinMap *>*/ *MACH0_(get_maps)(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
RzList /*<RzBinSection *>*/ *MACH0_(get_segments)(RzBinFile *bf) {
|
||||
RzPVector /*<RzBinSection *>*/ *MACH0_(get_segments)(RzBinFile *bf) {
|
||||
struct MACH0_(obj_t) *bin = bf->o->bin_obj;
|
||||
if (bin->sections_cache) {
|
||||
return rz_list_clone(bin->sections_cache);
|
||||
return rz_pvector_clone(bin->sections_cache);
|
||||
}
|
||||
RzList *list = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
RzPVector *vec = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
size_t i, j;
|
||||
|
||||
if (bin->nsegs > 0) {
|
||||
|
|
@ -2049,7 +2049,7 @@ RzList /*<RzBinSection *>*/ *MACH0_(get_segments)(RzBinFile *bf) {
|
|||
s->is_segment = true;
|
||||
rz_str_filter(s->name);
|
||||
s->perm = prot2perm(seg->initprot);
|
||||
rz_list_append(list, s);
|
||||
rz_pvector_push(vec, s);
|
||||
}
|
||||
}
|
||||
if (bin->nsects > 0) {
|
||||
|
|
@ -2091,13 +2091,13 @@ RzList /*<RzBinSection *>*/ *MACH0_(get_segments)(RzBinFile *bf) {
|
|||
#endif
|
||||
s->format = rz_str_newf("Cd %d[%" PFMT64d "]", ws, s->vsize / ws);
|
||||
}
|
||||
rz_list_append(list, s);
|
||||
rz_pvector_push(vec, s);
|
||||
free(segment_name);
|
||||
free(section_name);
|
||||
}
|
||||
}
|
||||
bin->sections_cache = list;
|
||||
return rz_list_clone(list);
|
||||
bin->sections_cache = vec;
|
||||
return rz_pvector_clone(vec);
|
||||
}
|
||||
|
||||
char *MACH0_(section_type_to_string)(ut64 type) {
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ struct MACH0_(obj_t) {
|
|||
struct symbol_t *symbols;
|
||||
ut64 main_addr;
|
||||
|
||||
RzList /*<RzBinSection *>*/ *sections_cache;
|
||||
RzPVector /*<RzBinSection *>*/ *sections_cache;
|
||||
RzSkipList /* struct reloc_t * */ *relocs; ///< lazily loaded, use only MACH0_(get_relocs)() to access this
|
||||
bool relocs_parsed; ///< whether relocs have already been parsed and relocs is filled (or NULL on error)
|
||||
bool reloc_targets_map_base_calculated;
|
||||
|
|
@ -236,7 +236,7 @@ RzList /*<char *>*/ *MACH0_(section_flag_to_rzlist)(ut64 flag);
|
|||
RzPVector /*<RzBinVirtualFile *>*/ *MACH0_(get_virtual_files)(RzBinFile *bf);
|
||||
RzPVector /*<RzBinMap *>*/ *MACH0_(get_maps_unpatched)(RzBinFile *bf);
|
||||
RzPVector /*<RzBinMap *>*/ *MACH0_(get_maps)(RzBinFile *bf);
|
||||
RzList /*<RzBinSection *>*/ *MACH0_(get_segments)(RzBinFile *bf);
|
||||
RzPVector /*<RzBinSection *>*/ *MACH0_(get_segments)(RzBinFile *bf);
|
||||
const struct symbol_t *MACH0_(get_symbols)(struct MACH0_(obj_t) * bin);
|
||||
void MACH0_(pull_symbols)(struct MACH0_(obj_t) * mo, RzBinSymbolCallback cb, void *user);
|
||||
void MACH0_(imports_foreach)(struct MACH0_(obj_t) * bin, mach0_import_foreach_cb cb, void *user);
|
||||
|
|
|
|||
|
|
@ -144,19 +144,19 @@ RzPVector /*<RzBinImport *>*/ *PE_(rz_bin_mdmp_pe_get_imports)(struct PE_(rz_bin
|
|||
return ret;
|
||||
}
|
||||
|
||||
RzList /*<RzBinSection *>*/ *PE_(rz_bin_mdmp_pe_get_sections)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin) {
|
||||
RzPVector /*<RzBinSection *>*/ *PE_(rz_bin_mdmp_pe_get_sections)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin) {
|
||||
/* TODO: Vet code, taken verbatim(ish) from bin_pe.c */
|
||||
int i;
|
||||
ut64 ba = pe_bin->vaddr; // baddr (arch);
|
||||
struct rz_bin_pe_section_t *sections = NULL;
|
||||
RzBinSection *ptr;
|
||||
RzList *ret;
|
||||
RzPVector *ret;
|
||||
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
if (!pe_bin->bin || !(sections = pe_bin->bin->sections)) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
PE_(rz_bin_pe_check_sections)
|
||||
|
|
@ -205,7 +205,7 @@ RzList /*<RzBinSection *>*/ *PE_(rz_bin_mdmp_pe_get_sections)(struct PE_(rz_bin_
|
|||
ptr->is_data = true;
|
||||
}
|
||||
}
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ struct PE_(rz_bin_mdmp_pe_bin) {
|
|||
|
||||
RzList /*<RzBinAddr *>*/ *PE_(rz_bin_mdmp_pe_get_entrypoint)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin);
|
||||
RzPVector /*<RzBinImport *>*/ *PE_(rz_bin_mdmp_pe_get_imports)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin);
|
||||
RzList /*<RzBinSection *>*/ *PE_(rz_bin_mdmp_pe_get_sections)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin);
|
||||
RzPVector /*<RzBinSection *>*/ *PE_(rz_bin_mdmp_pe_get_sections)(struct PE_(rz_bin_mdmp_pe_bin) * pe_bin);
|
||||
RzList /*<RzBinSymbol *>*/ *PE_(rz_bin_mdmp_pe_get_symbols)(RzBin *rbin, struct PE_(rz_bin_mdmp_pe_bin) * pe_bin);
|
||||
|
||||
#endif /* MDMP_PE_H */
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ static RzBinSection *rz_bin_mz_init_section(const struct rz_bin_mz_obj_t *bin,
|
|||
return section;
|
||||
}
|
||||
|
||||
RzList /*<RzBinSection *>*/ *rz_bin_mz_get_segments(const struct rz_bin_mz_obj_t *bin) {
|
||||
RzList *seg_list;
|
||||
RzListIter *iter;
|
||||
RzPVector /*<RzBinSection *>*/ *rz_bin_mz_get_segments(const struct rz_bin_mz_obj_t *bin) {
|
||||
RzPVector *seg_vec;
|
||||
void **iter;
|
||||
RzBinSection *section;
|
||||
MZ_image_relocation_entry *relocs;
|
||||
int i, num_relocs, section_number;
|
||||
|
|
@ -71,8 +71,8 @@ RzList /*<RzBinSection *>*/ *rz_bin_mz_get_segments(const struct rz_bin_mz_obj_t
|
|||
return NULL;
|
||||
}
|
||||
|
||||
seg_list = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
if (!seg_list) {
|
||||
seg_vec = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
if (!seg_vec) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +83,8 @@ RzList /*<RzBinSection *>*/ *rz_bin_mz_get_segments(const struct rz_bin_mz_obj_t
|
|||
if (!section) {
|
||||
goto err_out;
|
||||
}
|
||||
rz_list_add_sorted(seg_list, section, cmp_sections);
|
||||
rz_pvector_push(seg_vec, section);
|
||||
rz_pvector_sort(seg_vec, (RzPVectorComparator)cmp_sections, NULL);
|
||||
|
||||
relocs = bin->relocation_entries;
|
||||
num_relocs = bin->dos_header->num_relocs;
|
||||
|
|
@ -112,7 +113,7 @@ RzList /*<RzBinSection *>*/ *rz_bin_mz_get_segments(const struct rz_bin_mz_obj_t
|
|||
}
|
||||
|
||||
c.vaddr = section_laddr;
|
||||
if (rz_list_find(seg_list, &c, cmp_sections)) {
|
||||
if (rz_pvector_find(seg_vec, &c, (RzPVectorComparator)cmp_sections, NULL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +121,8 @@ RzList /*<RzBinSection *>*/ *rz_bin_mz_get_segments(const struct rz_bin_mz_obj_t
|
|||
if (!section) {
|
||||
goto err_out;
|
||||
}
|
||||
rz_list_add_sorted(seg_list, section, cmp_sections);
|
||||
rz_pvector_push(seg_vec, section);
|
||||
rz_pvector_sort(seg_vec, (RzPVectorComparator)cmp_sections, NULL);
|
||||
}
|
||||
|
||||
/* Add address of stack segment if it's inside the load module. */
|
||||
|
|
@ -130,15 +132,25 @@ RzList /*<RzBinSection *>*/ *rz_bin_mz_get_segments(const struct rz_bin_mz_obj_t
|
|||
if (!section) {
|
||||
goto err_out;
|
||||
}
|
||||
rz_list_add_sorted(seg_list, section, cmp_sections);
|
||||
rz_pvector_push(seg_vec, section);
|
||||
rz_pvector_sort(seg_vec, (RzPVectorComparator)cmp_sections, NULL);
|
||||
}
|
||||
|
||||
/* Fixup sizes and addresses, set name, permissions and set add flag */
|
||||
section_number = 0;
|
||||
rz_list_foreach (seg_list, iter, section) {
|
||||
rz_pvector_foreach (seg_vec, iter) {
|
||||
section = *iter;
|
||||
section->name = rz_str_newf("seg_%03d", section_number);
|
||||
if (section_number) {
|
||||
RzBinSection *p_section = rz_list_iter_get_prev_data(iter);
|
||||
// calculate current index in loop by subtracting base ptr
|
||||
ut32 ptr_gap = iter - (void **)seg_vec->v.a;
|
||||
ut32 cur_index = ptr_gap / sizeof(void **);
|
||||
RzBinSection *p_section = NULL;
|
||||
if (cur_index == 0) {
|
||||
p_section = *rz_pvector_index_ptr(seg_vec, rz_pvector_len(seg_vec) - 1);
|
||||
} else {
|
||||
p_section = *rz_pvector_index_ptr(seg_vec, cur_index - 1);
|
||||
}
|
||||
p_section->size = section->vaddr - p_section->vaddr;
|
||||
p_section->vsize = p_section->size;
|
||||
}
|
||||
|
|
@ -147,15 +159,15 @@ RzList /*<RzBinSection *>*/ *rz_bin_mz_get_segments(const struct rz_bin_mz_obj_t
|
|||
section->perm = rz_str_rwx("rwx");
|
||||
section_number++;
|
||||
}
|
||||
section = rz_list_get_top(seg_list);
|
||||
section = *rz_pvector_index_ptr(seg_vec, rz_pvector_len(seg_vec) - 1);
|
||||
section->size = bin->load_module_size - section->vaddr;
|
||||
section->vsize = section->size;
|
||||
|
||||
return seg_list;
|
||||
return seg_vec;
|
||||
|
||||
err_out:
|
||||
RZ_LOG_ERROR("Failed to get segment list\n");
|
||||
rz_list_free(seg_list);
|
||||
rz_pvector_free(seg_vec);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ struct rz_bin_mz_obj_t {
|
|||
};
|
||||
|
||||
RzBinAddr *rz_bin_mz_get_entrypoint(const struct rz_bin_mz_obj_t *bin);
|
||||
RzList /*<RzBinSection *>*/ *rz_bin_mz_get_segments(const struct rz_bin_mz_obj_t *bin);
|
||||
RzPVector /*<RzBinSection *>*/ *rz_bin_mz_get_segments(const struct rz_bin_mz_obj_t *bin);
|
||||
struct rz_bin_mz_reloc_t *rz_bin_mz_get_relocs(const struct rz_bin_mz_obj_t *bin);
|
||||
void *rz_bin_mz_free(struct rz_bin_mz_obj_t *bin);
|
||||
struct rz_bin_mz_obj_t *rz_bin_mz_new(const char *file);
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ static char *__func_name_from_ord(char *module, ut16 ordinal) {
|
|||
return name;
|
||||
}
|
||||
|
||||
RzList /*<RzBinSection *>*/ *rz_bin_ne_get_segments(rz_bin_ne_obj_t *bin) {
|
||||
RzPVector /*<RzBinSection *>*/ *rz_bin_ne_get_segments(rz_bin_ne_obj_t *bin) {
|
||||
int i;
|
||||
if (!bin) {
|
||||
return NULL;
|
||||
}
|
||||
RzList *segments = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
RzPVector *segments = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
if (!segments) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ RzList /*<RzBinSection *>*/ *rz_bin_ne_get_segments(rz_bin_ne_obj_t *bin) {
|
|||
bs->paddr = (ut64)se->offset * bin->alignment;
|
||||
bs->name = rz_str_newf("%s.%" PFMT64d, se->flags & IS_MOVEABLE ? "MOVEABLE" : "FIXED", bs->paddr);
|
||||
bs->is_segment = true;
|
||||
rz_list_append(segments, bs);
|
||||
rz_pvector_push(segments, bs);
|
||||
}
|
||||
bin->segments = segments;
|
||||
return segments;
|
||||
|
|
@ -396,7 +396,7 @@ RzList /*<RzBinAddr *>*/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin) {
|
|||
return NULL;
|
||||
}
|
||||
RzBinAddr *entry;
|
||||
RzList *segments = rz_bin_ne_get_segments(bin);
|
||||
RzPVector *segments = rz_bin_ne_get_segments(bin);
|
||||
if (!segments) {
|
||||
rz_list_free(entries);
|
||||
return NULL;
|
||||
|
|
@ -405,11 +405,11 @@ RzList /*<RzBinAddr *>*/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin) {
|
|||
entry = RZ_NEW0(RzBinAddr);
|
||||
if (!entry) {
|
||||
rz_list_free(entries);
|
||||
rz_list_free(segments);
|
||||
rz_pvector_free(segments);
|
||||
return NULL;
|
||||
}
|
||||
entry->bits = 16;
|
||||
RzBinSection *s = rz_list_get_n(segments, bin->ne_header->csEntryPoint - 1);
|
||||
RzBinSection *s = (RzBinSection *)rz_pvector_at(segments, bin->ne_header->csEntryPoint - 1);
|
||||
entry->paddr = bin->ne_header->ipEntryPoint + (s ? s->paddr : 0);
|
||||
rz_list_append(entries, entry);
|
||||
}
|
||||
|
|
@ -430,7 +430,7 @@ RzList /*<RzBinAddr *>*/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin) {
|
|||
entry = RZ_NEW0(RzBinAddr);
|
||||
if (!entry) {
|
||||
rz_list_free(entries);
|
||||
rz_list_free(segments);
|
||||
rz_pvector_free(segments);
|
||||
return NULL;
|
||||
}
|
||||
off++;
|
||||
|
|
@ -469,13 +469,13 @@ RzList /*<RzBinAddr *>*/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin) {
|
|||
}
|
||||
}
|
||||
end:
|
||||
rz_list_free(segments);
|
||||
rz_pvector_free(segments);
|
||||
bin->entries = entries;
|
||||
return entries;
|
||||
}
|
||||
|
||||
RzPVector /*<RzBinReloc *>*/ *rz_bin_ne_get_relocs(rz_bin_ne_obj_t *bin) {
|
||||
RzList *segments = bin->segments;
|
||||
RzPVector *segments = bin->segments;
|
||||
if (!segments) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -501,10 +501,11 @@ RzPVector /*<RzBinReloc *>*/ *rz_bin_ne_get_relocs(rz_bin_ne_obj_t *bin) {
|
|||
}
|
||||
|
||||
ut64 bufsz = rz_buf_size(bin->buf);
|
||||
RzListIter *it;
|
||||
void **it;
|
||||
RzBinSection *seg;
|
||||
int index = -1;
|
||||
rz_list_foreach (segments, it, seg) {
|
||||
rz_pvector_foreach (segments, it) {
|
||||
seg = *it;
|
||||
index++;
|
||||
if (!(bin->segment_entries[index].flags & RELOCINFO)) {
|
||||
continue;
|
||||
|
|
@ -581,7 +582,7 @@ RzPVector /*<RzBinReloc *>*/ *rz_bin_ne_get_relocs(rz_bin_ne_obj_t *bin) {
|
|||
// TODO
|
||||
} else {
|
||||
if (strstr(seg->name, "FIXED")) {
|
||||
RzBinSection *s = rz_list_get_n(segments, rel.segnum - 1);
|
||||
RzBinSection *s = (RzBinSection *)rz_pvector_at(segments, rel.segnum - 1);
|
||||
if (s) {
|
||||
offset = s->paddr + rel.segoff;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ typedef struct {
|
|||
ut8 *entry_table;
|
||||
ut8 *resident_name_table;
|
||||
RzBuffer *buf;
|
||||
RzList /*<RzBinSection *>*/ *segments;
|
||||
RzPVector /*<RzBinSection *>*/ *segments;
|
||||
RzList /*<RzBinAddr *>*/ *entries;
|
||||
RzList /*<rz_ne_resource *>*/ *resources;
|
||||
RzPVector /*<RzBinImport *>*/ *imports;
|
||||
|
|
@ -41,7 +41,7 @@ rz_bin_ne_obj_t *rz_bin_ne_new_buf(RzBuffer *buf, bool verbose);
|
|||
RzPVector /*<RzBinReloc *>*/ *rz_bin_ne_get_relocs(rz_bin_ne_obj_t *bin);
|
||||
RzPVector /*<RzBinImport *>*/ *rz_bin_ne_get_imports(rz_bin_ne_obj_t *bin);
|
||||
RzPVector /*<RzBinSymbol *>*/ *rz_bin_ne_get_symbols(rz_bin_ne_obj_t *bin);
|
||||
RzList /*<RzBinSection *>*/ *rz_bin_ne_get_segments(rz_bin_ne_obj_t *bin);
|
||||
RzPVector /*<RzBinSection *>*/ *rz_bin_ne_get_segments(rz_bin_ne_obj_t *bin);
|
||||
RzList /*<RzBinAddr *>*/ *rz_bin_ne_get_entrypoints(rz_bin_ne_obj_t *bin);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ static mach0_ut va2pa(mach0_ut p, ut32 *offset, ut32 *left, RzBinFile *bf) {
|
|||
mach0_ut r;
|
||||
mach0_ut addr;
|
||||
|
||||
RzListIter *iter = NULL;
|
||||
void **iter = NULL;
|
||||
RzBinSection *s = NULL;
|
||||
RzBinObject *obj = bf->o;
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ static mach0_ut va2pa(mach0_ut p, ut32 *offset, ut32 *left, RzBinFile *bf) {
|
|||
return bin->va2pa(p, offset, left, bf);
|
||||
}
|
||||
|
||||
const RzList *sctns = bin->sections_cache;
|
||||
const RzPVector *sctns = bin->sections_cache;
|
||||
if (!sctns) {
|
||||
sctns = rz_bin_plugin_mach.sections(bf);
|
||||
if (!sctns) {
|
||||
|
|
@ -158,7 +158,8 @@ static mach0_ut va2pa(mach0_ut p, ut32 *offset, ut32 *left, RzBinFile *bf) {
|
|||
}
|
||||
|
||||
addr = p;
|
||||
rz_list_foreach (sctns, iter, s) {
|
||||
rz_pvector_foreach (sctns, iter) {
|
||||
s = *iter;
|
||||
if (addr >= s->vaddr && addr < s->vaddr + s->vsize) {
|
||||
if (offset) {
|
||||
*offset = addr - s->vaddr;
|
||||
|
|
|
|||
|
|
@ -743,7 +743,7 @@ int rz_bin_omf_get_bits(rz_bin_omf_obj *obj) {
|
|||
return 16;
|
||||
}
|
||||
|
||||
int rz_bin_omf_send_sections(RzList /*<RzBinSection *>*/ *list, OMF_segment *section, rz_bin_omf_obj *obj) {
|
||||
int rz_bin_omf_send_sections(RzPVector /*<RzBinSection *>*/ *vec, OMF_segment *section, rz_bin_omf_obj *obj) {
|
||||
RzBinSection *new;
|
||||
OMF_data *data = section->data;
|
||||
ut32 ct_name = 1;
|
||||
|
|
@ -765,7 +765,7 @@ int rz_bin_omf_send_sections(RzList /*<RzBinSection *>*/ *list, OMF_segment *sec
|
|||
new->paddr = data->paddr;
|
||||
new->vaddr = section->vaddr + data->offset + OMF_BASE_ADDR;
|
||||
new->perm = RZ_PERM_RWX;
|
||||
rz_list_append(list, new);
|
||||
rz_pvector_push(vec, new);
|
||||
data = data->next;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ rz_bin_omf_obj *rz_bin_internal_omf_load(const ut8 *buf, ut64 size);
|
|||
void rz_bin_free_all_omf_obj(rz_bin_omf_obj *obj);
|
||||
bool rz_bin_omf_get_entry(rz_bin_omf_obj *obj, RzBinAddr *addr);
|
||||
int rz_bin_omf_get_bits(rz_bin_omf_obj *obj);
|
||||
int rz_bin_omf_send_sections(RzList /*<RzBinSection *>*/ *list, OMF_segment *section, rz_bin_omf_obj *obj);
|
||||
int rz_bin_omf_send_sections(RzPVector /*<RzBinSection *>*/ *vec, OMF_segment *section, rz_bin_omf_obj *obj);
|
||||
ut64 rz_bin_omf_get_paddr_sym(rz_bin_omf_obj *obj, OMF_symbol *sym);
|
||||
ut64 rz_bin_omf_get_vaddr_sym(rz_bin_omf_obj *obj, OMF_symbol *sym);
|
||||
|
||||
|
|
|
|||
|
|
@ -1159,7 +1159,7 @@ static pyc_object *get_object(RzBinPycObj *pyc, RzBuffer *buffer) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static bool extract_sections_symbols(RzBinPycObj *pyc, pyc_object *obj, RzList /*<RzBinSection *>*/ *sections, RzPVector /*<RzBinSymbol *>*/ *symbols, RzList /*<pyc_code_object *>*/ *cobjs, char *prefix) {
|
||||
static bool extract_sections_symbols(RzBinPycObj *pyc, pyc_object *obj, RzPVector /*<RzBinSection *>*/ *sections, RzPVector /*<RzBinSymbol *>*/ *symbols, RzList /*<pyc_code_object *>*/ *cobjs, char *prefix) {
|
||||
pyc_code_object *cobj = NULL;
|
||||
RzBinSection *section = NULL;
|
||||
RzBinSymbol *symbol = NULL;
|
||||
|
|
@ -1195,7 +1195,7 @@ static bool extract_sections_symbols(RzBinPycObj *pyc, pyc_object *obj, RzList /
|
|||
section->vaddr = cobj->start_offset;
|
||||
section->size = cobj->end_offset - cobj->start_offset;
|
||||
section->vsize = cobj->end_offset - cobj->start_offset;
|
||||
if (!rz_list_append(sections, section)) {
|
||||
if (!rz_pvector_push(sections, section)) {
|
||||
goto fail;
|
||||
}
|
||||
section = NULL;
|
||||
|
|
@ -1225,7 +1225,7 @@ fail:
|
|||
return false;
|
||||
}
|
||||
|
||||
bool get_sections_symbols_from_code_objects(RzBinPycObj *pyc, RzBuffer *buffer, RzList /*<RzBinSection *>*/ *sections, RzPVector /*<RzBinSymbol *>*/ *symbols, RzList /*<pyc_code_object *>*/ *cobjs, ut32 magic) {
|
||||
bool get_sections_symbols_from_code_objects(RzBinPycObj *pyc, RzBuffer *buffer, RzPVector /*<RzBinSection *>*/ *sections, RzPVector /*<RzBinSymbol *>*/ *symbols, RzList /*<pyc_code_object *>*/ *cobjs, ut32 magic) {
|
||||
bool ret;
|
||||
pyc->magic_int = magic;
|
||||
pyc->refs = rz_list_newf((RzListFree)free_object);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ typedef struct pyc_context {
|
|||
struct pyc_version version;
|
||||
/* used from marshall.c */
|
||||
RzList /*<char *>*/ *interned_table;
|
||||
RzList /*<RzBinSection *>*/ *sections_cache;
|
||||
RzPVector /*<RzBinSection *>*/ *sections_cache;
|
||||
RzPVector /*<RzBinString *>*/ *strings_cache;
|
||||
RzPVector /*<RzBinSymbol *>*/ *symbols_cache;
|
||||
RzList /*<RzList<void *> *>*/ *shared;
|
||||
|
|
@ -87,7 +87,7 @@ typedef struct pyc_context {
|
|||
ut32 symbols_ordinal;
|
||||
} RzBinPycObj;
|
||||
|
||||
bool get_sections_symbols_from_code_objects(RzBinPycObj *pyc, RzBuffer *buffer, RzList /*<RzBinSection *>*/ *sections, RzPVector /*<RzBinSymbol *>*/ *symbols, RzList /*<pyc_code_object *>*/ *objs, ut32 magic);
|
||||
bool get_sections_symbols_from_code_objects(RzBinPycObj *pyc, RzBuffer *buffer, RzPVector /*<RzBinSection *>*/ *sections, RzPVector /*<RzBinSymbol *>*/ *symbols, RzList /*<pyc_code_object *>*/ *objs, ut32 magic);
|
||||
ut64 get_code_object_addr(RzBinPycObj *pyc, RzBuffer *buffer, ut32 magic);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "pyc.h"
|
||||
#include "marshal.h"
|
||||
|
||||
bool pyc_get_sections_symbols(RzBinPycObj *pyc, RzList /*<RzBinSection *>*/ *sections, RzPVector /*<RzBinSymbol *>*/ *symbols, RzList /*<pyc_code_object *>*/ *cobjs, RzBuffer *buf, ut32 magic) {
|
||||
bool pyc_get_sections_symbols(RzBinPycObj *pyc, RzPVector /*<RzBinSection *>*/ *sections, RzPVector /*<RzBinSymbol *>*/ *symbols, RzList /*<pyc_code_object *>*/ *cobjs, RzBuffer *buf, ut32 magic) {
|
||||
return get_sections_symbols_from_code_objects(pyc, buf, sections, symbols, cobjs, magic);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include "pyc_magic.h"
|
||||
#include "marshal.h"
|
||||
|
||||
bool pyc_get_sections_symbols(RzBinPycObj *pyc, RzList /*<RzBinSection *>*/ *sections, RzPVector /*<RzBinSymbol *>*/ *symbols, RzList /*<pyc_code_object *>*/ *mem, RzBuffer *buf, ut32 magic);
|
||||
bool pyc_get_sections_symbols(RzBinPycObj *pyc, RzPVector /*<RzBinSection *>*/ *sections, RzPVector /*<RzBinSymbol *>*/ *symbols, RzList /*<pyc_code_object *>*/ *mem, RzBuffer *buf, ut32 magic);
|
||||
bool pyc_is_code(ut8 b, ut32 magic);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ typedef struct {
|
|||
Sdb *kv;
|
||||
lmf_header lmfh;
|
||||
RzList /*<RzBinSection *>*/ *fixups;
|
||||
RzList /*<RzBinSection *>*/ *sections;
|
||||
RzPVector /*<RzBinSection *>*/ *sections;
|
||||
RzPVector /*<RzBinMap *>*/ *maps;
|
||||
lmf_rw_end rwend;
|
||||
} QnxObj;
|
||||
|
|
|
|||
|
|
@ -273,8 +273,8 @@ RZ_IPI RZ_OWN char *rz_bin_file_golang_compiler(RZ_NONNULL RzBinFile *bf) {
|
|||
bool is_pe = false;
|
||||
GoBuildInfo go_info = { 0 };
|
||||
RzBinSection *section = NULL;
|
||||
RzListIter *it = NULL;
|
||||
RzList *sections = NULL;
|
||||
void **it = NULL;
|
||||
RzPVector *sections = NULL;
|
||||
const char *plugname = bf->o->plugin->name;
|
||||
|
||||
if (!strcmp(plugname, "pe") || !strcmp(plugname, "pe64")) {
|
||||
|
|
@ -290,7 +290,8 @@ RZ_IPI RZ_OWN char *rz_bin_file_golang_compiler(RZ_NONNULL RzBinFile *bf) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
rz_list_foreach (sections, it, section) {
|
||||
rz_pvector_foreach (sections, it) {
|
||||
section = *it;
|
||||
if (is_pe && strstr(section->name, "data") && section->size > 16) {
|
||||
find_go_build_info(bf, &go_info, section);
|
||||
} else if (!is_pe && (strstr(section->name, "go_buildinfo") || strstr(section->name, "go.buildinfo"))) {
|
||||
|
|
@ -300,7 +301,7 @@ RZ_IPI RZ_OWN char *rz_bin_file_golang_compiler(RZ_NONNULL RzBinFile *bf) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
rz_list_free(sections);
|
||||
rz_pvector_free(sections);
|
||||
|
||||
if (!go_info.version) {
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -144,19 +144,18 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
ArtObj *ao = bf->o->bin_obj;
|
||||
if (!ao) {
|
||||
return NULL;
|
||||
}
|
||||
ARTHeader art = ao->art;
|
||||
RzList *ret = NULL;
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(free))) {
|
||||
return NULL;
|
||||
}
|
||||
ret->free = free;
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -167,7 +166,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = 0;
|
||||
ptr->vaddr = art.image_base;
|
||||
ptr->perm = RZ_PERM_R; // r--
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -178,7 +177,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = art.bitmap_offset;
|
||||
ptr->vaddr = art.image_base + art.bitmap_offset;
|
||||
ptr->perm = RZ_PERM_RX; // r-x
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -189,7 +188,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->size = art.oat_file_end - art.oat_file_begin;
|
||||
ptr->vsize = ptr->size;
|
||||
ptr->perm = RZ_PERM_RX; // r-x
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -200,7 +199,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->size = art.oat_data_end - art.oat_data_begin;
|
||||
ptr->vsize = ptr->size;
|
||||
ptr->perm = RZ_PERM_R; // r--
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ static RzPVector /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzBfltObj *obj = bf->o->bin_obj;
|
||||
RzList *ret = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
RzPVector *ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
sec->perm = RZ_PERM_RWX;
|
||||
sec->name = strdup("TEXT");
|
||||
sec->is_segment = true;
|
||||
rz_list_push(ret, sec);
|
||||
rz_pvector_push(ret, sec);
|
||||
|
||||
sec = RZ_NEW0(RzBinSection);
|
||||
if (!sec) {
|
||||
|
|
@ -104,7 +104,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
sec->perm = RZ_PERM_RWX;
|
||||
sec->name = strdup("DATA");
|
||||
sec->is_segment = true;
|
||||
rz_list_push(ret, sec);
|
||||
rz_pvector_push(ret, sec);
|
||||
|
||||
// sections
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
sec->vsize = BFLT_HDR_SIZE;
|
||||
sec->perm = RZ_PERM_RWX;
|
||||
sec->name = strdup("header");
|
||||
rz_list_push(ret, sec);
|
||||
rz_pvector_push(ret, sec);
|
||||
|
||||
sec = RZ_NEW0(RzBinSection);
|
||||
if (!sec) {
|
||||
|
|
@ -130,7 +130,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
sec->vsize = obj->hdr.data_start - BFLT_HDR_SIZE;
|
||||
sec->perm = RZ_PERM_RWX;
|
||||
sec->name = strdup("text");
|
||||
rz_list_push(ret, sec);
|
||||
rz_pvector_push(ret, sec);
|
||||
|
||||
sec = RZ_NEW0(RzBinSection);
|
||||
if (!sec) {
|
||||
|
|
@ -143,7 +143,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
sec->perm = RZ_PERM_RWX;
|
||||
sec->name = strdup("data");
|
||||
sec->is_data = true;
|
||||
rz_list_push(ret, sec);
|
||||
rz_pvector_push(ret, sec);
|
||||
|
||||
sec = RZ_NEW0(RzBinSection);
|
||||
if (!sec) {
|
||||
|
|
@ -156,11 +156,11 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
sec->perm = RZ_PERM_RWX;
|
||||
sec->name = strdup("bss");
|
||||
sec->is_data = true;
|
||||
rz_list_push(ret, sec);
|
||||
rz_pvector_push(ret, sec);
|
||||
|
||||
return ret;
|
||||
beach:
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,12 +84,12 @@ static RzBinInfo *info(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
RzBuffer *obj = bf->o->bin_obj;
|
||||
|
||||
if (!(ret = rz_list_newf((RzListFree)rz_bin_section_free))) {
|
||||
if (!(ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free))) {
|
||||
return NULL;
|
||||
}
|
||||
// program headers is another section
|
||||
|
|
@ -101,7 +101,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = rz_buf_size(bf->buf) - ptr->size;
|
||||
ptr->vaddr = 0xf0000;
|
||||
ptr->perm = RZ_PERM_RWX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
// If image bigger than 128K - add one more section
|
||||
if (bf->size >= 0x20000) {
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
|
|
@ -112,7 +112,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = rz_buf_size(obj) - 2 * ptr->size;
|
||||
ptr->vaddr = 0xe0000;
|
||||
ptr->perm = RZ_PERM_RWX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,19 +173,18 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
BootImageObj *bio = bf->o->bin_obj;
|
||||
if (!bio) {
|
||||
return NULL;
|
||||
}
|
||||
BootImage *bi = &bio->bi;
|
||||
RzList *ret = NULL;
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(free))) {
|
||||
return NULL;
|
||||
}
|
||||
ret->free = free;
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -196,7 +195,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = 0;
|
||||
ptr->vaddr = 0;
|
||||
ptr->perm = RZ_PERM_R; // r--
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -207,7 +206,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = bi->page_size;
|
||||
ptr->vaddr = bi->kernel_addr;
|
||||
ptr->perm = RZ_PERM_R; // r--
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (bi->ramdisk_size > 0) {
|
||||
ut64 base = bi->kernel_size + 2 * bi->page_size - 1;
|
||||
|
|
@ -220,7 +219,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = ROUND_DOWN(base, bi->page_size);
|
||||
ptr->vaddr = bi->ramdisk_addr;
|
||||
ptr->perm = RZ_PERM_RX; // r-x
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
|
||||
if (bi->second_size > 0) {
|
||||
|
|
@ -234,7 +233,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = ROUND_DOWN(base, bi->page_size);
|
||||
ptr->vaddr = bi->second_addr;
|
||||
ptr->perm = RZ_PERM_RX; // r-x
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -269,9 +269,9 @@ static RzPVector /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
struct rz_bin_coff_obj *obj = (struct rz_bin_coff_obj *)bf->o->bin_obj;
|
||||
RzList *ret = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
RzPVector *ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -294,7 +294,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = obj->scn_va[i];
|
||||
}
|
||||
ptr->perm = rz_coff_perms_from_section_flags(obj->scn_hdrs[i].s_flags);
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ static RzPVector /*<RzBinImport *>*/ *imports(RzBinFile *bf) {
|
|||
return rz_bin_dex_imports(dex);
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzBinDex *dex = rz_bin_file_get_dex(bf);
|
||||
if (!dex) {
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -83,13 +83,13 @@ dol_err:
|
|||
return false;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
rz_return_val_if_fail(bf && bf->o && bf->o->bin_obj, NULL);
|
||||
int i;
|
||||
RzList *ret;
|
||||
RzPVector *ret;
|
||||
RzBinSection *s;
|
||||
DolHeader *dol = bf->o->bin_obj;
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -105,7 +105,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
s->size = dol->text_size[i];
|
||||
s->vsize = s->size;
|
||||
s->perm = rz_str_rwx("r-x");
|
||||
rz_list_append(ret, s);
|
||||
rz_pvector_push(ret, s);
|
||||
}
|
||||
/* data sections */
|
||||
for (i = 0; i < N_DATA; i++) {
|
||||
|
|
@ -119,7 +119,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
s->size = dol->data_size[i];
|
||||
s->vsize = s->size;
|
||||
s->perm = rz_str_rwx("r--");
|
||||
rz_list_append(ret, s);
|
||||
rz_pvector_push(ret, s);
|
||||
}
|
||||
/* bss section */
|
||||
s = RZ_NEW0(RzBinSection);
|
||||
|
|
@ -129,7 +129,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
s->size = dol->bss_size;
|
||||
s->vsize = s->size;
|
||||
s->perm = rz_str_rwx("rw-");
|
||||
rz_list_append(ret, s);
|
||||
rz_pvector_push(ret, s);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ static bool __is_data_section(const char *name) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static void sections_from_bin(RzList /*<RzBinSection *>*/ *ret, RzBinFile *bf, RzDyldBinImage *bin) {
|
||||
static void sections_from_bin(RzPVector /*<RzBinSection *>*/ *ret, RzBinFile *bf, RzDyldBinImage *bin) {
|
||||
RzDyldCache *cache = (RzDyldCache *)bf->o->bin_obj;
|
||||
if (!cache) {
|
||||
return;
|
||||
|
|
@ -231,7 +231,7 @@ static void sections_from_bin(RzList /*<RzBinSection *>*/ *ret, RzBinFile *bf, R
|
|||
ptr->vaddr = ptr->paddr;
|
||||
}
|
||||
ptr->perm = sections[i].perm;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
free(sections);
|
||||
MACH0_(mach0_free)
|
||||
|
|
@ -301,12 +301,12 @@ static RzPVector /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzDyldCache *cache = (RzDyldCache *)bf->o->bin_obj;
|
||||
if (!cache) {
|
||||
return NULL;
|
||||
}
|
||||
RzList *ret = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
RzPVector *ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -318,7 +318,9 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ut64 slide = rz_dyldcache_get_slide(cache);
|
||||
if (slide) {
|
||||
RzBinSection *section;
|
||||
rz_list_foreach (ret, iter, section) {
|
||||
void **it;
|
||||
rz_pvector_foreach (ret, it) {
|
||||
section = *it;
|
||||
section->vaddr += slide;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1508,12 +1508,12 @@ static RzPVector /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
ELFOBJ *obj = (bf && bf->o) ? bf->o->bin_obj : NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
RzList *ret = NULL;
|
||||
RzPVector *ret = NULL;
|
||||
|
||||
if (!obj || !(ret = rz_list_newf((RzListFree)rz_bin_section_free))) {
|
||||
if (!obj || !(ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1544,7 +1544,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->type = section->type;
|
||||
ptr->flags = section->flags;
|
||||
ptr->perm = section_perms_from_flags(section->flags);
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
|
||||
// program headers is another section
|
||||
|
|
@ -1615,7 +1615,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
|
||||
// add entry for ehdr
|
||||
|
|
@ -1632,7 +1632,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vsize = ehdr_size;
|
||||
ptr->perm = RZ_PERM_RW;
|
||||
ptr->is_segment = true;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
@ -1774,11 +1774,12 @@ static void lookup_symbols(RzBinFile *bf, RzBinInfo *ret) {
|
|||
}
|
||||
|
||||
static void lookup_sections(RzBinFile *bf, RzBinInfo *ret) {
|
||||
RzList *sections_list = sections(bf);
|
||||
RzListIter *iter;
|
||||
RzPVector *sections_vec = sections(bf);
|
||||
void **iter;
|
||||
RzBinSection *section;
|
||||
ret->has_retguard = -1;
|
||||
rz_list_foreach (sections_list, iter, section) {
|
||||
rz_pvector_foreach (sections_vec, iter) {
|
||||
section = *iter;
|
||||
if (ret->has_retguard != -1) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -1789,7 +1790,7 @@ static void lookup_sections(RzBinFile *bf, RzBinInfo *ret) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
rz_list_free(sections_list);
|
||||
rz_pvector_free(sections_vec);
|
||||
}
|
||||
|
||||
static bool has_sanitizers(RzBinFile *bf) {
|
||||
|
|
@ -1963,10 +1964,11 @@ static ut64 size(RzBinFile *bf) {
|
|||
ut64 off = 0;
|
||||
ut64 len = 0;
|
||||
if (!bf->o->sections) {
|
||||
RzListIter *iter;
|
||||
void **iter;
|
||||
RzBinSection *section;
|
||||
bf->o->sections = sections(bf);
|
||||
rz_list_foreach (bf->o->sections, iter, section) {
|
||||
rz_pvector_foreach (bf->o->sections, iter) {
|
||||
section = *iter;
|
||||
if (section->paddr > off) {
|
||||
off = section->paddr;
|
||||
len = section->size;
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ static RzPVector /*<RzBinImport *>*/ *imports(RzBinFile *bf) {
|
|||
return rz_bin_java_class_const_pool_as_imports(jclass);
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzBinJavaClass *jclass = rz_bin_file_get_java_class(bf);
|
||||
if (!jclass) {
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ static RzBinInfo *info(RzBinFile *bf) {
|
|||
return bin_info_obj->general_info;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
if (!bf) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return rz_list_clone(bin_info_obj->section_list);
|
||||
return rz_pvector_clone(bin_info_obj->section_vec);
|
||||
}
|
||||
|
||||
static RzPVector /*<RzBinSymbol *>*/ *symbols(RzBinFile *bf) {
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ static RzPVector /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
return MACH0_(get_maps)(bf);
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
return MACH0_(get_segments)(bf);
|
||||
}
|
||||
|
||||
|
|
@ -95,11 +95,12 @@ static RzBinAddr *newEntry(ut64 hpaddr, ut64 paddr, int type, int bits) {
|
|||
}
|
||||
|
||||
static void process_constructors(RzBinFile *bf, RzList /*<RzBinAddr *>*/ *ret, int bits) {
|
||||
RzList *secs = sections(bf);
|
||||
RzListIter *iter;
|
||||
RzPVector *secs = sections(bf);
|
||||
void **iter;
|
||||
RzBinSection *sec;
|
||||
int i, type;
|
||||
rz_list_foreach (secs, iter, sec) {
|
||||
rz_pvector_foreach (secs, iter) {
|
||||
sec = *iter;
|
||||
type = -1;
|
||||
if (strstr(sec->name, "_mod_fini_func")) {
|
||||
type = RZ_BIN_ENTRY_TYPE_FINI;
|
||||
|
|
@ -800,10 +801,11 @@ static ut64 size(RzBinFile *bf) {
|
|||
ut64 off = 0;
|
||||
ut64 len = 0;
|
||||
if (!bf->o->sections) {
|
||||
RzListIter *iter;
|
||||
void **iter;
|
||||
RzBinSection *section;
|
||||
bf->o->sections = sections(bf);
|
||||
rz_list_foreach (bf->o->sections, iter, section) {
|
||||
rz_pvector_foreach (bf->o->sections, iter) {
|
||||
section = *iter;
|
||||
if (section->paddr > off) {
|
||||
off = section->paddr;
|
||||
len = section->size;
|
||||
|
|
|
|||
|
|
@ -99,14 +99,13 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
SblHeader *sb = mbn_file_get_hdr(bf);
|
||||
RzBinSection *ptr = NULL;
|
||||
RzList *ret = NULL;
|
||||
if (!(ret = rz_list_new())) {
|
||||
RzPVector *ret = NULL;
|
||||
if (!(ret = rz_pvector_new(free))) {
|
||||
return NULL;
|
||||
}
|
||||
ret->free = free;
|
||||
|
||||
// add text segment
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
|
|
@ -119,7 +118,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = sb->vaddr;
|
||||
ptr->perm = RZ_PERM_RX; // r-x
|
||||
ptr->has_strings = true;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -131,7 +130,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = sb->sign_va;
|
||||
ptr->perm = RZ_PERM_R; // r--
|
||||
ptr->has_strings = true;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (sb->cert_sz && sb->cert_va > sb->vaddr) {
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
|
|
@ -144,7 +143,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = sb->cert_va;
|
||||
ptr->perm = RZ_PERM_R; // r--
|
||||
ptr->has_strings = true;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -219,12 +219,13 @@ static RzPVector /*<RzBinMap *>*/ *mdmp_maps(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *mdmp_sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *mdmp_sections(RzBinFile *bf) {
|
||||
MiniDmpModule *module;
|
||||
MiniDmpObj *obj;
|
||||
struct Pe32_rz_bin_mdmp_pe_bin *pe32_bin;
|
||||
struct Pe64_rz_bin_mdmp_pe_bin *pe64_bin;
|
||||
RzList *ret, *pe_secs;
|
||||
RzPVector *pe_secs;
|
||||
RzPVector *ret;
|
||||
RzListIter *it, *it0;
|
||||
RzBinSection *ptr;
|
||||
ut8 str_buffer[512];
|
||||
|
|
@ -232,7 +233,7 @@ static RzList /*<RzBinSection *>*/ *mdmp_sections(RzBinFile *bf) {
|
|||
|
||||
obj = (MiniDmpObj *)bf->o->bin_obj;
|
||||
|
||||
if (!(ret = rz_list_newf((RzListFree)rz_bin_section_free))) {
|
||||
if (!(ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +277,7 @@ static RzList /*<RzBinSection *>*/ *mdmp_sections(RzBinFile *bf) {
|
|||
/* As this is an encompassing section we will set the RWX to 0 */
|
||||
ptr->perm = 0;
|
||||
|
||||
if (!rz_list_append(ret, ptr)) {
|
||||
if (!rz_pvector_push(ret, ptr)) {
|
||||
free(ptr);
|
||||
break;
|
||||
}
|
||||
|
|
@ -285,15 +286,15 @@ static RzList /*<RzBinSection *>*/ *mdmp_sections(RzBinFile *bf) {
|
|||
rz_list_foreach (obj->pe32_bins, it0, pe32_bin) {
|
||||
if (pe32_bin->vaddr == module->base_of_image && pe32_bin->bin) {
|
||||
pe_secs = Pe32_rz_bin_mdmp_pe_get_sections(pe32_bin);
|
||||
rz_list_join(ret, pe_secs);
|
||||
rz_list_free(pe_secs);
|
||||
rz_pvector_join(ret, pe_secs);
|
||||
rz_pvector_free(pe_secs);
|
||||
}
|
||||
}
|
||||
rz_list_foreach (obj->pe64_bins, it0, pe64_bin) {
|
||||
if (pe64_bin->vaddr == module->base_of_image && pe64_bin->bin) {
|
||||
pe_secs = Pe64_rz_bin_mdmp_pe_get_sections(pe64_bin);
|
||||
rz_list_join(ret, pe_secs);
|
||||
rz_list_free(pe_secs);
|
||||
rz_pvector_join(ret, pe_secs);
|
||||
rz_pvector_free(pe_secs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
ut8 buf[64] = { 0 };
|
||||
const int buf_size = RZ_MIN(sizeof(buf), rz_buf_size(bf->buf));
|
||||
|
|
@ -118,7 +118,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!(ret = rz_list_newf(free))) {
|
||||
if (!(ret = rz_pvector_new(free))) {
|
||||
return NULL;
|
||||
}
|
||||
// add text segment
|
||||
|
|
@ -131,7 +131,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = rz_read_ble32(buf + 12, false);
|
||||
ptr->vaddr = ptr->paddr + baddr(bf);
|
||||
ptr->perm = RZ_PERM_RX; // r-x
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (MENUET_VERSION(buf)) {
|
||||
/* add data section */
|
||||
|
|
@ -146,7 +146,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = rz_read_ble32(buf + 40, false);
|
||||
ptr->vaddr = ptr->paddr + baddr(bf);
|
||||
ptr->perm = RZ_PERM_R; // r--
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return res;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
return rz_bin_mz_get_segments(bf->o->bin_obj);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ RzPVector /*<RzBinImport *>*/ *imports(RzBinFile *bf) {
|
|||
return rz_bin_ne_get_imports(bf->o->bin_obj);
|
||||
}
|
||||
|
||||
RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
return rz_bin_ne_get_segments(bf->o->bin_obj);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ static RzPVector /*<RzBinSymbol *>*/ *symbols(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
ines_hdr ihdr;
|
||||
memset(&ihdr, 0, INES_HDR_SIZE);
|
||||
|
|
@ -92,7 +92,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
RZ_LOG_ERROR("Truncated Header\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
|
|
@ -105,7 +105,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = ROM_START_ADDRESS;
|
||||
ptr->vsize = mirror ? ROM_MIRROR_ADDRESS - ROM_START_ADDRESS : ROM_SIZE; // make sure the ROM zero excess does not overlap the mirror
|
||||
ptr->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
if (mirror) {
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -116,7 +116,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = ROM_MIRROR_ADDRESS;
|
||||
ptr->vsize = ROM_MIRROR_SIZE;
|
||||
ptr->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,15 +136,15 @@ static RzBinSection *n3ds_firm_section_new(N3DSFirmSectHdr *shdr) {
|
|||
return section;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *n3ds_sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *n3ds_sections(RzBinFile *bf) {
|
||||
if (!bf || !bf->o) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
N3DSFirmHdr *hdr = n3ds_get_hdr(bf);
|
||||
|
||||
RzList *ret = NULL;
|
||||
if (!(ret = rz_list_new())) {
|
||||
RzPVector *ret = NULL;
|
||||
if (!(ret = rz_pvector_new(NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ static RzList /*<RzBinSection *>*/ *n3ds_sections(RzBinFile *bf) {
|
|||
if (!sect) {
|
||||
continue;
|
||||
}
|
||||
rz_list_append(ret, sect);
|
||||
rz_pvector_push(ret, sect);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -115,17 +115,17 @@ static ut64 nds_boffset(RzBinFile *bf) {
|
|||
return 0LL;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *nds_sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *nds_sections(RzBinFile *bf) {
|
||||
if (!bf || !bf->o) {
|
||||
return NULL;
|
||||
}
|
||||
RzList *ret = NULL;
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr9 = NULL, *ptr7 = NULL;
|
||||
|
||||
if (!(ret = rz_list_newf((RzListFree)rz_bin_section_free)) ||
|
||||
if (!(ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free)) ||
|
||||
!(ptr9 = RZ_NEW0(RzBinSection)) ||
|
||||
!(ptr7 = RZ_NEW0(RzBinSection))) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
free(ptr9);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ static RzList /*<RzBinSection *>*/ *nds_sections(RzBinFile *bf) {
|
|||
ptr9->paddr = hdr->arm9_rom_offset;
|
||||
ptr9->vaddr = hdr->arm9_ram_address;
|
||||
ptr9->perm = rz_str_rwx("rwx");
|
||||
rz_list_append(ret, ptr9);
|
||||
rz_pvector_push(ret, ptr9);
|
||||
|
||||
ptr7->name = strdup("arm7");
|
||||
ptr7->size = hdr->arm7_size;
|
||||
|
|
@ -145,7 +145,7 @@ static RzList /*<RzBinSection *>*/ *nds_sections(RzBinFile *bf) {
|
|||
ptr7->paddr = hdr->arm7_rom_offset;
|
||||
ptr7->vaddr = hdr->arm7_ram_address;
|
||||
ptr7->perm = rz_str_rwx("rwx");
|
||||
rz_list_append(ret, ptr7);
|
||||
rz_pvector_push(ret, ptr7);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,11 +59,11 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
if (!bf || !bf->buf) {
|
||||
return NULL;
|
||||
}
|
||||
RzList *ret = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
RzPVector *ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
section->vaddr = i ? (i * 0x10000 - 0xc000) : 0;
|
||||
section->size = section->vsize = 0x4000;
|
||||
section->perm = rz_str_rwx("rx");
|
||||
rz_list_append(ret, section);
|
||||
rz_pvector_push(ret, section);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,14 +63,14 @@ static RzBinInfo *info(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *s = RZ_NEW0(RzBinSection);
|
||||
if (!s) {
|
||||
return NULL;
|
||||
}
|
||||
ut64 sz = rz_buf_size(bf->buf);
|
||||
if (!(ret = rz_list_newf((RzListFree)rz_bin_section_free))) {
|
||||
if (!(ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free))) {
|
||||
free(s);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
s->vsize = 0x2000000;
|
||||
s->perm = RZ_PERM_RX;
|
||||
|
||||
rz_list_append(ret, s);
|
||||
rz_pvector_push(ret, s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -208,10 +208,10 @@ maps_err:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
if (!(ret = rz_list_newf((RzListFree)rz_bin_section_free))) {
|
||||
if (!(ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = 0;
|
||||
ptr->vaddr = 0;
|
||||
ptr->perm = RZ_PERM_R;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
int bufsz = rz_buf_size(bf->buf);
|
||||
|
||||
|
|
@ -251,7 +251,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = mod0;
|
||||
ptr->vaddr = mod0 + ba;
|
||||
ptr->perm = RZ_PERM_R; // rw-
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
} else {
|
||||
RZ_LOG_ERROR("Invalid MOD0 address\n");
|
||||
}
|
||||
|
|
@ -264,7 +264,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
RzBinSection *section;
|
||||
rz_pvector_foreach (msecs, iter) {
|
||||
section = *iter;
|
||||
rz_list_append(ret, section);
|
||||
rz_pvector_push(ret, section);
|
||||
}
|
||||
msecs->v.len = 0;
|
||||
rz_pvector_free(msecs);
|
||||
|
|
|
|||
|
|
@ -310,11 +310,11 @@ static RzPVector /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
RzBuffer *b = bf->buf;
|
||||
if (!(ret = rz_list_newf((RzListFree)rz_bin_section_free))) {
|
||||
if (!(ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -324,13 +324,13 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->name = strdup("header");
|
||||
ut32 tmp;
|
||||
if (!rz_buf_read_le32_at(b, NSO_OFF(text_memoffset), &tmp)) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
ptr->size = tmp;
|
||||
|
||||
if (!rz_buf_read_le32_at(b, NSO_OFF(text_memoffset), &tmp)) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
ptr->vsize = tmp;
|
||||
|
|
@ -338,7 +338,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = 0;
|
||||
ptr->vaddr = 0;
|
||||
ptr->perm = RZ_PERM_R;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
RzPVector *mappies = maps(bf);
|
||||
if (mappies) {
|
||||
|
|
@ -348,7 +348,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
RzBinSection *section;
|
||||
rz_pvector_foreach (msecs, iter) {
|
||||
section = *iter;
|
||||
rz_list_append(ret, section);
|
||||
rz_pvector_push(ret, section);
|
||||
}
|
||||
msecs->v.len = 0;
|
||||
rz_pvector_free(msecs);
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret;
|
||||
ut32 ct_omf_sect = 0;
|
||||
|
||||
if (!bf || !bf->o || !bf->o->bin_obj) {
|
||||
|
|
@ -95,7 +95,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
}
|
||||
rz_bin_omf_obj *obj = bf->o->bin_obj;
|
||||
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,29 +44,29 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
if (!bf->o->info) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(ret = rz_list_newf((RzListFree)free))) {
|
||||
if (!(ret = rz_pvector_new((RzPVectorFree)free))) {
|
||||
return NULL;
|
||||
}
|
||||
if (rz_buf_size(bf->buf) < 28) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
// add text segment
|
||||
ut32 textsize;
|
||||
if (!rz_buf_read_le32_at(bf->buf, 4, &textsize)) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
ptr->name = strdup("text");
|
||||
|
|
@ -75,11 +75,11 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = 8 * 4;
|
||||
ptr->vaddr = ptr->paddr;
|
||||
ptr->perm = RZ_PERM_RX; // r-x
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
// add data segment
|
||||
ut32 datasize;
|
||||
if (!rz_buf_read_le32_at(bf->buf, 8, &datasize)) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
if (datasize > 0) {
|
||||
|
|
@ -92,13 +92,13 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = textsize + (8 * 4);
|
||||
ptr->vaddr = ptr->paddr;
|
||||
ptr->perm = RZ_PERM_RW;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
// ignore bss or what
|
||||
// add syms segment
|
||||
ut32 symssize;
|
||||
if (!rz_buf_read_le32_at(bf->buf, 16, &symssize)) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -112,12 +112,12 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = datasize + textsize + (8 * 4);
|
||||
ptr->vaddr = ptr->paddr;
|
||||
ptr->perm = RZ_PERM_R; // r--
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
// add spsz segment
|
||||
ut32 spszsize;
|
||||
if (!rz_buf_read_le32_at(bf->buf, 24, &spszsize)) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
if (spszsize) {
|
||||
|
|
@ -130,13 +130,13 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = symssize + datasize + textsize + (8 * 4);
|
||||
ptr->vaddr = ptr->paddr;
|
||||
ptr->perm = RZ_PERM_R; // r--
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
|
||||
// add pcsz segment
|
||||
ut32 pcszsize;
|
||||
if (!rz_buf_read_le32_at(bf->buf, 24, &pcszsize)) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = spszsize + symssize + datasize + textsize + (8 * 4);
|
||||
ptr->vaddr = ptr->paddr;
|
||||
ptr->perm = RZ_PERM_R; // r--
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,19 +194,19 @@ static RzPVector /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
struct rz_bin_pe_section_t *sections = NULL;
|
||||
struct PE_(rz_bin_pe_obj_t) *bin = (struct PE_(rz_bin_pe_obj_t) *)bf->o->bin_obj;
|
||||
ut64 ba = baddr(bf);
|
||||
int n_nonzero = 0;
|
||||
int i;
|
||||
if (!(ret = rz_list_newf((RzListFree)rz_bin_section_free))) {
|
||||
if (!(ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free))) {
|
||||
return NULL;
|
||||
}
|
||||
if (!bin || !(sections = bin->sections)) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
PE_(rz_bin_pe_check_sections)
|
||||
|
|
@ -228,7 +228,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
if (ptr->size != 0) {
|
||||
n_nonzero++;
|
||||
}
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
if (n_nonzero == 1 && ptr && ptr->perm & RZ_PERM_R) {
|
||||
// if there is only one section, then we expect to have data in here also.
|
||||
|
|
|
|||
|
|
@ -87,19 +87,18 @@ static RzBinInfo *info(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
ut64 textsize = UT64_MAX;
|
||||
RzList *ret = NULL;
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
PebbleAppInfo pai = { { 0 } };
|
||||
if (!rz_buf_read_at(bf->buf, 0, (ut8 *)&pai, sizeof(pai))) {
|
||||
RZ_LOG_ERROR("Truncated Header\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(free))) {
|
||||
return NULL;
|
||||
}
|
||||
ret->free = free;
|
||||
// TODO: load all relocs
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -108,7 +107,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vsize = ptr->size = pai.num_reloc_entries * sizeof(ut32);
|
||||
ptr->vaddr = ptr->paddr = pai.reloc_list_start;
|
||||
ptr->perm = RZ_PERM_RW;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
if (ptr->vaddr < textsize) {
|
||||
textsize = ptr->vaddr;
|
||||
}
|
||||
|
|
@ -121,7 +120,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vsize = ptr->size = 0;
|
||||
ptr->vaddr = ptr->paddr = pai.sym_table_addr;
|
||||
ptr->perm = RZ_PERM_R;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
if (ptr->vaddr < textsize) {
|
||||
textsize = ptr->vaddr;
|
||||
}
|
||||
|
|
@ -133,7 +132,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = ptr->paddr = 0x80;
|
||||
ptr->vsize = ptr->size = textsize - ptr->paddr;
|
||||
ptr->perm = RZ_PERM_RWX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -142,7 +141,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vsize = ptr->size = sizeof(PebbleAppInfo);
|
||||
ptr->vaddr = ptr->paddr = 0;
|
||||
ptr->perm = RZ_PERM_R;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ static RzBinInfo *info(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
section->vaddr = baddr(bf);
|
||||
section->vsize = sz - 2;
|
||||
section->perm = RZ_PERM_RWX;
|
||||
rz_list_append(ret, section);
|
||||
rz_pvector_push(ret, section);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,25 +44,25 @@ static RzBinInfo *info(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *sect = NULL;
|
||||
psxexe_header psxheader;
|
||||
ut64 sz = 0;
|
||||
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(sect = RZ_NEW0(RzBinSection))) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (rz_buf_fread_at(bf->buf, 0, (ut8 *)&psxheader, "8c17i", 1) < sizeof(psxexe_header)) {
|
||||
RZ_LOG_ERROR("Truncated Header\n");
|
||||
free(sect);
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
sect->perm = RZ_PERM_RX;
|
||||
sect->has_strings = true;
|
||||
|
||||
rz_list_append(ret, sect);
|
||||
rz_pvector_push(ret, sect);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ static bool init_pyc_cache(RzBinPycObj *pyc, RzBuffer *buf) {
|
|||
rz_list_append(shared, cobjs);
|
||||
rz_list_append(shared, pyc->interned_table);
|
||||
pyc->shared = shared;
|
||||
RzList *sections = rz_list_newf((RzListFree)free);
|
||||
RzPVector *sections = rz_pvector_new((RzPVectorFree)free);
|
||||
if (!sections) {
|
||||
rz_list_free(shared);
|
||||
return false;
|
||||
|
|
@ -43,7 +43,7 @@ static bool init_pyc_cache(RzBinPycObj *pyc, RzBuffer *buf) {
|
|||
RzPVector *symbols = rz_pvector_new((RzPVectorFree)free);
|
||||
if (!symbols) {
|
||||
rz_list_free(shared);
|
||||
rz_list_free(sections);
|
||||
rz_pvector_free(sections);
|
||||
return false;
|
||||
}
|
||||
pyc->symbols_cache = symbols;
|
||||
|
|
@ -146,7 +146,7 @@ static ut64 baddr(RzBinFile *bf) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *arch) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *arch) {
|
||||
RzBinPycObj *ctx = arch->o->bin_obj;
|
||||
return ctx->sections_cache;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ static bool check_buffer(RzBuffer *buf) {
|
|||
|
||||
static void destroy(RzBinFile *bf) {
|
||||
QnxObj *qo = bf->o->bin_obj;
|
||||
rz_list_free(qo->sections);
|
||||
rz_pvector_free(qo->sections);
|
||||
rz_pvector_free(qo->maps);
|
||||
rz_list_free(qo->fixups);
|
||||
bf->o->bin_obj = NULL;
|
||||
|
|
@ -74,7 +74,7 @@ static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb
|
|||
return false;
|
||||
}
|
||||
|
||||
RzList *sections = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
RzPVector *sections = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
RzPVector *maps = rz_pvector_new((RzPVectorFree)rz_bin_map_free);
|
||||
RzList *fixups = rz_list_newf(free);
|
||||
if (!sections || !maps || !fixups) {
|
||||
|
|
@ -127,7 +127,7 @@ static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb
|
|||
ptr->paddr = offset;
|
||||
ptr->vsize = lrec.data_nbytes - LMF_RESOURCE_SIZE;
|
||||
ptr->size = ptr->vsize;
|
||||
rz_list_append(sections, ptr);
|
||||
rz_pvector_push(sections, ptr);
|
||||
|
||||
RzBinMap *map = RZ_NEW0(RzBinMap);
|
||||
if (!map) {
|
||||
|
|
@ -157,7 +157,7 @@ static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb
|
|||
ptr->vaddr = ldata.offset;
|
||||
ptr->vsize = lrec.data_nbytes - LMF_DATA_SIZE;
|
||||
ptr->size = ptr->vsize;
|
||||
rz_list_append(sections, ptr);
|
||||
rz_pvector_push(sections, ptr);
|
||||
|
||||
RzBinMap *map = RZ_NEW0(RzBinMap);
|
||||
if (!map) {
|
||||
|
|
@ -215,7 +215,7 @@ beach:
|
|||
free(qo);
|
||||
rz_list_free(fixups);
|
||||
rz_pvector_free(maps);
|
||||
rz_list_free(sections);
|
||||
rz_pvector_free(sections);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -301,10 +301,10 @@ static RzPVector /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
}
|
||||
|
||||
// Returns the sections
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
rz_return_val_if_fail(bf && bf->o, NULL);
|
||||
QnxObj *qo = bf->o->bin_obj;
|
||||
return rz_list_clone(qo->sections);
|
||||
return rz_pvector_clone(qo->sections);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ static RzBinInfo *info(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void addrom(RzList /*<RzBinSection *>*/ *ret, const char *name, int i, ut64 paddr, ut64 vaddr, ut32 size) {
|
||||
static void addrom(RzPVector /*<RzBinSection *>*/ *ret, const char *name, int i, ut64 paddr, ut64 vaddr, ut32 size) {
|
||||
RzBinSection *ptr = RZ_NEW0(RzBinSection);
|
||||
if (!ptr) {
|
||||
return;
|
||||
|
|
@ -105,7 +105,7 @@ static void addrom(RzList /*<RzBinSection *>*/ *ret, const char *name, int i, ut
|
|||
ptr->vaddr = vaddr;
|
||||
ptr->size = ptr->vsize = size;
|
||||
ptr->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
@ -126,8 +126,8 @@ static RzPVector /*<RzBinSymbol *>*/ *symbols(RzBinFile *bf) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
// RzBinSection *ptr = NULL;
|
||||
int hdroffset = 0;
|
||||
bool is_hirom = false;
|
||||
|
|
@ -163,7 +163,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
is_hirom = true;
|
||||
}
|
||||
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,9 +252,9 @@ static RzPVector /*<RzBinSymbol *>*/ *symbols(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
if (!(ret = rz_list_new())) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
if (!(ret = rz_pvector_new(NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
RzBinSection *ptr;
|
||||
|
|
@ -265,7 +265,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = ptr->vaddr = 0;
|
||||
ptr->size = ptr->vsize = 0x100;
|
||||
ptr->perm = RZ_PERM_R;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -274,7 +274,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = ptr->vaddr = 0x100;
|
||||
ptr->size = ptr->vsize = sizeof(SMD_Header);
|
||||
ptr->perm = RZ_PERM_R;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -289,7 +289,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
}
|
||||
ptr->size = ptr->vsize = rz_buf_size(bf->buf) - ptr->paddr;
|
||||
ptr->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ static RzBinInfo *info(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
spc_hdr spchdr;
|
||||
memset(&spchdr, 0, SPC_HDR_SIZE);
|
||||
|
|
@ -49,11 +49,11 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
eprintf("Truncated Header\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
ptr->name = strdup("RAM");
|
||||
|
|
@ -62,7 +62,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = 0x0;
|
||||
ptr->vsize = RAM_SIZE;
|
||||
ptr->perm = RZ_PERM_R;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -300,8 +300,8 @@ static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb
|
|||
return obj->bin_obj != NULL;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *res = rz_list_newf((RzListFree)rz_bin_section_free);
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *res = rz_pvector_new((RzPVectorFree)rz_bin_section_free);
|
||||
rz_return_val_if_fail(res && bf->o && bf->o->bin_obj, res);
|
||||
RzCoreSymCacheElement *element = bf->o->bin_obj;
|
||||
size_t i;
|
||||
|
|
@ -309,14 +309,14 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
RzCoreSymCacheElementSegment *seg = &element->segments[i];
|
||||
RzBinSection *s = bin_section_from_segment(seg);
|
||||
if (s) {
|
||||
rz_list_append(res, s);
|
||||
rz_pvector_push(res, s);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < element->hdr->n_sections; i++) {
|
||||
RzCoreSymCacheElementSection *sect = &element->sections[i];
|
||||
RzBinSection *s = bin_section_from_section(sect);
|
||||
if (s) {
|
||||
rz_list_append(res, s);
|
||||
rz_pvector_push(res, s);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -71,16 +71,15 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
struct rz_bin_te_section_t *sections = NULL;
|
||||
int i;
|
||||
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(free))) {
|
||||
return NULL;
|
||||
}
|
||||
ret->free = free;
|
||||
if (!(sections = rz_bin_te_get_sections(bf->o->bin_obj))) {
|
||||
free(ret);
|
||||
return NULL;
|
||||
|
|
@ -112,7 +111,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
if (!strncmp(ptr->name, "_TEXT_RE", 8)) {
|
||||
ptr->bits = RZ_SYS_BITS_16;
|
||||
}
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
free(sections);
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -137,15 +137,15 @@ static RzPVector /*<RzBinMem *>*/ *mem(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
struct rz_bin_vsf_obj *vsf_obj = (struct rz_bin_vsf_obj *)bf->o->bin_obj;
|
||||
if (!vsf_obj) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RzList *ret = NULL;
|
||||
RzPVector *ret = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
if (!(ret = rz_list_new())) {
|
||||
if (!(ret = rz_pvector_new(NULL))) {
|
||||
return NULL;
|
||||
}
|
||||
const int m_idx = vsf_obj->machine_idx;
|
||||
|
|
@ -166,7 +166,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = 0xa000;
|
||||
ptr->vsize = 1024 * 8; // BASIC size (8k)
|
||||
ptr->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
// KERNAL (0xe000 - 0xffff)
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
|
|
@ -178,7 +178,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = 0xe000;
|
||||
ptr->vsize = 1024 * 8; // KERNAL size (8k)
|
||||
ptr->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
// CHARGEN section ignored
|
||||
} else {
|
||||
|
|
@ -193,7 +193,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = 0x4000;
|
||||
ptr->vsize = 1024 * 28; // BASIC size (28k)
|
||||
ptr->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
// MONITOR (0xb000 - 0xbfff)
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
|
|
@ -206,7 +206,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = 0xb000;
|
||||
ptr->vsize = 1024 * 4; // BASIC size (4k)
|
||||
ptr->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
// EDITOR (0xc000 - 0xcfff)
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
|
|
@ -218,7 +218,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = 0xc000;
|
||||
ptr->vsize = 1024 * 4; // BASIC size (4k)
|
||||
ptr->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
// KERNAL (0xe000 - 0xffff)
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
|
|
@ -230,7 +230,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = 0xe000;
|
||||
ptr->vsize = 1024 * 8; // KERNAL size (8k)
|
||||
ptr->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
// CHARGEN section ignored
|
||||
}
|
||||
|
|
@ -250,7 +250,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = 0x0;
|
||||
ptr->vsize = size;
|
||||
ptr->perm = RZ_PERM_RWX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
} else {
|
||||
// RAM C128 (0x0000 - 0xffff): Bank 0
|
||||
// RAM C128 (0x0000 - 0xffff): Bank 1
|
||||
|
|
@ -266,7 +266,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = 0x0;
|
||||
ptr->vsize = size;
|
||||
ptr->perm = RZ_PERM_RWX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
return ret;
|
||||
|
|
@ -277,7 +277,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = 0x0;
|
||||
ptr->vsize = size;
|
||||
ptr->perm = RZ_PERM_RWX;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ static RzBinAddr *binsym(RzBinFile *bf, RzBinSpecialSymbol type) {
|
|||
return NULL; // TODO
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf);
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf);
|
||||
|
||||
static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
||||
RzBinWasmObj *bin = bf && bf->o ? bf->o->bin_obj : NULL;
|
||||
|
|
@ -83,25 +83,25 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzBinWasmObj *bin = bf && bf->o ? bf->o->bin_obj : NULL;
|
||||
RzList *ret = NULL;
|
||||
RzPVector *ret = NULL;
|
||||
RzList *secs = NULL;
|
||||
RzBinSection *ptr = NULL;
|
||||
RzBinWasmSection *sec;
|
||||
|
||||
if (!(ret = rz_list_newf((RzListFree)free))) {
|
||||
if (!(ret = rz_pvector_new((RzPVectorFree)free))) {
|
||||
return NULL;
|
||||
}
|
||||
if (!(secs = rz_bin_wasm_get_sections(bin))) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
RzListIter *iter;
|
||||
rz_list_foreach (secs, iter, sec) {
|
||||
if (!(ptr = RZ_NEW0(RzBinSection))) {
|
||||
rz_list_free(secs);
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
ptr->name = strdup((char *)sec->name);
|
||||
|
|
@ -114,7 +114,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->paddr = sec->offset;
|
||||
// TODO permissions
|
||||
ptr->perm = 0;
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,10 +145,10 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinAddr *>*/ *sections(RzBinFile *bf) {
|
||||
static RzPVector /*<RzBinAddr *>*/ *sections(RzBinFile *bf) {
|
||||
rz_bin_xbe_obj_t *obj = NULL;
|
||||
xbe_header *h = NULL;
|
||||
RzList *ret = NULL;
|
||||
RzPVector *ret = NULL;
|
||||
char tmp[0x100];
|
||||
int i, r;
|
||||
ut32 addr;
|
||||
|
|
@ -161,11 +161,10 @@ static RzList /*<RzBinAddr *>*/ *sections(RzBinFile *bf) {
|
|||
if (h->sections < 1) {
|
||||
return NULL;
|
||||
}
|
||||
ret = rz_list_new();
|
||||
ret = rz_pvector_new(free);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
ret->free = free;
|
||||
if (h->sections < 1 || h->sections > 255) {
|
||||
goto out_error;
|
||||
}
|
||||
|
|
@ -204,11 +203,11 @@ static RzList /*<RzBinAddr *>*/ *sections(RzBinFile *bf) {
|
|||
if (sect.flags & SECT_FLAG_W) {
|
||||
item->perm |= RZ_PERM_W;
|
||||
}
|
||||
rz_list_append(ret, item);
|
||||
rz_pvector_push(ret, item);
|
||||
}
|
||||
return ret;
|
||||
out_error:
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ static RzList /*<RKext *>*/ *filter_kexts(RzXNUKernelCacheObj *obj);
|
|||
static RzList /*<RKext *>*/ *carve_kexts(RzXNUKernelCacheObj *obj);
|
||||
static RzList /*<RKext *>*/ *kexts_from_load_commands(RzXNUKernelCacheObj *obj);
|
||||
|
||||
static void sections_from_mach0(RzList /*<RzBinSection *>*/ *ret, struct MACH0_(obj_t) * mach0, RzBinFile *bf, ut64 paddr, char *prefix, RzXNUKernelCacheObj *obj);
|
||||
static void sections_from_mach0(RzPVector /*<RzBinSection *>*/ *ret, struct MACH0_(obj_t) * mach0, RzBinFile *bf, ut64 paddr, char *prefix, RzXNUKernelCacheObj *obj);
|
||||
static void handle_data_sections(RzBinSection *sect);
|
||||
static void symbols_from_mach0(RzPVector /*<RzBinSymbol *>*/ *ret, struct MACH0_(obj_t) * mach0, RzBinFile *bf, ut64 paddr, int ordinal);
|
||||
static RzList /*<RzBinSymbol *>*/ *resolve_syscalls(RzXNUKernelCacheObj *obj, ut64 enosys_addr);
|
||||
|
|
@ -1105,11 +1105,11 @@ static RzPVector /*<RzBinMap *>*/ *maps(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList *ret = NULL;
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector *ret = NULL;
|
||||
RzBinObject *obj = bf ? bf->o : NULL;
|
||||
|
||||
if (!obj || !obj->bin_obj || !(ret = rz_list_newf((RzListFree)rz_bin_section_free))) {
|
||||
if (!obj || !obj->bin_obj || !(ret = rz_pvector_new((RzPVectorFree)rz_bin_section_free))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1159,7 +1159,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
ptr->vaddr = ptr->paddr;
|
||||
}
|
||||
ptr->perm = prot2perm(seg->initprot);
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
@ -1176,7 +1176,7 @@ static int prot2perm(int x) {
|
|||
return r;
|
||||
}
|
||||
|
||||
static void sections_from_mach0(RzList /*<RzBinSection *>*/ *ret, struct MACH0_(obj_t) * mach0, RzBinFile *bf, ut64 paddr, char *prefix, RzXNUKernelCacheObj *obj) {
|
||||
static void sections_from_mach0(RzPVector /*<RzBinSection *>*/ *ret, struct MACH0_(obj_t) * mach0, RzBinFile *bf, ut64 paddr, char *prefix, RzXNUKernelCacheObj *obj) {
|
||||
struct section_t *sections = NULL;
|
||||
if (!(sections = MACH0_(get_sections)(mach0))) {
|
||||
return;
|
||||
|
|
@ -1208,7 +1208,7 @@ static void sections_from_mach0(RzList /*<RzBinSection *>*/ *ret, struct MACH0_(
|
|||
if (!ptr->perm && strstr(sections[i].name, "__TEXT_EXEC.__text")) {
|
||||
ptr->perm = 1 | 4;
|
||||
}
|
||||
rz_list_append(ret, ptr);
|
||||
rz_pvector_push(ret, ptr);
|
||||
}
|
||||
free(sections);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,14 +103,14 @@ static RzList /*<RzBinAddr *>*/ *entries(RzBinFile *bf) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzList /*<RzBinSection *>*/ *ret = rz_list_new();
|
||||
static RzPVector /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
||||
RzPVector /*<RzBinSection *>*/ *ret = rz_pvector_new(NULL);
|
||||
if (!ret) {
|
||||
return NULL;
|
||||
}
|
||||
RzBinSection *text = RZ_NEW0(RzBinSection);
|
||||
if (!text) {
|
||||
rz_list_free(ret);
|
||||
rz_pvector_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
text->name = strdup("text");
|
||||
|
|
@ -119,7 +119,7 @@ static RzList /*<RzBinSection *>*/ *sections(RzBinFile *bf) {
|
|||
text->paddr = N64_ROM_START;
|
||||
text->vaddr = baddr(bf);
|
||||
text->perm = RZ_PERM_RX;
|
||||
rz_list_append(ret, text);
|
||||
rz_pvector_push(ret, text);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,7 +172,8 @@ static bool objc_build_refs(RzCoreObjc *objc) {
|
|||
}
|
||||
|
||||
static RzCoreObjc *core_objc_new(RzCore *core) {
|
||||
RzList *sections = rz_bin_get_sections(core->bin);
|
||||
RzBinObject *obj = rz_bin_cur_object(core->bin);
|
||||
const RzPVector *sections = obj ? rz_bin_object_get_sections_all(obj) : NULL;
|
||||
if (!sections) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -184,8 +185,9 @@ static RzCoreObjc *core_objc_new(RzCore *core) {
|
|||
}
|
||||
|
||||
RzBinSection *s;
|
||||
RzListIter *iter;
|
||||
rz_list_foreach (sections, iter, s) {
|
||||
void **iter;
|
||||
rz_pvector_foreach (sections, iter) {
|
||||
s = *iter;
|
||||
const char *name = s->name;
|
||||
if (strstr(name, "__objc_data")) {
|
||||
o->_data = s;
|
||||
|
|
@ -594,13 +596,15 @@ static void analyze_objc_stubs(RzCore *core, ut64 start, ut64 size) {
|
|||
*/
|
||||
RZ_API void rz_core_analysis_objc_stubs(RzCore *core) {
|
||||
rz_return_if_fail(core);
|
||||
RzList *sections = rz_bin_get_sections(core->bin);
|
||||
RzBinObject *obj = rz_bin_cur_object(core->bin);
|
||||
const RzPVector *sections = obj ? rz_bin_object_get_sections_all(obj) : NULL;
|
||||
if (!sections) {
|
||||
return;
|
||||
}
|
||||
RzBinSection *stubs_section;
|
||||
RzListIter *iter;
|
||||
rz_list_foreach (sections, iter, stubs_section) {
|
||||
void **iter;
|
||||
rz_pvector_foreach (sections, iter) {
|
||||
stubs_section = *iter;
|
||||
if (strstr(stubs_section->name, "__objc_stubs")) {
|
||||
goto found;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3922,7 +3922,7 @@ end:
|
|||
|
||||
static bool is_unknown_file(RzCore *core) {
|
||||
if (core->bin->cur && core->bin->cur->o) {
|
||||
return (rz_list_empty(core->bin->cur->o->sections));
|
||||
return (rz_pvector_empty(core->bin->cur->o->sections));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -4494,7 +4494,7 @@ RZ_IPI bool rz_analysis_var_global_list_show(RzAnalysis *analysis, RzCmdStateOut
|
|||
return true;
|
||||
}
|
||||
|
||||
static int check_rom_exists(const void *value, const void *data) {
|
||||
static int check_rom_exists(const void *value, const void *data, void *user) {
|
||||
const char *name = (const char *)value;
|
||||
const RzBinSection *sections = (const RzBinSection *)data;
|
||||
return strcmp(name, sections->name);
|
||||
|
|
@ -4523,7 +4523,7 @@ RZ_API bool rz_analysis_add_device_peripheral_map(RzBinObject *o, RzAnalysis *an
|
|||
if (!o->sections) {
|
||||
return false;
|
||||
}
|
||||
if (rz_list_find(o->sections, ".rom", check_rom_exists)) {
|
||||
if (rz_pvector_find(o->sections, ".rom", check_rom_exists, NULL)) {
|
||||
return false;
|
||||
}
|
||||
RzBinSection *s = RZ_NEW0(RzBinSection);
|
||||
|
|
@ -4536,7 +4536,7 @@ RZ_API bool rz_analysis_add_device_peripheral_map(RzBinObject *o, RzAnalysis *an
|
|||
s->size = rom_size;
|
||||
s->paddr = rom_address;
|
||||
s->perm = RZ_PERM_RX;
|
||||
rz_list_append(o->sections, s);
|
||||
rz_pvector_push(o->sections, s);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -956,16 +956,17 @@ RZ_API bool rz_core_bin_apply_sections(RzCore *core, RzBinFile *binfile, bool va
|
|||
if (!o) {
|
||||
return false;
|
||||
}
|
||||
RzList *sections = o->sections;
|
||||
RzPVector *sections = o->sections;
|
||||
|
||||
// make sure both flag spaces exist.
|
||||
rz_flag_space_push(core->flags, RZ_FLAGS_FS_SEGMENTS);
|
||||
rz_flag_space_set(core->flags, RZ_FLAGS_FS_SECTIONS);
|
||||
|
||||
bool segments_only = true;
|
||||
RzListIter *iter;
|
||||
void **iter;
|
||||
RzBinSection *section;
|
||||
rz_list_foreach (sections, iter, section) {
|
||||
rz_pvector_foreach (sections, iter) {
|
||||
section = *iter;
|
||||
if (!section->is_segment) {
|
||||
segments_only = false;
|
||||
break;
|
||||
|
|
@ -973,7 +974,8 @@ RZ_API bool rz_core_bin_apply_sections(RzCore *core, RzBinFile *binfile, bool va
|
|||
}
|
||||
|
||||
int section_index = 0;
|
||||
rz_list_foreach (sections, iter, section) {
|
||||
rz_pvector_foreach (sections, iter) {
|
||||
section = *iter;
|
||||
int va_sect = va ? VA_TRUE : VA_FALSE;
|
||||
if (va && !(section->perm & RZ_PERM_R)) {
|
||||
va_sect = VA_NOREBASE;
|
||||
|
|
@ -1747,13 +1749,14 @@ RZ_API RZ_BORROW const char *rz_core_bin_get_compile_time(RZ_NONNULL RzBinFile *
|
|||
}
|
||||
|
||||
static bool is_executable(RzBinObject *obj) {
|
||||
RzListIter *it;
|
||||
void **it;
|
||||
RzBinSection *sec;
|
||||
rz_return_val_if_fail(obj, false);
|
||||
if (obj->info && obj->info->arch) {
|
||||
return true;
|
||||
}
|
||||
rz_list_foreach (obj->sections, it, sec) {
|
||||
rz_pvector_foreach (obj->sections, it) {
|
||||
sec = *it;
|
||||
if (sec->perm & RZ_PERM_X) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2471,13 +2474,13 @@ RZ_API bool rz_core_bin_sections_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBin
|
|||
rz_return_val_if_fail(core && bf && bf->o && state, false);
|
||||
|
||||
RzBinObject *o = bf->o;
|
||||
RzList *sections = rz_bin_object_get_sections(o);
|
||||
RzPVector *sections = rz_bin_object_get_sections(o);
|
||||
if (!sections) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RzBinSection *section;
|
||||
RzListIter *iter;
|
||||
void **iter;
|
||||
RzOutputMode mode = state->mode;
|
||||
bool res = true;
|
||||
|
||||
|
|
@ -2493,7 +2496,8 @@ RZ_API bool rz_core_bin_sections_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBin
|
|||
rz_cmd_state_output_array_start(state);
|
||||
sections_headers_setup(core, state, hashes);
|
||||
|
||||
rz_list_foreach (sections, iter, section) {
|
||||
rz_pvector_foreach (sections, iter) {
|
||||
section = *iter;
|
||||
if (filter && filter->offset != UT64_MAX) {
|
||||
if (!is_in_symbol_range(section->vaddr, section->vsize, filter->offset) &&
|
||||
!is_in_symbol_range(section->paddr, section->size, filter->offset)) {
|
||||
|
|
@ -2532,7 +2536,7 @@ err:
|
|||
state->mode = mode;
|
||||
rz_table_free(state->d.t);
|
||||
}
|
||||
rz_list_free(sections);
|
||||
rz_pvector_free(sections);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -2632,7 +2636,7 @@ RZ_API bool rz_core_bin_segments_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBin
|
|||
rz_return_val_if_fail(core && bf && bf->o && state, false);
|
||||
|
||||
RzBinObject *o = bf->o;
|
||||
RzList *segments = rz_bin_object_get_segments(o);
|
||||
RzPVector *segments = rz_bin_object_get_segments(o);
|
||||
if (!segments) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2651,7 +2655,9 @@ RZ_API bool rz_core_bin_segments_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBin
|
|||
}
|
||||
}
|
||||
|
||||
rz_list_foreach (segments, iter, segment) {
|
||||
void **it;
|
||||
rz_pvector_foreach (segments, it) {
|
||||
segment = *it;
|
||||
if (filter && filter->offset != UT64_MAX) {
|
||||
if (!is_in_symbol_range(segment->vaddr, segment->vsize, filter->offset) &&
|
||||
!is_in_symbol_range(segment->paddr, segment->size, filter->offset)) {
|
||||
|
|
@ -2675,7 +2681,7 @@ RZ_API bool rz_core_bin_segments_print(RZ_NONNULL RzCore *core, RZ_NONNULL RzBin
|
|||
}
|
||||
|
||||
rz_cmd_state_output_array_end(state);
|
||||
rz_list_free(segments);
|
||||
rz_pvector_free(segments);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,11 +53,12 @@ static void loadGP(RzCore *core) {
|
|||
}
|
||||
}
|
||||
|
||||
static RZ_OWN RzList /*<RzBinSection *>*/ *__save_old_sections(RzCore *core) {
|
||||
RzList *sections = rz_bin_get_sections(core->bin);
|
||||
RzListIter *it;
|
||||
static RZ_OWN RzPVector /*<RzBinSection *>*/ *__save_old_sections(RzCore *core) {
|
||||
RzBinObject *obj = rz_bin_cur_object(core->bin);
|
||||
const RzPVector *sections = obj ? rz_bin_object_get_sections_all(obj) : NULL;
|
||||
void **it;
|
||||
RzBinSection *sec;
|
||||
RzList *old_sections = rz_list_new();
|
||||
RzPVector *old_sections = rz_pvector_new(NULL);
|
||||
|
||||
// Return an empty list
|
||||
if (!sections) {
|
||||
|
|
@ -65,8 +66,9 @@ static RZ_OWN RzList /*<RzBinSection *>*/ *__save_old_sections(RzCore *core) {
|
|||
return old_sections;
|
||||
}
|
||||
|
||||
old_sections->free = sections->free;
|
||||
rz_list_foreach (sections, it, sec) {
|
||||
old_sections->v.free_user = sections->v.free_user;
|
||||
rz_pvector_foreach (sections, it) {
|
||||
sec = *it;
|
||||
RzBinSection *old_sec = RZ_NEW0(RzBinSection);
|
||||
if (!old_sec) {
|
||||
break;
|
||||
|
|
@ -74,14 +76,14 @@ static RZ_OWN RzList /*<RzBinSection *>*/ *__save_old_sections(RzCore *core) {
|
|||
*old_sec = *sec;
|
||||
old_sec->name = strdup(sec->name);
|
||||
old_sec->format = NULL;
|
||||
rz_list_append(old_sections, old_sec);
|
||||
rz_pvector_push(old_sections, old_sec);
|
||||
}
|
||||
return old_sections;
|
||||
}
|
||||
|
||||
struct __rebase_struct {
|
||||
RzCore *core;
|
||||
RzList /*<RzBinSection *>*/ *old_sections;
|
||||
RzPVector /*<RzBinSection *>*/ *old_sections;
|
||||
ut64 old_base;
|
||||
ut64 diff;
|
||||
int type;
|
||||
|
|
@ -93,10 +95,11 @@ struct __rebase_struct {
|
|||
static bool __rebase_flags(RzFlagItem *flag, void *user) {
|
||||
struct __rebase_struct *reb = user;
|
||||
ut64 old_base = reb->old_base;
|
||||
RzListIter *it;
|
||||
void **it;
|
||||
RzBinSection *sec;
|
||||
// Only rebase flags that were in the rebased sections, otherwise it will take too long
|
||||
rz_list_foreach (reb->old_sections, it, sec) {
|
||||
rz_pvector_foreach (reb->old_sections, it) {
|
||||
sec = *it;
|
||||
if (__is_inside_section(flag->offset, sec)) {
|
||||
rz_flag_set(reb->core->flags, flag->name, flag->offset + reb->diff, flag->size);
|
||||
break;
|
||||
|
|
@ -120,8 +123,8 @@ static bool __rebase_xrefs(void *user, const ut64 k, const void *v) {
|
|||
return true;
|
||||
}
|
||||
|
||||
static void __rebase_everything(RzCore *core, RzList /*<RzBinSection *>*/ *old_sections, ut64 old_base) {
|
||||
RzListIter *it, *itit, *ititit;
|
||||
static void __rebase_everything(RzCore *core, RzPVector /*<RzBinSection *>*/ *old_sections, ut64 old_base) {
|
||||
RzListIter *it, *ititit;
|
||||
RzAnalysisFunction *fcn;
|
||||
ut64 new_base = core->bin->cur->o->baddr_shift;
|
||||
RzBinSection *old_section;
|
||||
|
|
@ -131,7 +134,9 @@ static void __rebase_everything(RzCore *core, RzList /*<RzBinSection *>*/ *old_s
|
|||
}
|
||||
// FUNCTIONS
|
||||
rz_list_foreach (core->analysis->fcns, it, fcn) {
|
||||
rz_list_foreach (old_sections, itit, old_section) {
|
||||
void **iter;
|
||||
rz_pvector_foreach (old_sections, iter) {
|
||||
old_section = *iter;
|
||||
if (!__is_inside_section(fcn->addr, old_section)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -230,7 +235,7 @@ RZ_API void rz_core_file_reopen_remote_debug(RzCore *core, const char *uri, ut64
|
|||
}
|
||||
|
||||
core->dbg->main_arena_resolved = false;
|
||||
RzList *old_sections = __save_old_sections(core);
|
||||
RzPVector *old_sections = __save_old_sections(core);
|
||||
ut64 old_base = core->bin->cur->o->baddr_shift;
|
||||
int bits = core->rasm->bits;
|
||||
rz_config_set_i(core->config, "asm.bits", bits);
|
||||
|
|
@ -254,14 +259,14 @@ RZ_API void rz_core_file_reopen_remote_debug(RzCore *core, const char *uri, ut64
|
|||
rz_core_bin_load(core, uri, addr);
|
||||
} else {
|
||||
RZ_LOG_ERROR("Cannot open file '%s'\n", uri);
|
||||
rz_list_free(old_sections);
|
||||
rz_pvector_free(old_sections);
|
||||
return;
|
||||
}
|
||||
rz_core_block_read(core);
|
||||
if (rz_config_get_i(core->config, "dbg.rebase")) {
|
||||
__rebase_everything(core, old_sections, old_base);
|
||||
}
|
||||
rz_list_free(old_sections);
|
||||
rz_pvector_free(old_sections);
|
||||
rz_core_seek_to_register(core, "PC", false);
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +302,7 @@ RZ_API void rz_core_file_reopen_debug(RzCore *core, const char *args) {
|
|||
return;
|
||||
}
|
||||
core->dbg->main_arena_resolved = false;
|
||||
RzList *old_sections = __save_old_sections(core);
|
||||
RzPVector *old_sections = __save_old_sections(core);
|
||||
ut64 old_base = core->bin->cur->o->baddr_shift;
|
||||
int bits = core->rasm->bits;
|
||||
char *bin_abspath = rz_file_abspath(binpath);
|
||||
|
|
@ -312,7 +317,7 @@ RZ_API void rz_core_file_reopen_debug(RzCore *core, const char *args) {
|
|||
if (rz_config_get_i(core->config, "dbg.rebase")) {
|
||||
__rebase_everything(core, old_sections, old_base);
|
||||
}
|
||||
rz_list_free(old_sections);
|
||||
rz_pvector_free(old_sections);
|
||||
rz_core_seek_to_register(core, "PC", false);
|
||||
free(bin_abspath);
|
||||
free(escaped_path);
|
||||
|
|
@ -1624,7 +1629,7 @@ RZ_API void rz_core_io_file_open(RZ_NONNULL RzCore *core, int fd) {
|
|||
// Backup the baddr and sections that were already rebased to
|
||||
// revert the rebase after the debug session is closed
|
||||
ut64 orig_baddr = core->bin->cur->o->baddr_shift;
|
||||
RzList *orig_sections = __save_old_sections(core);
|
||||
RzPVector *orig_sections = __save_old_sections(core);
|
||||
|
||||
rz_bin_file_delete_all(core->bin);
|
||||
rz_io_close_all(core->io);
|
||||
|
|
@ -1632,21 +1637,21 @@ RZ_API void rz_core_io_file_open(RZ_NONNULL RzCore *core, int fd) {
|
|||
|
||||
RzCoreFile *cfile = rz_core_file_open(core, file, RZ_PERM_R, 0);
|
||||
if (!cfile) {
|
||||
rz_list_free(orig_sections);
|
||||
rz_pvector_free(orig_sections);
|
||||
RZ_LOG_ERROR("Cannot open file '%s'\n", file);
|
||||
return;
|
||||
}
|
||||
core->num->value = cfile->fd;
|
||||
// If no baddr defined, use the one provided by the file
|
||||
if (!rz_core_bin_load(core, file, UT64_MAX)) {
|
||||
rz_list_free(orig_sections);
|
||||
rz_pvector_free(orig_sections);
|
||||
RZ_LOG_ERROR("Cannot load binary info of '%s'.\n", file);
|
||||
return;
|
||||
}
|
||||
rz_core_block_read(core);
|
||||
|
||||
__rebase_everything(core, orig_sections, orig_baddr);
|
||||
rz_list_free(orig_sections);
|
||||
rz_pvector_free(orig_sections);
|
||||
free(file);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2631,8 +2631,9 @@ RZ_API int rz_core_cmd_foreach3(RzCore *core, const char *cmd, char *each) { //
|
|||
ut64 offorig = core->offset;
|
||||
ut64 bszorig = core->blocksize;
|
||||
RzBinSection *sec;
|
||||
RzListIter *iter;
|
||||
rz_list_foreach (obj->sections, iter, sec) {
|
||||
void **iter;
|
||||
rz_pvector_foreach (obj->sections, iter) {
|
||||
sec = *iter;
|
||||
rz_core_seek(core, sec->vaddr, true);
|
||||
rz_core_block_size(core, sec->vsize);
|
||||
rz_core_cmd0(core, cmd);
|
||||
|
|
@ -4960,8 +4961,9 @@ static RzCmdStatus do_iter_sections(struct tsr2cmd_state *state, TSNode node, bo
|
|||
ut64 offorig = core->offset;
|
||||
ut64 bszorig = core->blocksize;
|
||||
RzBinSection *sec;
|
||||
RzListIter *iter;
|
||||
rz_list_foreach (obj->sections, iter, sec) {
|
||||
void **iter;
|
||||
rz_pvector_foreach (obj->sections, iter) {
|
||||
sec = *iter;
|
||||
if ((sec->is_segment && show_sections) || (!sec->is_segment && !show_sections)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,14 @@
|
|||
#include "../core_private.h"
|
||||
|
||||
static int bin_is_executable(RzBinObject *obj) {
|
||||
RzListIter *it;
|
||||
void **it;
|
||||
RzBinSection *sec;
|
||||
if (obj) {
|
||||
if (obj->info && obj->info->arch) {
|
||||
return true;
|
||||
}
|
||||
rz_list_foreach (obj->sections, it, sec) {
|
||||
rz_pvector_foreach (obj->sections, it) {
|
||||
sec = *it;
|
||||
if (sec->perm & RZ_PERM_X) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -291,7 +292,7 @@ RZ_IPI RzCmdStatus rz_cmd_info_section_bars_handler(RzCore *core, int argc, cons
|
|||
return RZ_CMD_STATUS_ERROR;
|
||||
}
|
||||
|
||||
RzList *sections = rz_bin_object_get_sections(o);
|
||||
RzPVector *sections = rz_bin_object_get_sections(o);
|
||||
if (!sections) {
|
||||
RZ_LOG_ERROR("Cannot retrieve sections\n");
|
||||
return RZ_CMD_STATUS_ERROR;
|
||||
|
|
@ -303,9 +304,10 @@ RZ_IPI RzCmdStatus rz_cmd_info_section_bars_handler(RzCore *core, int argc, cons
|
|||
goto sections_err;
|
||||
}
|
||||
|
||||
RzListIter *iter;
|
||||
void **iter;
|
||||
RzBinSection *section;
|
||||
rz_list_foreach (sections, iter, section) {
|
||||
rz_pvector_foreach (sections, iter) {
|
||||
section = *iter;
|
||||
char humansz[8];
|
||||
RzInterval pitv = (RzInterval){ section->paddr, section->size };
|
||||
RzInterval vitv = (RzInterval){ section->vaddr, section->vsize };
|
||||
|
|
@ -339,7 +341,7 @@ table_err:
|
|||
list_err:
|
||||
rz_list_free(list);
|
||||
sections_err:
|
||||
rz_list_free(sections);
|
||||
rz_pvector_free(sections);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -715,8 +715,9 @@ RZ_API RZ_OWN RzList /*<RzIOMap *>*/ *rz_core_get_boundaries_prot(RzCore *core,
|
|||
RzBinObject *obj = rz_bin_cur_object(core->bin);
|
||||
if (obj) {
|
||||
RzBinSection *s;
|
||||
RzListIter *iter;
|
||||
rz_list_foreach (obj->sections, iter, s) {
|
||||
void **iter;
|
||||
rz_pvector_foreach (obj->sections, iter) {
|
||||
s = *iter;
|
||||
if (!s->is_segment) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -734,8 +735,9 @@ RZ_API RZ_OWN RzList /*<RzIOMap *>*/ *rz_core_get_boundaries_prot(RzCore *core,
|
|||
ut64 from = UT64_MAX;
|
||||
ut64 to = 0;
|
||||
RzBinSection *s;
|
||||
RzListIter *iter;
|
||||
rz_list_foreach (obj->sections, iter, s) {
|
||||
void **iter;
|
||||
rz_pvector_foreach (obj->sections, iter) {
|
||||
s = *iter;
|
||||
if (s->is_segment) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -771,8 +773,9 @@ RZ_API RZ_OWN RzList /*<RzIOMap *>*/ *rz_core_get_boundaries_prot(RzCore *core,
|
|||
RzBinObject *obj = rz_bin_cur_object(core->bin);
|
||||
if (obj) {
|
||||
RzBinSection *s;
|
||||
RzListIter *iter;
|
||||
rz_list_foreach (obj->sections, iter, s) {
|
||||
void **iter;
|
||||
rz_pvector_foreach (obj->sections, iter) {
|
||||
s = *iter;
|
||||
if (s->is_segment) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -788,8 +791,9 @@ RZ_API RZ_OWN RzList /*<RzIOMap *>*/ *rz_core_get_boundaries_prot(RzCore *core,
|
|||
RzBinObject *obj = rz_bin_cur_object(core->bin);
|
||||
if (obj) {
|
||||
RzBinSection *s;
|
||||
RzListIter *iter;
|
||||
rz_list_foreach (obj->sections, iter, s) {
|
||||
void **iter;
|
||||
rz_pvector_foreach (obj->sections, iter) {
|
||||
s = *iter;
|
||||
if (!s->is_segment) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -804,8 +808,9 @@ RZ_API RZ_OWN RzList /*<RzIOMap *>*/ *rz_core_get_boundaries_prot(RzCore *core,
|
|||
RzBinObject *obj = rz_bin_cur_object(core->bin);
|
||||
if (obj) {
|
||||
RzBinSection *s;
|
||||
RzListIter *iter;
|
||||
rz_list_foreach (obj->sections, iter, s) {
|
||||
void **iter;
|
||||
rz_pvector_foreach (obj->sections, iter) {
|
||||
s = *iter;
|
||||
if (s->is_segment) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -445,17 +445,17 @@ static void analyse_golang_symbols(RzCore *core) {
|
|||
RZ_API bool rz_core_analysis_recover_golang_functions(RzCore *core) {
|
||||
rz_return_val_if_fail(core && core->bin && core->io, false);
|
||||
|
||||
RzList *section_list = rz_bin_get_sections(core->bin);
|
||||
RzBinObject *o = rz_bin_cur_object(core->bin);
|
||||
const RzPVector *sections = o ? rz_bin_object_get_sections_all(o) : NULL;
|
||||
RzPVector *symbols_vec = o ? (RzPVector *)rz_bin_object_get_symbols(o) : NULL;
|
||||
RzListIter *iter;
|
||||
void **it;
|
||||
void **iter;
|
||||
RzBinSection *section;
|
||||
ut32 num_syms = 0;
|
||||
GoPcLnTab pclntab = { 0 };
|
||||
ut8 header[8] = { 0 };
|
||||
|
||||
rz_list_foreach (section_list, iter, section) {
|
||||
rz_pvector_foreach (sections, iter) {
|
||||
section = *iter;
|
||||
// on ELF files the pclntab sections is named .gopclntab, but on macho is __gopclntab
|
||||
if (section->vsize >= 16 && strstr(section->name, "gopclntab")) {
|
||||
pclntab.vaddr = section->vaddr;
|
||||
|
|
@ -468,8 +468,8 @@ RZ_API bool rz_core_analysis_recover_golang_functions(RzCore *core) {
|
|||
|
||||
if (!pclntab.vaddr) {
|
||||
RzBinSymbol *symbol;
|
||||
rz_pvector_foreach (symbols_vec, it) {
|
||||
symbol = *it;
|
||||
rz_pvector_foreach (symbols_vec, iter) {
|
||||
symbol = *iter;
|
||||
// on PE files the pclntab sections is inside .rdata, so rizin creates a symbol for it
|
||||
if (symbol->size >= 16 && !strcmp(symbol->name, "gopclntab")) {
|
||||
pclntab.vaddr = symbol->vaddr;
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ typedef struct rz_bin_object_t {
|
|||
ut64 obj_size;
|
||||
RzPVector /*<RzBinVirtualFile *>*/ *vfiles;
|
||||
RzPVector /*<RzBinMap *>*/ *maps;
|
||||
RzList /*<RzBinSection *>*/ *sections;
|
||||
RzPVector /*<RzBinSection *>*/ *sections;
|
||||
RzPVector /*<RzBinImport *>*/ *imports;
|
||||
RzPVector /*<RzBinSymbol *>*/ *symbols;
|
||||
RzPVector /*<RzBinResource *>*/ *resources;
|
||||
|
|
@ -532,7 +532,7 @@ typedef struct rz_bin_plugin_t {
|
|||
RzPVector /*<RzBinMap *>*/ *(*maps)(RzBinFile *bf);
|
||||
RzBinAddr *(*binsym)(RzBinFile *bf, RzBinSpecialSymbol num);
|
||||
RzList /*<RzBinAddr *>*/ *(*entries)(RzBinFile *bf);
|
||||
RzList /*<RzBinSection *>*/ *(*sections)(RzBinFile *bf);
|
||||
RzPVector /*<RzBinSection *>*/ *(*sections)(RzBinFile *bf);
|
||||
RZ_OWN RzBinSourceLineInfo *(*lines)(RzBinFile *bf); //< only called once on load, ownership is transferred to the caller
|
||||
RzPVector /*<RzBinSymbol *>*/ *(*symbols)(RzBinFile *bf);
|
||||
RzPVector /*<RzBinImport *>*/ *(*imports)(RzBinFile *bf);
|
||||
|
|
@ -814,7 +814,7 @@ typedef struct rz_bin_resource_t {
|
|||
|
||||
typedef ut64 (*RzBinGetOffset)(RzBin *bin, int type, int idx);
|
||||
typedef char *(*RzBinGetName)(RzBin *bin, int type, int idx);
|
||||
typedef RzList *(*RzBinGetSections)(RzBin *bin);
|
||||
typedef const RzPVector *(*RzBinGetSections)(RzBinObject *obj);
|
||||
typedef RzBinSection *(*RzBinGetSectionAt)(RzBin *bin, ut64 addr);
|
||||
typedef char *(*RzBinDemangle)(RzBin *bin, const char *language, const char *mangled);
|
||||
|
||||
|
|
@ -923,7 +923,6 @@ RZ_API RZ_OWN RzPVector /*<RzBinString *>*/ *rz_bin_file_strings(RZ_NONNULL RzBi
|
|||
|
||||
// use RzBinFile instead
|
||||
RZ_DEPRECATE RZ_API RZ_BORROW RzList /*<RzBinAddr *>*/ *rz_bin_get_entries(RZ_NONNULL RzBin *bin);
|
||||
RZ_DEPRECATE RZ_API RZ_BORROW RzList /*<RzBinSection *>*/ *rz_bin_get_sections(RZ_NONNULL RzBin *bin);
|
||||
RZ_DEPRECATE RZ_API int rz_bin_is_static(RZ_NONNULL RzBin *bin);
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinTrycatch *>*/ *rz_bin_file_get_trycatch(RZ_NONNULL RzBinFile *bf);
|
||||
|
||||
|
|
@ -932,9 +931,9 @@ RZ_API const RzPVector /*<RzBinField *>*/ *rz_bin_object_get_fields(RZ_NONNULL R
|
|||
RZ_API const RzPVector /*<RzBinImport *>*/ *rz_bin_object_get_imports(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API const RzBinInfo *rz_bin_object_get_info(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API const RzPVector /*<char *>*/ *rz_bin_object_get_libs(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API const RzList /*<RzBinSection *>*/ *rz_bin_object_get_sections_all(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_object_get_sections(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API RZ_OWN RzList /*<RzBinSection *>*/ *rz_bin_object_get_segments(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API const RzPVector /*<RzBinSection *>*/ *rz_bin_object_get_sections_all(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinSection *>*/ *rz_bin_object_get_sections(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinSection *>*/ *rz_bin_object_get_segments(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API RZ_OWN RzPVector /*<RzBinMap *>*/ *rz_bin_object_get_maps(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API const RzPVector /*<RzBinClass *>*/ *rz_bin_object_get_classes(RZ_NONNULL RzBinObject *obj);
|
||||
RZ_API const RzPVector /*<RzBinString *>*/ *rz_bin_object_get_strings(RZ_NONNULL RzBinObject *obj);
|
||||
|
|
|
|||
|
|
@ -312,6 +312,9 @@ RZ_API void **rz_pvector_contains(RzPVector *vec, const void *x);
|
|||
// find the element in the vec based on cmparator
|
||||
RZ_API RZ_BORROW void **rz_pvector_find(RZ_NONNULL const RzPVector *vec, RZ_NONNULL const void *element, RZ_NONNULL RzPVectorComparator cmp, void *user);
|
||||
|
||||
// join two pvector into one, pvec1 should free the joined element in pvec2
|
||||
RZ_API bool rz_pvector_join(RZ_NONNULL RzPVector *pvec1, RZ_NONNULL RzPVector *pvec2);
|
||||
|
||||
// removes and returns the pointer at the given index. Does not call free.
|
||||
RZ_API void *rz_pvector_remove_at(RzPVector *vec, size_t index);
|
||||
|
||||
|
|
|
|||
|
|
@ -1299,10 +1299,12 @@ RZ_API int rz_main_rizin(int argc, const char **argv) {
|
|||
rz_core_seek(r, fi->offset, true);
|
||||
} else {
|
||||
if (o) {
|
||||
RzList *sections = rz_bin_get_sections(r->bin);
|
||||
RzListIter *iter;
|
||||
RzBinObject *obj = rz_bin_cur_object(r->bin);
|
||||
const RzPVector *sections = obj ? rz_bin_object_get_sections_all(obj) : NULL;
|
||||
void **iter;
|
||||
RzBinSection *s;
|
||||
rz_list_foreach (sections, iter, s) {
|
||||
rz_pvector_foreach (sections, iter) {
|
||||
s = *iter;
|
||||
if (s->perm & RZ_PERM_X) {
|
||||
ut64 addr = s->vaddr ? s->vaddr : s->paddr;
|
||||
rz_core_seek(r, addr, true);
|
||||
|
|
|
|||
|
|
@ -436,18 +436,20 @@ static int rabin_dump_symbols(RzBin *bin, int len) {
|
|||
}
|
||||
|
||||
static bool __dumpSections(RzBin *bin, const char *scnname, const char *output, const char *file) {
|
||||
RzList *sections;
|
||||
RzListIter *iter;
|
||||
void **iter;
|
||||
RzBinSection *section;
|
||||
ut8 *buf;
|
||||
char *ret;
|
||||
int r;
|
||||
|
||||
if (!(sections = rz_bin_get_sections(bin))) {
|
||||
RzBinObject *obj = rz_bin_cur_object(bin);
|
||||
const RzPVector *sections = obj ? rz_bin_object_get_sections_all(obj) : NULL;
|
||||
if (!sections) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rz_list_foreach (sections, iter, section) {
|
||||
rz_pvector_foreach (sections, iter) {
|
||||
section = *iter;
|
||||
if (!strcmp(scnname, section->name)) {
|
||||
if (!(buf = malloc(section->size))) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1236,31 +1236,31 @@ static void section_stringify(const RzBinSection *elem, RzStrBuf *sb) {
|
|||
}
|
||||
|
||||
static RzDiff *rz_diff_sections_new(DiffFile *dfile_a, DiffFile *dfile_b, bool compare_addr) {
|
||||
RzList *list_a = NULL;
|
||||
RzList *list_b = NULL;
|
||||
RzPVector *vec_a = NULL;
|
||||
RzPVector *vec_b = NULL;
|
||||
|
||||
list_a = rz_diff_file_get(dfile_a, sections);
|
||||
if (!list_a) {
|
||||
vec_a = rz_diff_file_get(dfile_a, sections);
|
||||
if (!vec_a) {
|
||||
rz_diff_error_ret(NULL, "cannot get sections from '%s'\n", dfile_a->dio->filename);
|
||||
}
|
||||
|
||||
list_b = rz_diff_file_get(dfile_b, sections);
|
||||
if (!list_b) {
|
||||
vec_b = rz_diff_file_get(dfile_b, sections);
|
||||
if (!vec_b) {
|
||||
rz_diff_error_ret(NULL, "cannot get sections from '%s'\n", dfile_b->dio->filename);
|
||||
}
|
||||
|
||||
rz_list_sort(list_a, (RzListComparator)section_compare);
|
||||
rz_list_sort(list_b, (RzListComparator)section_compare);
|
||||
rz_pvector_sort(vec_a, (RzPVectorComparator)section_compare, NULL);
|
||||
rz_pvector_sort(vec_b, (RzPVectorComparator)section_compare, NULL);
|
||||
|
||||
RzDiffMethods methods = {
|
||||
.elem_at = (RzDiffMethodElemAt)rz_diff_list_elem_at,
|
||||
.elem_at = (RzDiffMethodElemAt)rz_diff_pvector_elem_at,
|
||||
.elem_hash = (RzDiffMethodElemHash)(compare_addr ? section_hash_addr : section_hash),
|
||||
.compare = (RzDiffMethodCompare)(compare_addr ? section_compare_addr : section_compare),
|
||||
.stringify = (RzDiffMethodStringify)(compare_addr ? section_stringify_addr : section_stringify),
|
||||
.ignore = NULL,
|
||||
};
|
||||
|
||||
return rz_diff_generic_new(list_a, rz_list_length(list_a), list_b, rz_list_length(list_b), &methods);
|
||||
return rz_diff_generic_new(vec_a, rz_pvector_len(vec_a), vec_b, rz_pvector_len(vec_b), &methods);
|
||||
}
|
||||
|
||||
/**************************************** fields ***************************************/
|
||||
|
|
|
|||
|
|
@ -444,6 +444,28 @@ RZ_API RZ_BORROW void **rz_pvector_find(RZ_NONNULL const RzPVector *vec, RZ_NONN
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Joins 2 pvector into one (pvec2 pointer needs to be freed by the user)
|
||||
*
|
||||
**/
|
||||
RZ_API bool rz_pvector_join(RZ_NONNULL RzPVector *pvec1, RZ_NONNULL RzPVector *pvec2) {
|
||||
rz_return_val_if_fail(pvec1 && pvec2, 0);
|
||||
|
||||
if (rz_pvector_empty(pvec2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RzVector *vec = &pvec1->v;
|
||||
RESIZE_OR_RETURN_NULL(RZ_MAX(NEXT_VECTOR_CAPACITY, pvec1->v.len + pvec2->v.len));
|
||||
memmove((void **)pvec1->v.a + pvec1->v.len, pvec2->v.a, pvec2->v.elem_size * pvec2->v.len);
|
||||
pvec1->v.len += pvec2->v.len;
|
||||
|
||||
// element in pvec2 is freed by pvec1
|
||||
pvec2->v.len = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
RZ_API void *rz_pvector_remove_at(RzPVector *vec, size_t index) {
|
||||
rz_return_val_if_fail(vec, NULL);
|
||||
void *r = rz_pvector_at(vec, index);
|
||||
|
|
|
|||
|
|
@ -21,13 +21,13 @@ bool test_rz_bin(void) {
|
|||
|
||||
RzBinObject *obj = rz_bin_cur_object(bin);
|
||||
|
||||
RzList *sections = rz_bin_object_get_sections(obj);
|
||||
mu_assert_eq(rz_list_length(sections), 29, "rz_bin_object_get_sections");
|
||||
rz_list_free(sections);
|
||||
RzPVector *sections = rz_bin_object_get_sections(obj);
|
||||
mu_assert_eq(rz_pvector_len(sections), 29, "rz_bin_object_get_sections");
|
||||
rz_pvector_free(sections);
|
||||
|
||||
RzList *segments = rz_bin_object_get_segments(obj);
|
||||
mu_assert_eq(rz_list_length(segments), 10, "rz_bin_object_get_segments");
|
||||
rz_list_free(segments);
|
||||
RzPVector *segments = rz_bin_object_get_segments(obj);
|
||||
mu_assert_eq(rz_pvector_len(segments), 10, "rz_bin_object_get_segments");
|
||||
rz_pvector_free(segments);
|
||||
|
||||
const RzList *entries = rz_bin_object_get_entries(obj);
|
||||
mu_assert_eq(rz_list_length(entries), 1, "rz_bin_object_get_entries");
|
||||
|
|
|
|||
|
|
@ -921,6 +921,17 @@ static bool test_pvector_find(void) {
|
|||
mu_end;
|
||||
}
|
||||
|
||||
static bool test_pvector_join(void) {
|
||||
RzPVector m, n;
|
||||
init_test_pvector(&m, 5, 0);
|
||||
init_test_pvector(&n, 3, 0);
|
||||
mu_assert_eq(rz_pvector_len(&m), 5, "length is 5 before join");
|
||||
rz_pvector_join(&m, &n);
|
||||
mu_assert_eq(rz_pvector_len(&m), 8, "length is 8 after join");
|
||||
mu_assert_eq(*((ut32 *)rz_pvector_at(&m, 6)), 1, "m[6] = n[1]");
|
||||
mu_end;
|
||||
}
|
||||
|
||||
static bool test_pvector_contains(void) {
|
||||
RzPVector v;
|
||||
init_test_pvector(&v, 5, 0);
|
||||
|
|
@ -1424,6 +1435,7 @@ static int all_tests(void) {
|
|||
mu_run_test(test_pvector_at);
|
||||
mu_run_test(test_pvector_set);
|
||||
mu_run_test(test_pvector_find);
|
||||
mu_run_test(test_pvector_join);
|
||||
mu_run_test(test_pvector_contains);
|
||||
mu_run_test(test_pvector_remove_at);
|
||||
mu_run_test(test_pvector_insert);
|
||||
|
|
|
|||
Loading…
Reference in a new issue