Fix cross compilation (e.g. on Darwin). Following changes to make.tmpl,
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / elfload.h
blob9a7ae4ebb30a7ac15d481b06d1f37f63b77fd9fe
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007 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/>.
19 #ifndef GRUB_ELFLOAD_HEADER
20 #define GRUB_ELFLOAD_HEADER 1
22 #include <grub/err.h>
23 #include <grub/elf.h>
24 #include <grub/file.h>
25 #include <grub/symbol.h>
26 #include <grub/types.h>
28 struct grub_elf_file
30 grub_file_t file;
31 union {
32 Elf64_Ehdr ehdr64;
33 Elf32_Ehdr ehdr32;
34 } ehdr;
35 void *phdrs;
36 char *filename;
38 typedef struct grub_elf_file *grub_elf_t;
40 typedef int (*grub_elf32_phdr_iterate_hook_t)
41 (grub_elf_t elf, Elf32_Phdr *phdr, void *arg);
42 typedef int (*grub_elf64_phdr_iterate_hook_t)
43 (grub_elf_t elf, Elf64_Phdr *phdr, void *arg);
45 grub_elf_t grub_elf_open (const char *);
46 grub_elf_t grub_elf_file (grub_file_t file, const char *filename);
47 grub_err_t grub_elf_close (grub_elf_t);
49 int grub_elf_is_elf32 (grub_elf_t);
50 grub_size_t grub_elf32_size (grub_elf_t,
51 Elf32_Addr *, grub_uint32_t *);
52 enum grub_elf_load_flags
54 GRUB_ELF_LOAD_FLAGS_NONE = 0,
55 GRUB_ELF_LOAD_FLAGS_LOAD_PT_DYNAMIC = 1,
56 GRUB_ELF_LOAD_FLAGS_BITS = 6,
57 GRUB_ELF_LOAD_FLAGS_ALL_BITS = 0,
58 GRUB_ELF_LOAD_FLAGS_28BITS = 2,
59 GRUB_ELF_LOAD_FLAGS_30BITS = 4,
60 GRUB_ELF_LOAD_FLAGS_62BITS = 6,
62 grub_err_t grub_elf32_load (grub_elf_t, const char *filename,
63 void *load_offset, enum grub_elf_load_flags flags, grub_addr_t *,
64 grub_size_t *);
66 int grub_elf_is_elf64 (grub_elf_t);
67 grub_size_t grub_elf64_size (grub_elf_t,
68 Elf64_Addr *, grub_uint64_t *);
69 grub_err_t grub_elf64_load (grub_elf_t, const char *filename,
70 void *load_offset, enum grub_elf_load_flags flags, grub_addr_t *,
71 grub_size_t *);
72 grub_err_t grub_elf32_load_phdrs (grub_elf_t elf);
73 grub_err_t grub_elf64_load_phdrs (grub_elf_t elf);
75 #define FOR_ELF32_PHDRS(elf, phdr) \
76 for (grub_elf32_load_phdrs (elf), phdr = elf->phdrs; \
77 phdr && phdr < (Elf32_Phdr *) elf->phdrs + elf->ehdr.ehdr32.e_phnum; phdr++)
78 #define FOR_ELF64_PHDRS(elf, phdr) \
79 for (grub_elf64_load_phdrs (elf), phdr = elf->phdrs; \
80 phdr && phdr < (Elf64_Phdr *) elf->phdrs + elf->ehdr.ehdr64.e_phnum; phdr++)
82 #endif /* ! GRUB_ELFLOAD_HEADER */