2 * m68k a.out / ELF file structure definitions
4 * written by Yasha (ITOH Yasufumi)
7 * $NetBSD: aout68k.h,v 1.2 1999/11/16 00:48:12 itohy Exp $
10 * NetBSD/m68k a.out format (OMAGIC, NMAGIC)
12 * ----------------------------
13 * | file header (32 bytes) |
14 * |--------------------------|
16 * |--------------------------|
18 * |--------------------------|
19 * | text relocation table |
20 * |--------------------------|
21 * | data relocation table |
22 * |--------------------------|
24 * |--------------------------|
26 * ----------------------------
28 * OMAGIC: text and data segments are loaded contiguous
29 * NMAGIC: data segment is loaded at the next page of the text
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
53 #define AOUT_GET_MID(e) ((((e)->a_magic.val[0] & 0x03) << 8) | \
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 * |------------------------------------|
74 * |------------------------------------|
75 * | section header table (optional) |
76 * --------------------------------------
91 u_int8_t e_ident
[EL_NIDENT
]; /* ELF magic */
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 */
100 be_uint16_t e_machine
; /* architecture id */
102 be_uint32_t e_version
;
104 be_uint32_t e_entry
; /* entry address */
105 be_uint32_t e_phoff
; /* program header address */
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
{
124 #define SHT_PROGBITS 1
125 be_uint32_t sh_flags
;
128 #define SHF_EXECINSTR 4
130 be_uint32_t sh_offset
;
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 */
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 */
164 #define SIZE_ELF68K_PHDR (sizeof(struct elf_m68k_phdr))