ASFLAGS = @ASFLAGS@
LDFLAGS = @LDFLAGS@ $(LIBS)
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
- -DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\"
+ -DGRUB_LIBDIR=\"$(libdir)\" -DLOCALEDIR=\"$(localedir)\"
TARGET_CC = @TARGET_CC@
TARGET_CFLAGS = -ffreestanding @TARGET_CFLAGS@
TARGET_ASFLAGS = -nostdinc -fno-builtin @TARGET_ASFLAGS@
echo "TARGET_CC=$(TARGET_CC)" ; \
echo "TARGET_CFLAGS=$(TARGET_CFLAGS)" ; \
echo "TARGET_ASFLAGS=$(TARGET_ASFLAGS)" ; \
- echo "TARGET_CPPFLAGS=$(TARGET_CPPFLAGS) -I$(pkglibdir) -I$(includedir)" ; \
+ echo "TARGET_CPPFLAGS=$(TARGET_CPPFLAGS) -I$(libdir) -I$(includedir)" ; \
echo "STRIP=$(STRIP)" ; \
echo "OBJCONV=$(OBJCONV)" ; \
echo "TARGET_MODULE_FORMAT=$(TARGET_MODULE_FORMAT)" ; \
jmp 1f
- . = _start + GRUB_BOOT_MACHINE_CORE_ENTRY_ADDR
+ . = _start + GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR
VARIABLE(grub_core_entry_addr)
.long 0
1:
#include <grub/boot.h>
#include <grub/machine/boot.h>
+#include <grub/offsets.h>
.text
.align 4
call console_write
mov NOTIFICATION_STRING_LEN, %o3
- GET_ABS(firstlist - GRUB_BOOT_MACHINE_LIST_SIZE, %l2)
- set GRUB_BOOT_MACHINE_IMAGE_ADDRESS, %l3
+ GET_ABS(firstlist - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2)
+ set GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS, %l3
bootloop:
lduw [%l2 + 0x08], %o0
brz %o0, bootit
mov NOTIFICATION_STEP_LEN, %o3
ba bootloop
- sub %l2, GRUB_BOOT_MACHINE_LIST_SIZE, %l2
+ sub %l2, GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE, %l2
bootit:
GET_ABS(prom_close_name, %o0)
GET_ABS(notification_done, %o2)
call console_write
mov NOTIFICATION_DONE_LEN, %o3
- sethi %hi(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o2
- jmpl %o2 + %lo(GRUB_BOOT_MACHINE_IMAGE_ADDRESS), %o7
+ sethi %hi(GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o2
+ jmpl %o2 + %lo(GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS), %o7
mov CIF_REG, %o4
1: ba,a 1b
mips) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_MIPS=1" ;;
sparc64) machine_CFLAGS="$machine_CFLAGS -DGRUB_MACHINE_SPARC64=1" ;;
esac
+machine_CFLAGS="$machine_CFLAGS -DMACHINE=`echo ${target_cpu}_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
CFLAGS="$CFLAGS $machine_CFLAGS"
TARGET_ASFLAGS="$TARGET_ASFLAGS $machine_CFLAGS"
grub_uint32_t entry_addr;
grub_uint32_t code_base;
-#if GRUB_TARGET_SIZEOF_VOID_P == 4
grub_uint32_t data_base;
grub_uint32_t image_base;
-#else
- grub_uint64_t image_base;
-#endif
grub_uint32_t section_alignment;
grub_uint32_t file_alignment;
grub_uint16_t subsystem;
grub_uint16_t dll_characteristics;
-#if GRUB_TARGET_SIZEOF_VOID_P == 4
-
grub_uint32_t stack_reserve_size;
grub_uint32_t stack_commit_size;
grub_uint32_t heap_reserve_size;
grub_uint32_t heap_commit_size;
-#else
+ grub_uint32_t loader_flags;
+ grub_uint32_t num_data_directories;
+
+ /* Data directories. */
+ struct grub_pe32_data_directory export_table;
+ struct grub_pe32_data_directory import_table;
+ struct grub_pe32_data_directory resource_table;
+ struct grub_pe32_data_directory exception_table;
+ struct grub_pe32_data_directory certificate_table;
+ struct grub_pe32_data_directory base_relocation_table;
+ struct grub_pe32_data_directory debug;
+ struct grub_pe32_data_directory architecture;
+ struct grub_pe32_data_directory global_ptr;
+ struct grub_pe32_data_directory tls_table;
+ struct grub_pe32_data_directory load_config_table;
+ struct grub_pe32_data_directory bound_import;
+ struct grub_pe32_data_directory iat;
+ struct grub_pe32_data_directory delay_import_descriptor;
+ struct grub_pe32_data_directory com_runtime_header;
+ struct grub_pe32_data_directory reserved_entry;
+};
+
+struct grub_pe64_optional_header
+{
+ grub_uint16_t magic;
+ grub_uint8_t major_linker_version;
+ grub_uint8_t minor_linker_version;
+ grub_uint32_t code_size;
+ grub_uint32_t data_size;
+ grub_uint32_t bss_size;
+ grub_uint32_t entry_addr;
+ grub_uint32_t code_base;
+
+ grub_uint64_t image_base;
+
+ grub_uint32_t section_alignment;
+ grub_uint32_t file_alignment;
+ grub_uint16_t major_os_version;
+ grub_uint16_t minor_os_version;
+ grub_uint16_t major_image_version;
+ grub_uint16_t minor_image_version;
+ grub_uint16_t major_subsystem_version;
+ grub_uint16_t minor_subsystem_version;
+ grub_uint32_t reserved;
+ grub_uint32_t image_size;
+ grub_uint32_t header_size;
+ grub_uint32_t checksum;
+ grub_uint16_t subsystem;
+ grub_uint16_t dll_characteristics;
grub_uint64_t stack_reserve_size;
grub_uint64_t stack_commit_size;
grub_uint64_t heap_reserve_size;
grub_uint64_t heap_commit_size;
-#endif
-
grub_uint32_t loader_flags;
grub_uint32_t num_data_directories;
struct grub_pe32_optional_header optional_header;
};
+#define GRUB_PE32_SIGNATURE_SIZE 4
+
struct grub_pe32_fixup_block
{
grub_uint32_t page_rva;
#ifndef GRUB_BOOT_MACHINE_HEADER
#define GRUB_BOOT_MACHINE_HEADER 1
-#define MACHINE I386_PC
#include <grub/offsets.h>
/* The signature for bootloader. */
#ifndef KERNEL_MACHINE_HEADER
#define KERNEL_MACHINE_HEADER 1
-#define MACHINE I386_PC
-
#include <grub/offsets.h>
/* Enable LZMA compression */
#include <grub/i386/memory.h>
-#define MACHINE I386_PC
#include <grub/offsets.h>
/* The scratch buffer used in real mode code. */
#ifndef GRUB_KERNEL_MACHINE_HEADER
#define GRUB_KERNEL_MACHINE_HEADER 1
-/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
-#define GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE 0xc
-
-/* The offset of GRUB_PREFIX. */
-#define GRUB_KERNEL_MACHINE_PREFIX 0x10
-
-/* End of the data section. */
-#define GRUB_KERNEL_MACHINE_DATA_END 0x50
+#include <grub/offsets.h>
#ifndef ASM_FILE
--- /dev/null
+/*
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2002,2003,2007,2008 Free Software Foundation, Inc.
+ *
+ * GRUB 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.
+ *
+ * GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef OFFSETS_HEADER
+#define OFFSETS_HEADER 1
+
+/* The offset of GRUB_TOTAL_MODULE_SIZE. */
+#define GRUB_KERNEL_I386_PC_TOTAL_MODULE_SIZE 0x8
+
+/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
+#define GRUB_KERNEL_I386_PC_KERNEL_IMAGE_SIZE 0xc
+
+/* The offset of GRUB_COMPRESSED_SIZE. */
+#define GRUB_KERNEL_I386_PC_COMPRESSED_SIZE 0x10
+
+/* The offset of GRUB_INSTALL_DOS_PART. */
+#define GRUB_KERNEL_I386_PC_INSTALL_DOS_PART 0x14
+
+/* The offset of GRUB_INSTALL_BSD_PART. */
+#define GRUB_KERNEL_I386_PC_INSTALL_BSD_PART 0x18
+
+/* The offset of GRUB_PREFIX. */
+#define GRUB_KERNEL_I386_PC_PREFIX 0x1c
+
+/* End of the data section. */
+#define GRUB_KERNEL_I386_PC_DATA_END 0x5c
+
+/* The size of the first region which won't be compressed. */
+#define GRUB_KERNEL_I386_PC_RAW_SIZE (GRUB_KERNEL_I386_PC_DATA_END + 0x5F0)
+
+/* The segment where the kernel is loaded. */
+#define GRUB_BOOT_I386_PC_KERNEL_SEG 0x800
+
+/* The upper memory area (starting at 640 kiB). */
+#define GRUB_MEMORY_I386_PC_UPPER 0xa0000
+#define GRUB_MEMORY_I386_QEMU_UPPER GRUB_MEMORY_I386_PC_UPPER
+
+/* The offset of GRUB_CORE_ENTRY_ADDR. */
+#define GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR 0x4
+
+/* The offset of GRUB_CORE_ENTRY_ADDR. */
+#define GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR 0x8
+
+/* The offset of GRUB_KERNEL_IMAGE_SIZE. */
+#define GRUB_KERNEL_I386_QEMU_KERNEL_IMAGE_SIZE 0xc
+
+/* The offset of GRUB_PREFIX. */
+#define GRUB_KERNEL_I386_QEMU_PREFIX 0x10
+
+/* End of the data section. */
+#define GRUB_KERNEL_I386_QEMU_DATA_END 0x50
+
+#define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE 12
+
+#define GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS 0x4400
+
+#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX 0x4
+#define GRUB_KERNEL_POWERPC_IEEE1275_DATA_END 0x44
+#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
+
+#ifdef MACHINE
+#define GRUB_OFFSETS_CONCAT_(a,b,c) a ## b ## c
+#define GRUB_OFFSETS_CONCAT(a,b,c) GRUB_OFFSETS_CONCAT_(a,b,c)
+#define GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _TOTAL_MODULE_SIZE)
+#define GRUB_KERNEL_MACHINE_KERNEL_IMAGE_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _KERNEL_IMAGE_SIZE)
+#define GRUB_KERNEL_MACHINE_COMPRESSED_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _COMPRESSED_SIZE)
+
+#define GRUB_KERNEL_MACHINE_PREFIX GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _PREFIX)
+#define GRUB_KERNEL_MACHINE_DATA_END GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _DATA_END)
+#define GRUB_BOOT_MACHINE_KERNEL_SEG GRUB_OFFSETS_CONCAT (GRUB_BOOT_, MACHINE, _KERNEL_SEG)
+#define GRUB_MEMORY_MACHINE_UPPER GRUB_OFFSETS_CONCAT (GRUB_MEMORY_, MACHINE, _UPPER)
+#define GRUB_KERNEL_MACHINE_RAW_SIZE GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _RAW_SIZE)
+#define GRUB_KERNEL_MACHINE_INSTALL_BSD_PART GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _INSTALL_BSD_PART)
+#define GRUB_KERNEL_MACHINE_INSTALL_DOS_PART GRUB_OFFSETS_CONCAT (GRUB_KERNEL_, MACHINE, _INSTALL_DOS_PART)
+#endif
+
+#ifndef ASM_FILE
+struct grub_pc_bios_boot_blocklist
+{
+ grub_uint64_t start;
+ grub_uint16_t len;
+ grub_uint16_t segment;
+} __attribute__ ((packed));
+#endif
+
+#endif
#define GRUB_KERNEL_MACHINE_HEADER 1
#include <grub/symbol.h>
+#include <grub/offsets.h>
-#define GRUB_PLATFORM_IMAGE_FORMATS "raw, elf"
-#define GRUB_PLATFORM_IMAGE_DEFAULT_FORMAT "raw"
-
-#define GRUB_PLATFORM_IMAGE_DEFAULT GRUB_PLATFORM_IMAGE_RAW
-#define GRUB_KERNEL_MACHINE_PREFIX 0x4
-#define GRUB_KERNEL_MACHINE_DATA_END 0x44
-#define GRUB_KERNEL_MACHINE_LINK_ALIGN 4
-
-#define EM_TARGET EM_PPC
#define GRUB_KERNEL_MACHINE_LINK_ADDR 0x200000
#ifndef ASM_FILE
-typedef enum {
- GRUB_PLATFORM_IMAGE_RAW,
- GRUB_PLATFORM_IMAGE_ELF
-}
- grub_platform_image_format_t;
-#define GRUB_PLATFORM_IMAGE_RAW GRUB_PLATFORM_IMAGE_RAW
-#define GRUB_PLATFORM_IMAGE_ELF GRUB_PLATFORM_IMAGE_ELF
-
/* The prefix which points to the directory where GRUB modules and its
configuration file are located. */
extern char grub_prefix[];
_start:
jmp codestart
- . = _start + GRUB_KERNEL_MACHINE_CORE_ENTRY_ADDR
+ . = _start + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR
VARIABLE(grub_core_entry_addr)
.long 0
VARIABLE(grub_kernel_image_size)
unsigned section_align;
signed vaddr_offset;
unsigned install_dos_part, install_bsd_part;
+ grub_uint64_t link_addr;
};
struct image_target_desc image_targets[] =
},
{"i386-efi", 4, 0, IMAGE_EFI, FORMAT_PE, PLATFORM_FLAGS_NONE,
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
- .vaddr_offset = ALIGN_UP (sizeof (struct grub_pe32_header)
- + 5 * sizeof (struct grub_pe32_section_table),
+ .vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
+ + GRUB_PE32_SIGNATURE_SIZE
+ + sizeof (struct grub_pe32_coff_header)
+ + sizeof (struct grub_pe32_optional_header)
+ + 4 * sizeof (struct grub_pe32_section_table),
GRUB_PE32_SECTION_ALIGNMENT)
},
{"i386-ieee1275", 4, 0, IMAGE_I386_IEEE1275, FORMAT_ELF, PLATFORM_FLAGS_NONE,
.vaddr_offset = 0},
{"x86_64-efi", 8, 0, IMAGE_EFI, FORMAT_PE, PLATFORM_FLAGS_NONE,
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
- .vaddr_offset = ALIGN_UP (sizeof (struct grub_pe32_header)
- + 5 * sizeof (struct grub_pe32_section_table),
+ .vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
+ + GRUB_PE32_SIGNATURE_SIZE
+ + sizeof (struct grub_pe32_coff_header)
+ + sizeof (struct grub_pe64_optional_header)
+ + 4 * sizeof (struct grub_pe32_section_table),
GRUB_PE32_SECTION_ALIGNMENT)
},
{"mipsel-yeeloong-elf", 4, 0, IMAGE_YEELOONG_ELF, FORMAT_ELF, PLATFORM_FLAGS_NONE,
case IMAGE_EFI:
{
void *pe_img;
+ grub_uint8_t *header;
size_t pe_size;
- struct grub_pe32_header *header;
struct grub_pe32_coff_header *c;
- struct grub_pe32_optional_header *o;
struct grub_pe32_section_table *text_section, *data_section;
struct grub_pe32_section_table *mods_section, *reloc_section;
static const grub_uint8_t stub[] = GRUB_PE32_MSDOS_STUB;
- int header_size = ALIGN_UP (sizeof (struct grub_pe32_header)
- + 5 * sizeof (struct grub_pe32_section_table),
- image_target->section_align);
- int reloc_addr = ALIGN_UP (header_size + core_size, image_target->section_align);
+ int header_size;
+ int reloc_addr;
- pe_size = ALIGN_UP (reloc_addr + reloc_size, image_target->section_align);
+ if (image_target->voidp_sizeof == 4)
+ header_size = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
+ + GRUB_PE32_SIGNATURE_SIZE
+ + sizeof (struct grub_pe32_coff_header)
+ + sizeof (struct grub_pe32_optional_header)
+ + 4 * sizeof (struct grub_pe32_section_table),
+ GRUB_PE32_SECTION_ALIGNMENT);
+ else
+ header_size = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
+ + GRUB_PE32_SIGNATURE_SIZE
+ + sizeof (struct grub_pe32_coff_header)
+ + sizeof (struct grub_pe64_optional_header)
+ + 4 * sizeof (struct grub_pe32_section_table),
+ GRUB_PE32_SECTION_ALIGNMENT);
+
+ reloc_addr = ALIGN_UP (header_size + core_size,
+ image_target->section_align);
+
+ pe_size = ALIGN_UP (reloc_addr + reloc_size,
+ image_target->section_align);
pe_img = xmalloc (reloc_addr + reloc_size);
memset (pe_img, 0, header_size);
memcpy (pe_img + header_size, core_img, core_size);
header = pe_img;
/* The magic. */
- memcpy (header->msdos_stub, stub, sizeof (header->msdos_stub));
- memcpy (header->signature, "PE\0\0", sizeof (header->signature));
+ memcpy (header, stub, GRUB_PE32_MSDOS_STUB_SIZE);
+ memcpy (header + GRUB_PE32_MSDOS_STUB_SIZE, "PE\0\0",
+ GRUB_PE32_SIGNATURE_SIZE);
/* The COFF file header. */
- c = &header->coff_header;
+ c = header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE;
if (image_target->voidp_sizeof == 4)
c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_I386);
else
c->num_sections = grub_host_to_target16 (4);
c->time = grub_host_to_target32 (time (0));
- c->optional_header_size = grub_host_to_target16 (sizeof (header->optional_header));
c->characteristics = grub_host_to_target16 (GRUB_PE32_EXECUTABLE_IMAGE
| GRUB_PE32_LINE_NUMS_STRIPPED
| ((image_target->voidp_sizeof == 4)
| GRUB_PE32_DEBUG_STRIPPED);
/* The PE Optional header. */
- o = &header->optional_header;
- o->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC);
- o->code_size = grub_host_to_target32 (exec_size);
- o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size);
- o->bss_size = grub_cpu_to_le32 (bss_size);
- o->entry_addr = grub_cpu_to_le32 (start_address);
- o->code_base = grub_cpu_to_le32 (header_size);
if (image_target->voidp_sizeof == 4)
- o->data_base = grub_host_to_target32 (header_size + exec_size);
- o->image_base = 0;
- o->section_alignment = grub_host_to_target32 (image_target->section_align);
- o->file_alignment = grub_host_to_target32 (image_target->section_align);
- o->image_size = grub_host_to_target32 (pe_size);
- o->header_size = grub_host_to_target32 (header_size);
- o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
-
- /* Do these really matter? */
- o->stack_reserve_size = grub_host_to_target32 (0x10000);
- o->stack_commit_size = grub_host_to_target32 (0x10000);
- o->heap_reserve_size = grub_host_to_target32 (0x10000);
- o->heap_commit_size = grub_host_to_target32 (0x10000);
+ {
+ struct grub_pe32_optional_header *o;
+
+ c->optional_header_size = grub_host_to_target16 (sizeof (struct grub_pe32_optional_header));
+
+ o = header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE
+ + sizeof (struct grub_pe32_coff_header);
+ o->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC);
+ o->code_size = grub_host_to_target32 (exec_size);
+ o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size);
+ o->bss_size = grub_cpu_to_le32 (bss_size);
+ o->entry_addr = grub_cpu_to_le32 (start_address);
+ o->code_base = grub_cpu_to_le32 (header_size);
+
+ o->data_base = grub_host_to_target32 (header_size + exec_size);
+
+ o->image_base = 0;
+ o->section_alignment = grub_host_to_target32 (image_target->section_align);
+ o->file_alignment = grub_host_to_target32 (image_target->section_align);
+ o->image_size = grub_host_to_target32 (pe_size);
+ o->header_size = grub_host_to_target32 (header_size);
+ o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
+
+ /* Do these really matter? */
+ o->stack_reserve_size = grub_host_to_target32 (0x10000);
+ o->stack_commit_size = grub_host_to_target32 (0x10000);
+ o->heap_reserve_size = grub_host_to_target32 (0x10000);
+ o->heap_commit_size = grub_host_to_target32 (0x10000);
- o->num_data_directories = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
+ o->num_data_directories = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
- o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
- o->base_relocation_table.size = grub_host_to_target32 (reloc_size);
+ o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
+ o->base_relocation_table.size = grub_host_to_target32 (reloc_size);
+ }
+ else
+ {
+ struct grub_pe64_optional_header *o;
+
+ c->optional_header_size = grub_host_to_target16 (sizeof (struct grub_pe32_optional_header));
+
+ o = header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE
+ + sizeof (struct grub_pe32_coff_header);
+ o->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC);
+ o->code_size = grub_host_to_target32 (exec_size);
+ o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size);
+ o->bss_size = grub_cpu_to_le32 (bss_size);
+ o->entry_addr = grub_cpu_to_le32 (start_address);
+ o->code_base = grub_cpu_to_le32 (header_size);
+ o->image_base = 0;
+ o->section_alignment = grub_host_to_target32 (image_target->section_align);
+ o->file_alignment = grub_host_to_target32 (image_target->section_align);
+ o->image_size = grub_host_to_target32 (pe_size);
+ o->header_size = grub_host_to_target32 (header_size);
+ o->subsystem = grub_host_to_target16 (GRUB_PE32_SUBSYSTEM_EFI_APPLICATION);
+
+ /* Do these really matter? */
+ o->stack_reserve_size = grub_host_to_target32 (0x10000);
+ o->stack_commit_size = grub_host_to_target32 (0x10000);
+ o->heap_reserve_size = grub_host_to_target32 (0x10000);
+ o->heap_commit_size = grub_host_to_target32 (0x10000);
+
+ o->num_data_directories
+ = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES);
+ o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
+ o->base_relocation_table.size = grub_host_to_target32 (reloc_size);
+ }
/* The sections. */
text_section = (struct grub_pe32_section_table *) (header + 1);
strcpy (text_section->name, ".text");
phdr->p_flags = grub_host_to_target32 (PF_R | PF_W | PF_X);
if (image_target->id == IMAGE_YEELOONG_ELF)
- target_addr = ALIGN_UP (GRUB_KERNEL_MACHINE_LINK_ADDR
- + kernel_size + total_module_size, 32);
+ target_addr = ALIGN_UP (image_target->link_addr
+ + kernel_size + total_module_size, 32);
else
- target_addr = GRUB_KERNEL_MACHINE_LINK_ADDR;
+ target_addr = image_target->link_addr;
ehdr->e_entry = grub_host_to_target32 (target_addr);
phdr->p_vaddr = grub_host_to_target32 (target_addr);
phdr->p_paddr = grub_host_to_target32 (target_addr);
\n\
Make a bootable image of GRUB.\n\
\n\
- -d, --directory=DIR use images and modules under DIR [default=%s]\n\
+ -d, --directory=DIR use images and modules under DIR [default=%s/@platform@]\n\
-p, --prefix=DIR set grub_prefix directory [default=%s]\n\
-m, --memdisk=FILE embed FILE as a memdisk image\n\
-f, --font=FILE embed FILE as a boot font\n\
free (output);
}
+ if (!dir)
+ {
+ const char *last;
+ last = strchr (image_target->name, '-');
+ if (last)
+ last = strchr (last + 1, '-');
+ if (!last)
+ last = image_target->name + strlen (image_target->name);
+ dir = xmalloc (sizeof (GRUB_LIBDIR) + (last - image_target->name));
+ memcpy (dir, GRUB_LIBDIR, sizeof (GRUB_LIBDIR) - 1);
+ memcpy (dir + sizeof (GRUB_LIBDIR) - 1, image_target->name,
+ last - image_target->name);
+ *(dir + sizeof (GRUB_LIBDIR) - 1 + (last - image_target->name)) = 0;
+ }
+
generate_image (dir ? : GRUB_LIBDIR, prefix ? : DEFAULT_DIRECTORY, fp,
argv + optind, memdisk, font, config,
image_target, note);