commit bab8a914a37204c84878f414998c76638b6b3046
parent cc3140a780880c2c0e7cf74bd9b3adfb9652faa0
Author: Matsuda Kenji <info@mtkn.jp>
Date: Fri, 29 Mar 2024 18:06:25 +0900
debug: need gdb
Diffstat:
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/loader.c b/loader.c
@@ -95,6 +95,7 @@ EfiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *systab)
efi_printf("close file: %d\n", stat);
return stat;
}
+
mmsize = 8196;
stat = SystemTable->BootServices->GetMemoryMap(&mmsize, mmap, &mkey, &dsize, &dver);
if (stat != EFI_SUCCESS) {
diff --git a/utils.c b/utils.c
@@ -235,6 +235,9 @@ load_elf(EFI_FILE_PROTOCOL *elf, ElfHdr *ehdr, Phdr phdr[])
if (phdr[i].type != PT_LOAD) {
continue;
}
+ efi_printf("load_elf: allocate %d pages at %x\n",
+ (phdr[i].memsz + 0xfff) / 0x1000, &phdr[i].vaddr
+ );
stat = SystemTable->BootServices->AllocatePages(
AllocateAddress, EfiLoaderData,
(phdr[i].memsz + 0xfff) / 0x1000, &phdr[i].vaddr
@@ -243,12 +246,14 @@ load_elf(EFI_FILE_PROTOCOL *elf, ElfHdr *ehdr, Phdr phdr[])
efi_printf("allocate pages: %d\n", stat);
return stat;
}
+ efi_printf("load_elf: phdr[i].vaddr: %x\n", phdr[i].vaddr);
stat = elf->SetPosition(elf, phdr[i].offset);
if (stat != EFI_SUCCESS) {
efi_printf("set position: %d\n", stat);
return stat;
}
addr = (EFI_PHYSICAL_ADDRESS) phdr[i].vaddr;
+ efi_printf("load_elf: read to %x\n", addr);
size = phdr[i].filesz;
stat = elf->Read(elf, &size, (VOID *)addr);
if (stat != EFI_SUCCESS) {