delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/05/03/00:53:52

From: dph-man AT iName DOT com (Peter Hawkins)
Subject: ld bug? calling one assembly routine from another...
3 May 1998 00:53:52 -0700 :
Message-ID: <354BE77D.3E445DB1.cygnus.gnu-win32@iname.com>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

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 AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019