1 #ifndef OMF_H_
2 #define OMF_H_
3 
4 #include <r_util.h>
5 #include <r_types.h>
6 #include <r_bin.h>
7 
8 #include "omf_specs.h"
9 
10 typedef struct OMF_record_handler {
11 	OMF_record record;
12 	struct OMF_record_handler *next;
13 } OMF_record_handler;
14 
15 typedef struct {
16 	ut32 nb_elem;
17 	void *elems;
18 } OMF_multi_datas;
19 
20 typedef struct OMF_DATA{
21 	ut64 paddr; // offset in file
22 	ut64 size;
23 	ut32 offset;
24 	ut16 seg_idx;
25 	struct OMF_DATA	*next;
26 } OMF_data;
27 
28 // sections return by the plugin are the addr of datas because sections are
29 // separate on non contiguous block on the omf file
30 typedef struct {
31 	ut32 name_idx;
32 	ut64 size;
33 	ut8 bits;
34 	ut64 vaddr;
35 	OMF_data *data;
36 } OMF_segment;
37 
38 typedef struct {
39 	char *name;
40 	ut16 seg_idx;
41 	ut32 offset;
42 } OMF_symbol;
43 
44 typedef struct {
45 	ut8 bits;
46 	char **names;
47 	ut32 nb_name;
48 	OMF_segment **sections;
49 	ut32 nb_section;
50 	OMF_symbol **symbols;
51 	ut32 nb_symbol;
52 	OMF_record_handler *records;
53 } r_bin_omf_obj;
54 
55 // this value was chosen arbitrarily to made the loader work correctly
56 // if someone want to implement rellocation for omf he has to remove this
57 #define OMF_BASE_ADDR 0x1000
58 
59 bool r_bin_checksum_omf_ok(const ut8 *buf, ut64 buf_size);
60 r_bin_omf_obj *r_bin_internal_omf_load(const ut8 *buf, ut64 size);
61 void r_bin_free_all_omf_obj(r_bin_omf_obj *obj);
62 bool r_bin_omf_get_entry(r_bin_omf_obj *obj, RBinAddr *addr);
63 int r_bin_omf_get_bits(r_bin_omf_obj *obj);
64 int r_bin_omf_send_sections(RList *list, OMF_segment *section, r_bin_omf_obj *obj);
65 ut64 r_bin_omf_get_paddr_sym(r_bin_omf_obj *obj, OMF_symbol *sym);
66 ut64 r_bin_omf_get_vaddr_sym(r_bin_omf_obj *obj, OMF_symbol *sym);
67 
68 #endif
69