-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
48 lines (36 loc) · 923 Bytes
/
main.c
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
#include "opsoup.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define OUTPUT_FILE "ffe.asm"
opsoup_t *o;
int main(int argc, char **argv) {
opsoup_t ctx = {0};
int round = 1;
FILE *f = NULL;
o = &ctx;
o->verbose = (argc == 2 && strcmp(argv[1], "-v") == 0);
if (image_load() != 0) {
fprintf(stderr, "Error: Image load failed!\n");
return EXIT_FAILURE;
}
init_sync();
dis_pass1();
while (dis_pass2(round++)) {
o->nref = 0;
}
label_reloc_upgrade();
label_gen_names();
label_sort();
if ((f = fopen(OUTPUT_FILE, "w")) == NULL) {
fprintf(stderr, "main: couldn't open '%s' for writing: %s\n", OUTPUT_FILE, strerror(errno));
return EXIT_FAILURE;
}
label_extern_output(f);
dis_pass3(f);
data_output(f);
data_bss_output(f);
fclose(f);
return EXIT_SUCCESS;
}