Rizin
unix-like reverse engineering framework and cli tools
omf.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2015 ampotos <mercie_i@epitech.eu>
2 // SPDX-FileCopyrightText: 2015-2019 pancake <pancake@nopcode.org>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #include "omf.h"
6 
7 static bool is_valid_omf_type(ut8 type) {
8  int ct = 0;
9  ut8 types[] = {
19  OMF_VENDEXT, 0
20  };
21  for (; types[ct]; ct++) {
22  if (type == types[ct]) {
23  return true;
24  }
25  }
26  // RZ_LOG_ERROR("Invalid record type\n");
27  return false;
28 }
29 
31  ut16 size;
32  ut8 checksum = 0;
33 
34  if (buf_size < 3) {
35  RZ_LOG_ERROR("Invalid record (too short)\n");
36  return false;
37  }
38  size = rz_read_le16(buf + 1);
39  if (buf_size < size + 3) {
40  RZ_LOG_ERROR("Invalid record (too short)\n");
41  return false;
42  }
43  // Some compiler set checksum to 0
44  if (!buf[size + 2]) {
45  return true;
46  }
47  size += 3;
48  for (; size; size--) {
49  if (buf_size < size) {
50  RZ_LOG_ERROR("Invalid record (too short)\n");
51  return false;
52  }
53  checksum += buf[size - 1];
54  }
55  if (checksum) {
56  // RZ_LOG_ERROR("Invalid record checksum\n");
57  }
58  return !checksum ? true : false;
59 }
60 
61 static ut16 omf_get_idx(const ut8 *buf, int buf_size) {
62  if (buf_size < 2) {
63  return 0;
64  }
65  if (*buf & 0x80) {
66  return (ut16)((*buf & 0x7f) * 0x100 + buf[1]);
67  }
68  return *buf;
69 }
70 
71 static void free_lname(OMF_multi_datas *lname) {
72  ut32 ct = 0;
73 
74  while (ct < lname->nb_elem) {
75  RZ_FREE(((char **)lname->elems)[ct]);
76  ct++;
77  }
78  RZ_FREE(lname->elems);
79  RZ_FREE(lname);
80 }
81 
83  ut32 tmp_size = 0;
84  ut32 ct_name = 0;
85  OMF_multi_datas *ret = NULL;
86  char **names;
87  if (!record || !buf) {
88  return false;
89  }
90 
91  if (!(ret = RZ_NEW0(OMF_multi_datas))) {
92  return false;
93  }
94  record->content = ret;
95 
96  while ((int)tmp_size < (int)(record->size - 1)) {
97  int next;
98  ret->nb_elem++;
99  next = buf[3 + tmp_size] + 1;
100  if (next < 1) {
101  break;
102  }
103  tmp_size += next;
104  }
105  if (!(ret->elems = RZ_NEWS0(char *, ret->nb_elem + 1))) {
106  RZ_FREE(ret);
107  return false;
108  }
109  names = (char **)ret->elems;
110  tmp_size = 0;
111  while ((int)tmp_size < (int)(record->size - 1)) {
112  if (ct_name >= ret->nb_elem) {
113  RZ_LOG_ERROR("Invalid number of element (overflow)\n");
114  break;
115  }
116  // sometimes there is a name with a null size so we just skip it
117  char cb = buf[3 + tmp_size];
118  if (cb < 1) {
119  names[ct_name++] = NULL;
120  tmp_size++;
121  continue;
122  }
123  if (record->size + 3 < tmp_size + cb) {
124  RZ_LOG_ERROR("Invalid Lnames record (bad size)\n");
125  free(ret);
126  return false;
127  }
128  if (!(names[ct_name] = RZ_NEWS0(char, cb + 1))) {
129  free_lname(ret);
130  return false;
131  }
132  if ((tmp_size + 4 + cb) < buf_size) {
133  memcpy(names[ct_name], buf + 3 + tmp_size + 1, cb);
134  }
135  ct_name++;
136  tmp_size += cb + 1; // buf[3 + tmp_size] + 1;
137  }
138  return true;
139 }
140 
142  OMF_segment *ret = NULL;
143  int off_add;
144 
145  if (!(ret = RZ_NEW0(OMF_segment))) {
146  return false;
147  }
148  record->content = ret;
149 
150  if (record->size < 2) {
151  RZ_LOG_ERROR("Invalid Segdef record (bad size)\n");
152  return false;
153  }
154  off_add = buf[3] & 0xe ? 0 : 3;
155 
156  if (record->type == OMF_SEGDEF32) {
157  if (record->size < 5 + off_add) {
158  RZ_LOG_ERROR("Invalid Segdef record (bad size)\n");
159  return false;
160  }
161  ret->name_idx = omf_get_idx(buf + 8 + off_add, buf_size - 8 - off_add);
162  if (buf[3] & 2) {
163  ret->size = UT32_MAX;
164  } else {
165  ret->size = rz_read_le32(buf + 4 + off_add);
166  }
167  } else {
168  if (record->size < 3 + off_add) {
169  RZ_LOG_ERROR("Invalid Segdef record (bad size)\n");
170  return false;
171  }
172  ret->name_idx = omf_get_idx(buf + 6 + off_add, buf_size - 6 - off_add);
173  if (buf[3] & 2) {
174  ret->size = UT16_MAX;
175  }
176  ret->size = rz_read_le16(buf + 4 + off_add);
177  }
178 
179  ret->bits = (buf[3] & 1) ? 32 : 16;
180 
181  // tricks to keep the save index when copying content from record
182  record->type = OMF_SEGDEF;
183 
184  return true;
185 }
186 
187 static ut32 omf_count_symb(ut16 total_size, ut32 ct, const ut8 *buf, int bits) {
188  ut32 nb_symb = 0;
189  while (ct < total_size - 1) {
190  ct += buf[ct] + 1 + (bits == 32 ? 4 : 2);
191  if (ct > total_size - 1) {
192  return nb_symb;
193  }
194  if (buf[ct] & 0x80) {
195  ct += 2;
196  } else {
197  ct++;
198  }
199  nb_symb++;
200  }
201  return nb_symb;
202 }
203 
204 static int load_omf_symb(OMF_record *record, ut32 ct, const ut8 *buf, int buf_size, int bits, ut16 seg_idx) {
205  ut32 nb_symb = 0;
206  ut8 str_size = 0;
207  OMF_symbol *symbol;
208 
209  while (nb_symb < ((OMF_multi_datas *)record->content)->nb_elem) {
210  symbol = ((OMF_symbol *)((OMF_multi_datas *)record->content)->elems) + nb_symb;
211 
212  if (record->size - 1 < ct - 2) {
213  RZ_LOG_ERROR("Invalid Pubdef record (bad size)\n");
214  return false;
215  }
216  str_size = buf[ct];
217 
218  if (bits == 32) {
219  if (ct + 1 + str_size + 4 - 3 > record->size) {
220  RZ_LOG_ERROR("Invalid Pubdef record (bad size)\n");
221  return false;
222  }
223  symbol->offset = rz_read_le32(buf + ct + 1 + str_size);
224  } else {
225  if (ct + 1 + str_size + 2 - 3 > record->size) {
226  RZ_LOG_ERROR("Invalid Pubdef record (bad size)\n");
227  return false;
228  }
229  symbol->offset = rz_read_le16(buf + ct + 1 + str_size);
230  }
231 
232  symbol->seg_idx = seg_idx;
233 
234  if (!(symbol->name = RZ_NEWS0(char, str_size + 1))) {
235  return false;
236  }
237  symbol->name[str_size] = 0;
238  memcpy(symbol->name, buf + ct + 1, sizeof(char) * str_size);
239 
240  ct += 1 + str_size + (bits == 32 ? 4 : 2);
241  if (ct >= buf_size) {
242  return false;
243  }
244  if (buf[ct] & 0x80) { // type index
245  ct += 2;
246  } else {
247  ct++;
248  }
249  nb_symb++;
250  }
251  return true;
252 }
253 
254 static int load_omf_pubdef(OMF_record *record, const ut8 *buf, int buf_size) {
255  OMF_multi_datas *ret = NULL;
256  ut16 seg_idx;
257  ut16 ct = 0;
258  ut16 base_grp;
259 
260  if (record->size < 2) {
261  RZ_LOG_ERROR("Invalid Pubdef record (bad size)\n");
262  return false;
263  }
264 
265  ct = 3;
266  base_grp = omf_get_idx(buf + ct, buf_size - ct);
267  if (buf[ct] & 0x80) { // sizeof base groups index
268  ct += 2;
269  } else {
270  ct++;
271  }
272 
273  if (record->size < ct - 2) {
274  RZ_LOG_ERROR("Invalid Pubdef record (bad size)\n");
275  return false;
276  }
277 
278  seg_idx = omf_get_idx(buf + ct, buf_size - ct);
279 
280  if (buf[ct] & 0x80) { // sizeof base segment index
281  ct += 2;
282  } else {
283  ct++;
284  }
285 
286  if (!base_grp && !seg_idx) {
287  ct += 2;
288  }
289  if (record->size < ct - 2) {
290  RZ_LOG_ERROR("Invalid Pubdef record (bad size)\n");
291  return false;
292  }
293 
294  if (!(ret = RZ_NEW0(OMF_multi_datas))) {
295  return false;
296  }
297  record->content = ret;
298 
299  if (!(record->type & 1)) { // 16 bit addr
300  ret->nb_elem = omf_count_symb(record->size + 3, ct, buf, 16);
301  if (ret->nb_elem > 0) {
302  if (!(ret->elems = RZ_NEWS0(OMF_symbol, ret->nb_elem))) {
303  return false;
304  }
305  }
306  if (!load_omf_symb(record, ct, buf, buf_size, 16, seg_idx)) {
307  return false;
308  }
309  } else { // 32 bit addr
310  ret->nb_elem = omf_count_symb(record->size + 3, ct, buf, 32);
311  if (ret->nb_elem > 0) {
312  if (!(ret->elems = RZ_NEWS0(OMF_symbol, ret->nb_elem))) {
313  return false;
314  }
315  }
316  if (!load_omf_symb(record, ct, buf, buf_size, 32, seg_idx)) {
317  return false;
318  }
319  }
320 
321  // tricks to keep the save index when copying content from record
322  record->type = OMF_PUBDEF;
323  return true;
324 }
325 
326 static int load_omf_data(const ut8 *buf, int buf_size, OMF_record *record, ut64 global_ct) {
327  ut16 seg_idx;
328  ut32 offset;
329  ut16 ct = 4;
330  OMF_data *ret;
331 
332  if ((!(record->type & 1) && record->size < 4) || (record->size < 6)) {
333  RZ_LOG_ERROR("Invalid Ledata record (bad size)\n");
334  return false;
335  }
336  seg_idx = omf_get_idx(buf + 3, buf_size - 3);
337  if (seg_idx & 0xff00) {
338  if ((!(record->type & 1) && record->size < 5) || (record->size < 7)) {
339  RZ_LOG_ERROR("Invalid Ledata record (bad size)\n");
340  return false;
341  }
342  ct++;
343  }
344  if (record->type == OMF_LEDATA32) {
345  offset = rz_read_le32(buf + ct);
346  ct += 4;
347  } else {
348  offset = rz_read_le16(buf + ct);
349  ct += 2;
350  }
351  if (!(ret = RZ_NEW0(OMF_data))) {
352  return false;
353  }
354  record->content = ret;
355 
356  ret->size = record->size - 1 - (ct - 3);
357  ret->paddr = global_ct + ct;
358  ret->offset = offset;
359  ret->seg_idx = seg_idx;
360  ret->next = NULL;
361  record->type = OMF_LEDATA;
362 
363  return true;
364 }
365 
366 static int load_omf_content(OMF_record *record, const ut8 *buf, ut64 global_ct, ut64 buf_size) {
367  if (record->type == OMF_LNAMES) {
369  }
370  if (record->type == OMF_SEGDEF || record->type == OMF_SEGDEF32) {
372  }
373  if (record->type == OMF_PUBDEF || record->type == OMF_PUBDEF32 || record->type == OMF_LPUBDEF || record->type == OMF_LPUBDEF32) {
375  }
376  if (record->type == OMF_LEDATA || record->type == OMF_LEDATA32) {
377  return load_omf_data(buf, buf_size, record, global_ct);
378  }
379  // generic loader just copy data from buf to content
380  if (!record->size) {
381  RZ_LOG_ERROR("Invalid record (size to short)\n");
382  return false;
383  }
384  if (!(record->content = RZ_NEWS0(char, record->size))) {
385  return false;
386  }
387  ((char *)record->content)[record->size - 1] = 0;
388  return true;
389 }
390 
392  OMF_record_handler *new = NULL;
393 
395  if (!(new = RZ_NEW0(OMF_record_handler))) {
396  return NULL;
397  }
398  ((OMF_record *)new)->type = *buf;
399  ((OMF_record *)new)->size = rz_read_le16(buf + 1);
400 
401  // at least a record have a type a size and a checksum
402  if (((OMF_record *)new)->size > buf_size - 3 || buf_size < 4) {
403  RZ_LOG_ERROR("Invalid record (too short)\n");
404  RZ_FREE(new);
405  return NULL;
406  }
407 
408  if (!(load_omf_content((OMF_record *)new, buf, global_ct, buf_size))) {
409  RZ_FREE(new);
410  return NULL;
411  }
412  ((OMF_record *)new)->checksum = buf[2 + ((OMF_record *)new)->size];
413  new->next = NULL;
414  }
415  return new;
416 }
417 
418 static int load_all_omf_records(rz_bin_omf_obj *obj, const ut8 *buf, ut64 size) {
419  ut64 ct = 0;
420  OMF_record_handler *new_rec = NULL;
422 
423  while (ct < size) {
424  if (!(new_rec = load_record_omf(buf + ct, ct, size - ct))) {
425  return false;
426  }
427 
428  // the order is important because some link are made by index
429  if (!tmp) {
430  obj->records = new_rec;
431  tmp = obj->records;
432  } else {
433  tmp->next = new_rec;
434  tmp = tmp->next;
435  }
436  ct += 3 + ((OMF_record *)tmp)->size;
437  }
438  return true;
439 }
440 
443  ut32 ct = 0;
444 
445  while (tmp) {
446  if (((OMF_record *)tmp)->type == type) {
447  ct++;
448  }
449  tmp = tmp->next;
450  }
451  return ct;
452 }
453 
456  ut32 ct = 0;
457 
458  while (tmp) {
459  if (((OMF_record *)tmp)->type == type) {
460  ct += ((OMF_multi_datas *)((OMF_record *)tmp)->content)->nb_elem;
461  }
462  tmp = tmp->next;
463  }
464  return ct;
465 }
466 
468  while (tmp) {
469  if (((OMF_record *)tmp)->type == type) {
470  return (tmp);
471  }
472  tmp = tmp->next;
473  }
474  return NULL;
475 }
476 
477 static int cpy_omf_names(rz_bin_omf_obj *obj) {
479  OMF_multi_datas *lname;
480  int ct_obj = 0;
481  int ct_rec;
482 
484  lname = (OMF_multi_datas *)((OMF_record *)tmp)->content;
485 
486  ct_rec = -1;
487  while (++ct_rec < lname->nb_elem) {
488  if (!((char **)lname->elems)[ct_rec]) {
489  obj->names[ct_obj++] = NULL;
490  } else if (!(obj->names[ct_obj++] = strdup(((char **)lname->elems)[ct_rec]))) {
491  return false;
492  }
493  }
494  tmp = tmp->next;
495  }
496  return true;
497 }
498 
501  ut32 ct_obj = 0;
502 
504  obj->sections[ct_obj] = ((OMF_record *)tmp)->content;
505  ((OMF_record *)tmp)->content = NULL;
506 
507  if (!ct_obj) {
508  obj->sections[ct_obj]->vaddr = 0;
509  } else {
510  obj->sections[ct_obj]->vaddr = obj->sections[ct_obj - 1]->vaddr +
511  obj->sections[ct_obj - 1]->size;
512  }
513  ct_obj++;
514  tmp = tmp->next;
515  }
516 }
517 
521  int ct_obj = 0;
522  int ct_rec = 0;
523 
525  symbols = (OMF_multi_datas *)((OMF_record *)tmp)->content;
526 
527  ct_rec = -1;
528  while (++ct_rec < symbols->nb_elem) {
529  if (!(obj->symbols[ct_obj] = RZ_NEW0(OMF_symbol))) {
530  return false;
531  }
532  memcpy(obj->symbols[ct_obj], ((OMF_symbol *)symbols->elems) + ct_rec, sizeof(*(obj->symbols[ct_obj])));
533  obj->symbols[ct_obj]->name = strdup(((OMF_symbol *)symbols->elems)[ct_rec].name);
534  ct_obj++;
535  }
536  tmp = tmp->next;
537  }
538  return true;
539 }
540 
543  OMF_data *tmp_data;
544 
546  if (((OMF_data *)((OMF_record *)tmp)->content)->seg_idx - 1 >= obj->nb_section) {
547  RZ_LOG_ERROR("Invalid Ledata record (bad segment index)\n");
548  return false;
549  }
550  OMF_segment *os = obj->sections[((OMF_data *)((OMF_record *)tmp)->content)->seg_idx - 1];
551  if (os && (tmp_data = os->data)) {
552  while (tmp_data->next) {
553  tmp_data = tmp_data->next;
554  }
555  tmp_data->next = ((OMF_record *)tmp)->content;
556  } else {
557  obj->sections[((OMF_data *)((OMF_record *)tmp)->content)->seg_idx - 1]->data = ((OMF_record *)tmp)->content;
558  }
559  ((OMF_record *)tmp)->content = NULL;
560  tmp = tmp->next;
561  }
562  return true;
563 }
564 
565 static int get_omf_infos(rz_bin_omf_obj *obj) {
566  // get all name defined in lnames records
568  if (obj->nb_name > 0) {
569  if (!(obj->names = RZ_NEWS0(char *, obj->nb_name))) {
570  return false;
571  }
572  if (!cpy_omf_names(obj)) {
573  return false;
574  }
575  }
576  // get all sections (segdef record)
578  if (obj->nb_section > 0) {
579  if (!(obj->sections = RZ_NEWS0(OMF_segment *, obj->nb_section))) {
580  return false;
581  }
583  }
584  // get all data (ledata record)
585  get_omf_data_info(obj);
586  // get all symbols (pubdef + lpubdef)
588  if (obj->nb_symbol > 0) {
589  if (!(obj->symbols = RZ_NEWS0(OMF_symbol *, obj->nb_symbol))) {
590  return false;
591  }
592  if (!get_omf_symbol_info(obj)) {
593  return false;
594  }
595  }
596  return true;
597 }
598 
599 static void free_pubdef(OMF_multi_datas *datas) {
600 #if 0
601  while (ct_rec < datas->nb_elem) {
602  RZ_FREE (((OMF_symbol *)(datas->elems + ct_rec++))->name);
603  }
604 #endif
605  RZ_FREE(datas->elems);
606  RZ_FREE(datas);
607 }
608 
611  OMF_record_handler *rec = obj->records;
612 
613  while (rec) {
614  if (((OMF_record *)rec)->type == OMF_LNAMES) {
615  free_lname((OMF_multi_datas *)((OMF_record *)rec)->content);
616  } else if (((OMF_record *)rec)->type == OMF_PUBDEF) {
617  free_pubdef((OMF_multi_datas *)((OMF_record *)rec)->content);
618  } else {
619  RZ_FREE(((OMF_record *)rec)->content);
620  }
621  tmp = rec->next;
622  RZ_FREE(rec);
623  rec = tmp;
624  }
625  obj->records = NULL;
626 }
627 
629  ut32 ct = 0;
630  OMF_data *data;
631 
632  while (ct < obj->nb_section) {
633  while (obj->sections[ct]->data) {
634  data = obj->sections[ct]->data->next;
635  RZ_FREE(obj->sections[ct]->data);
636  obj->sections[ct]->data = data;
637  }
638  RZ_FREE(obj->sections[ct]);
639  ct++;
640  }
641  RZ_FREE(obj->sections);
642 }
643 
645  ut32 ct = 0;
646  while (ct < obj->nb_symbol) {
647  RZ_FREE(obj->symbols[ct]->name);
648  RZ_FREE(obj->symbols[ct]);
649 
650  ct++;
651  }
652  RZ_FREE(obj->symbols);
653 }
654 
656  ut32 ct = 0;
657 
658  while (ct < obj->nb_name) {
659  RZ_FREE(obj->names[ct]);
660  ct++;
661  }
662  RZ_FREE(obj->names);
663 }
664 
666  if (obj) {
667  if (obj->records) {
669  }
670  if (obj->sections) {
672  }
673  if (obj->symbols) {
675  }
676  if (obj->names) {
677  free_all_omf_names(obj);
678  }
679  free(obj);
680  }
681 }
682 
684  rz_bin_omf_obj *ret = NULL;
685 
686  if (!(ret = RZ_NEW0(rz_bin_omf_obj))) {
687  return NULL;
688  }
689  if (!load_all_omf_records(ret, buf, size)) {
691  return NULL;
692  }
693  if (!(get_omf_infos(ret))) {
695  return NULL;
696  }
698  return ret;
699 }
700 
702  ut32 ct_sym = 0;
703  OMF_data *data;
704  ut32 offset = 0;
705 
706  if (!obj) {
707  return false;
708  }
709  while (ct_sym < obj->nb_symbol) {
710  if (!strcmp(obj->symbols[ct_sym]->name, "_start")) {
711  if (obj->symbols[ct_sym]->seg_idx - 1 > obj->nb_section) {
712  RZ_LOG_ERROR("Invalid segment index for symbol _start\n");
713  return false;
714  }
715  addr->vaddr = obj->sections[obj->symbols[ct_sym]->seg_idx - 1]->vaddr + obj->symbols[ct_sym]->offset + OMF_BASE_ADDR;
716  data = obj->sections[obj->symbols[ct_sym]->seg_idx - 1]->data;
717  while (data) {
718  offset += data->size;
719  if (obj->symbols[ct_sym]->offset < offset) {
720  addr->paddr = (obj->symbols[ct_sym]->offset - data->offset) + data->paddr;
721  return true;
722  }
723  data = data->next;
724  }
725  }
726  ct_sym++;
727  }
728  return false;
729 }
730 
732  ut32 ct_sec = 0;
733  if (!obj) {
734  return 32;
735  }
736 
737  // we assume if one segdef define a 32 segment all opcodes are 32bits
738  while (ct_sec < obj->nb_section) {
739  if (obj->sections[ct_sec++]->bits == 32) {
740  return 32;
741  }
742  }
743  return 16;
744 }
745 
747  RzBinSection *new;
748  OMF_data *data = section->data;
749  ut32 ct_name = 1;
750 
751  while (data) {
752  if (!(new = RZ_NEW0(RzBinSection))) {
753  return false;
754  }
755 
756  // if index == 0, it's mean there is no name
757  if (section->name_idx && section->name_idx - 1 < obj->nb_name) {
758  new->name = rz_str_newf("%s_%d", obj->names[section->name_idx - 1], ct_name++);
759  } else {
760  new->name = rz_str_newf("no_name_%d", ct_name++);
761  }
762 
763  new->size = data->size;
764  new->vsize = data->size;
765  new->paddr = data->paddr;
766  new->vaddr = section->vaddr + data->offset + OMF_BASE_ADDR;
767  new->perm = RZ_PERM_RWX;
768  rz_list_append(list, new);
769  data = data->next;
770  }
771  return true;
772 }
773 
775  ut64 offset = 0;
776  if (!obj->sections) {
777  return 0LL;
778  }
779  if (sym->seg_idx - 1 > obj->nb_section) {
780  return 0LL;
781  }
782  int sidx = sym->seg_idx - 1;
783  if (sidx >= obj->nb_section) {
784  return 0LL;
785  }
786  OMF_data *data = obj->sections[sidx]->data;
787  while (data) {
788  offset += data->size;
789  if (sym->offset < offset) {
790  return sym->offset - data->offset + data->paddr;
791  }
792  data = data->next;
793  }
794  return 0;
795 }
796 
798  if (!obj->sections) {
799  return 0LL;
800  }
801  if (sym->seg_idx >= obj->nb_section) {
802  RZ_LOG_ERROR("Invalid segment index for symbol %s\n", sym->name);
803  return 0;
804  }
805  if (sym->seg_idx == 0) {
806  return 0;
807  }
808  return obj->sections[sym->seg_idx - 1]->vaddr + sym->offset + OMF_BASE_ADDR;
809 }
RzList * symbols(RzBinFile *bf)
Definition: bin_ne.c:102
int bits(struct state *s, int need)
Definition: blast.c:72
#define NULL
Definition: cris-opc.c:27
static int buf_size
Definition: debug_qnx.c:35
uint16_t ut16
#define true
uint32_t ut32
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
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static void list(RzEgg *egg)
Definition: rz-gg.c:52
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")
while(len< limit &&buf1[len]==buf2[len])++len
int type
Definition: mipsasm.c:17
static const struct names names[]
bool rz_bin_omf_get_entry(rz_bin_omf_obj *obj, RzBinAddr *addr)
Definition: omf.c:701
static int load_omf_segdef(OMF_record *record, const ut8 *buf, ut64 buf_size)
Definition: omf.c:141
static bool is_valid_omf_type(ut8 type)
Definition: omf.c:7
static ut16 omf_get_idx(const ut8 *buf, int buf_size)
Definition: omf.c:61
ut64 rz_bin_omf_get_vaddr_sym(rz_bin_omf_obj *obj, OMF_symbol *sym)
Definition: omf.c:797
int rz_bin_omf_send_sections(RzList *list, OMF_segment *section, rz_bin_omf_obj *obj)
Definition: omf.c:746
static int load_omf_data(const ut8 *buf, int buf_size, OMF_record *record, ut64 global_ct)
Definition: omf.c:326
void rz_bin_free_all_omf_obj(rz_bin_omf_obj *obj)
Definition: omf.c:665
static int get_omf_data_info(rz_bin_omf_obj *obj)
Definition: omf.c:541
static int load_omf_content(OMF_record *record, const ut8 *buf, ut64 global_ct, ut64 buf_size)
Definition: omf.c:366
static int cpy_omf_names(rz_bin_omf_obj *obj)
Definition: omf.c:477
static void get_omf_section_info(rz_bin_omf_obj *obj)
Definition: omf.c:499
static void free_all_omf_names(rz_bin_omf_obj *obj)
Definition: omf.c:655
static void free_lname(OMF_multi_datas *lname)
Definition: omf.c:71
static ut32 count_omf_record_type(rz_bin_omf_obj *obj, ut8 type)
Definition: omf.c:441
static bool load_omf_lnames(OMF_record *record, const ut8 *buf, ut64 buf_size)
Definition: omf.c:82
static int load_all_omf_records(rz_bin_omf_obj *obj, const ut8 *buf, ut64 size)
Definition: omf.c:418
static void free_all_omf_records(rz_bin_omf_obj *obj)
Definition: omf.c:609
static int load_omf_pubdef(OMF_record *record, const ut8 *buf, int buf_size)
Definition: omf.c:254
int rz_bin_omf_get_bits(rz_bin_omf_obj *obj)
Definition: omf.c:731
static void free_pubdef(OMF_multi_datas *datas)
Definition: omf.c:599
static ut32 count_omf_multi_record_type(rz_bin_omf_obj *obj, ut8 type)
Definition: omf.c:454
static int load_omf_symb(OMF_record *record, ut32 ct, const ut8 *buf, int buf_size, int bits, ut16 seg_idx)
Definition: omf.c:204
bool rz_bin_checksum_omf_ok(const ut8 *buf, ut64 buf_size)
Definition: omf.c:30
static void free_all_omf_sections(rz_bin_omf_obj *obj)
Definition: omf.c:628
static void free_all_omf_symbols(rz_bin_omf_obj *obj)
Definition: omf.c:644
static ut32 omf_count_symb(ut16 total_size, ut32 ct, const ut8 *buf, int bits)
Definition: omf.c:187
ut64 rz_bin_omf_get_paddr_sym(rz_bin_omf_obj *obj, OMF_symbol *sym)
Definition: omf.c:774
static OMF_record_handler * get_next_omf_record_type(OMF_record_handler *tmp, ut8 type)
Definition: omf.c:467
static int get_omf_infos(rz_bin_omf_obj *obj)
Definition: omf.c:565
rz_bin_omf_obj * rz_bin_internal_omf_load(const ut8 *buf, ut64 size)
Definition: omf.c:683
static OMF_record_handler * load_record_omf(const ut8 *buf, ut64 global_ct, ut64 buf_size)
Definition: omf.c:391
static int get_omf_symbol_info(rz_bin_omf_obj *obj)
Definition: omf.c:518
#define OMF_BASE_ADDR
Definition: omf.h:61
#define OMF_CEXTDEF
Definition: omf_specs.h:38
#define OMF_LINNUM32
Definition: omf_specs.h:20
#define OMF_BAKPAT
Definition: omf_specs.h:32
#define OMF_VERNUM
Definition: omf_specs.h:47
#define OMF_NBKPAT
Definition: omf_specs.h:44
#define OMF_ALIAS
Definition: omf_specs.h:43
#define OMF_LEDATA
Definition: omf_specs.h:27
#define OMF_SEGDEF
Definition: omf_specs.h:22
#define OMF_COMDAT32
Definition: omf_specs.h:40
#define OMF_COMDAT
Definition: omf_specs.h:39
#define OMF_GRPDEF
Definition: omf_specs.h:24
#define OMF_THEADR
Definition: omf_specs.h:11
#define OMF_LINNUM
Definition: omf_specs.h:19
#define OMF_COMENT
Definition: omf_specs.h:13
#define OMF_LINSYM
Definition: omf_specs.h:41
#define OMF_VENDEXT
Definition: omf_specs.h:48
#define OMF_MODEND
Definition: omf_specs.h:14
#define OMF_LLNAMES
Definition: omf_specs.h:46
#define OMF_FIXUPP
Definition: omf_specs.h:25
#define OMF_FIXUPP32
Definition: omf_specs.h:26
#define OMF_LNAMES
Definition: omf_specs.h:21
#define OMF_EXTDEF
Definition: omf_specs.h:16
#define OMF_LPUBDEF
Definition: omf_specs.h:35
#define OMF_BAKPAT32
Definition: omf_specs.h:33
#define OMF_LIDATA32
Definition: omf_specs.h:30
#define OMF_MODEND32
Definition: omf_specs.h:15
#define OMF_SEGDEF32
Definition: omf_specs.h:23
#define OMF_NBKPAT32
Definition: omf_specs.h:45
#define OMF_LCOMDEF
Definition: omf_specs.h:37
#define OMF_LHEADR
Definition: omf_specs.h:12
#define OMF_PUBDEF32
Definition: omf_specs.h:18
#define OMF_LINSYM32
Definition: omf_specs.h:42
#define OMF_LPUBDEF32
Definition: omf_specs.h:36
#define OMF_LEXTDEF
Definition: omf_specs.h:34
#define OMF_LIDATA
Definition: omf_specs.h:29
#define OMF_COMDEF
Definition: omf_specs.h:31
#define OMF_LEDATA32
Definition: omf_specs.h:28
#define OMF_PUBDEF
Definition: omf_specs.h:17
insn_type_descr_t types[]
Definition: or1k_disas.c:7
static ut16 rz_read_le16(const void *src)
Definition: rz_endian.h:206
static ut32 rz_read_le32(const void *src)
Definition: rz_endian.h:239
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_NEWS0(x, y)
Definition: rz_types.h:282
#define RZ_PERM_RWX
Definition: rz_types.h:98
#define RZ_FREE(x)
Definition: rz_types.h:369
#define UT32_MAX
Definition: rz_types_base.h:99
#define UT16_MAX
static int
Definition: sfsocketcall.h:114
Definition: omf.h:24
ut16 seg_idx
Definition: omf.h:28
ut32 offset
Definition: omf.h:27
struct OMF_DATA * next
Definition: omf.h:29
ut64 size
Definition: omf.h:26
ut64 paddr
Definition: omf.h:25
void * elems
Definition: omf.h:21
ut32 nb_elem
Definition: omf.h:20
OMF_data * data
Definition: omf.h:39
ut32 name_idx
Definition: omf.h:35
ut64 vaddr
Definition: omf.h:38
ut8 bits
Definition: omf.h:37
ut64 size
Definition: omf.h:36
Definition: omf.h:42
ut32 offset
Definition: omf.h:45
char * name
Definition: omf.h:43
ut16 seg_idx
Definition: omf.h:44
Definition: names.h:123
ut32 nb_name
Definition: omf.h:51
ut32 nb_symbol
Definition: omf.h:55
char ** names
Definition: omf.h:50
OMF_segment ** sections
Definition: omf.h:52
OMF_symbol ** symbols
Definition: omf.h:54
ut32 nb_section
Definition: omf.h:53
OMF_record_handler * records
Definition: omf.h:56
Definition: tar.h:52
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const char * cb[]
Definition: z80_tab.h:176
static int addr
Definition: z80asm.c:58