I'm getting linker error - "undefined reference to '_do_something'".
So I've changed asm file by adding _ before both do_something but I'm still getting the same error. Anybody know what I'm doing wrong?
this tells the C++ compiler not to use mangling when looking for do_something
Well I'm using C compiler and when I try to do something like that I'm getting "syntax error before string constant". The funniest thing is that under linux it's working just fine. Only under windows (djgpp) I'm having such problems.
Solar wrote:
Did you add the underscore both to the "GLOBAL" statement and the function label?
Yes I did.
Solar wrote:
To avoid the whole issue, use your original code, and force the C compiler not to use leading underscores: [tt]gcc -fno-leading-underscore ...[/tt]
I tried that too with no effect - getting "undefined reference to 'do_something'" >:(
Well, I don't have DJGPP at hand, and the Cygwin 'ld' chokes on the classic "PE operation on non-PE file".
But [tt]objdump -t entry.o[/tt] and [tt]objdump -t kernel.o[/tt] will show you the symbol tables of the object files. It turns out the Cygwin gcc at least is happily ignoring -fno-leading-underscores...
Every good solution is obvious once you've found it.
-fleading-underscore
This option and its counterpart, -fno-leading-underscore, forcibly change the
way C symbols are represented in the object file. One use is to help link with
legacy assembly code.
Warning: the -fleading-underscore switch causes GCC to generate code that is not
binary compatible with code generated without that switch. Use it to conform to
a non-default application binary interface. Not all targets provide complete
support for this switch.