Rizin
unix-like reverse engineering framework and cli tools
bobj.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2019 pancake <pancake@nopcode.org>
2 // SPDX-FileCopyrightText: 2009-2019 nibble <nibble.ds@gmail.com>
3 // SPDX-FileCopyrightText: 2009-2019 dso <dso@rice.edu>
4 // SPDX-License-Identifier: LGPL-3.0-only
5 
6 #include <rz_bin.h>
7 #include <rz_util.h>
8 #include "i/private.h"
9 
16  rz_return_if_fail(bstr);
17 
18  char *decoded = bstr->string;
19  do {
20  // ensure to decode base64 strings encoded multiple times.
21  char *tmp = (char *)rz_base64_decode_dyn(decoded, -1);
22  if (!tmp || !rz_str_is_printable(tmp)) {
23  free(tmp);
24  break;
25  }
26  free(decoded);
27  decoded = tmp;
28  } while (1);
29 
30  if (decoded == bstr->string) {
31  return;
32  }
33  free(bstr->string);
34  bstr->string = decoded;
35  bstr->length = strlen(decoded);
36  bstr->type = RZ_STRING_ENC_BASE64;
37 }
38 
41 
42  RzBinString *bstr;
44  rz_list_foreach (strings, iter, bstr) {
46  }
47 }
48 
49 RZ_API void rz_bin_mem_free(void *data) {
50  RzBinMem *mem = (RzBinMem *)data;
51  if (mem && mem->mirrors) {
52  mem->mirrors->free = rz_bin_mem_free;
53  rz_list_free(mem->mirrors);
54  mem->mirrors = NULL;
55  }
56  free(mem);
57 }
58 
61  switch (reloc->type) {
62  case RZ_BIN_RELOC_8:
63  return 8;
64  case RZ_BIN_RELOC_16:
65  return 16;
66  case RZ_BIN_RELOC_24:
67  return 24;
68  case RZ_BIN_RELOC_32:
69  return 32;
70  case RZ_BIN_RELOC_64:
71  return 64;
72  }
73  return 0;
74 }
75 
76 #define CMP_CHECK(member) \
77  do { \
78  if (ar->member != br->member) { \
79  return RZ_NUM_CMP(ar->member, br->member); \
80  } \
81  } while (0);
82 
83 static int reloc_cmp(const void *a, const void *b) {
84  const RzBinReloc *ar = a;
85  const RzBinReloc *br = b;
86  CMP_CHECK(vaddr);
87  CMP_CHECK(paddr);
88  CMP_CHECK(type);
89  CMP_CHECK(target_vaddr);
90  return 0;
91 }
92 
93 static int reloc_target_cmp(const void *a, const void *b) {
94  const RzBinReloc *ar = a;
95  const RzBinReloc *br = b;
96  CMP_CHECK(target_vaddr);
97  CMP_CHECK(vaddr);
98  CMP_CHECK(paddr);
99  CMP_CHECK(type);
100  return 0;
101 }
102 
103 #undef CMP_CHECK
104 
107  if (!ret) {
108  return NULL;
109  }
110  RzPVector sorter;
111  rz_pvector_init(&sorter, NULL);
113  RzPVector target_sorter;
114  rz_pvector_init(&target_sorter, NULL);
115  rz_pvector_reserve(&target_sorter, rz_list_length(relocs));
116  RzListIter *it;
117  RzBinReloc *reloc;
118  rz_list_foreach (relocs, it, reloc) {
119  rz_pvector_push(&sorter, reloc);
120  if (rz_bin_reloc_has_target(reloc)) {
121  rz_pvector_push(&target_sorter, reloc);
122  }
123  }
124  relocs->free = NULL; // ownership of relocs transferred
126  rz_pvector_sort(&sorter, reloc_cmp);
127  ret->relocs_count = rz_pvector_len(&sorter);
128  ret->relocs = (RzBinReloc **)rz_pvector_flush(&sorter);
129  rz_pvector_fini(&sorter);
130  rz_pvector_sort(&target_sorter, reloc_target_cmp);
131  ret->target_relocs_count = rz_pvector_len(&target_sorter);
132  ret->target_relocs = (RzBinReloc **)rz_pvector_flush(&target_sorter);
133  rz_pvector_fini(&target_sorter);
134  return ret;
135 }
136 
138  if (!storage) {
139  return;
140  }
141  for (size_t i = 0; i < storage->relocs_count; i++) {
142  rz_bin_reloc_free(storage->relocs[i]);
143  }
144  free(storage->relocs);
145  free(storage->target_relocs);
146  free(storage);
147 }
148 
149 static int reloc_vaddr_cmp(ut64 ref, RzBinReloc *reloc) {
150  return RZ_NUM_CMP(ref, reloc->vaddr);
151 }
152 
155  rz_return_val_if_fail(storage && size >= 1, NULL);
156  if (!storage->relocs) {
157  return NULL;
158  }
159  size_t i;
160  rz_array_lower_bound(storage->relocs, storage->relocs_count, vaddr, i, reloc_vaddr_cmp);
161  if (i >= storage->relocs_count) {
162  return NULL;
163  }
164  RzBinReloc *r = storage->relocs[i];
165  return r->vaddr >= vaddr && r->vaddr < vaddr + size ? r : NULL;
166 }
167 
168 static int reloc_target_vaddr_cmp(ut64 ref, RzBinReloc *reloc) {
169  return RZ_NUM_CMP(ref, reloc->target_vaddr);
170 }
171 
174  rz_return_val_if_fail(storage, NULL);
175  if (!storage->target_relocs) {
176  return NULL;
177  }
178  size_t i;
180  if (!i) {
181  return NULL;
182  }
183  i--;
184  RzBinReloc *r = storage->target_relocs[i];
185  return r->target_vaddr == vaddr ? r : NULL;
186 }
187 
189  if (!o) {
190  return;
191  }
192  free(o->regstate);
194  ht_up_free(o->addrzklassmethod);
195  rz_list_free(o->entries);
196  rz_list_free(o->maps);
197  rz_list_free(o->vfiles);
198  rz_list_free(o->fields);
199  rz_list_free(o->imports);
200  rz_list_free(o->libs);
204  ht_pp_free(o->import_name_symbols);
205  rz_list_free(o->symbols);
206  rz_list_free(o->classes);
207  ht_pp_free(o->classes_ht);
208  ht_pp_free(o->methods_ht);
210  rz_list_free(o->mem);
211  for (ut32 i = 0; i < RZ_BIN_SPECIAL_SYMBOL_LAST; i++) {
212  free(o->binsym[i]);
213  }
214  free(o);
215 }
216 
217 static char *swiftField(const char *dn, const char *cn) {
218  if (!dn || !cn) {
219  return NULL;
220  }
221 
222  char *p = strstr(dn, ".getter_");
223  if (!p) {
224  p = strstr(dn, ".setter_");
225  if (!p) {
226  p = strstr(dn, ".method_");
227  }
228  }
229  if (p) {
230  char *q = strstr(dn, cn);
231  if (q && q[strlen(cn)] == '.') {
232  q = strdup(q + strlen(cn) + 1);
233  char *r = strchr(q, '.');
234  if (r) {
235  *r = 0;
236  }
237  return q;
238  }
239  }
240  return NULL;
241 }
242 
244  RzBinSymbol *sym;
245  RzListIter *iter;
246  rz_list_foreach (bf->o->symbols, iter, sym) {
247  if (sym->name[0] != '_') {
248  continue;
249  }
250  const char *cn = sym->classname;
251  if (cn) {
253  if (!c) {
254  continue;
255  }
256  // swift specific
257  char *dn = sym->dname;
258  char *fn = swiftField(dn, cn);
259  if (fn) {
260  RzBinField *f = rz_bin_field_new(sym->paddr, sym->vaddr, sym->size, fn, NULL, NULL, false);
261  rz_list_append(c->fields, f);
262  free(fn);
263  } else {
264  char *mn = strstr(dn, "..");
265  if (!mn) {
266  mn = strstr(dn, cn);
267  if (mn && mn[strlen(cn)] == '.') {
268  rz_list_append(c->methods, sym);
269  }
270  }
271  }
272  }
273  }
274  return bf->o->classes;
275 }
276 
277 // TODO: kill offset and sz, because those should be inferred from binfile->buf
279  rz_return_val_if_fail(bf && plugin, NULL);
280  ut64 bytes_sz = rz_buf_size(bf->buf);
282  if (!o) {
283  return NULL;
284  }
285  o->opts = *opts;
286  if (o->opts.loadaddr == UT64_MAX) {
287  // no loadaddr means 0 loadaddr
288  o->opts.loadaddr = 0;
289  }
290  o->obj_size = (bytes_sz >= sz + offset) ? sz : 0;
291  o->boffset = offset;
292  o->regstate = NULL;
294  o->classes_ht = ht_pp_new0();
295  o->methods_ht = ht_pp_new0();
296  o->baddr_shift = 0;
297  o->plugin = plugin;
298 
299  if (plugin && plugin->load_buffer) {
300  if (!plugin->load_buffer(bf, o, bf->buf, bf->sdb)) {
301  if (bf->rbin->verbose) {
302  RZ_LOG_ERROR("rz_bin_object_new: load_buffer failed for %s plugin\n", plugin->name);
303  }
305  return NULL;
306  }
307  } else {
308  RZ_LOG_WARN("Plugin %s should implement load_buffer method.\n", plugin->name);
310  return NULL;
311  }
312 
313  // XXX - object size can't be set here and needs to be set where where
314  // the object is created from. The reason for this is to prevent
315  // mis-reporting when the file is loaded from impartial bytes or is
316  // extracted from a set of bytes in the file
317  rz_bin_file_set_obj(bf->rbin, bf, o);
320 
321  if (!bf->rbin->sdb) {
322  return o;
323  }
324 
325  sdb_ns_set(bf->sdb, "info", o->kv);
326  sdb_ns_set(bf->rbin->sdb, "cur", bf->sdb);
327  char *fdns = rz_str_newf("fd.%d", bf->fd);
328  if (fdns) {
329  sdb_ns_set(bf->rbin->sdb, fdns, bf->sdb);
330  free(fdns);
331  }
332  bf->sdb->refs++;
333 
334  return o;
335 }
336 
337 static void filter_classes(RzBinFile *bf, RzList *list) {
338  HtPU *db = ht_pu_new0();
339  HtPP *ht = ht_pp_new0();
340  RzListIter *iter, *iter2;
341  RzBinClass *cls;
342  RzBinSymbol *sym;
343  rz_list_foreach (list, iter, cls) {
344  if (!cls->name) {
345  continue;
346  }
347  int namepad_len = strlen(cls->name) + 32;
348  char *namepad = malloc(namepad_len + 1);
349  if (!namepad) {
350  RZ_LOG_ERROR("Cannot allocate %d byte(s)\n", namepad_len);
351  break;
352  }
353 
354  strcpy(namepad, cls->name);
355  char *p = rz_bin_filter_name(bf, db, cls->index, namepad);
356  if (p) {
357  namepad = p;
358  }
359  free(cls->name);
360  cls->name = namepad;
361  rz_list_foreach (cls->methods, iter2, sym) {
362  if (sym->name) {
363  rz_bin_filter_sym(bf, ht, sym->vaddr, sym);
364  }
365  }
366  }
367  ht_pu_free(db);
368  ht_pp_free(ht);
369 }
370 
372  ht_pp_free(o->classes_ht);
373  ht_pp_free(o->methods_ht);
374  o->classes_ht = ht_pp_new0();
375  o->methods_ht = ht_pp_new0();
376 
377  RzListIter *it, *it2;
378  RzBinClass *klass;
379  RzBinSymbol *method;
380  rz_list_foreach (o->classes, it, klass) {
381  if (klass->name) {
382  ht_pp_insert(o->classes_ht, klass->name, klass);
383 
384  rz_list_foreach (klass->methods, it2, method) {
385  const char *name = sdb_fmt("%s::%s", klass->name, method->name);
386  ht_pp_insert(o->methods_ht, name, method);
387  }
388  }
389  }
390 }
391 
393  rz_return_val_if_fail(bf && o && o->plugin, false);
394 
395  RzBin *bin = bf->rbin;
396  RzBinPlugin *p = o->plugin;
397  int minlen = (bf->rbin->minstrlen > 0) ? bf->rbin->minstrlen : p->minstrlen;
398  bf->o = o;
399 
400  if (p->file_type) {
401  int type = p->file_type(bf);
402  if (type == RZ_BIN_TYPE_CORE) {
403  if (p->regstate) {
404  o->regstate = p->regstate(bf);
405  }
406  }
407  }
408 
409  if (p->boffset) {
410  o->boffset = p->boffset(bf);
411  }
412  // XXX: no way to get info from xtr pluginz?
413  // Note, object size can not be set from here due to potential
414  // inconsistencies
415  if (p->size) {
416  o->size = p->size(bf);
417  }
418  // XXX this is expensive because is O(n^n)
419  if (p->binsym) {
420  for (size_t i = 0; i < RZ_BIN_SPECIAL_SYMBOL_LAST; i++) {
421  o->binsym[i] = p->binsym(bf, i);
422  if (o->binsym[i]) {
423  o->binsym[i]->paddr += o->opts.loadaddr;
424  }
425  }
426  }
427  if (p->entries) {
428  o->entries = p->entries(bf);
430  }
431  if (p->virtual_files) {
432  o->vfiles = p->virtual_files(bf);
433  }
434  if (p->maps) {
435  o->maps = p->maps(bf);
436  if (o->maps) {
437  REBASE_PADDR(o, o->maps, RzBinMap);
438  }
439  }
440  if (p->fields) {
441  o->fields = p->fields(bf);
442  if (o->fields) {
445  }
446  }
447  if (p->imports) {
448  rz_list_free(o->imports);
449  o->imports = p->imports(bf);
450  if (o->imports) {
452  }
453  }
454  if (p->symbols) {
455  o->symbols = p->symbols(bf);
456  if (o->symbols) {
459  if (bin->filter) {
461  }
462  o->import_name_symbols = ht_pp_new0();
463  if (o->import_name_symbols) {
464  RzBinSymbol *sym;
465  RzListIter *it;
466  rz_list_foreach (o->symbols, it, sym) {
467  if (!sym->is_imported || !sym->name || !*sym->name) {
468  continue;
469  }
470  ht_pp_insert(o->import_name_symbols, sym->name, sym);
471  }
472  }
473  }
474  }
475  if (p->libs) {
476  o->libs = p->libs(bf);
477  }
478  if (p->sections) {
479  // XXX sections are populated by call to size
480  if (!o->sections) {
481  o->sections = p->sections(bf);
482  }
484  if (bin->filter) {
486  }
487  }
488 
489  o->info = p->info ? p->info(bf) : NULL;
490 
491  if (bin->filter_rules & (RZ_BIN_REQ_RELOCS | RZ_BIN_REQ_IMPORTS)) {
492  if (p->relocs) {
493  RzList *l = p->relocs(bf);
494  if (l) {
495  REBASE_PADDR(o, l, RzBinReloc);
497  }
498  }
499  }
500  if (bin->filter_rules & RZ_BIN_REQ_STRINGS) {
501  RzList *strings;
502  if (p->strings) {
503  strings = p->strings(bf);
504  } else {
505  // when a bin plugin does not provide it's own strings
506  // we always take all the strings found in the binary
507  // the method also converts the paddrs to vaddrs
508  strings = rz_bin_file_strings(bf, minlen, true);
509  }
510 
511  if (bin->debase64) {
513  }
515 
516  // RzBinStrDb becomes the owner of the RzList strings
518  }
519 
520  if (o->info && RZ_STR_ISEMPTY(o->info->compiler)) {
521  free(o->info->compiler);
523  if (o->info->compiler) {
524  o->info->lang = "go";
525  }
526  }
527 
528  o->lang = rz_bin_language_detect(bf);
529 
530  if (bin->filter_rules & (RZ_BIN_REQ_CLASSES | RZ_BIN_REQ_CLASSES_SOURCES)) {
531  if (p->classes) {
532  RzList *classes = p->classes(bf);
533  if (classes) {
534  // XXX we should probably merge them instead
535  rz_list_free(o->classes);
536  o->classes = classes;
538  }
539 
540  if (o->lang == RZ_BIN_LANGUAGE_SWIFT) {
541  o->classes = classes_from_symbols(bf);
542  }
543  } else {
545  if (classes) {
546  o->classes = classes;
547  }
548  }
549 
550  if (bin->filter) {
551  filter_classes(bf, o->classes);
552  }
553 
554  // cache addr=class+method
555  if (o->classes) {
556  RzList *klasses = o->classes;
557  RzListIter *iter, *iter2;
558  RzBinClass *klass;
559  RzBinSymbol *method;
560  if (!o->addrzklassmethod) {
561  // this is slow. must be optimized, but at least its cached
562  o->addrzklassmethod = ht_up_new0();
563  rz_list_foreach (klasses, iter, klass) {
564  rz_list_foreach (klass->methods, iter2, method) {
565  ht_up_insert(o->addrzklassmethod, method->vaddr, method);
566  }
567  }
568  }
569  }
570  }
571  if (p->lines) {
572  o->lines = p->lines(bf);
573  }
574  if (p->get_sdb) {
575  Sdb *new_kv = p->get_sdb(bf);
576  if (new_kv != o->kv) {
577  sdb_free(o->kv);
578  }
579  o->kv = new_kv;
580  }
581  if (p->mem) {
582  o->mem = p->mem(bf);
583  }
584  if (p->resources) {
585  o->resources = p->resources(bf);
586  }
587  return true;
588 }
589 
591  rz_return_val_if_fail(bf && o, NULL);
592 
593  static bool first = true;
594  // rz_bin_object_set_items set o->relocs but there we don't have access
595  // to io so we need to be run from bin_relocs, free the previous reloc and get
596  // the patched ones
597  if (first && o->plugin && o->plugin->patch_relocs) {
598  RzList *tmp = o->plugin->patch_relocs(bf);
599  first = false;
600  if (!tmp) {
601  return o->relocs;
602  }
606  first = false;
607  bf->rbin->is_reloc_patched = true;
608  }
609  return o->relocs;
610 }
611 
617  rz_return_val_if_fail(o && imp && imp->name, NULL);
618  if (!o->import_name_symbols) {
619  return NULL;
620  }
621  return ht_pp_find(o->import_name_symbols, imp->name, NULL);
622 }
623 
626  if (!o->vfiles) {
627  return NULL;
628  }
629  RzListIter *it;
630  RzBinVirtualFile *vf;
631  rz_list_foreach (o->vfiles, it, vf) {
632  if (!strcmp(vf->name, name)) {
633  return vf;
634  }
635  }
636  return NULL;
637 }
638 
640  rz_return_val_if_fail(bin && bin->cur, NULL);
641  return bin->cur->o;
642 }
643 
645  rz_return_val_if_fail(bf && arch && name, NULL);
646  if (bf->o) {
647  RzBinInfo *info = bf->o->info;
648  if (info && info->arch && info->file &&
649  (bits == info->bits) &&
650  !strcmp(info->arch, arch) &&
651  !strcmp(info->file, name)) {
652  return bf->o;
653  }
654  }
655  return NULL;
656 }
657 
662  return o ? addr + o->baddr_shift : addr;
663 }
664 
665 /* \brief Resolve the given address pair to a vaddr if possible
666  * returns vaddr, rebased with the baseaddr of bin, if va is enabled for bin,
667  * paddr otherwise
668  */
671 
672  if (paddr == UT64_MAX) {
673  // everything we have is the vaddr
674  return vaddr;
675  }
676 
677  /* hack to realign thumb symbols */
678  if (o->info && o->info->arch) {
679  if (o->info->bits == 16) {
680  RzBinSection *s = rz_bin_get_section_at(o, paddr, false);
681  // autodetect thumb
682  if (s && (s->perm & RZ_PERM_X) && strstr(s->name, "text")) {
683  if (!strcmp(o->info->arch, "arm") && (vaddr & 1)) {
684  vaddr = (vaddr >> 1) << 1;
685  }
686  }
687  }
688  }
689 
690  if (o->info && o->info->has_va) {
691  return rz_bin_object_addr_with_base(o, vaddr);
692  }
693  return paddr;
694 }
695 
701  if (sym < 0 || sym >= RZ_BIN_SPECIAL_SYMBOL_LAST) {
702  return NULL;
703  }
704  return o ? o->binsym[sym] : NULL;
705 }
706 
712  return obj->entries;
713 }
714 
720  return obj->fields;
721 }
722 
728  return obj->imports;
729 }
730 
736  return obj->info;
737 }
738 
744  return obj->libs;
745 }
746 
752  return obj->sections;
753 }
754 
755 static RzList *get_sections_or_segment(RzBinObject *obj, bool is_segment) {
756  RzList *res = rz_list_new();
757  if (!res) {
758  return NULL;
759  }
761  RzListIter *it;
762  RzBinSection *sec;
763  rz_list_foreach (all, it, sec) {
764  if (sec->is_segment == is_segment) {
765  rz_list_append(res, sec);
766  }
767  }
768  return res;
769 }
770 
776  return get_sections_or_segment(obj, false);
777 }
778 
784  return get_sections_or_segment(obj, true);
785 }
786 
792  return obj->classes;
793 }
794 
800  if (!obj->strings) {
801  return NULL;
802  }
803  return obj->strings->list;
804 }
805 
811  return obj->mem;
812 }
813 
819  return obj->symbols;
820 }
821 
825 RZ_API const RzList /*<RzBinResource *>*/ *rz_bin_object_get_resources(RZ_NONNULL RzBinObject *obj) {
827  return obj->resources;
828 }
829 
834  rz_return_val_if_fail(bin && bf && obj, false);
836 
837  RzList *strings = NULL;
838  RzBinPlugin *plugin = obj->plugin;
839  if (plugin && plugin->strings) {
840  strings = plugin->strings(bf);
841  } else {
842  // when a bin plugin does not provide it's own strings
843  // we always take all the strings found in the binary
844  // the method also converts the paddrs to vaddrs
845  strings = rz_bin_file_strings(bf, bin->minstrlen, true);
846  }
847 
848  if (bin->debase64) {
850  }
852 
853  // RzBinStrDb becomes the owner of the RzList strings
854  obj->strings = rz_bin_string_database_new(strings);
855  return obj->strings != NULL;
856 }
857 
862  rz_return_val_if_fail(obj, false);
863  if (!obj->strings) {
864  return NULL;
865  }
866  if (is_va) {
867  return ht_up_find(obj->strings->virt, address, NULL);
868  }
869  return ht_up_find(obj->strings->phys, address, NULL);
870 }
871 
876  rz_return_val_if_fail(obj, false);
877  return obj->info ? obj->info->big_endian : false;
878 }
879 
884  rz_return_val_if_fail(obj, false);
885  if (obj->libs && rz_list_length(obj->libs) > 0) {
886  return RZ_BIN_DBG_STATIC & obj->info->dbg_info;
887  }
888  return true;
889 }
890 
891 static void bin_section_map_fini(void *e, void *user) {
892  (void)user;
894  rz_pvector_fini(&bsm->sections);
895 }
896 
904 
906  if (!all) {
907  return NULL;
908  }
909 
911  RzList *segments = rz_list_new();
912  RzBinSection *section, *segment;
913  RzListIter *iter;
914 
915  rz_list_foreach (all, iter, section) {
916  RzList *list = section->is_segment ? segments : sections;
918  }
919 
921  if (!res) {
922  goto err;
923  }
924  rz_vector_reserve(res, rz_list_length(segments));
925 
926  rz_list_foreach (segments, iter, segment) {
927  if (segment->vaddr == UT64_MAX) {
928  continue;
929  }
930  RzInterval segment_itv = (RzInterval){ segment->vaddr, segment->size };
931  RzListIter *iter2;
932 
934  map.segment = segment;
935  rz_pvector_init(&map.sections, NULL);
936 
937  rz_list_foreach (sections, iter2, section) {
938  if (section->vaddr == UT64_MAX) {
939  continue;
940  }
941  RzInterval section_itv = (RzInterval){ section->vaddr, section->vsize };
942  if (rz_itv_begin(section_itv) >= rz_itv_begin(segment_itv) && rz_itv_end(section_itv) <= rz_itv_end(segment_itv) && section->name[0]) {
943  rz_pvector_push(&map.sections, section);
944  }
945  }
946  rz_vector_push(res, &map);
947  }
948 
949 err:
950  rz_list_free(segments);
952  return res;
953 }
954 
955 static ut64 map_p2v(RzBinMap *m, ut64 paddr) {
956  ut64 delta = paddr - m->paddr;
957  if (delta >= m->vsize) {
958  return UT64_MAX;
959  }
960  return m->vaddr + delta;
961 }
962 
972  RzBinMap *m = rz_bin_object_get_map_at(obj, paddr, false);
973  if (!m) {
974  return UT64_MAX;
975  }
976 
977  return map_p2v(m, paddr);
978 }
979 
989  RzPVector *maps = rz_bin_object_get_maps_at(obj, paddr, false);
990  if (!maps) {
991  return NULL;
992  }
993 
994  RzVector *res = rz_vector_new(sizeof(ut64), NULL, NULL);
995  void **it;
996  rz_pvector_foreach (maps, it) {
997  RzBinMap *map = *(RzBinMap **)it;
998  ut64 vaddr = map_p2v(map, paddr);
999  if (vaddr != UT64_MAX) {
1000  rz_vector_push(res, &vaddr);
1001  }
1002  }
1003 
1005  return res;
1006 }
1007 
1017  RzBinMap *m = rz_bin_object_get_map_at(obj, vaddr, true);
1018  if (!m) {
1019  return UT64_MAX;
1020  }
1021 
1022  ut64 delta = vaddr - m->vaddr;
1023  if (delta >= m->psize) {
1024  return UT64_MAX;
1025  }
1026  return m->paddr + delta;
1027 }
1028 
1037  RzBinStrDb *db = RZ_NEW0(RzBinStrDb);
1038  if (!db) {
1039  RZ_LOG_ERROR("rz_bin: Cannot allocate RzBinStrDb\n");
1040  rz_list_free(list);
1041  return NULL;
1042  }
1043 
1045  db->phys = ht_up_new0();
1046  db->virt = ht_up_new0();
1047  if (!db->list || !db->phys || !db->virt) {
1048  RZ_LOG_ERROR("rz_bin: Cannot allocate RzBinStrDb internal data structure.\n");
1049  goto fail;
1050  }
1051 
1052  RzListIter *it;
1053  RzBinString *bstr;
1054  rz_list_foreach (list, it, bstr) {
1055  if (!ht_up_update(db->phys, bstr->paddr, bstr)) {
1056  RZ_LOG_ERROR("rz_bin: Cannot insert/update RzBinString in RzBinStrDb (phys)\n");
1057  goto fail;
1058  }
1059  if (!ht_up_update(db->virt, bstr->vaddr, bstr)) {
1060  RZ_LOG_ERROR("rz_bin: Cannot insert/update RzBinString in RzBinStrDb (virt)\n");
1061  goto fail;
1062  }
1063  }
1064  return db;
1065 
1066 fail:
1068  return NULL;
1069 }
1070 
1077  if (!db) {
1078  return;
1079  }
1080  rz_list_free(db->list);
1081  ht_up_free(db->phys);
1082  ht_up_free(db->virt);
1083  free(db);
1084 }
1085 
1095  rz_return_val_if_fail(db && bstr, false);
1096 
1097  if (!rz_list_append(db->list, bstr)) {
1098  RZ_LOG_ERROR("rz_bin: Cannot add RzBinString in RzBinStrDb (list)\n");
1099  return false;
1100  }
1101 
1102  if (!ht_up_update(db->phys, bstr->paddr, bstr)) {
1103  RZ_LOG_ERROR("rz_bin: Cannot add RzBinString in RzBinStrDb (phys)\n");
1104  return false;
1105  }
1106 
1107  if (!ht_up_update(db->virt, bstr->vaddr, bstr)) {
1108  RZ_LOG_ERROR("rz_bin: Cannot add RzBinString in RzBinStrDb (virt)\n");
1109  return false;
1110  }
1111  return true;
1112 }
1113 
1118  rz_return_val_if_fail(db, false);
1119 
1120  RzBinString *bstr = ht_up_find(is_va ? db->virt : db->phys, address, NULL);
1121  if (!bstr) {
1122  return false;
1123  }
1124 
1125  ht_up_delete(db->virt, bstr->vaddr);
1126  ht_up_delete(db->phys, bstr->paddr);
1127  rz_list_delete_data(db->list, bstr);
1128  return true;
1129 }
#define e(frag)
#define RZ_IPI
Definition: analysis_wasm.c:11
lzma_index ** i
Definition: index.h:629
static const ut32 ar[]
Definition: apprentice.c:1935
static RzILOpEffect * cls(cs_insn *insn)
Definition: arm_il64.c:915
static bool err
Definition: armass.c:435
RZ_API RzBinClass * rz_bin_file_add_class(RzBinFile *bf, const char *name, const char *super, int view)
Definition: bfile.c:523
RZ_IPI bool rz_bin_file_set_obj(RzBin *bin, RzBinFile *bf, RzBinObject *obj)
Definition: bfile.c:263
RZ_IPI void rz_bin_class_free(RzBinClass *k)
Definition: bfile.c:512
RZ_API RZ_OWN RzList * rz_bin_file_strings(RZ_NONNULL RzBinFile *bf, size_t min_length, bool raw_strings)
Generates a RzList struct containing RzBinString from a given RzBinFile.
Definition: bfile_string.c:325
RZ_API void rz_bin_filter_symbols(RzBinFile *bf, RzList *list)
Definition: filter.c:128
RZ_API void rz_bin_filter_sections(RzBinFile *bf, RzList *list)
Definition: filter.c:144
RZ_API char * rz_bin_filter_name(RzBinFile *bf, HtPU *db, ut64 vaddr, char *name)
Definition: filter.c:33
RZ_API void rz_bin_filter_sym(RzBinFile *bf, HtPP *ht, ut64 vaddr, RzBinSymbol *sym)
Definition: filter.c:81
RZ_IPI RZ_OWN char * rz_bin_file_golang_compiler(RZ_NONNULL RzBinFile *bf)
Returns the golang compiler info if buildinfo struct is found.
Definition: golang.c:265
RZ_API void rz_bin_info_free(RzBinInfo *rb)
Definition: bin.c:97
RZ_API void rz_bin_string_free(void *_str)
Definition: bin.c:192
RZ_API RZ_BORROW RzBinMap * rz_bin_object_get_map_at(RZ_NONNULL RzBinObject *o, ut64 off, bool va)
Find the last binary map at offset off .
Definition: bin.c:643
RZ_API RZ_OWN RzPVector * rz_bin_object_get_maps_at(RzBinObject *o, ut64 off, bool va)
Find all binary maps at offset off .
Definition: bin.c:668
RZ_API RZ_BORROW RzBinSection * rz_bin_get_section_at(RzBinObject *o, ut64 off, int va)
Find the binary section at offset off.
Definition: bin.c:611
RZ_API RzBinField * rz_bin_field_new(ut64 paddr, ut64 vaddr, int size, const char *name, const char *comment, const char *format, bool format_named)
Definition: bin.c:935
RZ_API void rz_bin_set_baddr(RzBin *bin, ut64 baddr)
Definition: bin.c:549
RZ_API void rz_bin_reloc_free(RzBinReloc *reloc)
Definition: bin.c:188
static RzList * maps(RzBinFile *bf)
Definition: bin_bf.c:116
static RzList * classes(RzBinFile *bf)
Definition: bin_dex.c:71
RZ_API RzBinLanguage rz_bin_language_detect(RzBinFile *binfile)
Tries to detect which language is used in the binary based on symbols and libraries.
Definition: bin_language.c:69
RzBinInfo * info(RzBinFile *bf)
Definition: bin_ne.c:86
RzList * sections(RzBinFile *bf)
Definition: bin_ne.c:110
RzList * relocs(RzBinFile *bf)
Definition: bin_ne.c:114
int bits(struct state *s, int need)
Definition: blast.c:72
RZ_API bool rz_bin_string_database_remove(RZ_NONNULL RzBinStrDb *db, ut64 address, bool is_va)
Return true if the given address has been removed to the RzBinObject string database.
Definition: bobj.c:1117
static RzList * classes_from_symbols(RzBinFile *bf)
Definition: bobj.c:243
RZ_API RZ_OWN RzBinStrDb * rz_bin_string_database_new(RZ_NULLABLE RZ_OWN RzList *list)
Allocates and initializes the RzBinStrDb structure with the given list of strings.
Definition: bobj.c:1036
RZ_API const RzBinInfo * rz_bin_object_get_info(RZ_NONNULL RzBinObject *obj)
Get the RzBinInfo of the binary object.
Definition: bobj.c:734
static void filter_classes(RzBinFile *bf, RzList *list)
Definition: bobj.c:337
static char * swiftField(const char *dn, const char *cn)
Definition: bobj.c:217
RZ_API const RzList * rz_bin_object_get_entries(RZ_NONNULL RzBinObject *obj)
Get list of RzBinAddr representing the entry points of the binary object.
Definition: bobj.c:710
RZ_API const RzList * rz_bin_object_get_classes(RZ_NONNULL RzBinObject *obj)
Get list of RzBinClass representing the classes (e.g. C++ classes) defined in the binary object.
Definition: bobj.c:790
RZ_API void rz_bin_string_database_free(RZ_NULLABLE RzBinStrDb *db)
Frees a RzBinStrDb structure.
Definition: bobj.c:1076
RZ_API RzBinVirtualFile * rz_bin_object_get_virtual_file(RzBinObject *o, const char *name)
Definition: bobj.c:624
RZ_API RZ_BORROW RzBinString * rz_bin_object_get_string_at(RZ_NONNULL RzBinObject *obj, ut64 address, bool is_va)
Return RzBinString if at address there is an entry in the RzBinObject string database.
Definition: bobj.c:861
RZ_API void rz_bin_string_decode_base64(RZ_NONNULL RzBinString *bstr)
Tries to decode the base64 string hold by RzBinString and overwrites it.
Definition: bobj.c:15
RZ_API const RzList * rz_bin_object_get_imports(RZ_NONNULL RzBinObject *obj)
Get list of RzBinImport representing the imports of the binary object.
Definition: bobj.c:726
RZ_API int rz_bin_object_set_items(RzBinFile *bf, RzBinObject *o)
Definition: bobj.c:392
RZ_API const RzBinAddr * rz_bin_object_get_special_symbol(RzBinObject *o, RzBinSpecialSymbol sym)
Return the RzBinAddr structure representing the special symbol sym.
Definition: bobj.c:699
RZ_API const RzList * rz_bin_object_get_fields(RZ_NONNULL RzBinObject *obj)
Get list of RzBinField representing the fields of the binary object.
Definition: bobj.c:718
RZ_API RZ_OWN RzVector * rz_bin_object_sections_mapping_list(RZ_NONNULL RzBinObject *obj)
Get the mapping between segments and sections in the binary.
Definition: bobj.c:902
static int reloc_vaddr_cmp(ut64 ref, RzBinReloc *reloc)
Definition: bobj.c:149
RZ_API const RzList * rz_bin_object_get_libs(RZ_NONNULL RzBinObject *obj)
Get list of char* representing the libraries used by the binary object.
Definition: bobj.c:742
RZ_API const RzList * rz_bin_object_get_sections_all(RZ_NONNULL RzBinObject *obj)
Get list of RzBinSection representing both the sections and the segments of the binary object.
Definition: bobj.c:750
RZ_API ut64 rz_bin_object_addr_with_base(RzBinObject *o, ut64 addr)
Put the given address on top of o's base address.
Definition: bobj.c:661
RZ_API RzVector * rz_bin_object_p2v_all(RZ_NONNULL RzBinObject *obj, ut64 paddr)
Convert offset in the file to all possible virtual addresses according to binary mappings.
Definition: bobj.c:987
static void bin_section_map_fini(void *e, void *user)
Definition: bobj.c:891
RZ_IPI RzBinObject * rz_bin_object_get_cur(RzBin *bin)
Definition: bobj.c:639
RZ_API RzBinSymbol * rz_bin_object_get_symbol_of_import(RzBinObject *o, RzBinImport *imp)
Find the symbol that represents the given import This is necessary for example to determine the addre...
Definition: bobj.c:616
RZ_API const RzList * rz_bin_object_get_strings(RZ_NONNULL RzBinObject *obj)
Get list of RzBinString representing the strings identified in the binary object.
Definition: bobj.c:798
static int reloc_cmp(const void *a, const void *b)
Definition: bobj.c:83
static int reloc_target_vaddr_cmp(ut64 ref, RzBinReloc *reloc)
Definition: bobj.c:168
RZ_API RzBinRelocStorage * rz_bin_reloc_storage_new(RZ_OWN RzList *relocs)
Definition: bobj.c:105
RZ_API bool rz_bin_object_reset_strings(RZ_NONNULL RzBin *bin, RZ_NONNULL RzBinFile *bf, RZ_NONNULL RzBinObject *obj)
Remove all previously identified strings in the binary object and scan it again for strings.
Definition: bobj.c:833
RZ_API ut64 rz_bin_object_v2p(RZ_NONNULL RzBinObject *obj, ut64 vaddr)
Convert virtual address to offset in the file according to binary mappings.
Definition: bobj.c:1015
RZ_API ut64 rz_bin_object_get_vaddr(RzBinObject *o, ut64 paddr, ut64 vaddr)
Definition: bobj.c:669
static ut64 map_p2v(RzBinMap *m, ut64 paddr)
Definition: bobj.c:955
RZ_API const RzList * rz_bin_object_get_mem(RZ_NONNULL RzBinObject *obj)
Get list of RzBinMem representing the memory regions identified in the binary object.
Definition: bobj.c:809
RZ_API ut64 rz_bin_object_p2v(RZ_NONNULL RzBinObject *obj, ut64 paddr)
Convert offset in the file to virtual address according to binary mappings.
Definition: bobj.c:970
RZ_API void rz_bin_mem_free(void *data)
Definition: bobj.c:49
RZ_IPI void rz_bin_object_free(RzBinObject *o)
Definition: bobj.c:188
static void rz_bin_object_rebuild_classes_ht(RzBinObject *o)
Definition: bobj.c:371
#define CMP_CHECK(member)
Definition: bobj.c:76
RZ_API bool rz_bin_string_database_add(RZ_NONNULL RzBinStrDb *db, RZ_NONNULL RzBinString *bstr)
{ function_description }
Definition: bobj.c:1094
RZ_API const RzList * rz_bin_object_get_resources(RZ_NONNULL RzBinObject *obj)
Get a list of RzBinResource representing the resources in the binary object.
Definition: bobj.c:825
RZ_API RZ_OWN RzList * rz_bin_object_get_segments(RZ_NONNULL RzBinObject *obj)
Get list of RzBinSection representing only the segments of the binary object.
Definition: bobj.c:782
static RzList * get_sections_or_segment(RzBinObject *obj, bool is_segment)
Definition: bobj.c:755
RZ_API bool rz_bin_object_is_big_endian(RZ_NONNULL RzBinObject *obj)
Return true if the binary object obj is big endian.
Definition: bobj.c:875
RZ_API RZ_OWN RzList * rz_bin_object_get_sections(RZ_NONNULL RzBinObject *obj)
Get list of RzBinSection representing only the sections of the binary object.
Definition: bobj.c:774
static void bin_object_decode_all_base64_strings(RzList *strings)
Definition: bobj.c:39
RZ_IPI RzBinObject * rz_bin_object_new(RzBinFile *bf, RzBinPlugin *plugin, RzBinObjectLoadOptions *opts, ut64 offset, ut64 sz)
Definition: bobj.c:278
RZ_API RzBinReloc * rz_bin_reloc_storage_get_reloc_to(RzBinRelocStorage *storage, ut64 vaddr)
Get a reloc that points exactly to vaddr or NULL.
Definition: bobj.c:173
RZ_API RzBinReloc * rz_bin_reloc_storage_get_reloc_in(RzBinRelocStorage *storage, ut64 vaddr, ut64 size)
Get the reloc with the lowest vaddr that starts inside the given interval.
Definition: bobj.c:154
RZ_API const RzList * rz_bin_object_get_symbols(RZ_NONNULL RzBinObject *obj)
Get list of RzBinSymbol representing the symbols in the binary object.
Definition: bobj.c:817
RZ_API RzBinRelocStorage * rz_bin_object_patch_relocs(RzBinFile *bf, RzBinObject *o)
Definition: bobj.c:590
RZ_API void rz_bin_reloc_storage_free(RzBinRelocStorage *storage)
Definition: bobj.c:137
RZ_IPI RzBinObject * rz_bin_object_find_by_arch_bits(RzBinFile *bf, const char *arch, int bits, const char *name)
Definition: bobj.c:644
RZ_API bool rz_bin_object_is_static(RZ_NONNULL RzBinObject *obj)
Return true if the binary object obj is detected as statically compiled.
Definition: bobj.c:883
RZ_API ut64 rz_bin_reloc_size(RzBinReloc *reloc)
size of the reloc (where it is supposed to be patched) in bits
Definition: bobj.c:60
static int reloc_target_cmp(const void *a, const void *b)
Definition: bobj.c:93
#define RZ_API
#define NULL
Definition: cris-opc.c:27
#define r
Definition: crypto_rc6.c:12
cs_arch arch
Definition: cstool.c:13
RZ_API void rz_bin_source_line_info_free(RzBinSourceLineInfo *sli)
Definition: dbginfo.c:137
uint32_t ut32
size_t map(int syms, int left, int len)
Definition: enough.c:237
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type strings(--mime-type and\n" " --mime-encoding)\n") OPT('s'
RZ_API char * sdb_fmt(const char *fmt,...)
Definition: fmt.c:26
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
void * p
Definition: libc.cpp:67
void * mem
Definition: libc.cpp:91
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API bool rz_list_delete_data(RZ_NONNULL RzList *list, void *ptr)
Deletes an entry in the list by searching for a pointer.
Definition: list.c:148
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
Definition: list.c:109
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
void * malloc(size_t size)
Definition: malloc.c:123
static const char struct stat static buf struct stat static buf static idle const char static path static fd const char static len const void static prot const char struct module static image struct kernel_sym static table unsigned char static buf static fsuid unsigned struct dirent unsigned static count const struct iovec static count static pid const void static len static flags const struct sched_param static p static pid static policy struct timespec static tp static suid unsigned fn
Definition: sflib.h:186
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
int type
Definition: mipsasm.c:17
RZ_API int sdb_ns_set(Sdb *s, const char *name, Sdb *r)
Definition: ns.c:156
static RzSocket * s
Definition: rtr.c:28
#define rz_warn_if_fail(expr)
Definition: rz_assert.h:35
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API ut8 * rz_base64_decode_dyn(const char *in, int len)
Definition: ubase64.c:65
#define RZ_BIN_DBG_STATIC
Definition: rz_bin.h:28
@ RZ_BIN_LANGUAGE_SWIFT
Definition: rz_bin.h:152
#define RZ_BIN_REQ_CLASSES_SOURCES
Definition: rz_bin.h:79
#define RZ_BIN_REQ_RELOCS
Definition: rz_bin.h:58
@ RZ_BIN_RELOC_32
Definition: rz_bin.h:176
@ RZ_BIN_RELOC_24
Definition: rz_bin.h:175
@ RZ_BIN_RELOC_16
Definition: rz_bin.h:174
@ RZ_BIN_RELOC_64
Definition: rz_bin.h:177
@ RZ_BIN_RELOC_8
Definition: rz_bin.h:173
#define REBASE_PADDR(o, l, type_t)
Definition: rz_bin.h:662
#define RZ_BIN_REQ_CLASSES
Definition: rz_bin.h:61
#define RZ_BIN_REQ_IMPORTS
Definition: rz_bin.h:46
@ RZ_BIN_TYPE_CORE
Definition: rz_bin.h:182
RzBinSpecialSymbol
Definition: rz_bin.h:136
@ RZ_BIN_SPECIAL_SYMBOL_LAST
Definition: rz_bin.h:141
static bool rz_bin_reloc_has_target(RzBinReloc *reloc)
Definition: rz_bin.h:828
#define RZ_BIN_REQ_STRINGS
Definition: rz_bin.h:52
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
Definition: buf.c:1225
static ut64 rz_itv_begin(RzInterval itv)
Definition: rz_itv.h:34
struct rz_interval_t RzInterval
static ut64 rz_itv_end(RzInterval itv)
Definition: rz_itv.h:42
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
#define RZ_LOG_WARN(fmtstr,...)
Definition: rz_log.h:56
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
#define RZ_NUM_CMP(a, b)
Typical comparison (1/0/-1) for two numbers of arbitrary types, including unsigned.
Definition: rz_num.h:157
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
@ RZ_STRING_ENC_BASE64
Definition: rz_str.h:27
#define RZ_STR_ISEMPTY(x)
Definition: rz_str.h:67
RZ_API bool rz_str_is_printable(const char *str)
Definition: str.c:2038
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_PERM_X
Definition: rz_types.h:95
#define RZ_FREE_CUSTOM(x, y)
Definition: rz_types.h:375
#define RZ_BORROW
Definition: rz_types.h:63
#define UT64_MAX
Definition: rz_types_base.h:86
static void ** rz_pvector_reserve(RzPVector *vec, size_t capacity)
Definition: rz_vector.h:312
RZ_API void rz_pvector_sort(RzPVector *vec, RzPVectorComparator cmp)
Definition: vector.c:408
RZ_API void rz_pvector_init(RzPVector *vec, RzPVectorFree free)
Definition: vector.c:298
RZ_API void rz_pvector_fini(RzPVector *vec)
Definition: vector.c:331
RZ_API void * rz_vector_reserve(RzVector *vec, size_t capacity)
Definition: vector.c:214
static size_t rz_pvector_len(const RzPVector *vec)
Definition: rz_vector.h:231
RZ_API void * rz_vector_push(RzVector *vec, void *x)
Definition: vector.c:197
#define rz_array_upper_bound(array, len, x, i, cmp)
Definition: rz_vector.h:374
static void ** rz_pvector_push(RzPVector *vec, void *x)
Definition: rz_vector.h:300
RZ_API void rz_pvector_free(RzPVector *vec)
Definition: vector.c:336
#define rz_array_lower_bound(array, len, x, i, cmp)
Definition: rz_vector.h:351
RZ_API RzVector * rz_vector_new(size_t elem_size, RzVectorFree free, void *free_user)
Definition: vector.c:42
static void ** rz_pvector_flush(RzPVector *vec)
Definition: rz_vector.h:320
#define rz_pvector_foreach(vec, it)
Definition: rz_vector.h:334
RZ_API bool sdb_free(Sdb *s)
Definition: sdb.c:206
#define b(i)
Definition: sha256.c:42
#define f(i)
Definition: sha256.c:46
#define c(i)
Definition: sha256.c:43
#define a(i)
Definition: sha256.c:41
#define br(opcode, mask, lose, flags)
Definition: malloc.c:26
Definition: z80asm.h:102
ut64 paddr
Definition: rz_bin.h:187
char * name
Definition: rz_bin.h:647
RzList * methods
Definition: rz_bin.h:653
ut64 loadaddr
starting physical address to read from the target file
Definition: rz_bin.h:249
ut64 baseaddr
where the linker maps the binary in memory
Definition: rz_bin.h:248
XX curplugin == o->plugin.
Definition: rz_bin.h:298
RzBinObject * o
Definition: rz_bin.h:305
RZ_DEPRECATE Sdb * sdb
deprecated, put info in C structures instead of this
Definition: rz_bin.h:315
struct rz_bin_t * rbin
Definition: rz_bin.h:316
int fd
when used in combination with RzIO, this refers to the io fd.
Definition: rz_bin.h:300
RzBuffer * buf
Definition: rz_bin.h:303
char * name
Definition: rz_bin.h:701
int has_va
Definition: rz_bin.h:228
const char * lang
Definition: rz_bin.h:224
char * file
Definition: rz_bin.h:210
char * arch
Definition: rz_bin.h:214
char * compiler
Definition: rz_bin.h:244
Description of a single memory mapping into virtual memory from a binary.
Definition: rz_bin.h:602
RzList * classes
Definition: rz_bin.h:281
RzList * fields
Definition: rz_bin.h:277
RzBinObjectLoadOptions opts
Definition: rz_bin.h:260
RzList * imports
Definition: rz_bin.h:268
HtPP * import_name_symbols
Acceleration structure for fast access of the symbol for a given import. This associates the name of ...
Definition: rz_bin.h:275
RzList * maps
Definition: rz_bin.h:266
RzList * symbols
Definition: rz_bin.h:269
ut64 boffset
Definition: rz_bin.h:262
RzList * entries
Definition: rz_bin.h:276
RzBinStrDb * strings
Definition: rz_bin.h:280
RzBinLanguage lang
Definition: rz_bin.h:290
struct rz_bin_plugin_t * plugin
Definition: rz_bin.h:289
RzBinSourceLineInfo * lines
Definition: rz_bin.h:284
RzList * resources
Definition: rz_bin.h:270
RzBinInfo * info
Definition: rz_bin.h:287
RZ_DEPRECATE RZ_BORROW Sdb * kv
deprecated, put info in C structures instead of this (holds a copy of another pointer....
Definition: rz_bin.h:291
HtPP * methods_ht
Definition: rz_bin.h:283
RzList * mem
Definition: rz_bin.h:285
HtPP * classes_ht
Definition: rz_bin.h:282
char * regstate
Definition: rz_bin.h:286
RzList * libs
Definition: rz_bin.h:278
RzList * sections
Definition: rz_bin.h:267
ut64 obj_size
Definition: rz_bin.h:264
st64 baddr_shift
Definition: rz_bin.h:261
RzList * vfiles
Definition: rz_bin.h:265
HtUP * addrzklassmethod
Definition: rz_bin.h:292
RzBinAddr * binsym[RZ_BIN_SPECIAL_SYMBOL_LAST]
Definition: rz_bin.h:288
RzBinRelocStorage * relocs
Definition: rz_bin.h:279
RzList *(* patch_relocs)(RzBinFile *bf)
Definition: rz_bin.h:539
RzList *(* strings)(RzBinFile *bf)
Definition: rz_bin.h:531
bool(* load_buffer)(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb)
Definition: rz_bin.h:515
char * name
Definition: rz_bin.h:509
Efficient storage of relocations to query by address.
Definition: rz_bin.h:732
RzBinReloc ** target_relocs
all relocs that have a valid target_vaddr, ordered by their target_vaddr. size is target_relocs_count...
Definition: rz_bin.h:735
size_t target_relocs_count
Definition: rz_bin.h:736
RzBinReloc ** relocs
all relocs, ordered by their vaddr
Definition: rz_bin.h:733
RzBinRelocType type
Definition: rz_bin.h:712
ut64 vaddr
the vaddr where the value should be patched into
Definition: rz_bin.h:716
ut64 target_vaddr
the target address that the patched reloc points to
Definition: rz_bin.h:718
RzPVector sections
Definition: rz_bin.h:643
bool is_segment
Definition: rz_bin.h:634
RzList * list
Contains all the strings in list form.
Definition: private.h:38
HtUP * virt
Contains all the strings but mapped by virtual address.
Definition: private.h:40
HtUP * phys
Contains all the strings but mapped by physical address.
Definition: private.h:39
bool is_imported
Definition: rz_bin.h:684
char * name
Definition: rz_bin.h:675
char * classname
Definition: rz_bin.h:678
char * dname
Definition: rz_bin.h:676
bool verbose
Definition: rz_bin.h:359
bool is_reloc_patched
Definition: rz_bin.h:363
int minstrlen
Definition: rz_bin.h:336
RZ_DEPRECATE Sdb * sdb
Definition: rz_bin.h:340
RZ_OWN RZ_NONNULL char * name
Definition: rz_bin.h:596
RzListFree free
Definition: rz_list.h:21
Definition: sdb.h:63
int refs
Definition: sdb.h:68
#define fail(test)
Definition: tests.h:29
static st64 delta
Definition: vmenus.c:2425
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58