xref: /linux/arch/mips/boot/ecoff.h (revision 0c3bf184)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * Some ECOFF definitions.
41da177e4SLinus Torvalds  */
5*0c3bf184SThomas Bogendoerfer 
6*0c3bf184SThomas Bogendoerfer #include <stdint.h>
7*0c3bf184SThomas Bogendoerfer 
81da177e4SLinus Torvalds typedef struct filehdr {
9*0c3bf184SThomas Bogendoerfer 	uint16_t	f_magic;	/* magic number */
10*0c3bf184SThomas Bogendoerfer 	uint16_t	f_nscns;	/* number of sections */
11*0c3bf184SThomas Bogendoerfer 	int32_t		f_timdat;	/* time & date stamp */
12*0c3bf184SThomas Bogendoerfer 	int32_t		f_symptr;	/* file pointer to symbolic header */
13*0c3bf184SThomas Bogendoerfer 	int32_t		f_nsyms;	/* sizeof(symbolic hdr) */
14*0c3bf184SThomas Bogendoerfer 	uint16_t	f_opthdr;	/* sizeof(optional hdr) */
15*0c3bf184SThomas Bogendoerfer 	uint16_t	f_flags;	/* flags */
161da177e4SLinus Torvalds } FILHDR;
171da177e4SLinus Torvalds #define FILHSZ	sizeof(FILHDR)
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds #define MIPSEBMAGIC	0x160
201da177e4SLinus Torvalds #define MIPSELMAGIC	0x162
211da177e4SLinus Torvalds 
221da177e4SLinus Torvalds typedef struct scnhdr {
231da177e4SLinus Torvalds 	char		s_name[8];	/* section name */
24*0c3bf184SThomas Bogendoerfer 	int32_t		s_paddr;	/* physical address, aliased s_nlib */
25*0c3bf184SThomas Bogendoerfer 	int32_t		s_vaddr;	/* virtual address */
26*0c3bf184SThomas Bogendoerfer 	int32_t		s_size;		/* section size */
27*0c3bf184SThomas Bogendoerfer 	int32_t		s_scnptr;	/* file ptr to raw data for section */
28*0c3bf184SThomas Bogendoerfer 	int32_t		s_relptr;	/* file ptr to relocation */
29*0c3bf184SThomas Bogendoerfer 	int32_t		s_lnnoptr;	/* file ptr to gp histogram */
30*0c3bf184SThomas Bogendoerfer 	uint16_t	s_nreloc;	/* number of relocation entries */
31*0c3bf184SThomas Bogendoerfer 	uint16_t	s_nlnno;	/* number of gp histogram entries */
32*0c3bf184SThomas Bogendoerfer 	int32_t		s_flags;	/* flags */
331da177e4SLinus Torvalds } SCNHDR;
341da177e4SLinus Torvalds #define SCNHSZ		sizeof(SCNHDR)
35*0c3bf184SThomas Bogendoerfer #define SCNROUND	((int32_t)16)
361da177e4SLinus Torvalds 
371da177e4SLinus Torvalds typedef struct aouthdr {
38*0c3bf184SThomas Bogendoerfer 	int16_t	magic;		/* see above				*/
39*0c3bf184SThomas Bogendoerfer 	int16_t	vstamp;		/* version stamp			*/
40*0c3bf184SThomas Bogendoerfer 	int32_t	tsize;		/* text size in bytes, padded to DW bdry*/
41*0c3bf184SThomas Bogendoerfer 	int32_t	dsize;		/* initialized data "  "		*/
42*0c3bf184SThomas Bogendoerfer 	int32_t	bsize;		/* uninitialized data "	  "		*/
43*0c3bf184SThomas Bogendoerfer 	int32_t	entry;		/* entry pt.				*/
44*0c3bf184SThomas Bogendoerfer 	int32_t	text_start;	/* base of text used for this file	*/
45*0c3bf184SThomas Bogendoerfer 	int32_t	data_start;	/* base of data used for this file	*/
46*0c3bf184SThomas Bogendoerfer 	int32_t	bss_start;	/* base of bss used for this file	*/
47*0c3bf184SThomas Bogendoerfer 	int32_t	gprmask;	/* general purpose register mask	*/
48*0c3bf184SThomas Bogendoerfer 	int32_t	cprmask[4];	/* co-processor register masks		*/
49*0c3bf184SThomas Bogendoerfer 	int32_t	gp_value;	/* the gp value used for this object	*/
501da177e4SLinus Torvalds } AOUTHDR;
511da177e4SLinus Torvalds #define AOUTHSZ sizeof(AOUTHDR)
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds #define OMAGIC		0407
541da177e4SLinus Torvalds #define NMAGIC		0410
551da177e4SLinus Torvalds #define ZMAGIC		0413
561da177e4SLinus Torvalds #define SMAGIC		0411
571da177e4SLinus Torvalds #define LIBMAGIC	0443
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds #define N_TXTOFF(f, a) \
601da177e4SLinus Torvalds  ((a).magic == ZMAGIC || (a).magic == LIBMAGIC ? 0 : \
611da177e4SLinus Torvalds   ((a).vstamp < 23 ? \
621da177e4SLinus Torvalds    ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + 7) & 0xfffffff8) : \
631da177e4SLinus Torvalds    ((FILHSZ + AOUTHSZ + (f).f_nscns * SCNHSZ + SCNROUND-1) & ~(SCNROUND-1)) ) )
641da177e4SLinus Torvalds #define N_DATOFF(f, a) \
651da177e4SLinus Torvalds   N_TXTOFF(f, a) + (a).tsize;
66