Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / x68k / stand / aout2hux / aout68k.h
blobccbefedcd4539ea86e494fc34ac9fc398a54df2d
1 /*
2 * m68k a.out / ELF file structure definitions
4 * written by Yasha (ITOH Yasufumi)
5 * public domain
7 * $NetBSD: aout68k.h,v 1.2 1999/11/16 00:48:12 itohy Exp $
8 */
9 /*
10 * NetBSD/m68k a.out format (OMAGIC, NMAGIC)
12 * ----------------------------
13 * | file header (32 bytes) |
14 * |--------------------------|
15 * | text |
16 * |--------------------------|
17 * | data |
18 * |--------------------------|
19 * | text relocation table |
20 * |--------------------------|
21 * | data relocation table |
22 * |--------------------------|
23 * | symbol table |
24 * |--------------------------|
25 * | string table |
26 * ----------------------------
28 * OMAGIC: text and data segments are loaded contiguous
29 * NMAGIC: data segment is loaded at the next page of the text
32 struct aout_m68k {
33 be_uint32_t a_magic; /* encoded magic number */
34 be_uint32_t a_text; /* size of text section */
35 be_uint32_t a_data; /* size of data section */
36 be_uint32_t a_bss; /* size of bss */
37 be_uint32_t a_syms; /* size of symbol table */
38 be_uint32_t a_entry; /* entry point address */
39 be_uint32_t a_trsize; /* size of text relocation */
40 be_uint32_t a_drsize; /* size of data relocation */
43 #define AOUT_GET_MAGIC(e) (((e)->a_magic.val[2]<<8) | (e)->a_magic.val[3])
44 #define AOUT_OMAGIC 0407
45 #define AOUT_NMAGIC 0410
46 #define AOUT_ZMAGIC 0413 /* demand paging --- header is in the text */
48 #define AOUT_GET_FLAGS(e) ((e)->a_magic.val[0] >> 2)
49 #define AOUT_FLAG_PIC 0x10
50 #define AOUT_FLAG_DYNAMIC 0x20
52 /* machine ID */
53 #define AOUT_GET_MID(e) ((((e)->a_magic.val[0] & 0x03) << 8) | \
54 (e)->a_magic.val[1])
55 #define AOUT_MID_M68K 135 /* m68k BSD binary, 8KB page */
56 #define AOUT_MID_M68K4K 136 /* m68k BSD binary, 4KB page */
58 #define AOUT_PAGESIZE(e) (AOUT_GET_MAGIC(e) == AOUT_OMAGIC ? 1 : \
59 AOUT_GET_MID(e) == AOUT_MID_M68K ? 8192 : 4096)
62 * m68k ELF executable format
64 * --------------------------------------
65 * | ELF header (52 bytes) |
66 * |------------------------------------|
67 * | Program header (32bytes x 1 or 2) |
68 * |------------------------------------|
69 * | section 1 (text) |
70 * |------------------------------------|
71 * | section 2 (data) |
72 * |------------------------------------|
73 * | ... |
74 * |------------------------------------|
75 * | section header table (optional) |
76 * --------------------------------------
80 * ELF header for m68k
82 struct elf_m68k_hdr {
83 #define EI_MAG0 0
84 #define EI_MAG1 1
85 #define EI_MAG2 2
86 #define EI_MAG3 3
87 #define EI_CLASS 4
88 #define EI_DATA 5
89 #define EI_VERSION 6
90 #define EL_NIDENT 16
91 u_int8_t e_ident[EL_NIDENT]; /* ELF magic */
92 #define ELFMAG0 0x7f
93 #define ELFMAG1 0x45 /* 'E' */
94 #define ELFMAG2 0x4c /* 'L' */
95 #define ELFMAG3 0x46 /* 'F' */
96 #define ELFCLASS32 1 /* 32bit */
97 #define ELFDATA2MSB 2 /* big endian */
98 be_uint16_t e_type; /* type of this file */
99 #define ET_EXEC 2
100 be_uint16_t e_machine; /* architecture id */
101 #define EM_68K 4
102 be_uint32_t e_version;
103 #define EV_CURRENT 1
104 be_uint32_t e_entry; /* entry address */
105 be_uint32_t e_phoff; /* program header address */
106 be_uint32_t e_shoff;
107 be_uint32_t e_flags;
108 be_uint16_t e_ehsize;
109 be_uint16_t e_phentsize; /* program header entry size */
110 be_uint16_t e_phnum; /* number of program header entries */
111 be_uint16_t e_shentsize; /* section header entry size */
112 be_uint16_t e_shnum; /* number of section header entries */
113 be_uint16_t e_shstrndx;
116 #define SIZE_ELF68K_HDR (sizeof(struct elf_m68k_hdr))
119 * Section header for m68k ELF
121 struct elf_m68k_shdr {
122 be_uint32_t sh_name;
123 be_uint32_t sh_type;
124 #define SHT_PROGBITS 1
125 be_uint32_t sh_flags;
126 #define SHF_WRITE 1
127 #define SHF_ALLOC 2
128 #define SHF_EXECINSTR 4
129 be_uint32_t sh_addr;
130 be_uint32_t sh_offset;
131 be_uint32_t sh_size;
132 be_uint32_t sh_link;
133 be_uint32_t sh_info;
134 be_uint32_t sh_addralign;
135 be_uint32_t sh_entsize;
138 #define ELF68K_ISDATASEG(sh) \
139 (get_uint32(&(sh)->sh_type) == SHT_PROGBITS && \
140 (get_uint32(&(sh)->sh_flags) & \
141 (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR)) == \
142 (SHF_WRITE | SHF_ALLOC)) /* no SHF_EXECINSTR */
144 #define SIZE_ELF68K_SHDR (sizeof(struct elf_m68k_shdr))
147 * Program header for m68k ELF
149 struct elf_m68k_phdr {
150 be_uint32_t p_type; /* type of segment */
151 #define PT_LOAD 1
152 be_uint32_t p_offset; /* file offset */
153 be_uint32_t p_vaddr; /* virtual address */
154 be_uint32_t p_paddr; /* physical address (ignored) */
155 be_uint32_t p_filesz; /* size on file */
156 be_uint32_t p_memsz; /* size on memory */
157 be_uint32_t p_flags;
158 #define PF_R 4
159 #define PF_W 2
160 #define PF_X 1
161 be_uint32_t p_align;
164 #define SIZE_ELF68K_PHDR (sizeof(struct elf_m68k_phdr))