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/>.
20 * Copyright (c) 1992, 1993
21 * The Regents of the University of California. All rights reserved.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
26 * 1. Redistributions of source code must retain the above copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 4. Neither the name of the University nor the names of its contributors
32 * may be used to endorse or promote products derived from this software
33 * without specific prior written permission.
35 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
36 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
40 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
41 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * from: @(#)exec.h 8.1 (Berkeley) 6/11/93
51 #ifndef GRUB_AOUT_HEADER
52 #define GRUB_AOUT_HEADER 1
54 #include <grub/types.h>
55 #include <grub/file.h>
57 struct grub_aout32_header
59 grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
60 grub_uint32_t a_text; /* text segment size */
61 grub_uint32_t a_data; /* initialized data size */
62 grub_uint32_t a_bss; /* uninitialized data size */
63 grub_uint32_t a_syms; /* symbol table size */
64 grub_uint32_t a_entry; /* entry point */
65 grub_uint32_t a_trsize; /* text relocation size */
66 grub_uint32_t a_drsize; /* data relocation size */
69 struct grub_aout64_header
71 grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
72 grub_uint64_t a_text; /* text segment size */
73 grub_uint64_t a_data; /* initialized data size */
74 grub_uint64_t a_bss; /* uninitialized data size */
75 grub_uint64_t a_syms; /* symbol table size */
76 grub_uint64_t a_entry; /* entry point */
77 grub_uint64_t a_trsize; /* text relocation size */
78 grub_uint64_t a_drsize; /* data relocation size */
81 union grub_aout_header
83 struct grub_aout32_header aout32;
84 struct grub_aout64_header aout64;
87 #define AOUT_TYPE_NONE 0
88 #define AOUT_TYPE_AOUT32 1
89 #define AOUT_TYPE_AOUT64 6
91 #define AOUT32_OMAGIC 0x107 /* 0407 old impure format */
92 #define AOUT32_NMAGIC 0x108 /* 0410 read-only text */
93 #define AOUT32_ZMAGIC 0x10b /* 0413 demand load format */
94 #define AOUT32_QMAGIC 0xcc /* 0314 "compact" demand load format */
96 #define AOUT64_OMAGIC 0x1001
97 #define AOUT64_ZMAGIC 0x1002
98 #define AOUT64_NMAGIC 0x1003
100 #define AOUT_MID_ZERO 0 /* unknown - implementation dependent */
101 #define AOUT_MID_SUN010 1 /* sun 68010/68020 binary */
102 #define AOUT_MID_SUN020 2 /* sun 68020-only binary */
103 #define AOUT_MID_I386 134 /* i386 BSD binary */
104 #define AOUT_MID_SPARC 138 /* sparc */
105 #define AOUT_MID_HP200 200 /* hp200 (68010) BSD binary */
106 #define AOUT_MID_SUN 0x103
107 #define AOUT_MID_HP300 300 /* hp300 (68020+68881) BSD binary */
108 #define AOUT_MID_HPUX 0x20C /* hp200/300 HP-UX binary */
109 #define AOUT_MID_HPUX800 0x20B /* hp800 HP-UX binary */
111 #define AOUT_FLAG_PIC 0x10 /* contains position independent code */
112 #define AOUT_FLAG_DYNAMIC 0x20 /* contains run-time link-edit info */
113 #define AOUT_FLAG_DPMASK 0x30 /* mask for the above */
115 #define AOUT_GETMAGIC(header) ((header).a_midmag & 0xffff)
116 #define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
117 #define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
121 int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
123 grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
124 void *load_addr, int load_size,
125 grub_size_t bss_size);
129 #endif /* ! GRUB_AOUT_HEADER */