os01
os01 copied to clipboard
Fails to be built on latest Ubuntu 17.10
I get this on building chapter 8 code:
make all make -C bootloader make[1]: Entering directory '/home/bhaisaab/Lab/oslab/os01/code/chapter8/os/bootloader' nasm -f elf bootloader.asm -F dwarf -g -o ../build/bootloader/bootloader.o ld -m elf_i386 -T bootloader.lds ../build/bootloader/bootloader.o -o ../build/bootloader/bootloader.o.elf objcopy -O binary ../build/bootloader/bootloader.o.elf ../build/bootloader/bootloader.o make[1]: Leaving directory '/home/bhaisaab/Lab/oslab/os01/code/chapter8/os/bootloader' make -C os make[1]: Entering directory '/home/bhaisaab/Lab/oslab/os01/code/chapter8/os/os' gcc -ffreestanding -nostdlib -m32 -gdwarf-4 -ggdb3 -m32 -c main.c -o ../build/os/main.o ld -m elf_i386 -nmagic -Tos.lds ../build/os/main.o -o ../build/os/os ld: ../build/os/os: error: PHDR segment not covered by LOAD segment ld: final link failed: Invalid operation Makefile:15: recipe for target '../build/os/os' failed make[1]: *** [../build/os/os] Error 1 make[1]: Leaving directory '/home/bhaisaab/Lab/oslab/os01/code/chapter8/os/os' Makefile:14: recipe for target 'os' failed make: *** [os] Error 2
On running the existing disk.img, qemu complains:
qemu-system-i386 -fda disk.img 130 ↵ WARNING: Image format was not specified for 'disk.img' and probing guessed raw. Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted. Specify the 'raw' format explicitly to remove the restrictions. qemu-system-i386: Trying to execute code outside RAM or ROM at 0x000a0000 This usually means one of the following happened:
I solved the problem with this linker script:
ENTRY(main);
PHDRS
{
code PT_LOAD;
headers PT_PHDR FILEHDR PHDRS;
}
SECTIONS
{
.text 0x500: { *(.text) } :code
.data : { *(.data) }
.bss : { *(.bss) }
/DISCARD/ : { *(.eh_frame) }
}
Hope this can help
@sjx233, why did just swapping the entris in PHDRS work?
thanks
@sjx233, why did just swapping the entris in
PHDRSwork? thanks
error: PHDR segment not covered by LOAD segment
I swapped these segments according to the error message, and it worked magically. 😃
lol oqee :joy: I'm searching for the reason of the error and found nothing so far