Page 1 of 1

Can't link!

Posted: Fri Mar 26, 2004 8:55 am
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 :-[

Re:Can't link!

Posted: Fri Mar 26, 2004 8:57 am
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.. :/

Re:Can't link!

Posted: Fri Mar 26, 2004 9:14 am
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

Re:Can't link!

Posted: Fri Mar 26, 2004 9:35 am
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...

Re:Can't link!

Posted: Fri Mar 26, 2004 10:21 am
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.

Re:Can't link!

Posted: Fri Mar 26, 2004 10:23 am
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...

Re:Can't link!

Posted: Fri Mar 26, 2004 1:55 pm
by mr. x2
It's working now, had to remove those _ as pype said.