[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
multiboot elf loader fails if file class (32/64bit) is different than ho
From: |
Thomas Haller |
Subject: |
multiboot elf loader fails if file class (32/64bit) is different than host |
Date: |
Tue, 20 Sep 2011 16:11:58 +0200 |
User-agent: |
RoundCube Webmail/0.3.1 |
Hello GRUB developers,
i'am trying to boot a self developed kernel with grub in bochs. The kernel
image is an x86_64 elf file. "readelf -h" output is:
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x10000c
Start of program headers: 64 (bytes into file)
Start of section headers: 24784 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 2
Size of section headers: 64 (bytes)
Number of section headers: 11
Section header string table index: 10
I'am using grub 1.99 compiled for i386-pc. The output after "multiboot
/boot/kernel" is "error: invalid offset in section header.". I found out
that grub uses the 32bit Elf_Shdr structure even if the file is 64bit. My
patch proposal is to apply the same handling as Elf_Ehdr or Elf_Phdr to
Elf_Shdr too.
diff -ruN grub-1.99/grub-core/loader/multiboot_elfxx.c
grub-1.99_new/grub-core/loader/multiboot_elfxx.c
--- grub-1.99/grub-core/loader/multiboot_elfxx.c 2010-12-01
15:45:43.000000000 +0100
+++ grub-1.99_new/grub-core/loader/multiboot_elfxx.c 2011-09-20
15:57:02.000000000 +0200
@@ -22,12 +22,14 @@
# define ELFCLASSXX ELFCLASS32
# define Elf_Ehdr Elf32_Ehdr
# define Elf_Phdr Elf32_Phdr
+# define Elf_Shdr Elf32_Shdr
#elif defined(MULTIBOOT_LOAD_ELF64)
# define XX 64
# define E_MACHINE MULTIBOOT_ELF64_MACHINE
# define ELFCLASSXX ELFCLASS64
# define Elf_Ehdr Elf64_Ehdr
# define Elf_Phdr Elf64_Phdr
+# define Elf_Shdr Elf64_Shdr
#else
#error "I'm confused"
#endif
@@ -223,3 +225,4 @@
#undef ELFCLASSXX
#undef Elf_Ehdr
#undef Elf_Phdr
+#undef Elf_Shdr
Thanks in advance,
Thomas Haller
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- multiboot elf loader fails if file class (32/64bit) is different than host,
Thomas Haller <=