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