-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathmipsdisasm.h
More file actions
54 lines (44 loc) · 2.09 KB
/
mipsdisasm.h
File metadata and controls
54 lines (44 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef MIPSDISASM_H_
#define MIPSDISASM_H_
// typedefs
typedef struct _disasm_state disasm_state;
typedef enum
{
ASM_GAS, // GNU as
ASM_ARMIPS, // armips
} asm_syntax;
// allocate and initialize disassembler state to be passed into disassembler routines
// syntax: assembler syntax to use
// merge_pseudo: if true, attempt to link pseudo instructions
// returns disassembler state
disasm_state *disasm_state_init(asm_syntax syntax, int merge_pseudo);
// free disassembler state allocated during pass1
// state: disassembler state returned from disasm_state_alloc() or mipsdisasm_pass1()
void disasm_state_free(disasm_state *state);
// add a label to the disassembler state
// state: disassembler state returned from disasm_state_alloc() or mipsdisasm_pass1()
// name: string name of label (if NULL, generated based on vaddr)
// vaddr: virtual address of label
void disasm_label_add(disasm_state *state, const char *name, unsigned int vaddr);
// lookup a global label from the disassembler state
// state: disassembler state returned from disasm_state_alloc() or mipsdisasm_pass1()
// vaddr: virtual address of label
// name: string to write label to
// returns 1 if found, 0 otherwise
int disasm_label_lookup(const disasm_state *state, unsigned int vaddr, char *name);
// first pass of disassembler - collects procedures called and sorts them
// data: buffer containing raw MIPS assembly
// offset: buffer offset to start at
// length: length to disassemble starting at 'offset'
// vaddr: virtual address of first byte
// syntax: assembler syntax to use
// state: disassembler state. if NULL, is allocated, returned at end
void mipsdisasm_pass1(unsigned char *data, unsigned int offset, unsigned int length, unsigned int vaddr, disasm_state *state);
// disassemble a region of code, output to file stream
// out: stream to output data to
// state: disassembler state from pass1
// offset: starting offset to match in disassembler state
void mipsdisasm_pass2(FILE *out, disasm_state *state, unsigned int offset);
// get version string of raw disassembler
const char *disasm_get_version(void);
#endif // MIPSDISASM_H_