d38e24c285
* conf/i386-pc.rmk (pkglib_MODULES): Add aout.mod _bsd.mod and bsd.mod. (aout_mod_SOURCES): New variable. (aout_mod_CFLAGS): Likewise. (aout_mod_LDFLAGS): Likewise. (_bsd_mod_SOURCES): New variable. (_bsd_mod_CFLAGS): Likewise. (_bsd_mod_LDFLAGS): Likewise. (bsd_mod_SOURCES): New variable. (bsd_mod_CFLAGS): Likewise. (bsd_mod_LDFLAGS): Likewise. * include/grub/aout.h: New file. * include/grub/i386/loader.h (grub_unix_real_boot): New function. * include/grub/i386/bsd.h: New file. * include/grub/i386/pc/init.h (grub_get_mmap_entry): Use EXPORT_FUNC to make it public. * kern/elf.c (grub_elf32_load): Get the physical address after the hook function is called, so that it's possible to change it inside the hook. (grub_elf64_load): Likewise. (grub_elf_file): Don't close the file if elf header is not found. (grub_elf_close): Close the file if grub_elf_file fails (The new grub_elf_file won't close it). (grub_elf32_size): Use NESTED_FUNC_ATTR for nested function calcsize. (grub_elf64_size): Likewise. * kern/i386/loader.S (grub_unix_real_boot): New function. * loader/aout.c: New file. * loader/i386/bsd.c: New file. * loader/i386/bsd_normal.c: New file. * loader/i386/pc/multiboot.c (grub_multiboot): Handle a.out format. * loader/multiboot2.c (grub_multiboot2): Reset grub_errno so that it can test othe formats.
61 lines
1.7 KiB
C
61 lines
1.7 KiB
C
/*
|
|
* Copyright (C) 2008 Free Software Foundation, Inc.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <grub/file.h>
|
|
#include <grub/err.h>
|
|
#include <grub/dl.h>
|
|
#include <grub/aout.h>
|
|
|
|
int
|
|
grub_aout_get_type (union grub_aout_header *header)
|
|
{
|
|
int magic;
|
|
|
|
magic = AOUT_GETMAGIC (header->aout32);
|
|
if ((magic == AOUT32_OMAGIC) || (magic == AOUT32_NMAGIC) ||
|
|
(magic == AOUT32_ZMAGIC) || (magic == AOUT32_QMAGIC))
|
|
return AOUT_TYPE_AOUT32;
|
|
else if ((magic == AOUT64_OMAGIC) || (magic == AOUT64_NMAGIC) ||
|
|
(magic == AOUT64_ZMAGIC))
|
|
return AOUT_TYPE_AOUT64;
|
|
else
|
|
return AOUT_TYPE_NONE;
|
|
}
|
|
|
|
grub_err_t
|
|
grub_aout_load (grub_file_t file, int offset,
|
|
grub_addr_t load_addr,
|
|
int load_size,
|
|
grub_addr_t bss_end_addr)
|
|
{
|
|
if ((grub_file_seek (file, offset)) == (grub_off_t) - 1)
|
|
return grub_errno;
|
|
|
|
if (!load_size)
|
|
load_size = file->size - offset;
|
|
|
|
grub_file_read (file, (char *) load_addr, load_size);
|
|
|
|
if (grub_errno)
|
|
return grub_errno;
|
|
|
|
if (bss_end_addr)
|
|
grub_memset (load_addr + load_size, 0,
|
|
bss_end_addr - load_addr - load_size);
|
|
|
|
return GRUB_ERR_NONE;
|
|
}
|