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