main.c
1.06 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
/*==============================================================================
main.c : cord main program
==============================================================================*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "proc.h"
main(int argc, char **argv){
parse_command_line(argc, argv);
read_orig_binary(); /* read binary */
if(option.debug)
dump_procs();
/*------------------
open reorder file
------------------*/
read_reorder_files();
/*------------------
open new binary
------------------*/
bin.fd_out = open(option.out_file, O_WRONLY|O_CREAT|O_TRUNC, 0755);
if(bin.fd_out <= 0){
sysfatal("cannot open %s", option.out_file);
}
/*------------------
copy the entire binary first
------------------*/
bin_copy(bin.fd_in, bin.fd_out);
reorder_it();
write_it();
elf_end(bin.elf);
elf_end(bin.new_elf);
post_process_rpt(bin.fd_in, bin.fd_out);
post_process_line(bin.fd_in, bin.fd_out);
}