Skip to content
Snippets Groups Projects
Commit bf2c6bae authored by Avi Kivity's avatar Avi Kivity
Browse files

build: keep elf64 headers in memory image

We need the headers so we can provide the symbols to loaded libraries.
This means we cannot use objcopy to munge the binary format to elf32-i386,
as the loader doesn't understand this format.

Instead, add a separate 32-bit only stage (in elf32-i386 format) that loads
the 64-bit image into memory as its payload.  This keeps multiboot happy and
leave our headers alone.
parent 5e3836b0
No related branches found
No related tags found
No related merge requests found
...@@ -6,8 +6,11 @@ autodepend = -MD $(@.o=.d) -MT $@ ...@@ -6,8 +6,11 @@ autodepend = -MD $(@.o=.d) -MT $@
all: loader.bin all: loader.bin
loader.bin: loader.elf loader.bin: arch/x64/boot32.o arch/x64/loader32.ld
objcopy -O elf32-i386 $^ $@ $(LD) -nostartfiles -static -nodefaultlibs -o $@ \
$(filter-out %.bin, $(^:%.ld=-T %.ld))
arch/x64/boot32.o: loader.elf
fs = fs/fs.o fs/bootfs.o bootfs.o fs = fs/fs.o fs/bootfs.o bootfs.o
......
...@@ -2,14 +2,6 @@ ...@@ -2,14 +2,6 @@
.text .text
.code32 .code32
mb_magic = 0x1BADB002
mb_flags = 0x00000001 # flags: 4k module alignment
multiboot:
.long mb_magic
.long mb_flags
.long 0-mb_magic-mb_flags
.data .data
.align 4096 .align 4096
ident_pt_l4: ident_pt_l4:
......
.text
.code32
mb_magic = 0x1BADB002
mb_flags = 0x00000001 # flags: 4k module alignment
multiboot:
.long mb_magic
.long mb_flags
.long 0-mb_magic-mb_flags
.global start32
start32:
jmp *24+elf64_header
.align 4096
elf64_header:
.incbin "loader.elf"
OUTPUT_FORMAT(elf32-i386)
SECTIONS
{
.text 0x1ff000 : { *(.text*) }
}
ENTRY(start32);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment