Linking C and ASM
Posted: Thu Aug 01, 2002 7:58 pm
I'm making a small Pmode kernel, and I can't seem to be able to link a compiled C file with a compiled ASM file!
What I am trying to do is have my ASM file be the 'start' of the kernel. inside the asm file, it calls a function from the C file.
I can't get them to link right. Here is my ASM code:
EXTERN _test
call _test
jmp $ ;hang
There is my C file:
void test() {
//Code Here
}
I am compiling the c file like this : gcc -O3 -c kernel_c.c
I am compiling the ASM like this: NASM -f obj kernel.asm
I am linking them with jloc like this: JLOC kernel.ld kernel.bin
The linker control file (kernel.ld) looks like this:
ALL:
kernel.obj
kernel_c.o
START: 0,0FF800000
,,code,,kernel.obj
CODE: 0
,,code
DATA: 0,#10
,,data
BSS: 0,#10
,,bss
(BTW, this is a Protected Mode Kernel loaded from the bootf02 bootstrap)
What am I doing wrong here? When I try to link it, it tells me that there are 'overlapping chunks' and 'unable to assign section for: ALL, kernel.obj, _NASMDEFSEG'
How do I link a C and an ASM file together and have the ASM file be the beginning of the kernel?
What I am trying to do is have my ASM file be the 'start' of the kernel. inside the asm file, it calls a function from the C file.
I can't get them to link right. Here is my ASM code:
EXTERN _test
call _test
jmp $ ;hang
There is my C file:
void test() {
//Code Here
}
I am compiling the c file like this : gcc -O3 -c kernel_c.c
I am compiling the ASM like this: NASM -f obj kernel.asm
I am linking them with jloc like this: JLOC kernel.ld kernel.bin
The linker control file (kernel.ld) looks like this:
ALL:
kernel.obj
kernel_c.o
START: 0,0FF800000
,,code,,kernel.obj
CODE: 0
,,code
DATA: 0,#10
,,data
BSS: 0,#10
,,bss
(BTW, this is a Protected Mode Kernel loaded from the bootf02 bootstrap)
What am I doing wrong here? When I try to link it, it tells me that there are 'overlapping chunks' and 'unable to assign section for: ALL, kernel.obj, _NASMDEFSEG'
How do I link a C and an ASM file together and have the ASM file be the beginning of the kernel?