I've been working on moving my OS to a new repository and setting up CI. I was doing some local Docker testing when I discovered that the toolchain I built in my container would not produce a viable ELF file (it was not Multiboot compatible)
I opened a hex editor and took a look for the multiboot signature and found it positioned at 0x100000 in terms of file offset, so the file was now 1MB larger and totally invalid.
readelf gave the following output:
Code: Select all
Elf file type is EXEC (Executable file)
Entry point 0x100098
There is 1 program header, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000156218 0x00000000001c2971 RWE 0x1000
Here's my linker script:
Code: Select all
OUTPUT_FORMAT(elf64-x86-64)
ENTRY(_start)
SECTIONS
{
/* Kernel is loaded at 1M */
. = 1M;
__kernel_start = .;
/* Code section */
.text BLOCK(4K) : ALIGN (4k)
{
__multiboot_start = .;
KEEP(*(.multiboot))
__multiboot_end = .;
__bootstrap_start = .;
*(.bootstrap)
__bootstrap_end = .;
__text_start = .;
*(.text)
__text_end = .;
__ap_start = .;
*(.ap_bootstrap)
__ap_end = .;
}
/* Read-only data */
.rodata BLOCK(4K) : ALIGN(4K)
{
__rodata_start = .;
*(.rodata)
__rodata_end = .;
}
/* Initialized data */
.data BLOCK(4K) : ALIGN(4K)
{
__data_start = .;
*(.data)
__data_end = .;
}
/* BSS */
.bss BLOCK(4K) : ALIGN(4K)
{
__bss_start = .;
*(COMMON)
*(.bss)
__bss_end = .;
}
__kernel_end = .;
}