[Help] LD is saying undefined reference.
Posted: Thu Jan 24, 2019 11:08 pm
Hey guys,
It's been about eight years since I last did anything OS Dev related, and I want to get back into it. I'm taking baby steps to refresh my memory; however, I'm running into an issue with linking that I can't figure out. Whenever I try to link my object files, I get this error in the terminal:
I'm running 64-bit Linux Mint in Parallels on Mac OS X.
I have start.asm with this snippet of code:
To compile the asm file, I'm using this:
main.c
To compile main.c, I'm using these arguments:
Finally, to link them, I'm using this:
Is the error caused to the way I'm compile my ASM, linking my files, or the way I'm calling an external function from Assembly?
Thanks for all the help! It's going to take a little bit to get back in the grove of things.
I'm also going based off of Bran's Kernel Development guide (figured that might be a decent place to start with a memory refresher)... although, a lot of it seems questionable. Does anyone have any opinions on that guide?
It's been about eight years since I last did anything OS Dev related, and I want to get back into it. I'm taking baby steps to refresh my memory; however, I'm running into an issue with linking that I can't figure out. Whenever I try to link my object files, I get this error in the terminal:
Code: Select all
start.o: In function `stublet':
start.asm:(.text+0x29): undefined reference to `_main'
I have start.asm with this snippet of code:
Code: Select all
stublet:
extern _main
call _main
jmp $
Code: Select all
nasm -f elf64 -o start.o start.asm
Code: Select all
void main(){
...
}
Code: Select all
gcc -Wall -o -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c
Code: Select all
ld -T linker.ld -o kernel.bin start.o main.o
Thanks for all the help! It's going to take a little bit to get back in the grove of things.
I'm also going based off of Bran's Kernel Development guide (figured that might be a decent place to start with a memory refresher)... although, a lot of it seems questionable. Does anyone have any opinions on that guide?