delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/08/13/10:10:47

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <4A8421F9.7060605@gmail.com>
Date: Thu, 13 Aug 2009 15:23:53 +0100
From: Dave Korn <dave DOT korn DOT cygwin AT googlemail DOT com>
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Unable to link
References: <4A82DC03 DOT 7040800 AT gmail DOT com> <4A82E3ED DOT 9020406 AT gmail DOT com> <a5e176f80908122305m33bb50baj38553a94e78cba74 AT mail DOT gmail DOT com>
In-Reply-To: <a5e176f80908122305m33bb50baj38553a94e78cba74@mail.gmail.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

Javier Sedano wrote:

>   On a first though I was about to say "no"... but on second though...
> not sure. I've got several .s files (assembly code) that seems to be
> hand-written (they have lots of the kind of comments that humans use
> to do, so does not seem to be compiled). See trace below.

  There ya go.  They're hand-written according to Linux conventions.

>   So let's see if I understand the problem: when I define (and
> implement) a function f1(), gcc on Linux will use the name f1 for the
> function, but gcc on cygwin will use _f1. So if my .s has been created
> with Linux on mind, the developer used f1, and cygwin can not find it.
> Right so far?

  Yep, spot on.

>   So any other idea? Any modifier to gcc not to use the leading _?

  Well.  You could hack your .S file and add leading underscores.  Or you
could write a .h header file that declares prototypes of all the functions,
and uses GCC's 'asm ("name")' extension to specify the assembler names as the
non-underscored versions.

  Or, you could try the -fno-leading-underscore switch, but then that would
break your code in a whole world of other ways because it wouldn't be able to
link against any of the standard cygwin functions!

  However, you have larger problems than that.  This assembly code is
hand-written for linux.  Now, ...

> # ----------------------------------------------------------------------
> # Does nothing
> # ----------------------------------------------------------------------
> testBP_1:
>         ret

... something as simple as that will assemble and work just fine on Cygwin.
But anything much more complex is liable to run into problems.  For example,
on Linux you use the "int 80" instruction to perform a syscall; on Cygwin, you
just call a subroutine like any other.  The compatibility between Cygwin and
Linux exists at the C source-code level (and above), but under the hood, in
assembly world, it's very different.  That's why you need to recompile stuff
on Cygwin; the actual machine code that's generated is very different.

  You will almost certainly need to write a windows-specific version of the .S
files to make this work.  How complex or tricky that is I can't guess as it
depends entirely on the complexity of the .S files you need to translate.
Sorry not to have better news for you.

    cheers,
      DaveK



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


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