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 #ifndef _FREEBSD_EXEC_H
36 #define _FREEBSD_EXEC_H
37
38 #define FREEBSD_N_GETMAGIC(ex) \
39 ( (ex).a_midmag & 0xffff )
40 #define FREEBSD_N_GETMID(ex) \
41 ( ((ex).a_midmag >> 16) & 0x03ff )
42 #define FREEBSD_N_GETFLAG(ex) \
43 ( ((ex).a_midmag >> 26) & 0x3f )
44 #define FREEBSD_N_SETMAGIC(ex,mag,mid,flag) \
45 ( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \
46 ((mag) & 0xffff) )
47
48 #define FREEBSD_N_ALIGN(ex,x) \
49 (FREEBSD_N_GETMAGIC(ex) == ZMAGIC || \
50 FREEBSD_N_GETMAGIC(ex) == QMAGIC ? \
51 ((x) + FREEBSD___LDPGSZ - 1) & \
52 ~(unsigned long)(FREEBSD___LDPGSZ - 1) : (x))
53
54
55 #define FREEBSD_N_BADMAG(ex) \
56 (FREEBSD_N_GETMAGIC(ex) != OMAGIC && \
57 FREEBSD_N_GETMAGIC(ex) != NMAGIC && \
58 FREEBSD_N_GETMAGIC(ex) != ZMAGIC && \
59 FREEBSD_N_GETMAGIC(ex) != QMAGIC)
60
61
62 #define FREEBSD_N_TXTADDR(ex) \
63 ((FREEBSD_N_GETMAGIC(ex) == OMAGIC || \
64 FREEBSD_N_GETMAGIC(ex) == NMAGIC || \
65 FREEBSD_N_GETMAGIC(ex) == ZMAGIC) ? 0 : __LDPGSZ)
66
67
68 #define FREEBSD_N_DATADDR(ex) \
69 FREEBSD_N_ALIGN(ex, FREEBSD_N_TXTADDR(ex) + (ex).a_text)
70
71
72 #define FREEBSD_N_TXTOFF(ex) \
73 (FREEBSD_N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : \
74 FREEBSD_N_GETMAGIC(ex) == QMAGIC ? 0 : sizeof(struct exec))
75
76
77 #define FREEBSD_N_DATOFF(ex) \
78 FREEBSD_N_ALIGN(ex, FREEBSD_N_TXTOFF(ex) + (ex).a_text)
79
80
81 #define FREEBSD_N_RELOFF(ex) \
82 FREEBSD_N_ALIGN(ex, FREEBSD_N_DATOFF(ex) + (ex).a_data)
83
84
85 #define FREEBSD_N_SYMOFF(ex) \
86 (FREEBSD_N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize)
87
88
89 #define FREEBSD_N_STROFF(ex) (FREEBSD_N_SYMOFF(ex) + (ex).a_syms)
90
91 #define FREEBSD_ELF_AUX_ARGSIZ (sizeof(AuxInfo) * 15 / sizeof(char *))
92
93 #define FREEBSD_AOUT_HDR_SIZE sizeof(struct exec)
94
95 int exec_freebsd_aout_makecmds(struct proc *, struct exec_package *);
96 int exec_freebsd_elf32_makecmds(struct proc *, struct exec_package *);
97 int freebsd_elf_probe(struct proc *, struct exec_package *, char *,
98 u_long *, u_int8_t *);
99
100 extern char freebsd_sigcode[], freebsd_esigcode[];
101
102 #endif