OSDN Git Service

the flat.h header uses things like uint32_t but does not pull in the
[uclinux-h8/elf2flt.git] / flat.h
1 /*
2  * Copyright (C) 2002-2005  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  * This is Free Software, under the GNU Public Licence v2 or greater.
10  *
11  */
12
13 #ifndef _LINUX_FLAT_H
14 #define _LINUX_FLAT_H
15
16 #ifdef __KERNEL__
17 #include <linux/types.h>
18 #include <asm/flat.h>
19 #endif
20 #include <stdint.h>
21
22 #define FLAT_VERSION                    0x00000004L
23
24 #ifdef CONFIG_BINFMT_SHARED_FLAT
25 #define MAX_SHARED_LIBS                 (4)
26 #else
27 #define MAX_SHARED_LIBS                 (1)
28 #endif
29
30 /*
31  * To make everything easier to port and manage cross platform
32  * development,  all fields are in network byte order.
33  */
34
35 struct flat_hdr {
36     char magic[4];
37     uint32_t rev;          /* version (as above) */
38     uint32_t entry;        /* Offset of first executable instruction
39                               with text segment from beginning of file */
40     uint32_t data_start;   /* Offset of data segment from beginning of
41                               file */
42     uint32_t data_end;     /* Offset of end of data segment from beginning
43                               of file */
44     uint32_t bss_end;      /* Offset of end of bss segment from beginning
45                               of file */
46
47     /* (It is assumed that data_end through bss_end forms the bss segment.) */
48
49     uint32_t stack_size;   /* Size of stack, in bytes */
50     uint32_t reloc_start;  /* Offset of relocation records from beginning
51                               of file */
52     uint32_t reloc_count;  /* Number of relocation records */
53     uint32_t flags;       
54     uint32_t build_date;   /* When the program/library was built */
55     uint32_t filler[5];    /* Reservered, set to zero */
56 };
57
58 #define FLAT_FLAG_RAM    0x0001 /* load program entirely into RAM */
59 #define FLAT_FLAG_GOTPIC 0x0002 /* program is PIC with GOT */
60 #define FLAT_FLAG_GZIP   0x0004 /* all but the header is compressed */
61 #define FLAT_FLAG_GZDATA 0x0008 /* only data/relocs are compressed (for XIP) */
62 #define FLAT_FLAG_KTRACE 0x0010 /* output useful kernel trace for debugging */
63 #define FLAT_FLAG_L1STK  0x0020 /* use a 4k stack in L1 scratch memory.  */
64
65 #ifdef __KERNEL__ /* so systems without linux headers can compile the apps */
66 /*
67  * While it would be nice to keep this header clean,  users of older
68  * tools still need this support in the kernel.  So this section is
69  * purely for compatibility with old tool chains.
70  *
71  * DO NOT make changes or enhancements to the old format please,  just work
72  *        with the format above,  except to fix bugs with old format support.
73  */
74
75 #include <asm/byteorder.h>
76
77 #define OLD_FLAT_VERSION                0x00000002L
78 #define OLD_FLAT_RELOC_TYPE_TEXT        0
79 #define OLD_FLAT_RELOC_TYPE_DATA        1
80 #define OLD_FLAT_RELOC_TYPE_BSS         2
81
82 typedef union {
83     uint32_t        value;
84     struct {
85 # if defined(mc68000) && !defined(CONFIG_COLDFIRE)
86         int32_t     offset : 30;
87         uint32_t    type   : 2;
88 #       define OLD_FLAT_FLAG_RAM    0x1 /* load program entirely into RAM */
89 # elif defined(__BIG_ENDIAN_BITFIELD)
90         uint32_t    type   : 2;
91         int32_t     offset : 30;
92 #       define OLD_FLAT_FLAG_RAM    0x1 /* load program entirely into RAM */
93 # elif defined(__LITTLE_ENDIAN_BITFIELD)
94         int32_t     offset : 30;
95         uint32_t    type   : 2;
96 #       define OLD_FLAT_FLAG_RAM    0x1 /* load program entirely into RAM */
97 # else
98 #       error "Unknown bitfield order for flat files."
99 # endif
100     } reloc;
101 } flat_v2_reloc_t;
102
103 #endif /* __KERNEL__ */
104
105 #endif /* _LINUX_FLAT_H */
106
107 /* this __MUST__ be at the VERY end of the file - do NOT move!!
108  * Local Variables:
109  * c-basic-offset: 4
110  * tab-width: 8
111  * end:
112  * vi: tabstop=8 shiftwidth=4 textwidth=79 noexpandtab
113  */