mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-27 01:29:27 +00:00
2010-01-25 Robert Millan <rmh.grub@aybabtu.com>
* stage2/imgact_aout.h: Rewrite using aout.h from GRUB 1.97.2 as a base. * stage2/boot.c (load_image): Remove a.out handler for *BSD kernels.
This commit is contained in:
1 parent
8dbf5c8999
commit
9a43953b56
3 files changed
+18
-169
No files matched your search
@@ -1,3 +1,9 @@
|
|||||||
|
2010-01-25 Robert Millan <rmh.grub@aybabtu.com>
|
||||||
|
|
||||||
|
* stage2/imgact_aout.h: Rewrite using aout.h from GRUB 1.97.2 as
|
||||||
|
a base.
|
||||||
|
* stage2/boot.c (load_image): Remove a.out handler for *BSD kernels.
|
||||||
|
|
||||||
2010-01-21 Robert Millan <rmh.grub@aybabtu.com>
|
2010-01-21 Robert Millan <rmh.grub@aybabtu.com>
|
||||||
|
|
||||||
* configure.ac: Remove `--enable-example-kernel' option.
|
* configure.ac: Remove `--enable-example-kernel' option.
|
||||||
|
|||||||
@@ -169,53 +169,6 @@ load_image (char *kernel, char *arg, kernel_t suggested_type,
|
|||||||
exec_type = 2;
|
exec_type = 2;
|
||||||
str = "kludge";
|
str = "kludge";
|
||||||
}
|
}
|
||||||
else if (len > sizeof (struct exec) && !N_BADMAG ((*(pu.aout))))
|
|
||||||
{
|
|
||||||
entry_addr = (entry_func) pu.aout->a_entry;
|
|
||||||
|
|
||||||
if (type == KERNEL_TYPE_NONE)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* If it doesn't have a Multiboot header, then presume
|
|
||||||
* it is either a FreeBSD or NetBSD executable. If so,
|
|
||||||
* then use a magic number of normal ordering, ZMAGIC to
|
|
||||||
* determine if it is FreeBSD.
|
|
||||||
*
|
|
||||||
* This is all because freebsd and netbsd seem to require
|
|
||||||
* masking out some address bits... differently for each
|
|
||||||
* one... plus of course we need to know which booting
|
|
||||||
* method to use.
|
|
||||||
*/
|
|
||||||
entry_addr = (entry_func) ((int) entry_addr & 0xFFFFFF);
|
|
||||||
|
|
||||||
if (buffer[0] == 0xb && buffer[1] == 1)
|
|
||||||
{
|
|
||||||
type = KERNEL_TYPE_FREEBSD;
|
|
||||||
cur_addr = (int) entry_addr;
|
|
||||||
str2 = "FreeBSD";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
type = KERNEL_TYPE_NETBSD;
|
|
||||||
cur_addr = (int) entry_addr & 0xF00000;
|
|
||||||
if (N_GETMAGIC ((*(pu.aout))) != NMAGIC)
|
|
||||||
align_4k = 0;
|
|
||||||
str2 = "NetBSD";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* first offset into file */
|
|
||||||
grub_seek (N_TXTOFF (*(pu.aout)));
|
|
||||||
text_len = pu.aout->a_text;
|
|
||||||
data_len = pu.aout->a_data;
|
|
||||||
bss_len = pu.aout->a_bss;
|
|
||||||
|
|
||||||
if (cur_addr < 0x100000)
|
|
||||||
errnum = ERR_BELOW_1MB;
|
|
||||||
|
|
||||||
exec_type = 1;
|
|
||||||
str = "a.out";
|
|
||||||
}
|
|
||||||
else if (lh->boot_flag == BOOTSEC_SIGNATURE
|
else if (lh->boot_flag == BOOTSEC_SIGNATURE
|
||||||
&& lh->setup_sects <= LINUX_MAX_SETUP_SECTS)
|
&& lh->setup_sects <= LINUX_MAX_SETUP_SECTS)
|
||||||
{
|
{
|
||||||
|
|||||||
+12
-122
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992, 1993
|
* Copyright (c) 1992, 1993
|
||||||
* The Regents of the University of California. All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
@@ -11,10 +10,6 @@
|
|||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* 3. All advertising materials mentioning features or use of this software
|
|
||||||
* must display the following acknowledgement:
|
|
||||||
* This product includes software developed by the University of
|
|
||||||
* California, Berkeley and its contributors.
|
|
||||||
* 4. Neither the name of the University nor the names of its contributors
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
* may be used to endorse or promote products derived from this software
|
* may be used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
@@ -32,127 +27,22 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: @(#)exec.h 8.1 (Berkeley) 6/11/93
|
* from: @(#)exec.h 8.1 (Berkeley) 6/11/93
|
||||||
* $Id$
|
* $FreeBSD$
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* 11/23/95 - Kludge to get "ntohl" null macro added. -- ESB
|
|
||||||
* - and for __LDPGSZ
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _IMGACT_AOUT_H_
|
#ifndef GRUB_AOUT_HEADER
|
||||||
#define _IMGACT_AOUT_H_
|
#define GRUB_AOUT_HEADER 1
|
||||||
|
|
||||||
/* XXX ESB */
|
|
||||||
#define ntohl(x) ((x << 24) | ((x & 0xFF00) << 8) \
|
|
||||||
| ((x >> 8) & 0xFF00) | (x >> 24))
|
|
||||||
#define htonl(x) ntohl(x)
|
|
||||||
#define __LDPGSZ 0x1000
|
|
||||||
|
|
||||||
#define N_GETMAGIC(ex) \
|
|
||||||
( (ex).a_midmag & 0xffff )
|
|
||||||
#define N_GETMID(ex) \
|
|
||||||
( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETMID_NET(ex) : \
|
|
||||||
((ex).a_midmag >> 16) & 0x03ff )
|
|
||||||
#define N_GETFLAG(ex) \
|
|
||||||
( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETFLAG_NET(ex) : \
|
|
||||||
((ex).a_midmag >> 26) & 0x3f )
|
|
||||||
#define N_SETMAGIC(ex,mag,mid,flag) \
|
|
||||||
( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \
|
|
||||||
((mag) & 0xffff) )
|
|
||||||
|
|
||||||
#define N_GETMAGIC_NET(ex) \
|
|
||||||
(ntohl((ex).a_midmag) & 0xffff)
|
|
||||||
#define N_GETMID_NET(ex) \
|
|
||||||
((ntohl((ex).a_midmag) >> 16) & 0x03ff)
|
|
||||||
#define N_GETFLAG_NET(ex) \
|
|
||||||
((ntohl((ex).a_midmag) >> 26) & 0x3f)
|
|
||||||
#define N_SETMAGIC_NET(ex,mag,mid,flag) \
|
|
||||||
( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \
|
|
||||||
(((mag)&0xffff)) ) )
|
|
||||||
|
|
||||||
#define N_ALIGN(ex,x) \
|
|
||||||
(N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \
|
|
||||||
N_GETMAGIC_NET(ex) == ZMAGIC || N_GETMAGIC_NET(ex) == QMAGIC ? \
|
|
||||||
((x) + __LDPGSZ - 1) & ~(unsigned long)(__LDPGSZ - 1) : (x))
|
|
||||||
|
|
||||||
/* Valid magic number check. */
|
|
||||||
#define N_BADMAG(ex) \
|
|
||||||
(N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \
|
|
||||||
N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \
|
|
||||||
N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \
|
|
||||||
N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC)
|
|
||||||
|
|
||||||
|
|
||||||
/* Address of the bottom of the text segment. */
|
|
||||||
#define N_TXTADDR(ex) \
|
|
||||||
((N_GETMAGIC(ex) == OMAGIC || N_GETMAGIC(ex) == NMAGIC || \
|
|
||||||
N_GETMAGIC(ex) == ZMAGIC) ? 0 : __LDPGSZ)
|
|
||||||
|
|
||||||
/* Address of the bottom of the data segment. */
|
|
||||||
#define N_DATADDR(ex) \
|
|
||||||
N_ALIGN(ex, N_TXTADDR(ex) + (ex).a_text)
|
|
||||||
|
|
||||||
/* Text segment offset. */
|
|
||||||
#define N_TXTOFF(ex) \
|
|
||||||
(N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC || \
|
|
||||||
N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct exec))
|
|
||||||
|
|
||||||
/* Data segment offset. */
|
|
||||||
#define N_DATOFF(ex) \
|
|
||||||
N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text)
|
|
||||||
|
|
||||||
/* Relocation table offset. */
|
|
||||||
#define N_RELOFF(ex) \
|
|
||||||
N_ALIGN(ex, N_DATOFF(ex) + (ex).a_data)
|
|
||||||
|
|
||||||
/* Symbol table offset. */
|
|
||||||
#define N_SYMOFF(ex) \
|
|
||||||
(N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize)
|
|
||||||
|
|
||||||
/* String table offset. */
|
|
||||||
#define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Header prepended to each a.out file.
|
|
||||||
* only manipulate the a_midmag field via the
|
|
||||||
* N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct exec
|
struct exec
|
||||||
{
|
{
|
||||||
unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
|
unsigned int a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
|
||||||
unsigned long a_text; /* text segment size */
|
unsigned int a_text; /* text segment size */
|
||||||
unsigned long a_data; /* initialized data size */
|
unsigned int a_data; /* initialized data size */
|
||||||
unsigned long a_bss; /* uninitialized data size */
|
unsigned int a_bss; /* uninitialized data size */
|
||||||
unsigned long a_syms; /* symbol table size */
|
unsigned int a_syms; /* symbol table size */
|
||||||
unsigned long a_entry; /* entry point */
|
unsigned int a_entry; /* entry point */
|
||||||
unsigned long a_trsize; /* text relocation size */
|
unsigned int a_trsize; /* text relocation size */
|
||||||
unsigned long a_drsize; /* data relocation size */
|
unsigned int a_drsize; /* data relocation size */
|
||||||
};
|
};
|
||||||
#define a_magic a_midmag /* XXX Hack to work with current kern_execve.c */
|
|
||||||
|
|
||||||
/* a_magic */
|
#endif /* ! GRUB_AOUT_HEADER */
|
||||||
#define OMAGIC 0x107 /* 0407 old impure format */
|
|
||||||
#define NMAGIC 0x108 /* 0410 read-only text */
|
|
||||||
#define ZMAGIC 0x10b /* 0413 demand load format */
|
|
||||||
#define QMAGIC 0xcc /* 0314 "compact" demand load format */
|
|
||||||
|
|
||||||
/* a_mid */
|
|
||||||
#define MID_ZERO 0 /* unknown - implementation dependent */
|
|
||||||
#define MID_SUN010 1 /* sun 68010/68020 binary */
|
|
||||||
#define MID_SUN020 2 /* sun 68020-only binary */
|
|
||||||
#define MID_I386 134 /* i386 BSD binary */
|
|
||||||
#define MID_SPARC 138 /* sparc */
|
|
||||||
#define MID_HP200 200 /* hp200 (68010) BSD binary */
|
|
||||||
#define MID_HP300 300 /* hp300 (68020+68881) BSD binary */
|
|
||||||
#define MID_HPUX 0x20C /* hp200/300 HP-UX binary */
|
|
||||||
#define MID_HPUX800 0x20B /* hp800 HP-UX binary */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* a_flags
|
|
||||||
*/
|
|
||||||
#define EX_PIC 0x10 /* contains position independant code */
|
|
||||||
#define EX_DYNAMIC 0x20 /* contains run-time link-edit info */
|
|
||||||
#define EX_DPMASK 0x30 /* mask for the above */
|
|
||||||
|
|
||||||
#endif /* !_IMGACT_AOUT_H_ */
|
|
||||||
Reference in new issue
Block a user