xref: /OK3568_Linux_fs/kernel/arch/mips/boot/ecoff.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Some ECOFF definitions.
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun #include <stdint.h>
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun typedef struct filehdr {
9*4882a593Smuzhiyun 	uint16_t	f_magic;	/* magic number */
10*4882a593Smuzhiyun 	uint16_t	f_nscns;	/* number of sections */
11*4882a593Smuzhiyun 	int32_t		f_timdat;	/* time & date stamp */
12*4882a593Smuzhiyun 	int32_t		f_symptr;	/* file pointer to symbolic header */
13*4882a593Smuzhiyun 	int32_t		f_nsyms;	/* sizeof(symbolic hdr) */
14*4882a593Smuzhiyun 	uint16_t	f_opthdr;	/* sizeof(optional hdr) */
15*4882a593Smuzhiyun 	uint16_t	f_flags;	/* flags */
16*4882a593Smuzhiyun } FILHDR;
17*4882a593Smuzhiyun #define FILHSZ	sizeof(FILHDR)
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #define MIPSEBMAGIC	0x160
20*4882a593Smuzhiyun #define MIPSELMAGIC	0x162
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun typedef struct scnhdr {
23*4882a593Smuzhiyun 	char		s_name[8];	/* section name */
24*4882a593Smuzhiyun 	int32_t		s_paddr;	/* physical address, aliased s_nlib */
25*4882a593Smuzhiyun 	int32_t		s_vaddr;	/* virtual address */
26*4882a593Smuzhiyun 	int32_t		s_size;		/* section size */
27*4882a593Smuzhiyun 	int32_t		s_scnptr;	/* file ptr to raw data for section */
28*4882a593Smuzhiyun 	int32_t		s_relptr;	/* file ptr to relocation */
29*4882a593Smuzhiyun 	int32_t		s_lnnoptr;	/* file ptr to gp histogram */
30*4882a593Smuzhiyun 	uint16_t	s_nreloc;	/* number of relocation entries */
31*4882a593Smuzhiyun 	uint16_t	s_nlnno;	/* number of gp histogram entries */
32*4882a593Smuzhiyun 	int32_t		s_flags;	/* flags */
33*4882a593Smuzhiyun } SCNHDR;
34*4882a593Smuzhiyun #define SCNHSZ		sizeof(SCNHDR)
35*4882a593Smuzhiyun #define SCNROUND	((int32_t)16)
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun typedef struct aouthdr {
38*4882a593Smuzhiyun 	int16_t	magic;		/* see above				*/
39*4882a593Smuzhiyun 	int16_t	vstamp;		/* version stamp			*/
40*4882a593Smuzhiyun 	int32_t	tsize;		/* text size in bytes, padded to DW bdry*/
41*4882a593Smuzhiyun 	int32_t	dsize;		/* initialized data "  "		*/
42*4882a593Smuzhiyun 	int32_t	bsize;		/* uninitialized data "	  "		*/
43*4882a593Smuzhiyun 	int32_t	entry;		/* entry pt.				*/
44*4882a593Smuzhiyun 	int32_t	text_start;	/* base of text used for this file	*/
45*4882a593Smuzhiyun 	int32_t	data_start;	/* base of data used for this file	*/
46*4882a593Smuzhiyun 	int32_t	bss_start;	/* base of bss used for this file	*/
47*4882a593Smuzhiyun 	int32_t	gprmask;	/* general purpose register mask	*/
48*4882a593Smuzhiyun 	int32_t	cprmask[4];	/* co-processor register masks		*/
49*4882a593Smuzhiyun 	int32_t	gp_value;	/* the gp value used for this object	*/
50*4882a593Smuzhiyun } AOUTHDR;
51*4882a593Smuzhiyun #define AOUTHSZ sizeof(AOUTHDR)
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun #define OMAGIC		0407
54*4882a593Smuzhiyun #define NMAGIC		0410
55*4882a593Smuzhiyun #define ZMAGIC		0413
56*4882a593Smuzhiyun #define SMAGIC		0411
57*4882a593Smuzhiyun #define LIBMAGIC	0443
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun #define N_TXTOFF(f, a) \
60*4882a593Smuzhiyun  ((a).magic == ZMAGIC || (a).magic == LIBMAGIC ? 0 : \
61*4882a593Smuzhiyun   ((a).vstamp < 23 ? \
62*4882a593Smuzhiyun    ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + 7) & 0xfffffff8) : \
63*4882a593Smuzhiyun    ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + SCNROUND-1) & ~(SCNROUND-1)) ) )
64*4882a593Smuzhiyun #define N_DATOFF(f, a) \
65*4882a593Smuzhiyun   N_TXTOFF(f, a) + (a).tsize;
66