2008-07-02 Bean <bean123ch@gmail.com>

* include/grub/ieee1275.h (grub_ieee1275_flag): New constant
	GRUB_IEEE1275_FLAG_CANNOT_INTERPRET, GRUB_IEEE1275_FLAG_FORCE_CLAIM
	and GRUB_IEEE1275_FLAG_NO_ANSI.

	* kern/ieee1275/cmain.c (grub_ieee1275_find_options): Set flag
	GRUB_IEEE1275_FLAG_CANNOT_INTERPRET, GRUB_IEEE1275_FLAG_FORCE_CLAIM
	and GRUB_IEEE1275_FLAG_NO_ANSI for Open Hackware.

	* kern/ieee1275/ieee1275.c (grub_ieee1275_interpret): Return
	immediately if GRUB_IEEE1275_FLAG_CANNOT_INTERPRET is set.

	* kern/ieee1275/init.c (grub_claim_heap): Claim memory directly if
	GRUB_IEEE1275_FLAG_FORCE_CLAIM is set.

	* term/ieee1275/ofconsole.c (grub_ofconsole_writeesc): Don't output
	esc sequence on non ANSI terminal.
	(grub_ofconsole_gotoxy): Emulate backspace key on non ANSI terminal.

	* util/elf/grub-mkimage.c (add_segments): Move ELF header to the
	beginning of file.
This commit is contained in:
bean 2008-07-02 07:38:46 +00:00
parent 2270f77bea
commit d4156eeedf
7 changed files with 89 additions and 16 deletions

View file

@ -166,8 +166,8 @@ add_segments (char *dir, FILE *out, int chrp, char *mods[])
FILE *in;
char *kernel_path;
grub_addr_t grub_end = 0;
off_t phdroff;
int i;
off_t offset;
int i, phdr_size;
/* Read ELF header. */
kernel_path = grub_util_get_path (dir, "kernel.elf");
@ -177,8 +177,21 @@ add_segments (char *dir, FILE *out, int chrp, char *mods[])
grub_util_read_at (&ehdr, sizeof (ehdr), 0, in);
phdrs = xmalloc (grub_target_to_host16 (ehdr.e_phentsize)
* (grub_target_to_host16 (ehdr.e_phnum) + 2));
offset = ALIGN_UP (sizeof (ehdr), sizeof (long));
ehdr.e_phoff = grub_host_to_target32 (offset);
phdr_size = (grub_target_to_host16 (ehdr.e_phentsize) *
grub_target_to_host16 (ehdr.e_phnum));
if (mods[0] != NULL)
phdr_size += grub_target_to_host16 (ehdr.e_phentsize);
if (chrp)
phdr_size += grub_target_to_host16 (ehdr.e_phentsize);
phdrs = xmalloc (phdr_size);
offset += ALIGN_UP (phdr_size, sizeof (long));
/* Copy all existing segments. */
for (i = 0; i < grub_target_to_host16 (ehdr.e_phnum); i++)
{
@ -207,8 +220,11 @@ add_segments (char *dir, FILE *out, int chrp, char *mods[])
grub_util_read_at (segment_img, grub_target_to_host32 (phdr->p_filesz),
grub_target_to_host32 (phdr->p_offset), in);
phdr->p_offset = grub_host_to_target32 (offset);
grub_util_write_image_at (segment_img, grub_target_to_host32 (phdr->p_filesz),
grub_target_to_host32 (phdr->p_offset), out);
offset, out);
offset += ALIGN_UP (grub_target_to_host32 (phdr->p_filesz), sizeof (long));
free (segment_img);
}
@ -249,14 +265,10 @@ add_segments (char *dir, FILE *out, int chrp, char *mods[])
ehdr.e_shnum = 0;
ehdr.e_shstrndx = 0;
/* Append entire segment table to the file. */
phdroff = ALIGN_UP (grub_util_get_fp_size (out), sizeof (long));
grub_util_write_image_at (phdrs, grub_target_to_host16 (ehdr.e_phentsize)
* grub_target_to_host16 (ehdr.e_phnum), phdroff,
out);
/* Write entire segment table to the file. */
grub_util_write_image_at (phdrs, phdr_size, grub_target_to_host32 (ehdr.e_phoff), out);
/* Write ELF header. */
ehdr.e_phoff = grub_host_to_target32 (phdroff);
grub_util_write_image_at (&ehdr, sizeof (ehdr), 0, out);
free (phdrs);