-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfusion.c
70 lines (51 loc) · 1.49 KB
/
fusion.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "stdio.h"
#include "getopt.h"
#include "elf_reader.h"
#include "affichage_elf.h"
#include "elf_fusion.h"
#include "elf_writer.h"
void usage(char *name) {
fprintf(stderr, "Usage:\n"
"%s [ --help ] file1 file2 file_sortie\n\n", name);
}
void write_elf_data(Elf32_data* elf, FILE* file);
int main(int argc, char *argv[]){
FILE* elf1 = NULL;
FILE* elf2 = NULL;
FILE* resultat_file = NULL;
Elf32_data elf1_data;
Elf32_data elf2_data;
Elf32_data result;
if(argc < 3){
usage(argv[0]);
exit(1);
}
elf1 = fopen(argv[1], "r");
elf2 = fopen(argv[2], "r");
resultat_file = fopen(argv[3], "w");
printf("======== LECTURE ========\n");
elf1_data = read_elf_data(elf1);
elf2_data = read_elf_data(elf2);
/*
print_section_header_table(elf1_data);
print_section_header_table(elf2_data);
*/
printf("\n======== MERGE ========\n");
merge(&result, &elf1_data, &elf2_data);
printf("\n==== MERGED SECTIONS HEADER ====\n");
print_section_header_table(result);
printf("\n==== MERGED SYMBOL TABLE ====\n");
print_symbol_table(result);
printf("\n==== MERGED RELOCATION TABLE ====\n");
print_relocation_table(result);
printf("\n======== ECRITURE ========\n");
write_elf_data(&result, resultat_file);
printf("\n======== FREE ========\n");
free_elf_data(elf1_data);
free_elf_data(elf2_data);
//free_elf_data(result);
fclose(elf1);
fclose(elf2);
fclose(resultat_file);
return 0;
}