10d7dde61ececf0e980c6ad62420764fcefd5e67
[grub.git] / include / grub / aout.h
1 /*
2  *  GRUB  --  GRand Unified Bootloader
3  *  Copyright (C) 2008  Free Software Foundation, Inc.
4  *
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.
9  *
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.
14  *
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/>.
17  */
18
19 /*-
20  * Copyright (c) 1992, 1993
21  *      The Regents of the University of California.  All rights reserved.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
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.
34  *
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
45  * SUCH DAMAGE.
46  *
47  *      from: @(#)exec.h        8.1 (Berkeley) 6/11/93
48  * $FreeBSD$
49  */
50
51 #ifndef GRUB_AOUT_HEADER
52 #define GRUB_AOUT_HEADER 1
53
54 #include <grub/types.h>
55
56 struct grub_aout32_header
57 {
58   grub_uint32_t a_midmag;       /* htonl(flags<<26 | mid<<16 | magic) */
59   grub_uint32_t a_text;         /* text segment size */
60   grub_uint32_t a_data;         /* initialized data size */
61   grub_uint32_t a_bss;          /* uninitialized data size */
62   grub_uint32_t a_syms;         /* symbol table size */
63   grub_uint32_t a_entry;        /* entry point */
64   grub_uint32_t a_trsize;       /* text relocation size */
65   grub_uint32_t a_drsize;       /* data relocation size */
66 };
67
68 struct grub_aout64_header
69 {
70   grub_uint32_t a_midmag;       /* htonl(flags<<26 | mid<<16 | magic) */
71   grub_uint64_t a_text;         /* text segment size */
72   grub_uint64_t a_data;         /* initialized data size */
73   grub_uint64_t a_bss;          /* uninitialized data size */
74   grub_uint64_t a_syms;         /* symbol table size */
75   grub_uint64_t a_entry;        /* entry point */
76   grub_uint64_t a_trsize;       /* text relocation size */
77   grub_uint64_t a_drsize;       /* data relocation size */
78 };
79
80 union grub_aout_header
81 {
82   struct grub_aout32_header aout32;
83   struct grub_aout64_header aout64;
84 };
85
86 #define AOUT_TYPE_NONE          0
87 #define AOUT_TYPE_AOUT32        1
88 #define AOUT_TYPE_AOUT64        6
89
90 #define AOUT32_OMAGIC           0x107   /* 0407 old impure format */
91 #define AOUT32_NMAGIC           0x108   /* 0410 read-only text */
92 #define AOUT32_ZMAGIC           0x10b   /* 0413 demand load format */
93 #define AOUT32_QMAGIC           0xcc    /* 0314 "compact" demand load format */
94
95 #define AOUT64_OMAGIC           0x1001
96 #define AOUT64_ZMAGIC           0x1002
97 #define AOUT64_NMAGIC           0x1003
98
99 #define AOUT_MID_ZERO           0       /* unknown - implementation dependent */
100 #define AOUT_MID_SUN010         1       /* sun 68010/68020 binary */
101 #define AOUT_MID_SUN020         2       /* sun 68020-only binary */
102 #define AOUT_MID_I386           134     /* i386 BSD binary */
103 #define AOUT_MID_SPARC          138     /* sparc */
104 #define AOUT_MID_HP200          200     /* hp200 (68010) BSD binary */
105 #define AOUT_MID_SUN            0x103
106 #define AOUT_MID_HP300          300     /* hp300 (68020+68881) BSD binary */
107 #define AOUT_MID_HPUX           0x20C   /* hp200/300 HP-UX binary */
108 #define AOUT_MID_HPUX800        0x20B   /* hp800 HP-UX binary */
109
110 #define AOUT_FLAG_PIC           0x10    /* contains position independent code */
111 #define AOUT_FLAG_DYNAMIC       0x20    /* contains run-time link-edit info */
112 #define AOUT_FLAG_DPMASK        0x30    /* mask for the above */
113
114 #define AOUT_GETMAGIC(header) ((header).a_midmag & 0xffff)
115 #define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
116 #define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
117
118 #ifndef GRUB_UTIL
119
120 int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
121
122 grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
123                                         void *load_addr, int load_size,
124                                         grub_size_t bss_size);
125
126 #endif
127
128 #endif /* ! GRUB_AOUT_HEADER */