Skip to content

Commit 40cbd5c

Browse files
authored
Merge pull request #302 from agustingianni/multiboot-fix
Fix for multiboot loader
2 parents 0e2b0d0 + 39b9f64 commit 40cbd5c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib/firmware/multiboot.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ multiboot_parse_elf(struct multiboot_state *s, struct image *img)
222222
{
223223
struct elf_ehdr *ehdr = img->mapping;
224224
struct elf_phdr *phdr;
225-
uint32_t low = (uint32_t)-1, high = 0, memsize, addr, entry;
225+
uint32_t low = (uint32_t)-1, high = 0, memsize, addr, entry, offset = (uint32_t)-1;
226226
int i;
227227

228228
if (ehdr->e_ident[0] != 0x7f ||
@@ -248,6 +248,8 @@ multiboot_parse_elf(struct multiboot_state *s, struct image *img)
248248
entry < phdr[i].p_vaddr + phdr[i].p_filesz)
249249
entry = entry - phdr[i].p_vaddr + phdr[i].p_paddr;
250250

251+
if (phdr[i].p_offset < offset)
252+
offset = phdr[i].p_offset;
251253
if (addr < low)
252254
low = addr;
253255
if (addr + memsize > high)
@@ -257,6 +259,7 @@ multiboot_parse_elf(struct multiboot_state *s, struct image *img)
257259
if (low == (uint32_t)-1 || high == 0)
258260
die("multiboot: failed to parse ELF file\n");
259261

262+
s->kernel_offset = offset;
260263
s->kernel_load_addr = low;
261264
s->kernel_size = high - low;
262265
s->kernel_entry_addr = entry;

0 commit comments

Comments
 (0)