Fill info for remaining platforms. Make efi image identical to image of previous grub-mkimage
This commit is contained in:
parent
962b15b4c1
commit
bb3208158a
9 changed files with 101 additions and 45 deletions
|
@ -4,8 +4,6 @@ COMMON_CFLAGS = -mrtd -mregparm=3
|
||||||
|
|
||||||
# Images.
|
# Images.
|
||||||
|
|
||||||
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
|
|
||||||
|
|
||||||
pkglib_PROGRAMS += kernel.img
|
pkglib_PROGRAMS += kernel.img
|
||||||
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
||||||
kern/i386/misc.S \
|
kern/i386/misc.S \
|
||||||
|
@ -26,7 +24,7 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \
|
||||||
symlist.c
|
symlist.c
|
||||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR),-Bstatic
|
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x8200,-Bstatic
|
||||||
|
|
||||||
sbin_SCRIPTS += grub-install
|
sbin_SCRIPTS += grub-install
|
||||||
grub_install_SOURCES = util/grub-install.in
|
grub_install_SOURCES = util/grub-install.in
|
||||||
|
|
|
@ -238,6 +238,7 @@ struct grub_pe32_section_table
|
||||||
#define GRUB_PE32_SCN_ALIGN_SHIFT 20
|
#define GRUB_PE32_SCN_ALIGN_SHIFT 20
|
||||||
#define GRUB_PE32_SCN_ALIGN_MASK 7
|
#define GRUB_PE32_SCN_ALIGN_MASK 7
|
||||||
|
|
||||||
|
#define GRUB_PE32_SIGNATURE_SIZE 4
|
||||||
|
|
||||||
struct grub_pe32_header
|
struct grub_pe32_header
|
||||||
{
|
{
|
||||||
|
@ -245,17 +246,20 @@ struct grub_pe32_header
|
||||||
grub_uint8_t msdos_stub[GRUB_PE32_MSDOS_STUB_SIZE];
|
grub_uint8_t msdos_stub[GRUB_PE32_MSDOS_STUB_SIZE];
|
||||||
|
|
||||||
/* This is always PE\0\0. */
|
/* This is always PE\0\0. */
|
||||||
char signature[4];
|
char signature[GRUB_PE32_SIGNATURE_SIZE];
|
||||||
|
|
||||||
/* The COFF file header. */
|
/* The COFF file header. */
|
||||||
struct grub_pe32_coff_header coff_header;
|
struct grub_pe32_coff_header coff_header;
|
||||||
|
|
||||||
|
#if GRUB_TARGET_SIZEOF_VOID_P == 8
|
||||||
|
/* The Optional header. */
|
||||||
|
struct grub_pe64_optional_header optional_header;
|
||||||
|
#else
|
||||||
/* The Optional header. */
|
/* The Optional header. */
|
||||||
struct grub_pe32_optional_header optional_header;
|
struct grub_pe32_optional_header optional_header;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GRUB_PE32_SIGNATURE_SIZE 4
|
|
||||||
|
|
||||||
struct grub_pe32_fixup_block
|
struct grub_pe32_fixup_block
|
||||||
{
|
{
|
||||||
grub_uint32_t page_rva;
|
grub_uint32_t page_rva;
|
||||||
|
|
|
@ -23,11 +23,5 @@
|
||||||
configuration file are located. */
|
configuration file are located. */
|
||||||
extern char grub_prefix[];
|
extern char grub_prefix[];
|
||||||
|
|
||||||
/* The offset of GRUB_PREFIX. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_PREFIX 0x8
|
|
||||||
|
|
||||||
/* End of the data section. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_DATA_END 0x50
|
|
||||||
|
|
||||||
#endif /* ! GRUB_MACHINE_KERNEL_HEADER */
|
#endif /* ! GRUB_MACHINE_KERNEL_HEADER */
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,4 @@
|
||||||
/* Non-zero value is only needed for PowerMacs. */
|
/* Non-zero value is only needed for PowerMacs. */
|
||||||
#define GRUB_MOD_GAP 0x0
|
#define GRUB_MOD_GAP 0x0
|
||||||
|
|
||||||
#define GRUB_KERNEL_CPU_PREFIX 0x2
|
|
||||||
#define GRUB_KERNEL_CPU_DATA_END 0x42
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -93,6 +93,7 @@
|
||||||
#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX 0x4
|
#define GRUB_KERNEL_POWERPC_IEEE1275_PREFIX 0x4
|
||||||
#define GRUB_KERNEL_POWERPC_IEEE1275_DATA_END 0x44
|
#define GRUB_KERNEL_POWERPC_IEEE1275_DATA_END 0x44
|
||||||
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
|
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
|
||||||
|
#define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR 0x200000
|
||||||
|
|
||||||
#define GRUB_KERNEL_MIPS_YEELOONG_LINK_ADDR 0x80200000
|
#define GRUB_KERNEL_MIPS_YEELOONG_LINK_ADDR 0x80200000
|
||||||
|
|
||||||
|
@ -106,6 +107,26 @@
|
||||||
#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE
|
#define GRUB_KERNEL_MIPS_YEELOONG_PREFIX GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE
|
||||||
#define GRUB_KERNEL_MIPS_YEELOONG_DATA_END GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE + 0x48
|
#define GRUB_KERNEL_MIPS_YEELOONG_DATA_END GRUB_KERNEL_MIPS_YEELOONG_RAW_SIZE + 0x48
|
||||||
|
|
||||||
|
/* The offset of GRUB_PREFIX. */
|
||||||
|
#define GRUB_KERNEL_I386_EFI_PREFIX 0x8
|
||||||
|
|
||||||
|
/* End of the data section. */
|
||||||
|
#define GRUB_KERNEL_I386_EFI_DATA_END 0x50
|
||||||
|
|
||||||
|
/* The offset of GRUB_PREFIX. */
|
||||||
|
#define GRUB_KERNEL_X86_64_EFI_PREFIX 0x8
|
||||||
|
|
||||||
|
/* End of the data section. */
|
||||||
|
#define GRUB_KERNEL_X86_64_EFI_DATA_END 0x50
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_I386_COREBOOT_PREFIX 0x2
|
||||||
|
#define GRUB_KERNEL_I386_COREBOOT_DATA_END 0x42
|
||||||
|
#define GRUB_KERNEL_I386_COREBOOT_LINK_ADDR 0x8200
|
||||||
|
|
||||||
|
#define GRUB_KERNEL_I386_IEEE1275_PREFIX 0x2
|
||||||
|
#define GRUB_KERNEL_I386_IEEE1275_DATA_END 0x42
|
||||||
|
#define GRUB_KERNEL_I386_IEEE1275_LINK_ADDR 0x10000
|
||||||
|
|
||||||
#ifdef MACHINE
|
#ifdef MACHINE
|
||||||
#define GRUB_OFFSETS_CONCAT_(a,b,c) a ## b ## c
|
#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_OFFSETS_CONCAT(a,b,c) GRUB_OFFSETS_CONCAT_(a,b,c)
|
||||||
|
|
|
@ -23,11 +23,5 @@
|
||||||
configuration file are located. */
|
configuration file are located. */
|
||||||
extern char grub_prefix[];
|
extern char grub_prefix[];
|
||||||
|
|
||||||
/* The offset of GRUB_PREFIX. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_PREFIX 0x8
|
|
||||||
|
|
||||||
/* End of the data section. */
|
|
||||||
#define GRUB_KERNEL_MACHINE_DATA_END 0x50
|
|
||||||
|
|
||||||
#endif /* ! GRUB_MACHINE_KERNEL_HEADER */
|
#endif /* ! GRUB_MACHINE_KERNEL_HEADER */
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ _start:
|
||||||
* This is a special data area at a fixed offset from the beginning.
|
* This is a special data area at a fixed offset from the beginning.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
. = _start + GRUB_KERNEL_CPU_PREFIX
|
. = _start + GRUB_KERNEL_MACHINE_PREFIX
|
||||||
|
|
||||||
VARIABLE(grub_prefix)
|
VARIABLE(grub_prefix)
|
||||||
/* to be filled by grub-mkimage */
|
/* to be filled by grub-mkimage */
|
||||||
|
@ -51,7 +51,7 @@ VARIABLE(grub_prefix)
|
||||||
* Leave some breathing room for the prefix.
|
* Leave some breathing room for the prefix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
. = _start + GRUB_KERNEL_CPU_DATA_END
|
. = _start + GRUB_KERNEL_MACHINE_DATA_END
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
|
* Support for booting GRUB from a Multiboot boot loader (e.g. GRUB itself).
|
||||||
|
|
|
@ -43,7 +43,7 @@ _start:
|
||||||
* This is a special data area at a fixed offset from the beginning.
|
* This is a special data area at a fixed offset from the beginning.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
. = _start + GRUB_KERNEL_CPU_PREFIX
|
. = _start + GRUB_KERNEL_MACHINE_PREFIX
|
||||||
|
|
||||||
VARIABLE(grub_prefix)
|
VARIABLE(grub_prefix)
|
||||||
/* to be filled by grub-mkimage */
|
/* to be filled by grub-mkimage */
|
||||||
|
@ -52,7 +52,7 @@ VARIABLE(grub_prefix)
|
||||||
* Leave some breathing room for the prefix.
|
* Leave some breathing room for the prefix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
. = _start + GRUB_KERNEL_CPU_DATA_END
|
. = _start + GRUB_KERNEL_MACHINE_DATA_END
|
||||||
|
|
||||||
codestart:
|
codestart:
|
||||||
movl %eax, EXT_C(grub_ieee1275_entry_fn)
|
movl %eax, EXT_C(grub_ieee1275_entry_fn)
|
||||||
|
|
|
@ -82,8 +82,17 @@ struct image_target_desc image_targets[] =
|
||||||
.bigendian = 0,
|
.bigendian = 0,
|
||||||
.id = IMAGE_COREBOOT,
|
.id = IMAGE_COREBOOT,
|
||||||
.flags = PLATFORM_FLAGS_NONE,
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.prefix = GRUB_KERNEL_I386_COREBOOT_PREFIX,
|
||||||
|
.data_end = GRUB_KERNEL_I386_COREBOOT_DATA_END,
|
||||||
|
.raw_size = 0,
|
||||||
|
.total_module_size = TARGET_NO_FIELD,
|
||||||
|
.kernel_image_size = TARGET_NO_FIELD,
|
||||||
|
.compressed_size = TARGET_NO_FIELD,
|
||||||
.section_align = 1,
|
.section_align = 1,
|
||||||
.vaddr_offset = 0
|
.vaddr_offset = 0,
|
||||||
|
.install_dos_part = TARGET_NO_FIELD,
|
||||||
|
.install_bsd_part = TARGET_NO_FIELD,
|
||||||
|
.link_addr = GRUB_KERNEL_I386_COREBOOT_LINK_ADDR
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "i386-pc",
|
.name = "i386-pc",
|
||||||
|
@ -109,13 +118,21 @@ struct image_target_desc image_targets[] =
|
||||||
.bigendian = 0,
|
.bigendian = 0,
|
||||||
.id = IMAGE_EFI,
|
.id = IMAGE_EFI,
|
||||||
.flags = PLATFORM_FLAGS_NONE,
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.prefix = GRUB_KERNEL_I386_EFI_PREFIX,
|
||||||
|
.data_end = GRUB_KERNEL_I386_EFI_DATA_END,
|
||||||
|
.raw_size = 0,
|
||||||
|
.total_module_size = TARGET_NO_FIELD,
|
||||||
|
.kernel_image_size = TARGET_NO_FIELD,
|
||||||
|
.compressed_size = TARGET_NO_FIELD,
|
||||||
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
||||||
.vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
.vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
||||||
+ GRUB_PE32_SIGNATURE_SIZE
|
+ GRUB_PE32_SIGNATURE_SIZE
|
||||||
+ sizeof (struct grub_pe32_coff_header)
|
+ sizeof (struct grub_pe32_coff_header)
|
||||||
+ sizeof (struct grub_pe32_optional_header)
|
+ sizeof (struct grub_pe32_optional_header)
|
||||||
+ 4 * sizeof (struct grub_pe32_section_table),
|
+ 4 * sizeof (struct grub_pe32_section_table),
|
||||||
GRUB_PE32_SECTION_ALIGNMENT)
|
GRUB_PE32_SECTION_ALIGNMENT),
|
||||||
|
.install_dos_part = TARGET_NO_FIELD,
|
||||||
|
.install_bsd_part = TARGET_NO_FIELD,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "i386-ieee1275",
|
.name = "i386-ieee1275",
|
||||||
|
@ -123,8 +140,17 @@ struct image_target_desc image_targets[] =
|
||||||
.bigendian = 0,
|
.bigendian = 0,
|
||||||
.id = IMAGE_I386_IEEE1275,
|
.id = IMAGE_I386_IEEE1275,
|
||||||
.flags = PLATFORM_FLAGS_NONE,
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.prefix = GRUB_KERNEL_I386_IEEE1275_PREFIX,
|
||||||
|
.data_end = GRUB_KERNEL_I386_IEEE1275_DATA_END,
|
||||||
|
.raw_size = 0,
|
||||||
|
.total_module_size = TARGET_NO_FIELD,
|
||||||
|
.kernel_image_size = TARGET_NO_FIELD,
|
||||||
|
.compressed_size = TARGET_NO_FIELD,
|
||||||
.section_align = 1,
|
.section_align = 1,
|
||||||
.vaddr_offset = 0
|
.vaddr_offset = 0,
|
||||||
|
.install_dos_part = TARGET_NO_FIELD,
|
||||||
|
.install_bsd_part = TARGET_NO_FIELD,
|
||||||
|
.link_addr = GRUB_KERNEL_I386_IEEE1275_LINK_ADDR
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "i386-qemu",
|
.name = "i386-qemu",
|
||||||
|
@ -150,13 +176,21 @@ struct image_target_desc image_targets[] =
|
||||||
.bigendian = 0,
|
.bigendian = 0,
|
||||||
.id = IMAGE_EFI,
|
.id = IMAGE_EFI,
|
||||||
.flags = PLATFORM_FLAGS_NONE,
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.prefix = GRUB_KERNEL_X86_64_EFI_PREFIX,
|
||||||
|
.data_end = GRUB_KERNEL_X86_64_EFI_DATA_END,
|
||||||
|
.raw_size = 0,
|
||||||
|
.total_module_size = TARGET_NO_FIELD,
|
||||||
|
.kernel_image_size = TARGET_NO_FIELD,
|
||||||
|
.compressed_size = TARGET_NO_FIELD,
|
||||||
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
.section_align = GRUB_PE32_SECTION_ALIGNMENT,
|
||||||
.vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
.vaddr_offset = ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE
|
||||||
+ GRUB_PE32_SIGNATURE_SIZE
|
+ GRUB_PE32_SIGNATURE_SIZE
|
||||||
+ sizeof (struct grub_pe32_coff_header)
|
+ sizeof (struct grub_pe32_coff_header)
|
||||||
+ sizeof (struct grub_pe64_optional_header)
|
+ sizeof (struct grub_pe64_optional_header)
|
||||||
+ 4 * sizeof (struct grub_pe32_section_table),
|
+ 4 * sizeof (struct grub_pe32_section_table),
|
||||||
GRUB_PE32_SECTION_ALIGNMENT)
|
GRUB_PE32_SECTION_ALIGNMENT),
|
||||||
|
.install_dos_part = TARGET_NO_FIELD,
|
||||||
|
.install_bsd_part = TARGET_NO_FIELD,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "mipsel-yeeloong-elf",
|
.name = "mipsel-yeeloong-elf",
|
||||||
|
@ -184,8 +218,17 @@ struct image_target_desc image_targets[] =
|
||||||
.bigendian = 1,
|
.bigendian = 1,
|
||||||
.id = IMAGE_PPC,
|
.id = IMAGE_PPC,
|
||||||
.flags = PLATFORM_FLAGS_NONE,
|
.flags = PLATFORM_FLAGS_NONE,
|
||||||
|
.prefix = GRUB_KERNEL_POWERPC_IEEE1275_PREFIX,
|
||||||
|
.data_end = GRUB_KERNEL_POWERPC_IEEE1275_DATA_END,
|
||||||
|
.raw_size = 0,
|
||||||
|
.total_module_size = TARGET_NO_FIELD,
|
||||||
|
.kernel_image_size = TARGET_NO_FIELD,
|
||||||
|
.compressed_size = TARGET_NO_FIELD,
|
||||||
.section_align = 1,
|
.section_align = 1,
|
||||||
.vaddr_offset = 0
|
.vaddr_offset = 0,
|
||||||
|
.install_dos_part = TARGET_NO_FIELD,
|
||||||
|
.install_bsd_part = TARGET_NO_FIELD,
|
||||||
|
.link_addr = GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "sparc64-ieee1275-raw",
|
.name = "sparc64-ieee1275-raw",
|
||||||
|
@ -629,6 +672,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
{
|
{
|
||||||
void *pe_img;
|
void *pe_img;
|
||||||
grub_uint8_t *header;
|
grub_uint8_t *header;
|
||||||
|
void *sections;
|
||||||
size_t pe_size;
|
size_t pe_size;
|
||||||
struct grub_pe32_coff_header *c;
|
struct grub_pe32_coff_header *c;
|
||||||
struct grub_pe32_section_table *text_section, *data_section;
|
struct grub_pe32_section_table *text_section, *data_section;
|
||||||
|
@ -669,7 +713,8 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
GRUB_PE32_SIGNATURE_SIZE);
|
GRUB_PE32_SIGNATURE_SIZE);
|
||||||
|
|
||||||
/* The COFF file header. */
|
/* The COFF file header. */
|
||||||
c = header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE;
|
c = (struct grub_pe32_coff_header *) (header + GRUB_PE32_MSDOS_STUB_SIZE
|
||||||
|
+ GRUB_PE32_SIGNATURE_SIZE);
|
||||||
if (image_target->voidp_sizeof == 4)
|
if (image_target->voidp_sizeof == 4)
|
||||||
c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_I386);
|
c->machine = grub_host_to_target16 (GRUB_PE32_MACHINE_I386);
|
||||||
else
|
else
|
||||||
|
@ -692,11 +737,13 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
|
|
||||||
c->optional_header_size = grub_host_to_target16 (sizeof (struct grub_pe32_optional_header));
|
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
|
o = (struct grub_pe32_optional_header *)
|
||||||
+ sizeof (struct grub_pe32_coff_header);
|
(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->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC);
|
||||||
o->code_size = grub_host_to_target32 (exec_size);
|
o->code_size = grub_host_to_target32 (exec_size);
|
||||||
o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size);
|
o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size
|
||||||
|
- header_size);
|
||||||
o->bss_size = grub_cpu_to_le32 (bss_size);
|
o->bss_size = grub_cpu_to_le32 (bss_size);
|
||||||
o->entry_addr = grub_cpu_to_le32 (start_address);
|
o->entry_addr = grub_cpu_to_le32 (start_address);
|
||||||
o->code_base = grub_cpu_to_le32 (header_size);
|
o->code_base = grub_cpu_to_le32 (header_size);
|
||||||
|
@ -720,18 +767,21 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
|
|
||||||
o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
|
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.size = grub_host_to_target32 (reloc_size);
|
||||||
|
sections = o + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct grub_pe64_optional_header *o;
|
struct grub_pe64_optional_header *o;
|
||||||
|
|
||||||
c->optional_header_size = grub_host_to_target16 (sizeof (struct grub_pe32_optional_header));
|
c->optional_header_size = grub_host_to_target16 (sizeof (struct grub_pe64_optional_header));
|
||||||
|
|
||||||
o = header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE
|
o = (struct grub_pe64_optional_header *)
|
||||||
+ sizeof (struct grub_pe32_coff_header);
|
(header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE
|
||||||
|
+ sizeof (struct grub_pe32_coff_header));
|
||||||
o->magic = grub_host_to_target16 (GRUB_PE32_PE64_MAGIC);
|
o->magic = grub_host_to_target16 (GRUB_PE32_PE64_MAGIC);
|
||||||
o->code_size = grub_host_to_target32 (exec_size);
|
o->code_size = grub_host_to_target32 (exec_size);
|
||||||
o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size);
|
o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size
|
||||||
|
- header_size);
|
||||||
o->bss_size = grub_cpu_to_le32 (bss_size);
|
o->bss_size = grub_cpu_to_le32 (bss_size);
|
||||||
o->entry_addr = grub_cpu_to_le32 (start_address);
|
o->entry_addr = grub_cpu_to_le32 (start_address);
|
||||||
o->code_base = grub_cpu_to_le32 (header_size);
|
o->code_base = grub_cpu_to_le32 (header_size);
|
||||||
|
@ -753,9 +803,10 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
|
|
||||||
o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr);
|
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.size = grub_host_to_target32 (reloc_size);
|
||||||
|
sections = o + 1;
|
||||||
}
|
}
|
||||||
/* The sections. */
|
/* The sections. */
|
||||||
text_section = (struct grub_pe32_section_table *) (header + 1);
|
text_section = sections;
|
||||||
strcpy (text_section->name, ".text");
|
strcpy (text_section->name, ".text");
|
||||||
text_section->virtual_size = grub_cpu_to_le32 (exec_size);
|
text_section->virtual_size = grub_cpu_to_le32 (exec_size);
|
||||||
text_section->virtual_address = grub_cpu_to_le32 (header_size);
|
text_section->virtual_address = grub_cpu_to_le32 (header_size);
|
||||||
|
@ -763,8 +814,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
text_section->raw_data_offset = grub_cpu_to_le32 (header_size);
|
text_section->raw_data_offset = grub_cpu_to_le32 (header_size);
|
||||||
text_section->characteristics = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_CODE
|
text_section->characteristics = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_CODE
|
||||||
| GRUB_PE32_SCN_MEM_EXECUTE
|
| GRUB_PE32_SCN_MEM_EXECUTE
|
||||||
| GRUB_PE32_SCN_MEM_READ
|
| GRUB_PE32_SCN_MEM_READ);
|
||||||
| GRUB_PE32_SCN_ALIGN_64BYTES);
|
|
||||||
|
|
||||||
data_section = text_section + 1;
|
data_section = text_section + 1;
|
||||||
strcpy (data_section->name, ".data");
|
strcpy (data_section->name, ".data");
|
||||||
|
@ -775,8 +825,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
data_section->characteristics
|
data_section->characteristics
|
||||||
= grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
|
= grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
|
||||||
| GRUB_PE32_SCN_MEM_READ
|
| GRUB_PE32_SCN_MEM_READ
|
||||||
| GRUB_PE32_SCN_MEM_WRITE
|
| GRUB_PE32_SCN_MEM_WRITE);
|
||||||
| GRUB_PE32_SCN_ALIGN_64BYTES);
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
bss_section = data_section + 1;
|
bss_section = data_section + 1;
|
||||||
|
@ -802,8 +851,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
|
||||||
mods_section->characteristics
|
mods_section->characteristics
|
||||||
= grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
|
= grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA
|
||||||
| GRUB_PE32_SCN_MEM_READ
|
| GRUB_PE32_SCN_MEM_READ
|
||||||
| GRUB_PE32_SCN_MEM_WRITE
|
| GRUB_PE32_SCN_MEM_WRITE);
|
||||||
| GRUB_PE32_SCN_ALIGN_64BYTES);
|
|
||||||
|
|
||||||
reloc_section = mods_section + 1;
|
reloc_section = mods_section + 1;
|
||||||
strcpy (reloc_section->name, ".reloc");
|
strcpy (reloc_section->name, ".reloc");
|
||||||
|
|
Loading…
Reference in a new issue