Can't link!

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
mr. x2

Can't link!

Post by mr. x2 »

I'm now converting from Windows to Linux and I tried to compile my kernel the other day... not very good results :/
Everything worked well, except when I tried to link files that used files assembled by nasm.

Here's how I make the whole thing:

Code: Select all

nasm -f aout kinit.asm
nasm -f aout kints.asm
gcc -nostartfiles -nostdlib -fno-builtin -fwritable-strings -c source/*.c
ld -T kernel.ld
I think there's no need to show my kernel.ld, because it's working in linux with djgpp... but tell me if you want to see it :)

PS: I'm posting as mr. x2 because I've forgotten my password :-[
mr. x2

Re:Can't link!

Post by mr. x2 »

Oh, something else I forgot: to tell you my errors ;)

sched.o(.text+0x302): In function `Schedule':
: undefined reference to `task_switch'

Hmm, now I see there's other .o's that are compiled by gcc that can't be accessed either.. :/
Ozguxxx

Re:Can't link!

Post by Ozguxxx »

Well Im not very good at linkers stuff but I cannot see what you are linking -the object *.o files- while calling ld.
I mean
ld -T kernel.ld
should be like:
ld -T kernel.ld sched.o kernel.o process.o foo.o
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Can't link!

Post by Pype.Clicker »

another thing that might be of importance is that DjGpp usually prepends some underscore before any C name while linux gcc doesn't. Don't complain about it: they're from different worlds and respect different ABI standards.

The easiest workaround for you is to edit your ASM sources and remove any underscore (you'll now have "call main" rather than "call _main") and use the -f-no-leading-underscore flag for GCC if you ever want to compile under DjGpp again...
mr. x2

Re:Can't link!

Post by mr. x2 »

Ozguhn: nah, I have INPUT entries in my linker script...

It didn't get better after removing all _'s, I think not anyway.
mr. x2

Re:Can't link!

Post by mr. x2 »

Code: Select all

OUTPUT_FORMAT("binary")
ENTRY(start)   
OUTPUT("kernel.bin")

INPUT(kinit.o)
INPUT(kints.o)
INPUT(ints.o)
INPUT(driver_keyboard.o)
INPUT(driver_floppy.o)
INPUT(kernel.o)
INPUT(app_console.o)
INPUT(io.o)
INPUT(pic.o)
INPUT(idt.o)
INPUT(panic.o)
INPUT(doprintf.o)
INPUT(queue.o)
INPUT(string.o)
INPUT(memory.o)
INPUT(math.o)
INPUT(dma.o)
INPUT(driver_pefs.o)
INPUT(timer.o)
INPUT(mem_manager.o)
INPUT(driver_layers.o)
INPUT(sched.o)
INPUT(driver_FAT.o)
INPUT(driver_fs.o)
INPUT(driver_dev.o)
INPUT(config_parser.o)
Upper part of my kernel.ld...
mr. x2

Re:Can't link!

Post by mr. x2 »

It's working now, had to remove those _ as pype said.
Post Reply