2009-07-20 Joe Auricchio <jauricchio@gmail.com>
[grub2/phcoder.git] / include / grub / aout.h
blobc5650ddf8a2849abab607e4daf78d288019c912b
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2008 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_AOUT_HEADER
20 #define GRUB_AOUT_HEADER 1
22 #include <grub/types.h>
24 struct grub_aout32_header
26 grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
27 grub_uint32_t a_text; /* text segment size */
28 grub_uint32_t a_data; /* initialized data size */
29 grub_uint32_t a_bss; /* uninitialized data size */
30 grub_uint32_t a_syms; /* symbol table size */
31 grub_uint32_t a_entry; /* entry point */
32 grub_uint32_t a_trsize; /* text relocation size */
33 grub_uint32_t a_drsize; /* data relocation size */
36 struct grub_aout64_header
38 grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
39 grub_uint64_t a_text; /* text segment size */
40 grub_uint64_t a_data; /* initialized data size */
41 grub_uint64_t a_bss; /* uninitialized data size */
42 grub_uint64_t a_syms; /* symbol table size */
43 grub_uint64_t a_entry; /* entry point */
44 grub_uint64_t a_trsize; /* text relocation size */
45 grub_uint64_t a_drsize; /* data relocation size */
48 union grub_aout_header
50 struct grub_aout32_header aout32;
51 struct grub_aout64_header aout64;
54 #define AOUT_TYPE_NONE 0
55 #define AOUT_TYPE_AOUT32 1
56 #define AOUT_TYPE_AOUT64 6
58 #define AOUT32_OMAGIC 0x107 /* 0407 old impure format */
59 #define AOUT32_NMAGIC 0x108 /* 0410 read-only text */
60 #define AOUT32_ZMAGIC 0x10b /* 0413 demand load format */
61 #define AOUT32_QMAGIC 0xcc /* 0314 "compact" demand load format */
63 #define AOUT64_OMAGIC 0x1001
64 #define AOUT64_ZMAGIC 0x1002
65 #define AOUT64_NMAGIC 0x1003
67 #define AOUT_MID_ZERO 0 /* unknown - implementation dependent */
68 #define AOUT_MID_SUN010 1 /* sun 68010/68020 binary */
69 #define AOUT_MID_SUN020 2 /* sun 68020-only binary */
70 #define AOUT_MID_I386 134 /* i386 BSD binary */
71 #define AOUT_MID_SPARC 138 /* sparc */
72 #define AOUT_MID_HP200 200 /* hp200 (68010) BSD binary */
73 #define AOUT_MID_HP300 300 /* hp300 (68020+68881) BSD binary */
74 #define AOUT_MID_HPUX 0x20C /* hp200/300 HP-UX binary */
75 #define AOUT_MID_HPUX800 0x20B /* hp800 HP-UX binary */
77 #define AOUT_FLAG_PIC 0x10 /* contains position independent code */
78 #define AOUT_FLAG_DYNAMIC 0x20 /* contains run-time link-edit info */
79 #define AOUT_FLAG_DPMASK 0x30 /* mask for the above */
81 #define AOUT_GETMAGIC(header) ((header).a_midmag & 0xffff)
82 #define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
83 #define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
85 int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
87 grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
88 grub_addr_t load_addr, int load_size,
89 grub_addr_t bss_end_addr);
91 #endif /* ! GRUB_AOUT_HEADER */