I use cygwin as a compiler, nasm as an assembler and ld as a linker.
I can easily jump to a c function from the assembler code, but i cannot go the other way round, the linker always gives an undefined referene error.
I have put a leading underscore in my asm code and i have defined my asm function as extern in my c code (and yes i have checked i haven't missed copied my functions name), but i still get a linker error.
There are no other assembler, compiler or linking errors.
Any ideas what the problem might be?
Thanks in advance,
Jules
linker problems
-
- Member
- Posts: 391
- Joined: Wed Jul 25, 2007 8:45 am
- Libera.chat IRC: aejsmith
- Location: London, UK
- Contact:
I would recommend building an ELF cross-compiler. In my experience Cygwin's compiler has many odd quirks. Basically, I think the problem is that it prepends all symbol names with a _, so when you have an extern for an ASM function, it will put a _ on it. You could try building your code with -fno-leading-underscore, though
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Have you defined the function in the assembler file as global. In C all functions and variables are defined as global by default but in assembler you must explicitly state it as global.
Nasm:
Nasm:
Code: Select all
global _c_function_to_call