• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/include/linux/
1/* This file is derived from the GAS 2.1.4 assembler control file.
2   The GAS product is under the GNU General Public License, version 2 or later.
3   As such, this file is also under that license.
4
5   If the file format changes in the COFF object, this file should be
6   subsequently updated to reflect the changes.
7
8   The actual loader module only uses a few of these structures. The full
9   set is documented here because I received the full set. If you wish
10   more information about COFF, then O'Reilly has a very excellent book.
11*/
12
13#define  E_SYMNMLEN  8   /* Number of characters in a symbol name         */
14#define  E_FILNMLEN 14   /* Number of characters in a file name           */
15#define  E_DIMNUM    4   /* Number of array dimensions in auxiliary entry */
16
17/*
18 * These defines are byte order independent. There is no alignment of fields
19 * permitted in the structures. Therefore they are declared as characters
20 * and the values loaded from the character positions. It also makes it
21 * nice to have it "endian" independent.
22 */
23
24/* Load a short int from the following tables with little-endian formats */
25#define COFF_SHORT_L(ps) ((short)(((unsigned short)((unsigned char)ps[1])<<8)|\
26				  ((unsigned short)((unsigned char)ps[0]))))
27
28/* Load a long int from the following tables with little-endian formats */
29#define COFF_LONG_L(ps) (((long)(((unsigned long)((unsigned char)ps[3])<<24) |\
30				 ((unsigned long)((unsigned char)ps[2])<<16) |\
31				 ((unsigned long)((unsigned char)ps[1])<<8)  |\
32				 ((unsigned long)((unsigned char)ps[0])))))
33
34/* Load a short int from the following tables with big-endian formats */
35#define COFF_SHORT_H(ps) ((short)(((unsigned short)((unsigned char)ps[0])<<8)|\
36				  ((unsigned short)((unsigned char)ps[1]))))
37
38/* Load a long int from the following tables with big-endian formats */
39#define COFF_LONG_H(ps) (((long)(((unsigned long)((unsigned char)ps[0])<<24) |\
40				 ((unsigned long)((unsigned char)ps[1])<<16) |\
41				 ((unsigned long)((unsigned char)ps[2])<<8)  |\
42				 ((unsigned long)((unsigned char)ps[3])))))
43
44/* These may be overridden later by brain dead implementations which generate
45   a big-endian header with little-endian data. In that case, generate a
46   replacement macro which tests a flag and uses either of the two above
47   as appropriate. */
48
49#define COFF_LONG(v)   COFF_LONG_L(v)
50#define COFF_SHORT(v)  COFF_SHORT_L(v)
51
52/*** coff information for Intel 386/486.  */
53
54/********************** FILE HEADER **********************/
55
56struct COFF_filehdr {
57	char f_magic[2];	/* magic number			*/
58	char f_nscns[2];	/* number of sections		*/
59	char f_timdat[4];	/* time & date stamp		*/
60	char f_symptr[4];	/* file pointer to symtab	*/
61	char f_nsyms[4];	/* number of symtab entries	*/
62	char f_opthdr[2];	/* sizeof(optional hdr)		*/
63	char f_flags[2];	/* flags			*/
64};
65
66/*
67 *   Bits for f_flags:
68 *
69 *	F_RELFLG	relocation info stripped from file
70 *	F_EXEC		file is executable  (i.e. no unresolved external
71 *			references)
72 *	F_LNNO		line numbers stripped from file
73 *	F_LSYMS		local symbols stripped from file
74 *	F_MINMAL	this is a minimal object file (".m") output of fextract
75 *	F_UPDATE	this is a fully bound update file, output of ogen
76 *	F_SWABD		this file has had its bytes swabbed (in names)
77 *	F_AR16WR	this file has the byte ordering of an AR16WR
78 *			(e.g. 11/70) machine
79 *	F_AR32WR	this file has the byte ordering of an AR32WR machine
80 *			(e.g. vax and iNTEL 386)
81 *	F_AR32W		this file has the byte ordering of an AR32W machine
82 *			(e.g. 3b,maxi)
83 *	F_PATCH		file contains "patch" list in optional header
84 *	F_NODF		(minimal file only) no decision functions for
85 *			replaced functions
86 */
87
88#define  COFF_F_RELFLG		0000001
89#define  COFF_F_EXEC		0000002
90#define  COFF_F_LNNO		0000004
91#define  COFF_F_LSYMS		0000010
92#define  COFF_F_MINMAL		0000020
93#define  COFF_F_UPDATE		0000040
94#define  COFF_F_SWABD		0000100
95#define  COFF_F_AR16WR		0000200
96#define  COFF_F_AR32WR		0000400
97#define  COFF_F_AR32W		0001000
98#define  COFF_F_PATCH		0002000
99#define  COFF_F_NODF		0002000
100
101#define	COFF_I386MAGIC	        0x14c   /* Linux's system    */
102
103#define COFF_I386BADMAG(x) (COFF_SHORT((x).f_magic) != COFF_I386MAGIC)
104
105#define	COFF_FILHDR	struct COFF_filehdr
106#define	COFF_FILHSZ	sizeof(COFF_FILHDR)
107
108/********************** AOUT "OPTIONAL HEADER" **********************/
109
110/* Linux COFF must have this "optional" header. Standard COFF has no entry
111   location for the "entry" point. They normally would start with the first
112   location of the .text section. This is not a good idea for linux. So,
113   the use of this "optional" header is not optional. It is required.
114
115   Do not be tempted to assume that the size of the optional header is
116   a constant and simply index the next byte by the size of this structure.
117   Use the 'f_opthdr' field in the main coff header for the size of the
118   structure actually written to the file!!
119*/
120
121typedef struct
122{
123  char 	magic[2];		/* type of file				 */
124  char	vstamp[2];		/* version stamp			 */
125  char	tsize[4];		/* text size in bytes, padded to FW bdry */
126  char	dsize[4];		/* initialized   data "   "		 */
127  char	bsize[4];		/* uninitialized data "   "		 */
128  char	entry[4];		/* entry pt.				 */
129  char 	text_start[4];		/* base of text used for this file       */
130  char 	data_start[4];		/* base of data used for this file       */
131}
132COFF_AOUTHDR;
133
134#define COFF_AOUTSZ (sizeof(COFF_AOUTHDR))
135
136#define COFF_STMAGIC	0401
137#define COFF_OMAGIC     0404
138#define COFF_JMAGIC     0407    /* dirty text and data image, can't share  */
139#define COFF_DMAGIC     0410    /* dirty text segment, data aligned        */
140#define COFF_ZMAGIC     0413    /* The proper magic number for executables  */
141#define COFF_SHMAGIC	0443	/* shared library header                   */
142
143/********************** SECTION HEADER **********************/
144
145struct COFF_scnhdr {
146  char		s_name[8];	/* section name			    */
147  char		s_paddr[4];	/* physical address, aliased s_nlib */
148  char		s_vaddr[4];	/* virtual address		    */
149  char		s_size[4];	/* section size			    */
150  char		s_scnptr[4];	/* file ptr to raw data for section */
151  char		s_relptr[4];	/* file ptr to relocation	    */
152  char		s_lnnoptr[4];	/* file ptr to line numbers	    */
153  char		s_nreloc[2];	/* number of relocation entries	    */
154  char		s_nlnno[2];	/* number of line number entries    */
155  char		s_flags[4];	/* flags			    */
156};
157
158#define	COFF_SCNHDR	struct COFF_scnhdr
159#define	COFF_SCNHSZ	sizeof(COFF_SCNHDR)
160
161/*
162 * names of "special" sections
163 */
164
165#define COFF_TEXT	".text"
166#define COFF_DATA	".data"
167#define COFF_BSS	".bss"
168#define COFF_COMMENT    ".comment"
169#define COFF_LIB        ".lib"
170
171#define COFF_SECT_TEXT  0      /* Section for instruction code             */
172#define COFF_SECT_DATA  1      /* Section for initialized globals          */
173#define COFF_SECT_BSS   2      /* Section for un-initialized globals       */
174#define COFF_SECT_REQD  3      /* Minimum number of sections for good file */
175
176#define COFF_STYP_REG     0x00 /* regular segment                          */
177#define COFF_STYP_DSECT   0x01 /* dummy segment                            */
178#define COFF_STYP_NOLOAD  0x02 /* no-load segment                          */
179#define COFF_STYP_GROUP   0x04 /* group segment                            */
180#define COFF_STYP_PAD     0x08 /* .pad segment                             */
181#define COFF_STYP_COPY    0x10 /* copy section                             */
182#define COFF_STYP_TEXT    0x20 /* .text segment                            */
183#define COFF_STYP_DATA    0x40 /* .data segment                            */
184#define COFF_STYP_BSS     0x80 /* .bss segment                             */
185#define COFF_STYP_INFO   0x200 /* .comment section                         */
186#define COFF_STYP_OVER   0x400 /* overlay section                          */
187#define COFF_STYP_LIB    0x800 /* library section                          */
188
189/*
190 * Shared libraries have the following section header in the data field for
191 * each library.
192 */
193
194struct COFF_slib {
195  char		sl_entsz[4];	/* Size of this entry               */
196  char		sl_pathndx[4];	/* size of the header field         */
197};
198
199#define	COFF_SLIBHD	struct COFF_slib
200#define	COFF_SLIBSZ	sizeof(COFF_SLIBHD)
201
202/********************** LINE NUMBERS **********************/
203
204/* 1 line number entry for every "breakpointable" source line in a section.
205 * Line numbers are grouped on a per function basis; first entry in a function
206 * grouping will have l_lnno = 0 and in place of physical address will be the
207 * symbol table index of the function name.
208 */
209
210struct COFF_lineno {
211  union {
212    char l_symndx[4];	/* function name symbol index, iff l_lnno == 0*/
213    char l_paddr[4];	/* (physical) address of line number	*/
214  } l_addr;
215  char l_lnno[2];	/* line number		*/
216};
217
218#define	COFF_LINENO	struct COFF_lineno
219#define	COFF_LINESZ	6
220
221/********************** SYMBOLS **********************/
222
223#define COFF_E_SYMNMLEN	 8	/* # characters in a short symbol name	*/
224#define COFF_E_FILNMLEN	14	/* # characters in a file name		*/
225#define COFF_E_DIMNUM	 4	/* # array dimensions in auxiliary entry */
226
227/*
228 *  All symbols and sections have the following definition
229 */
230
231struct COFF_syment
232{
233  union {
234    char e_name[E_SYMNMLEN];    /* Symbol name (first 8 characters) */
235    struct {
236      char e_zeroes[4];         /* Leading zeros */
237      char e_offset[4];         /* Offset if this is a header section */
238    } e;
239  } e;
240
241  char e_value[4];              /* Value (address) of the segment */
242  char e_scnum[2];              /* Section number */
243  char e_type[2];               /* Type of section */
244  char e_sclass[1];             /* Loader class */
245  char e_numaux[1];             /* Number of auxiliary entries which follow */
246};
247
248#define COFF_N_BTMASK	(0xf)   /* Mask for important class bits */
249#define COFF_N_TMASK	(0x30)  /* Mask for important type bits  */
250#define COFF_N_BTSHFT	(4)     /* # bits to shift class field   */
251#define COFF_N_TSHIFT	(2)     /* # bits to shift type field    */
252
253/*
254 *  Auxiliary entries because the main table is too limiting.
255 */
256
257union COFF_auxent {
258
259/*
260 *  Debugger information
261 */
262
263  struct {
264    char x_tagndx[4];	        /* str, un, or enum tag indx */
265    union {
266      struct {
267	char  x_lnno[2];        /* declaration line number */
268	char  x_size[2];        /* str/union/array size */
269      } x_lnsz;
270      char x_fsize[4];	        /* size of function */
271    } x_misc;
272
273    union {
274      struct {		        /* if ISFCN, tag, or .bb */
275	char x_lnnoptr[4];	/* ptr to fcn line # */
276	char x_endndx[4];	/* entry ndx past block end */
277      } x_fcn;
278
279      struct {		        /* if ISARY, up to 4 dimen. */
280	char x_dimen[E_DIMNUM][2];
281      } x_ary;
282    } x_fcnary;
283
284    char x_tvndx[2];	/* tv index */
285  } x_sym;
286
287/*
288 *   Source file names (debugger information)
289 */
290
291  union {
292    char x_fname[E_FILNMLEN];
293    struct {
294      char x_zeroes[4];
295      char x_offset[4];
296    } x_n;
297  } x_file;
298
299/*
300 *   Section information
301 */
302
303  struct {
304    char x_scnlen[4];	/* section length */
305    char x_nreloc[2];	/* # relocation entries */
306    char x_nlinno[2];	/* # line numbers */
307  } x_scn;
308
309/*
310 *   Transfer vector (branch table)
311 */
312
313  struct {
314    char x_tvfill[4];	/* tv fill value */
315    char x_tvlen[2];	/* length of .tv */
316    char x_tvran[2][2];	/* tv range */
317  } x_tv;		/* info about .tv section (in auxent of symbol .tv)) */
318};
319
320#define	COFF_SYMENT	struct COFF_syment
321#define	COFF_SYMESZ	18
322#define	COFF_AUXENT	union COFF_auxent
323#define	COFF_AUXESZ	18
324
325#define COFF_ETEXT	"etext"
326
327/********************** RELOCATION DIRECTIVES **********************/
328
329struct COFF_reloc {
330  char r_vaddr[4];        /* Virtual address of item    */
331  char r_symndx[4];       /* Symbol index in the symtab */
332  char r_type[2];         /* Relocation type            */
333};
334
335#define COFF_RELOC struct COFF_reloc
336#define COFF_RELSZ 10
337
338#define COFF_DEF_DATA_SECTION_ALIGNMENT  4
339#define COFF_DEF_BSS_SECTION_ALIGNMENT   4
340#define COFF_DEF_TEXT_SECTION_ALIGNMENT  4
341
342/* For new sections we haven't heard of before */
343#define COFF_DEF_SECTION_ALIGNMENT       4
344