I am writing a hobby OS. I would like to include a small
asm program into my main kernel
elf that can serve as the first process to load.
I am having trouble getting this to work.
The program is
initcode.s. I using the following
Makefile (which I modified from the xv6 os source) for this task:
$(AS) $(ASFLAGS) initcode.s -o initcode.o
ld $(LDFLAGS) -N -e start -Ttext 0 -o initcode initcode.o
objcopy --input binary --output elf32-i386 --binary-architecture i386 initcode.out initcode
kernel.elf: $(OBJECTS) initcode
ld -T link.ld -melf_i386 $(OBJECTS) -o kernel.elf initcode
The main kernel compiles and links fine.
objcopy also creates markers which enable me to find the binary from within the kernel code. However the contents of
initcode is trashed, the contents does not resemble what the assembler step produced (
How can I achieve my goal: include
initcode.s as a separate binary somewhere in my main
kernel.elf with some markers generated so I can find it from within my kernel.