This is the mail archive of the cygwin 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]
Other format: [Raw text]

Re: Unable to link

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.


Problem reports:
Unsubscribe info:

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