Subject: ld bug? calling one assembly routine from another...
From: [email-masked] (Peter Hawkins)

3 May 1998 00:53:52 -0700
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

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
"[email-masked]" with one line of text: "help".