xref: /OK3568_Linux_fs/kernel/include/linux/flat.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (C) 2002-2003  David McCullough <davidm@snapgear.com>
4*4882a593Smuzhiyun  * Copyright (C) 1998       Kenneth Albanowski <kjahds@kjahds.com>
5*4882a593Smuzhiyun  *                          The Silver Hammer Group, Ltd.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * This file provides the definitions and structures needed to
8*4882a593Smuzhiyun  * support uClinux flat-format executables.
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun #ifndef _LINUX_FLAT_H
11*4882a593Smuzhiyun #define _LINUX_FLAT_H
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #define	FLAT_VERSION			0x00000004L
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun /*
16*4882a593Smuzhiyun  * To make everything easier to port and manage cross platform
17*4882a593Smuzhiyun  * development,  all fields are in network byte order.
18*4882a593Smuzhiyun  */
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun struct flat_hdr {
21*4882a593Smuzhiyun 	char	magic[4];
22*4882a593Smuzhiyun 	__be32	rev;          /* version (as above) */
23*4882a593Smuzhiyun 	__be32	entry;        /* Offset of first executable instruction
24*4882a593Smuzhiyun 				 with text segment from beginning of file */
25*4882a593Smuzhiyun 	__be32	data_start;   /* Offset of data segment from beginning of
26*4882a593Smuzhiyun 				 file */
27*4882a593Smuzhiyun 	__be32	data_end;     /* Offset of end of data segment from beginning
28*4882a593Smuzhiyun 				 of file */
29*4882a593Smuzhiyun 	__be32	bss_end;      /* Offset of end of bss segment from beginning
30*4882a593Smuzhiyun 				 of file */
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun 	/* (It is assumed that data_end through bss_end forms the bss segment.) */
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun 	__be32	stack_size;   /* Size of stack, in bytes */
35*4882a593Smuzhiyun 	__be32	reloc_start;  /* Offset of relocation records from beginning of
36*4882a593Smuzhiyun 				 file */
37*4882a593Smuzhiyun 	__be32	reloc_count;  /* Number of relocation records */
38*4882a593Smuzhiyun 	__be32	flags;
39*4882a593Smuzhiyun 	__be32	build_date;   /* When the program/library was built */
40*4882a593Smuzhiyun 	__u32	filler[5];    /* Reservered, set to zero */
41*4882a593Smuzhiyun };
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #define FLAT_FLAG_RAM    0x0001 /* load program entirely into RAM */
44*4882a593Smuzhiyun #define FLAT_FLAG_GOTPIC 0x0002 /* program is PIC with GOT */
45*4882a593Smuzhiyun #define FLAT_FLAG_GZIP   0x0004 /* all but the header is compressed */
46*4882a593Smuzhiyun #define FLAT_FLAG_GZDATA 0x0008 /* only data/relocs are compressed (for XIP) */
47*4882a593Smuzhiyun #define FLAT_FLAG_KTRACE 0x0010 /* output useful kernel trace for debugging */
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun /*
50*4882a593Smuzhiyun  * While it would be nice to keep this header clean,  users of older
51*4882a593Smuzhiyun  * tools still need this support in the kernel.  So this section is
52*4882a593Smuzhiyun  * purely for compatibility with old tool chains.
53*4882a593Smuzhiyun  *
54*4882a593Smuzhiyun  * DO NOT make changes or enhancements to the old format please,  just work
55*4882a593Smuzhiyun  *        with the format above,  except to fix bugs with old format support.
56*4882a593Smuzhiyun  */
57*4882a593Smuzhiyun 
58*4882a593Smuzhiyun #define	OLD_FLAT_VERSION			0x00000002L
59*4882a593Smuzhiyun #define OLD_FLAT_RELOC_TYPE_TEXT	0
60*4882a593Smuzhiyun #define OLD_FLAT_RELOC_TYPE_DATA	1
61*4882a593Smuzhiyun #define OLD_FLAT_RELOC_TYPE_BSS		2
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun typedef union {
64*4882a593Smuzhiyun 	u32		value;
65*4882a593Smuzhiyun 	struct {
66*4882a593Smuzhiyun #if defined(__LITTLE_ENDIAN_BITFIELD) || \
67*4882a593Smuzhiyun     (defined(mc68000) && !defined(CONFIG_COLDFIRE))
68*4882a593Smuzhiyun 		s32	offset : 30;
69*4882a593Smuzhiyun 		u32	type : 2;
70*4882a593Smuzhiyun # elif defined(__BIG_ENDIAN_BITFIELD)
71*4882a593Smuzhiyun 		u32	type : 2;
72*4882a593Smuzhiyun 		s32	offset : 30;
73*4882a593Smuzhiyun # else
74*4882a593Smuzhiyun #   	error "Unknown bitfield order for flat files."
75*4882a593Smuzhiyun # endif
76*4882a593Smuzhiyun 	} reloc;
77*4882a593Smuzhiyun } flat_v2_reloc_t;
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun #endif /* _LINUX_FLAT_H */
80