The script is :
Code: Select all
ENTRY(_start)
SECTIONS
{
. = 1M;
.text BLOCK(4K) : ALIGN(4K)
{
*(.multiboot)
*(.text)
}
.rodata BLOCK(4K) : ALIGN(4K)
{
*(.rodata)
}
.data BLOCK(4K) : ALIGN(4K)
{
*(.data)
}
.bss BLOCK(4K) : ALIGN(4K)
{
*(COMMON)
*(.bss)
}
end = .;
}
Now :
1. Linking like this :
Code: Select all
clang --target=i686-pc-none-elf -march=i686 -T linker.ld -o myos.bin -ffreestanding -O2 -nostdlib *.o -lgcc
Code: Select all
/usr/bin/ld: boot.o: warning: relocation in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
However, the hello world boots as it should, and I don't know what these warnings are so ...?
2. Linking like above (or even like below) but with the -static option gives 0 warnings ; but grub tells me "multiboot header not found".
3. Linking like first but with an added
Code: Select all
-fuse-ld=lld
Code: Select all
ld.lld: error: linker.ld:7: unknown section directive: 4K
All above being done on Arch Linux , Linux lts 5.10.21-1 , Clang 11.1.0 (from the Arch repo) , i686-elf-gcc 10.2.0 from the GNU mirror, Binutils 2.36.1 with pretty much a hello world kernel.
As would be obvious, I am quite new here, though by no means ignorant. Thanks a lot for help in advance !
P.S : The assembly "boot.s" that I am using (same as the Barebones one) :
Code: Select all
.set ALIGN, 1<<0
.set MEMINFO, 1<<1
.set FLAGS, ALIGN | MEMINFO
.set MAGIC, 0x1BADB002
.set CHECKSUM, -(MAGIC + FLAGS)
.section .multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
.section .bss
.align 16
stack_bottom:
.skip 16384 # 16 KiB
stack_top:
.section .text
.global _start
.type _start, @function
_start:
mov $stack_top, %esp
call kernel_main
cli
1: hlt
jmp 1b
.size _start, . - _start