File: aout.c

package info (click to toggle)
grub2 2.02+dfsg1-20
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 61,784 kB
  • sloc: ansic: 384,086; asm: 16,323; sh: 13,230; cpp: 1,994; makefile: 1,488; python: 1,458; sed: 423; lex: 393; yacc: 267; awk: 75; lisp: 50; perl: 31
file content (62 lines) | stat: -rw-r--r-- 1,758 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
 *  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/misc.h>
#include <grub/aout.h>

GRUB_MOD_LICENSE ("GPLv3+");

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,
                void *load_addr,
		int load_size, grub_size_t bss_size)
{
  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, load_addr, load_size);

  if (grub_errno)
    return grub_errno;

  if (bss_size)
    grub_memset ((char *) load_addr + load_size, 0, bss_size);

  return GRUB_ERR_NONE;
}