This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

ld bug? calling one assembly routine from another...


Hi there... (I hope i'm not generating too much traffic..)

I think I've discovered a bug in the linker which comes with the EGCS
1.0.2 distribution of Mingw32 (not sure whether it applies to cygwin32
versions), when linking object files created with Nasm v0.97. Nasm can
be obtained from http://www.cryogen.com/nasm/

Compile the following files like so:
nasmw -f coff t1.nas
nasmw -f coff t2.nas
gcc -c t.c -o t.o
gcc t1.o t2.o t.o -o test.exe

This produces a test.exe which crashes. (my version caused the call in
t1.nas to call to an address 1 byte after the call itself, which is in
the middle of the call instruction).

I believe the bug must be related to win32 gnu ld, rather than nasm, as
the DJGPP linker has no such problem. (admittedly the DJGPP linker
version is older than my win32 version).

; t1.nas
[BITS 32]

[GLOBAL _moofle]
[EXTERN foom]

[SECTION text]
_moofle:
; int 3 ; If you want to run under a debugger and watch this happening
 nop
 call foom
 nop
 nop
 ret

; t2.nas
[BITS 32]
[GLOBAL foom]
[SECTION text]
foom:
nop
nop
nop ; nops to pad out the function a bit
nop
nop
nop
ret

// t.c
extern void moofle(void);
main()
{
 moofle();
}

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]