Rizin
unix-like reverse engineering framework and cli tools
bin_coff.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2014-2019 Fedor Sakharov <fedor.sakharov@gmail.com>
2 // SPDX-FileCopyrightText: 2019 deroad <wargio@libero.it>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #include <rz_types.h>
6 #include <rz_util.h>
7 #include <rz_lib.h>
8 #include <rz_bin.h>
9 #include <ht_uu.h>
10 
11 #include "coff/coff.h"
12 
13 #define VFILE_NAME_RELOC_TARGETS "reloc-targets"
14 #define VFILE_NAME_PATCHED "patched"
15 
16 static void populate_symbols(RzBinFile *bf);
17 
18 static Sdb *get_sdb(RzBinFile *bf) {
19  RzBinObject *o = bf->o;
20  if (!o) {
21  return NULL;
22  }
23  struct rz_bin_coff_obj *bin = (struct rz_bin_coff_obj *)o->bin_obj;
24  if (bin->kv) {
25  return bin->kv;
26  }
27  return NULL;
28 }
29 
30 static bool rz_coff_is_stripped(struct rz_bin_coff_obj *obj) {
32 }
33 
34 static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb) {
36  return obj->bin_obj != NULL;
37 }
38 
39 static void destroy(RzBinFile *bf) {
40  rz_bin_coff_free((struct rz_bin_coff_obj *)bf->o->bin_obj);
41 }
42 
43 static ut64 baddr(RzBinFile *bf) {
44  return 0;
45 }
46 
48  return NULL;
49 }
50 
51 #define DTYPE_IS_FUNCTION(type) (COFF_SYM_GET_DTYPE(type) == COFF_SYM_DTYPE_FUNCTION)
52 
53 static bool is_imported_symbol(struct coff_symbol *s) {
54  return s->n_scnum == COFF_SYM_SCNUM_UNDEF && s->n_sclass == COFF_SYM_CLASS_EXTERNAL;
55 }
56 
57 static bool _fill_bin_symbol(RzBin *rbin, struct rz_bin_coff_obj *bin, int idx, RzBinSymbol **sym) {
58  RzBinSymbol *ptr = *sym;
59  struct coff_symbol *s = NULL;
60  struct coff_scn_hdr *sc_hdr = NULL;
61  if (idx < 0 || idx > bin->hdr.f_nsyms) {
62  return false;
63  }
64  if (!bin->symbols) {
65  return false;
66  }
67  s = &bin->symbols[idx];
68  char *coffname = rz_coff_symbol_name(bin, s);
69  if (!coffname) {
70  return false;
71  }
72  ptr->size = 4;
73  ptr->ordinal = 0;
74  ptr->name = coffname;
75  ptr->forwarder = "NONE";
78  ptr->vaddr = UT64_MAX;
79  if (s->n_scnum < bin->hdr.f_nscns + 1 && s->n_scnum > 0) {
80  // first index is 0 that is why -1
81  sc_hdr = &bin->scn_hdrs[s->n_scnum - 1];
82  ptr->paddr = sc_hdr->s_scnptr + s->n_value;
83  if (bin->scn_va) {
84  ptr->vaddr = bin->scn_va[s->n_scnum - 1] + s->n_value;
85  }
86  }
87  if (ptr->is_imported) {
88  // if the symbol is an import and it will be assigned an artificial target,
89  // assign this target as the vaddr of the symbol.
90  bool found;
91  ut64 imp_idx = ht_uu_find(bin->imp_index, idx, &found);
92  if (found) {
93  ptr->vaddr = rz_coff_import_index_addr(bin, imp_idx);
94  }
95  }
96 
97  switch (s->n_sclass) {
100  break;
101  case COFF_SYM_CLASS_FILE:
102  ptr->type = RZ_BIN_TYPE_FILE_STR;
103  break;
106  break;
108  if (s->n_scnum == COFF_SYM_SCNUM_UNDEF) {
109  ptr->paddr = UT64_MAX;
110  ptr->bind = "NONE";
111  } else {
113  }
114  ptr->type = (DTYPE_IS_FUNCTION(s->n_type) || !strcmp(coffname, "main"))
117  break;
119  if (s->n_scnum == COFF_SYM_SCNUM_ABS) {
120  ptr->type = "ABS";
121  ptr->paddr = UT64_MAX;
122  char *newname = rz_str_newf("%s-0x%08x", coffname, s->n_value);
123  if (newname) {
124  free(ptr->name);
125  ptr->name = newname;
126  }
127  } else if (sc_hdr && !memcmp(sc_hdr->s_name, s->n_name, 8)) {
129  } else {
130  ptr->type = DTYPE_IS_FUNCTION(s->n_type)
133  }
134  break;
136  ptr->type = "LABEL";
137  ptr->size = 0;
138  break;
139  default:
140  ptr->type = rz_str_constpool_get(&rbin->constpool, sdb_fmt("%i", s->n_sclass));
141  break;
142  }
143  return true;
144 }
145 
148  if (!ptr || idx < 0 || idx > bin->hdr.f_nsyms) {
149  free(ptr);
150  return NULL;
151  }
152  struct coff_symbol *s = &bin->symbols[idx];
153  if (!is_imported_symbol(s)) {
154  free(ptr);
155  return NULL;
156  }
157  char *coffname = rz_coff_symbol_name(bin, s);
158  if (!coffname) {
159  free(ptr);
160  return NULL;
161  }
162  ptr->name = coffname;
163  ptr->bind = "NONE";
164  ptr->type = DTYPE_IS_FUNCTION(s->n_type)
167  return ptr;
168 }
169 
170 static RzList *entries(RzBinFile *bf) {
171  struct rz_bin_coff_obj *obj = (struct rz_bin_coff_obj *)bf->o->bin_obj;
172  RzList *ret;
173  if (!(ret = rz_list_newf(free))) {
174  return NULL;
175  }
176  RzBinAddr *ptr = rz_coff_get_entry(obj);
177  if (ptr) {
178  rz_list_append(ret, ptr);
179  }
180  return ret;
181 }
182 
185  if (!r) {
186  return NULL;
187  }
188  RzBinObject *o = bf->o;
189  struct rz_bin_coff_obj *obj = o ? o->bin_obj : NULL;
190  if (!obj) {
191  return r;
192  }
193  populate_symbols(bf); // the patching depends on symbols to be available
194  // virtual file for reloc targets (where the relocs will point into)
196  if (rtmsz) {
197  RzBuffer *buf = rz_buf_new_empty(rtmsz);
198  if (!buf) {
199  return r;
200  }
202  if (!vf) {
203  return r;
204  }
205  vf->buf = buf;
206  vf->buf_owned = true;
208  rz_list_push(r, vf);
209  }
210  // virtual file mirroring the raw file, but with relocs patched
212  if (buf_patched) {
214  if (!vf) {
215  return r;
216  }
217  vf->buf = buf_patched;
219  rz_list_push(r, vf);
220  }
221  return r;
222 }
223 
224 static RzList *maps(RzBinFile *bf) {
226  if (!ret) {
227  return NULL;
228  }
229  RzBinObject *o = bf->o;
230  struct rz_bin_coff_obj *obj = o ? o->bin_obj : NULL;
231  if (!obj || !obj->scn_hdrs) {
232  return ret;
233  }
234  populate_symbols(bf);
235  for (size_t i = 0; i < obj->hdr.f_nscns; i++) {
236  RzBinMap *ptr = RZ_NEW0(RzBinMap);
237  if (!ptr) {
238  return ret;
239  }
240  struct coff_scn_hdr *hdr = &obj->scn_hdrs[i];
241  ptr->name = rz_coff_symbol_name(obj, hdr);
242  ptr->psize = hdr->s_size;
243  ptr->vsize = hdr->s_size;
244  ptr->paddr = hdr->s_scnptr;
245  if (obj->scn_va) {
246  ptr->vaddr = obj->scn_va[i];
247  }
248  ptr->perm = rz_coff_perms_from_section_flags(hdr->s_flags);
249  if (hdr->s_nreloc) {
251  }
252  rz_list_append(ret, ptr);
253  }
255  if (rtmsz) {
256  // virtual file for reloc targets (where the relocs will point into)
258  if (!map) {
259  return ret;
260  }
261  map->name = strdup("reloc-targets");
262  map->paddr = 0;
263  map->psize = rtmsz;
265  map->vsize = rtmsz;
266  map->perm = RZ_PERM_R;
267  map->vfile_name = strdup(VFILE_NAME_RELOC_TARGETS);
268  rz_list_prepend(ret, map);
269  }
270  return ret;
271 }
272 
273 static RzList *sections(RzBinFile *bf) {
274  struct rz_bin_coff_obj *obj = (struct rz_bin_coff_obj *)bf->o->bin_obj;
276  if (!ret) {
277  return NULL;
278  }
279  if (!obj || !obj->scn_hdrs) {
280  return ret;
281  }
282  for (size_t i = 0; i < obj->hdr.f_nscns; i++) {
284  if (!ptr) {
285  return ret;
286  }
287  ptr->name = rz_coff_symbol_name(obj, &obj->scn_hdrs[i]);
288  if (strstr(ptr->name, "data")) {
289  ptr->is_data = true;
290  }
291  ptr->size = obj->scn_hdrs[i].s_size;
292  ptr->vsize = obj->scn_hdrs[i].s_size;
293  ptr->paddr = obj->scn_hdrs[i].s_scnptr;
294  if (obj->scn_va) {
295  ptr->vaddr = obj->scn_va[i];
296  }
297  ptr->perm = rz_coff_perms_from_section_flags(obj->scn_hdrs[i].s_flags);
298  rz_list_append(ret, ptr);
299  }
300  return ret;
301 }
302 
303 static void populate_imports(struct rz_bin_coff_obj *obj) {
304  if (obj->imp_index->count || !obj->symbols) {
305  return;
306  }
307  int ord = 0;
308  ut64 imp_idx = 0;
309  for (size_t i = 0; i < obj->hdr.f_nsyms; i++) {
310  RzBinImport *ptr = _fill_bin_import(obj, i);
311  if (ptr) {
312  ptr->ordinal = ord++;
313  ht_up_insert(obj->imp_ht, (ut64)i, ptr);
314  ht_uu_insert(obj->imp_index, (ut64)i, imp_idx++);
315  }
316  i += obj->symbols[i].n_numaux;
317  }
318 }
319 
320 static void populate_symbols(RzBinFile *bf) {
321  struct rz_bin_coff_obj *obj = (struct rz_bin_coff_obj *)bf->o->bin_obj;
322  if (obj->sym_ht->count || !obj->symbols) {
323  return;
324  }
325  populate_imports(obj);
326  for (size_t i = 0; i < obj->hdr.f_nsyms; i++) {
328  if (!ptr) {
329  break;
330  }
331  if (_fill_bin_symbol(bf->rbin, obj, i, &ptr)) {
332  ht_up_insert(obj->sym_ht, (ut64)i, ptr);
333  } else {
334  free(ptr);
335  }
336  i += obj->symbols[i].n_numaux;
337  }
338 }
339 
340 static RzList *symbols(RzBinFile *bf) {
341  struct rz_bin_coff_obj *obj = (struct rz_bin_coff_obj *)bf->o->bin_obj;
343  if (!ret) {
344  return NULL;
345  }
346  if (obj->symbols) {
347  populate_symbols(bf);
348  for (size_t i = 0; i < obj->hdr.f_nsyms; i++) {
349  RzBinSymbol *ptr = ht_up_find(obj->sym_ht, i, NULL);
350  if (ptr) {
351  rz_list_append(ret, ptr);
352  }
353  i += obj->symbols[i].n_numaux;
354  }
355  }
356  return ret;
357 }
358 
359 static RzList *imports(RzBinFile *bf) {
360  int i;
361  struct rz_bin_coff_obj *obj = (struct rz_bin_coff_obj *)bf->o->bin_obj;
363  if (!ret) {
364  return NULL;
365  }
366  if (obj->symbols) {
367  populate_imports(obj);
368  for (i = 0; i < obj->hdr.f_nsyms; i++) {
369  RzBinImport *ptr = ht_up_find(obj->imp_ht, i, NULL);
370  if (ptr) {
371  rz_list_append(ret, ptr);
372  }
373  i += obj->symbols[i].n_numaux;
374  }
375  }
376  return ret;
377 }
378 
379 static RzList *libs(RzBinFile *bf) {
380  return NULL;
381 }
382 
383 static RzList *relocs(RzBinFile *bf) {
384  populate_symbols(bf);
385  return rz_coff_get_relocs(bf->o->bin_obj);
386 }
387 
388 static RzBinInfo *info(RzBinFile *bf) {
389  RzBinInfo *ret = RZ_NEW0(RzBinInfo);
390  struct rz_bin_coff_obj *obj = (struct rz_bin_coff_obj *)bf->o->bin_obj;
391 
392  ret->file = bf->file ? strdup(bf->file) : NULL;
393  ret->rclass = strdup("coff");
394  ret->bclass = strdup("coff");
395  ret->type = strdup("COFF (Executable file)");
396  ret->os = strdup("any");
397  ret->subsystem = strdup("any");
398  ret->big_endian = obj->endian;
399  ret->has_va = true;
400  ret->dbg_info = 0;
401 
402  if (rz_coff_is_stripped(obj)) {
404  } else {
405  if (!(obj->hdr.f_flags & COFF_FLAGS_TI_F_RELFLG)) {
406  ret->dbg_info |= RZ_BIN_DBG_RELOCS;
407  }
408  if (!(obj->hdr.f_flags & COFF_FLAGS_TI_F_LNNO)) {
410  }
411  if (!(obj->hdr.f_flags & COFF_FLAGS_TI_F_EXEC)) {
412  ret->dbg_info |= RZ_BIN_DBG_SYMS;
413  }
414  }
415 
416  switch (obj->hdr.f_magic) {
421  ret->machine = strdup("mips");
422  ret->arch = strdup("mips");
423  ret->bits = 32;
424  break;
426  ret->machine = strdup("i386");
427  ret->arch = strdup("x86");
428  ret->bits = 32;
429  break;
431  ret->machine = strdup("AMD64");
432  ret->arch = strdup("x86");
433  ret->bits = 64;
434  break;
436  ret->machine = strdup("H8300");
437  ret->arch = strdup("h8300");
438  ret->bits = 16;
439  break;
442  ret->cpu = strdup("29000");
443  ret->machine = strdup("amd29k");
444  ret->arch = strdup("amd29k");
445  ret->bits = 32;
446  break;
448  ret->machine = strdup("arm");
449  ret->arch = strdup("arm");
450  ret->bits = 16;
451  break;
454  ret->machine = strdup("arm");
455  ret->arch = strdup("arm");
456  ret->bits = 32;
457  break;
459  ret->machine = strdup("arm");
460  ret->arch = strdup("arm");
461  ret->bits = 64;
462  break;
467  ret->machine = strdup("sh");
468  ret->arch = strdup("sh");
469  ret->bits = 32;
470  break;
471  case COFF_FILE_TI_COFF:
472  switch (obj->target_id) {
474  ret->machine = strdup("c54x");
475  ret->arch = strdup("tms320");
476  ret->bits = 32;
477  break;
479  ret->machine = strdup("c55x");
480  ret->arch = strdup("tms320");
481  ret->bits = 32;
482  break;
484  ret->machine = strdup("c55x+");
485  ret->arch = strdup("tms320");
486  ret->bits = 32;
487  break;
488  }
489  break;
490  default:
491  ret->machine = strdup("unknown");
492  }
493 
494  return ret;
495 }
496 
497 static RzList *fields(RzBinFile *bf) {
498  return NULL;
499 }
500 
501 static ut64 size(RzBinFile *bf) {
502  return 0;
503 }
504 
505 static bool check_buffer(RzBuffer *buf) {
506 #if 0
507 TODO: do more checks here to avoid false positives
508 
509 ut16 MACHINE
510 ut16 NSECTIONS
511 ut32 DATE
512 ut32 PTRTOSYMTABLE
513 ut32 NUMOFSYMS
514 ut16 OPTHDRSIZE
515 ut16 CHARACTERISTICS
516 #endif
517 
518  ut8 tmp[20];
519  int r = rz_buf_read_at(buf, 0, tmp, sizeof(tmp));
520  return r >= 20 && rz_coff_supported_arch(tmp);
521 }
522 
524  .name = "coff",
525  .desc = "COFF format rz_bin plugin",
526  .license = "LGPL3",
527  .get_sdb = &get_sdb,
528  .load_buffer = &load_buffer,
529  .destroy = &destroy,
530  .check_buffer = &check_buffer,
531  .baddr = &baddr,
532  .binsym = &binsym,
533  .entries = &entries,
534  .virtual_files = &virtual_files,
535  .maps = &maps,
536  .sections = &sections,
537  .symbols = &symbols,
538  .imports = &imports,
539  .info = &info,
540  .fields = &fields,
541  .size = &size,
542  .libs = &libs,
543  .relocs = &relocs
544 };
545 
546 #ifndef RZ_PLUGIN_INCORE
549  .data = &rz_bin_plugin_coff,
551 };
552 #endif
lzma_index ** i
Definition: index.h:629
RZ_API void rz_bin_symbol_free(RzBinSymbol *sym)
Definition: bin.c:175
RZ_API void rz_bin_map_free(RzBinMap *map)
Definition: bin.c:1023
RZ_API void rz_bin_import_free(RzBinImport *imp)
Definition: bin.c:137
RZ_API void rz_bin_section_free(RzBinSection *bs)
Definition: bin.c:1116
RZ_API void rz_bin_virtual_file_free(RzBinVirtualFile *vfile)
Definition: bin.c:1012
static RzBinAddr * binsym(RzBinFile *bf, RzBinSpecialSymbol sym)
Definition: bin_coff.c:47
static Sdb * get_sdb(RzBinFile *bf)
Definition: bin_coff.c:18
static bool check_buffer(RzBuffer *buf)
Definition: bin_coff.c:505
static bool load_buffer(RzBinFile *bf, RzBinObject *obj, RzBuffer *buf, Sdb *sdb)
Definition: bin_coff.c:34
static RzList * symbols(RzBinFile *bf)
Definition: bin_coff.c:340
static void populate_imports(struct rz_bin_coff_obj *obj)
Definition: bin_coff.c:303
static ut64 size(RzBinFile *bf)
Definition: bin_coff.c:501
static RzList * libs(RzBinFile *bf)
Definition: bin_coff.c:379
static void populate_symbols(RzBinFile *bf)
Definition: bin_coff.c:320
static bool _fill_bin_symbol(RzBin *rbin, struct rz_bin_coff_obj *bin, int idx, RzBinSymbol **sym)
Definition: bin_coff.c:57
static RzList * fields(RzBinFile *bf)
Definition: bin_coff.c:497
static void destroy(RzBinFile *bf)
Definition: bin_coff.c:39
RZ_API RzLibStruct rizin_plugin
Definition: bin_coff.c:547
static RzBinImport * _fill_bin_import(struct rz_bin_coff_obj *bin, int idx)
Definition: bin_coff.c:146
#define VFILE_NAME_PATCHED
Definition: bin_coff.c:14
static RzList * virtual_files(RzBinFile *bf)
Definition: bin_coff.c:183
static RzBinInfo * info(RzBinFile *bf)
Definition: bin_coff.c:388
static ut64 baddr(RzBinFile *bf)
Definition: bin_coff.c:43
static RzList * entries(RzBinFile *bf)
Definition: bin_coff.c:170
#define VFILE_NAME_RELOC_TARGETS
Definition: bin_coff.c:13
static bool rz_coff_is_stripped(struct rz_bin_coff_obj *obj)
Definition: bin_coff.c:30
static RzList * maps(RzBinFile *bf)
Definition: bin_coff.c:224
static bool is_imported_symbol(struct coff_symbol *s)
Definition: bin_coff.c:53
static RzList * sections(RzBinFile *bf)
Definition: bin_coff.c:273
#define DTYPE_IS_FUNCTION(type)
Definition: bin_coff.c:51
static RzList * imports(RzBinFile *bf)
Definition: bin_coff.c:359
static RzList * relocs(RzBinFile *bf)
Definition: bin_coff.c:383
RzBinPlugin rz_bin_plugin_coff
Definition: bin_coff.c:523
RZ_API struct rz_bin_coff_obj * rz_bin_coff_new_buf(RzBuffer *buf, bool verbose)
Definition: coff.c:278
RZ_API void rz_bin_coff_free(struct rz_bin_coff_obj *obj)
Definition: coff.c:266
RZ_API ut64 rz_coff_perms_from_section_flags(ut32 flags)
Definition: coff.c:36
RZ_API RzBinAddr * rz_coff_get_entry(struct rz_bin_coff_obj *obj)
Definition: coff.c:89
RZ_API bool rz_coff_supported_arch(const ut8 *buf)
Definition: coff.c:9
RZ_API char * rz_coff_symbol_name(struct rz_bin_coff_obj *obj, void *ptr)
Definition: coff.c:50
RZ_API ut64 rz_coff_get_reloc_targets_vfile_size(struct rz_bin_coff_obj *obj)
size of the artificial reloc target vfile
Definition: coff_reloc.c:206
RZ_API ut64 rz_coff_get_reloc_targets_map_base(struct rz_bin_coff_obj *obj)
base vaddr where to map the artificial reloc target vfile
Definition: coff_reloc.c:9
RZ_API RZ_BORROW RzBuffer * rz_coff_get_patched_buf(struct rz_bin_coff_obj *bin)
Definition: coff_reloc.c:219
RZ_API RzList * rz_coff_get_relocs(struct rz_bin_coff_obj *bin)
Definition: coff_reloc.c:195
RZ_API ut64 rz_coff_import_index_addr(struct rz_bin_coff_obj *obj, ut64 imp_index)
Definition: coff_reloc.c:32
#define COFF_FILE_MACHINE_TMS320C55PLUS
Definition: coff_specs.h:41
#define COFF_FILE_MACHINE_SH3DSP
Definition: coff_specs.h:27
#define COFF_FILE_MACHINE_SH4
Definition: coff_specs.h:28
#define COFF_SYM_CLASS_FILE
Definition: coff_specs.h:134
#define COFF_FILE_MACHINE_AMD29KBE
Definition: coff_specs.h:21
#define COFF_FILE_MACHINE_ARM64
Definition: coff_specs.h:13
#define COFF_FILE_MACHINE_AMD64
Definition: coff_specs.h:10
#define COFF_FILE_MACHINE_ARM
Definition: coff_specs.h:11
#define COFF_FILE_MACHINE_TMS320C54
Definition: coff_specs.h:36
#define COFF_FILE_TI_COFF
Definition: coff_specs.h:34
#define COFF_FLAGS_TI_F_EXEC
Definition: coff_specs.h:44
#define COFF_FLAGS_TI_F_LNNO
Definition: coff_specs.h:45
#define COFF_FILE_MACHINE_MIPSFPU
Definition: coff_specs.h:19
#define COFF_FILE_MACHINE_SH3
Definition: coff_specs.h:26
#define COFF_FILE_MACHINE_MIPS16
Definition: coff_specs.h:18
#define COFF_FLAGS_TI_F_RELFLG
Definition: coff_specs.h:43
#define COFF_FILE_MACHINE_MIPSFPU16
Definition: coff_specs.h:20
#define COFF_SYM_CLASS_LABEL
Definition: coff_specs.h:118
#define COFF_FILE_MACHINE_I386
Definition: coff_specs.h:15
#define COFF_SYM_CLASS_EXTERNAL
Definition: coff_specs.h:114
#define COFF_SYM_SCNUM_UNDEF
Definition: coff_specs.h:85
#define COFF_FILE_MACHINE_TMS320C55
Definition: coff_specs.h:38
#define COFF_FILE_MACHINE_SH5
Definition: coff_specs.h:29
#define COFF_SYM_CLASS_STATIC
Definition: coff_specs.h:115
#define COFF_FILE_MACHINE_AMD29KLE
Definition: coff_specs.h:22
#define COFF_FILE_MACHINE_THUMB
Definition: coff_specs.h:30
#define COFF_FILE_MACHINE_R4000
Definition: coff_specs.h:25
#define COFF_FILE_MACHINE_H8300
Definition: coff_specs.h:32
#define COFF_SYM_CLASS_FUNCTION
Definition: coff_specs.h:132
#define COFF_FILE_MACHINE_ARMNT
Definition: coff_specs.h:12
#define COFF_SYM_SCNUM_ABS
Definition: coff_specs.h:86
#define COFF_FLAGS_TI_F_LSYMS
Definition: coff_specs.h:46
#define COFF_SYM_CLASS_SECTION
Definition: coff_specs.h:135
#define RZ_API
#define NULL
Definition: cris-opc.c:27
#define r
Definition: crypto_rc6.c:12
uint16_t ut16
uint32_t ut32
size_t map(int syms, int left, int len)
Definition: enough.c:237
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
RZ_API const KEY_TYPE bool * found
Definition: ht_inc.h:130
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
RZ_API RZ_BORROW RzListIter * rz_list_prepend(RZ_NONNULL RzList *list, void *data)
Appends at the beginning of the list a new element.
Definition: list.c:316
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
Definition: list.c:60
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
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 idx
Definition: setup.py:197
static RzSocket * s
Definition: rtr.c:28
#define RZ_BIN_DBG_RELOCS
Definition: rz_bin.h:31
#define RZ_BIN_DBG_STRIPPED
Definition: rz_bin.h:27
RzBinSpecialSymbol
Definition: rz_bin.h:136
#define RZ_BIN_DBG_SYMS
Definition: rz_bin.h:30
#define RZ_BIN_BIND_LOCAL_STR
Definition: rz_bin.h:106
#define RZ_BIN_BIND_GLOBAL_STR
Definition: rz_bin.h:107
#define RZ_BIN_TYPE_FILE_STR
Definition: rz_bin.h:125
#define RZ_BIN_TYPE_FUNC_STR
Definition: rz_bin.h:119
#define RZ_BIN_TYPE_UNKNOWN_STR
Definition: rz_bin.h:134
#define RZ_BIN_TYPE_SECTION_STR
Definition: rz_bin.h:124
#define RZ_BIN_DBG_LINENUMS
Definition: rz_bin.h:29
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
Definition: buf.c:1136
RZ_API RZ_OWN RzBuffer * rz_buf_new_empty(ut64 len)
Creates a new empty buffer with a predefined size;.
Definition: buf.c:285
@ RZ_LIB_TYPE_BIN
Definition: rz_lib.h:75
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API const char * rz_str_constpool_get(RzStrConstPool *pool, const char *str)
Definition: str_constpool.c:19
#define RZ_PERM_R
Definition: rz_types.h:93
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define UT64_MAX
Definition: rz_types_base.h:86
#define RZ_VERSION
Definition: rz_version.h:8
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Definition: sfsocketcall.h:125
Definition: malloc.c:26
RzBuffer * buf_patched
overlay over the original file with relocs patched
Definition: coff.h:38
ut8 endian
Definition: coff.h:29
ut64 * scn_va
Definition: coff.h:35
HtUP * sym_ht
Definition: coff.h:32
ut16 target_id
Definition: coff.h:25
HtUP * imp_ht
Definition: coff.h:33
struct coff_symbol * symbols
Definition: coff.h:23
struct coff_hdr hdr
Definition: coff.h:20
struct coff_scn_hdr * scn_hdrs
Definition: coff.h:22
HtUU * imp_index
locally-generated indices for imports, in particular for deterministically assigning reloc targets
Definition: coff.h:34
XX curplugin == o->plugin.
Definition: rz_bin.h:298
RzBinObject * o
Definition: rz_bin.h:305
struct rz_bin_t * rbin
Definition: rz_bin.h:316
char * file
Definition: rz_bin.h:299
const char * type
Definition: rz_bin.h:704
const char * bind
Definition: rz_bin.h:703
ut32 ordinal
Definition: rz_bin.h:707
char * name
Definition: rz_bin.h:701
int has_va
Definition: rz_bin.h:228
char * type
Definition: rz_bin.h:211
char * os
Definition: rz_bin.h:219
char * subsystem
Definition: rz_bin.h:220
char * machine
Definition: rz_bin.h:216
char * bclass
Definition: rz_bin.h:212
char * file
Definition: rz_bin.h:210
ut64 dbg_info
Definition: rz_bin.h:240
char * cpu
Definition: rz_bin.h:215
char * rclass
Definition: rz_bin.h:213
char * arch
Definition: rz_bin.h:214
int big_endian
Definition: rz_bin.h:235
Description of a single memory mapping into virtual memory from a binary.
Definition: rz_bin.h:602
ut64 vsize
size to map in the destination address space. If vsize > psize, excessive bytes are meant to be fille...
Definition: rz_bin.h:606
ut32 perm
Definition: rz_bin.h:608
ut64 paddr
address of the map inside the file
Definition: rz_bin.h:603
ut64 psize
size of the data inside the file
Definition: rz_bin.h:604
ut64 vaddr
address in the destination address space to map to
Definition: rz_bin.h:605
RZ_NULLABLE char * name
Definition: rz_bin.h:607
RZ_NULLABLE char * vfile_name
Definition: rz_bin.h:615
void * bin_obj
Definition: rz_bin.h:293
char * name
Definition: rz_bin.h:509
char * version
Definition: rz_bin.h:512
char * name
Definition: rz_bin.h:619
const char * bind
Definition: rz_bin.h:681
bool is_imported
Definition: rz_bin.h:684
const char * type
Definition: rz_bin.h:682
char * name
Definition: rz_bin.h:675
ut32 ordinal
Definition: rz_bin.h:692
const char * forwarder
Definition: rz_bin.h:680
bool verbose
Definition: rz_bin.h:359
RzStrConstPool constpool
Definition: rz_bin.h:362
RZ_NONNULL RzBuffer * buf
Definition: rz_bin.h:597
bool buf_owned
whether buf is owned and freed by this RzBinVirtualFile
Definition: rz_bin.h:598
RZ_OWN RZ_NONNULL char * name
Definition: rz_bin.h:596
Definition: sdb.h:63
uint32_t checks
Definition: list.c:109
if(dbg->bits==RZ_SYS_BITS_64)
Definition: windows-arm64.h:4
ut64(WINAPI *w32_GetEnabledXStateFeatures)()