2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>

Properly align 64-bit targets.

	* util/grub-mkrawimage.c (ALIGN_ADDR): New macro.
	(generate_image): Use ALIGN_ADDR.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-02-13 15:54:27 +01:00
parent b274d734f3
commit da278c4d34
2 changed files with 14 additions and 5 deletions

View file

@ -1,3 +1,10 @@
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
Properly align 64-bit targets.
* util/grub-mkrawimage.c (ALIGN_ADDR): New macro.
(generate_image): Use ALIGN_ADDR.
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
Properly create cross-endian images.

View file

@ -41,6 +41,8 @@
#include "progname.h"
#define ALIGN_ADDR(x) (ALIGN_UP((x), GRUB_TARGET_SIZEOF_VOID_P))
#ifdef ENABLE_LZMA
#include <grub/lib/LzmaEnc.h>
@ -129,20 +131,20 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
if (font_path)
{
font_size = ALIGN_UP(grub_util_get_image_size (font_path), 4);
font_size = ALIGN_ADDR (grub_util_get_image_size (font_path));
total_module_size += font_size + sizeof (struct grub_module_header);
}
if (config_path)
{
config_size_pure = grub_util_get_image_size (config_path) + 1;
config_size = ALIGN_UP(config_size_pure, 4);
config_size = ALIGN_ADDR (config_size_pure);
grub_util_info ("the size of config file is 0x%x", config_size);
total_module_size += config_size + sizeof (struct grub_module_header);
}
for (p = path_list; p; p = p->next)
total_module_size += (ALIGN_UP (grub_util_get_image_size (p->name), 4)
total_module_size += (ALIGN_ADDR (grub_util_get_image_size (p->name))
+ sizeof (struct grub_module_header));
grub_util_info ("the total module size is 0x%x", total_module_size);
@ -168,7 +170,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
size_t mod_size, orig_size;
orig_size = grub_util_get_image_size (p->name);
mod_size = ALIGN_UP(orig_size, 4);
mod_size = ALIGN_ADDR (orig_size);
header = (struct grub_module_header *) (kernel_img + offset);
memset (header, 0, sizeof (struct grub_module_header));
@ -339,7 +341,7 @@ generate_image (const char *dir, char *prefix, FILE *out, char *mods[],
Elf32_Phdr *phdr;
grub_uint32_t target_addr;
program_size = ALIGN_UP (core_size, 4);
program_size = ALIGN_ADDR (core_size);
elf_img = xmalloc (program_size + sizeof (*ehdr) + sizeof (*phdr));
memset (elf_img, 0, program_size + sizeof (*ehdr) + sizeof (*phdr));