Fix non-loading of BSS
This commit is contained in:
parent
79f8b757ce
commit
ffadea42bb
1 changed files with 12 additions and 9 deletions
|
@ -88,7 +88,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer)
|
||||||
/* Load every loadable segment in memory. */
|
/* Load every loadable segment in memory. */
|
||||||
for (i = 0; i < ehdr->e_phnum; i++)
|
for (i = 0; i < ehdr->e_phnum; i++)
|
||||||
{
|
{
|
||||||
if (phdr(i)->p_type == PT_LOAD && phdr(i)->p_filesz != 0)
|
if (phdr(i)->p_type == PT_LOAD)
|
||||||
{
|
{
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
void *source;
|
void *source;
|
||||||
|
@ -109,15 +109,18 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, void *buffer)
|
||||||
source = get_virtual_current_address (ch);
|
source = get_virtual_current_address (ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (grub_file_seek (file, (grub_off_t) phdr(i)->p_offset)
|
if (phdr(i)->p_filesz != 0)
|
||||||
== (grub_off_t) -1)
|
{
|
||||||
return grub_error (GRUB_ERR_BAD_OS,
|
if (grub_file_seek (file, (grub_off_t) phdr(i)->p_offset)
|
||||||
"invalid offset in program header");
|
== (grub_off_t) -1)
|
||||||
|
return grub_error (GRUB_ERR_BAD_OS,
|
||||||
|
"invalid offset in program header");
|
||||||
|
|
||||||
if (grub_file_read (file, source, phdr(i)->p_filesz)
|
if (grub_file_read (file, source, phdr(i)->p_filesz)
|
||||||
!= (grub_ssize_t) phdr(i)->p_filesz)
|
!= (grub_ssize_t) phdr(i)->p_filesz)
|
||||||
return grub_error (GRUB_ERR_BAD_OS,
|
return grub_error (GRUB_ERR_BAD_OS,
|
||||||
"couldn't read segment from file");
|
"couldn't read segment from file");
|
||||||
|
}
|
||||||
|
|
||||||
if (phdr(i)->p_filesz < phdr(i)->p_memsz)
|
if (phdr(i)->p_filesz < phdr(i)->p_memsz)
|
||||||
grub_memset ((grub_uint8_t *) source + phdr(i)->p_filesz, 0,
|
grub_memset ((grub_uint8_t *) source + phdr(i)->p_filesz, 0,
|
||||||
|
|
Loading…
Add table
Reference in a new issue