1
2
3
4
5
6
7
8
9
10
11
12struct external_filehdr {
13 char f_magic[2];
14 char f_nscns[2];
15 char f_timdat[4];
16 char f_symptr[4];
17 char f_nsyms[4];
18 char f_opthdr[2];
19 char f_flags[2];
20};
21
22
23#define U802WRMAGIC 0730
24#define U802ROMAGIC 0735
25#define U802TOCMAGIC 0737
26
27#define BADMAG(x) \
28 ((x).f_magic != U802ROMAGIC && (x).f_magic != U802WRMAGIC && \
29 (x).f_magic != U802TOCMAGIC)
30
31#define FILHDR struct external_filehdr
32#define FILHSZ 20
33
34
35
36
37
38typedef struct
39{
40 unsigned char magic[2];
41 unsigned char vstamp[2];
42 unsigned char tsize[4];
43 unsigned char dsize[4];
44 unsigned char bsize[4];
45 unsigned char entry[4];
46 unsigned char text_start[4];
47 unsigned char data_start[4];
48 unsigned char o_toc[4];
49 unsigned char o_snentry[2];
50 unsigned char o_sntext[2];
51 unsigned char o_sndata[2];
52 unsigned char o_sntoc[2];
53 unsigned char o_snloader[2];
54 unsigned char o_snbss[2];
55 unsigned char o_algntext[2];
56 unsigned char o_algndata[2];
57 unsigned char o_modtype[2];
58 unsigned char o_cputype[2];
59 unsigned char o_maxstack[4];
60 unsigned char o_maxdata[4];
61 unsigned char o_resv2[12];
62}
63AOUTHDR;
64
65#define AOUTSZ 72
66#define SMALL_AOUTSZ (28)
67#define AOUTHDRSZ 72
68
69#define RS6K_AOUTHDR_OMAGIC 0x0107
70#define RS6K_AOUTHDR_NMAGIC 0x0108
71#define RS6K_AOUTHDR_ZMAGIC 0x010B
72
73
74
75
76
77struct external_scnhdr {
78 char s_name[8];
79 char s_paddr[4];
80 char s_vaddr[4];
81 char s_size[4];
82 char s_scnptr[4];
83 char s_relptr[4];
84 char s_lnnoptr[4];
85 char s_nreloc[2];
86 char s_nlnno[2];
87 char s_flags[4];
88};
89
90
91
92
93#define _TEXT ".text"
94#define _DATA ".data"
95#define _BSS ".bss"
96#define _PAD ".pad"
97#define _LOADER ".loader"
98
99#define SCNHDR struct external_scnhdr
100#define SCNHSZ 40
101
102
103#define STYP_LOADER 0x1000
104
105
106#define STYP_DEBUG 0x2000
107
108
109
110#define STYP_OVRFLO 0x8000
111
112
113
114
115
116
117
118
119struct external_lineno {
120 union {
121 char l_symndx[4];
122 char l_paddr[4];
123 } l_addr;
124 char l_lnno[2];
125};
126
127
128#define LINENO struct external_lineno
129#define LINESZ 6
130
131
132
133
134#define E_SYMNMLEN 8
135#define E_FILNMLEN 14
136#define E_DIMNUM 4
137
138struct external_syment
139{
140 union {
141 char e_name[E_SYMNMLEN];
142 struct {
143 char e_zeroes[4];
144 char e_offset[4];
145 } e;
146 } e;
147 char e_value[4];
148 char e_scnum[2];
149 char e_type[2];
150 char e_sclass[1];
151 char e_numaux[1];
152};
153
154
155
156#define N_BTMASK (017)
157#define N_TMASK (060)
158#define N_BTSHFT (4)
159#define N_TSHIFT (2)
160
161
162union external_auxent {
163 struct {
164 char x_tagndx[4];
165 union {
166 struct {
167 char x_lnno[2];
168 char x_size[2];
169 } x_lnsz;
170 char x_fsize[4];
171 } x_misc;
172 union {
173 struct {
174 char x_lnnoptr[4];
175 char x_endndx[4];
176 } x_fcn;
177 struct {
178 char x_dimen[E_DIMNUM][2];
179 } x_ary;
180 } x_fcnary;
181 char x_tvndx[2];
182 } x_sym;
183
184 union {
185 char x_fname[E_FILNMLEN];
186 struct {
187 char x_zeroes[4];
188 char x_offset[4];
189 } x_n;
190 } x_file;
191
192 struct {
193 char x_scnlen[4];
194 char x_nreloc[2];
195 char x_nlinno[2];
196 } x_scn;
197
198 struct {
199 char x_tvfill[4];
200 char x_tvlen[2];
201 char x_tvran[2][2];
202 } x_tv;
203
204 struct {
205 unsigned char x_scnlen[4];
206 unsigned char x_parmhash[4];
207 unsigned char x_snhash[2];
208 unsigned char x_smtyp[1];
209 unsigned char x_smclas[1];
210 unsigned char x_stab[4];
211 unsigned char x_snstab[2];
212 } x_csect;
213
214};
215
216#define SYMENT struct external_syment
217#define SYMESZ 18
218#define AUXENT union external_auxent
219#define AUXESZ 18
220#define DBXMASK 0x80
221#define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK)
222
223
224
225
226
227
228struct external_reloc {
229 char r_vaddr[4];
230 char r_symndx[4];
231 char r_size[1];
232 char r_type[1];
233};
234
235
236#define RELOC struct external_reloc
237#define RELSZ 10
238
239#define DEFAULT_DATA_SECTION_ALIGNMENT 4
240#define DEFAULT_BSS_SECTION_ALIGNMENT 4
241#define DEFAULT_TEXT_SECTION_ALIGNMENT 4
242
243#define DEFAULT_SECTION_ALIGNMENT 4
244