as I read the OSDEV Linker Scripts Wiki article while I rewrote my linker script (in fact I am rewriting my whole kernel - wich isn't so much since I just began with this all a few weeks ago) I wanted to try out the STARTUP expression in ld. - Sounded right to ensure that the assembly loader is right at the beginning of the binary. If I insert the STARTUP (loader.o) expression to my linker.ld file I get the following errors by the compiler:
Code: Select all
nasm -f elf -o loader.o loader.s
gcc -m32 -Wall -Wextra -nostdlib -nostdinc -fno-builtin -nostartfiles -nodefaultlibs -ffreestanding -fno-stack-protector -I ./include/ -I ./HAL/ -o init.o -c init.c
ld -melf_i386 -T linker.ld -o kernel.img loader.o init.o
loader.o: In function `loader':
loader.s:(.text+0x0): multiple definition of `loader'
loader.o:loader.s:(.text+0x0): first defined here
loader.o: In function `hltLoop':
loader.s:(.text+0xc): multiple definition of `hltLoop'
loader.o:loader.s:(.text+0xc): first defined here
Code: Select all
global loader
global hltLoop
; some expressions for multiboot standard compliance
section .text
loader:
; load C kernel
hltLoop:
hlt
jmp hltLoop
The interesting thing is that the info utility of my archlinux says the following when I invoke "info ld" and search for "STARTUP":
As you see in the invocation of the linker, the loader.o file is already specified first on the command line. The STARTUP expression shouldn't make any difference - but if I remove the STARTUP expression everything works fine.'STARTUP(FILENAME)'
(...)
FILENAME will become the first input file to be linked, as though
it were specified first on the command line.
(...)
I feel betrayed by the linker.
I feel betrayed by the info utility.
I feel betrayed by google.
Maybe someone can bring a little light into my dark.
If you need more information just ask. Thanks for reading until down here
Have a nice day, weekend, evening, night. (Choose appropriate.)
Lasse