1 #ifndef __ELFFLT_H__
2 #define __ELFFLT_H__
3
4 #include <unistd.h>
5 #include "elf.h"
6 #define USE_INT32_FOR_PTRS
7 #include "flt.h"
8
9 #define ELFFLT_OK 0
10 #define ELFFLT_BAD_ELF_HEADER 1
11 #define ELFFLT_NO_SYMTAB 2
12 #define ELFFLT_NO_STRTAB 3
13 #define ELFFLT_NO_TEXT 4
14 #define ELFFLT_SYMBOL_NOT_FOUND 5
15 #define ELFFLT_SEGMENT_NOT_FOUND 6
16 #define ELFFLT_NO_MODULEINFO 7
17 #define ELFFLT_UNHANDLED_RELOC 8
18 #define ELFFLT_OUTOF_RANGE 9
19 #define ELFFLT_INPUT_ERROR 10
20 #define ELFFLT_OUTPUT_ERROR 11
21 #define ELFFLT_UNSAFE_SYMBOL 12
22
23
24
25
26 int elfloader_load(char* fltfile );
27
28
29 struct relevant_section {
30 unsigned char number;
31 uint32_t offset;
32 char *address;
33
34 int size;
35 char *name;
36 uint32_t base_addr;
37 uint32_t flat_offset;
38
39 uint32_t relaoff;
40 uint32_t relasize;
41 };
42
43 extern struct relevant_section bss, data, rodata, text;
44
45 extern char* flat_buf;
46 extern flat_hdr* flat;
47
48 typedef uint32_t reloc_record_t;
49
50 extern uint32_t flat_reloc_count;
51 extern reloc_record_t *flat_reloc;
52 extern reloc_record_t *flat_reloc_cur;
53
54 typedef struct
55 {
56 uint32_t offs;
57 uint32_t importidx;
58 } import_record_t;
59
60 extern uint32_t flat_import_count;
61 extern import_record_t* flat_import_buf;
62 extern import_record_t* flat_import_cur;
63
64 extern unsigned int strtaboff;
65 extern unsigned int symtaboff;
66
67
68 int apply_realloc( struct relevant_section* base_sect,
69 struct elf32_rela *rela,
70 struct relevant_section* tgt_sect,
71 struct elf32_sym *sym,
72 int symidx
73 );
74
75 int apply_import( struct relevant_section* base_sect,
76 struct elf32_rela *rela,
77 int importidx,
78 struct elf32_sym *sym
79 );
80
81 #endif
82