-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathld.h
81 lines (51 loc) · 1.85 KB
/
ld.h
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
71
72
73
74
75
76
77
78
79
80
81
/******************************************************************************
* @file ld.h
*****************************************************************************/
#ifndef _LD_H
#define _LD_H
enum {
LD_FORMAT_NONE = 0,
LD_FORMAT_I386_AOUT, LD_FORMAT_I386_COFF, LD_FORMAT_I386_PE,
LD_FORMAT_BINARY, LD_FORMAT_MSDOS, LD_FORMAT_MSDOS_MZ
};
#define GET_INT32(arr) ((int32_t) arr[0] | (((int32_t) arr[1]) << 8) | (((int32_t) arr[2]) << 16) | (((int32_t) arr[3]) << 24))
#define GET_UINT32(arr) ((uint32_t) arr[0] | (((uint32_t) arr[1]) << 8) | (((uint32_t) arr[2]) << 16) | (((uint32_t) arr[3]) << 24))
#include "types.h"
struct aout_object {
const char *filename;
void *raw;
unsigned long size;
struct aout_exec *header;
struct relocation_info *trelocs, *drelocs;
struct nlist *symtab;
char *strtab;
int32_t symtab_count, trelocs_count, drelocs_count;
uint32_t text_slide, data_slide, bss_slide;
};
struct coff_object {
const char *filename;
void *raw;
unsigned long size;
struct coff_header *header;
};
struct ld_state {
const char **files;
long nb_files;
const char *entry, *mapfile, *outfile;
int code_offset, format, impure;
struct aout_object **aout_objs;
long nb_aout_objs;
struct coff_object **coff_objs;
long nb_coff_objs;
unsigned long text_size, data_size, bss_size;
unsigned long stack_size;
int flat_bin;
int include_bss;
};
extern struct ld_state *state;
extern const char *program_name;
#define FILE_ALIGNMENT 512
#define SECTION_ALIGNMENT 4096
#define DIV_ROUNDUP(a, b) (((a) + ((b) - 1)) / (b))
#define ALIGN_UP(x, a) (DIV_ROUNDUP ((x), (a)) * (a))
#endif /* _LD_H */