Page 1 of 1

ld links wrong call address form asm to c

Posted: Wed Feb 02, 2011 2:56 pm
by Paulus
Hello

I have a big problem with calls from asm code to c code.
If calls are from c code everything is ok.

That is my start.asm:

Code: Select all

bits 32
section .text
align 4

global Start
Start:
    cli           
extern _kernel_main	
    call _kernel_main
	nop
	jmp $
That is the begining of my kernel after disassemble:

Code: Select all

seg000:00010000                 cli
seg000:00010001                 call    near ptr unk_1000A ;<---------------------- This is a invalid call address
seg000:00010006                 nop
seg000:00010007
seg000:00010007 loc_10007:                              ; CODE XREF: seg000:loc_10007j
seg000:00010007                 jmp     short loc_10007
seg000:00010007 ; ---------------------------------------------------------------------------
seg000:00010009                 db    0
seg000:0001000A unk_1000A       db    0                 ; CODE XREF: seg000:00010001p
seg000:0001000B                 db    0
seg000:0001000C                 db    0
seg000:0001000D                 db    0
seg000:0001000E                 db    0
seg000:0001000F                 db    0
seg000:00010010 ; ---------------------------------------------------------------------------
seg000:00010010                 sub     esp, 0Ch               ;<-----------------------_kernel_main  start here
seg000:00010013                 call    sub_101E0
Why that address is invalid? How can i fix it?
I have the same problem with irq's. Assembler handler fails to call c handler.

i'm using nasm and cygwin.

Thank you in advance.
Sorry for mistakes, i'm not very good at English.

Re: ld links wrong call address form asm to c

Posted: Thu Feb 03, 2011 7:27 am
by Tosi
It looks like you are using the GCC that came with Cygwin, which is intended for porting *nix applications to Windows. It is inserting function calls and data intended for that setup. Either use a cross compiler or pass the right command-line options to get the compiler to keep from adding things.

Re: ld links wrong call address form asm to c

Posted: Thu Feb 03, 2011 9:33 am
by Solar