Commit 13d46535 authored by Mike Hibler's avatar Mike Hibler
Browse files

Do not attempt to load PT_DYNAMIC segment for FreeBSD kernel.

This segment just references part of another PT_LOAD segment that contains
info related to dynamic linking. Loading this segment just re-loads a part
of another segment that was already loaded. More gratuitous seeks, bad for
TFTP.

The FreeBSD loader handles the PT_DYNAMIC segment, but it appears to
be for its own benefit and does not affect the kernel that was loaded.
parent 08c38d20
......@@ -1451,10 +1451,24 @@ static grub_err_t
grub_bsd_load_elf (grub_elf_t elf, const char *filename)
{
grub_err_t err;
int dynflag = 0;
kern_end = 0;
kern_start = ~0;
#if 0
/*
* XXX this is wrong and a pointless thing to do.
* The program header PT_DYNAMIC entry identifies a section of
* a PT_LOAD segment that contains the dynamic linking table.
*
* Reading this section from the file again is pointless.
* The FreeBSD boot loader instead extracts this info to (apparently)
* build its own tables for use in the loader.
*/
dynflag = GRUB_ELF_LOAD_FLAGS_LOAD_PT_DYNAMIC;
#endif
if (grub_elf_is_elf32 (elf))
{
grub_relocator_chunk_t ch;
......@@ -1488,7 +1502,7 @@ grub_bsd_load_elf (grub_elf_t elf, const char *filename)
kern_chunk_src = get_virtual_current_address (ch);
err = grub_elf32_load (elf, filename, (grub_uint8_t *) kern_chunk_src - kern_start, GRUB_ELF_LOAD_FLAGS_LOAD_PT_DYNAMIC | GRUB_ELF_LOAD_FLAGS_28BITS, 0, 0);
err = grub_elf32_load (elf, filename, (grub_uint8_t *) kern_chunk_src - kern_start, dynflag | GRUB_ELF_LOAD_FLAGS_28BITS, 0, 0);
if (err)
return err;
if (kernel_type != KERNEL_TYPE_OPENBSD)
......@@ -1550,7 +1564,7 @@ grub_bsd_load_elf (grub_elf_t elf, const char *filename)
}
err = grub_elf64_load (elf, filename,
(grub_uint8_t *) kern_chunk_src - kern_start, GRUB_ELF_LOAD_FLAGS_LOAD_PT_DYNAMIC | GRUB_ELF_LOAD_FLAGS_28BITS, 0, 0);
(grub_uint8_t *) kern_chunk_src - kern_start, dynflag | GRUB_ELF_LOAD_FLAGS_28BITS, 0, 0);
if (err)
return err;
if (kernel_type != KERNEL_TYPE_OPENBSD)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment