public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* ld COFF processing
@ 2000-09-01 17:37 Serban Simu
  2000-09-01 17:39 ` DJ Delorie
  0 siblings, 1 reply; 4+ messages in thread
From: Serban Simu @ 2000-09-01 17:37 UTC (permalink / raw)
  To: cygwin

I'm trying to use ld on a Windows NT object file produced with cl. The
problems that I have are related to the fact that ld removes some of the
sections from the output file, which causes further link to fail.

Here is a simple example:

$ cl /c s.cpp		(produces s.obj)
$ ld -o s.a -r s.obj	(produces s.a)

Linking against s.a, using Microsoft's 'cl' works in most of the simple
cases, although the ld operation removed some of the sections. I have also
tried the --oformat pe-i386 and -m i386pe with the same effect. In case
s.cpp uses exceptions, 'cl' creates a special section .xdata$x and a .text$x
which are not put in the output file.

My question is, to what extent is the pe-i386 format compatible with the
Microsoft format?

Thank you for your help with that!

Serban


-----------
Versions used:

cl:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

ld:
GNU ld version 19990818 (with BFD 19990818)


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ld COFF processing
  2000-09-01 17:37 ld COFF processing Serban Simu
@ 2000-09-01 17:39 ` DJ Delorie
  2000-09-08  9:54   ` Serban Simu
  0 siblings, 1 reply; 4+ messages in thread
From: DJ Delorie @ 2000-09-01 17:39 UTC (permalink / raw)
  To: serban; +Cc: cygwin

> $ ld -o s.a -r s.obj	(produces s.a)
>
> My question is, to what extent is the pe-i386 format compatible with the
> Microsoft format?

The formats are compatible, but you're using the tools wrong.  The
"ar" program creates libraries, not the "ld" program.  Please read the
documentation for the tools for further instructions.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: ld COFF processing
  2000-09-01 17:39 ` DJ Delorie
@ 2000-09-08  9:54   ` Serban Simu
  2000-09-08 10:16     ` DJ Delorie
  0 siblings, 1 reply; 4+ messages in thread
From: Serban Simu @ 2000-09-08  9:54 UTC (permalink / raw)
  To: DJ Delorie; +Cc: cygwin

Thanks for the answer.

I have actually put the problem wrong. What I'm trying to do, is to process
the object files using ld. I'll list my reasons below. My intention is not
to build an archive library (with ar).

On Linux, the command that I mentioned produces new.obj, identical with
s.obj, same sections, symbols, etc:
	$ ld -o new.obj -r s.obj

On NT, when s.obj is compiled with Microsoft tools (cl) it can have, for
example, many .text sections and
some other special sections. After issuing the above mentioned command, the
output object file has many sections less (for example only one section
.text and the special sections missing) and is considerably smaller in size.
A lot of information from the COFF PE object file is lost once it's passed
through ld.

Also, the object file produced on NT can't be linked again using Microsoft
'link', which reports an internal error.

My question is if there is any way that ld on NT can link and produce a
relocatable (ld -r) output object file in the same way it does on Linux? Is
there an NT usage restriction that says: don't use 'ld -r' with object files
created with 'cl /c'?

I would also appreciate if anyone could point me to an ld or a bfd patch to
solve this problem!

Thanks!

-Serban

P.S. Although unrelated directly to this mailing list, here is the reason I
want to use 'ld -r' instead of creating an archive with 'ar'. I need to
create a static library without exposing the internal symbol names but only
the exportable symbol names. The internal symbols cannot be stripped out
(using 'strip' or ld options) because they are needed for the relocation. I
modified ld (actually the bfd backend) to change symbol names as it creates
the output file. However, the problem I exposed is experienced with the
unmodified Cygwin ld.








> -----Original Message-----
> From: DJ Delorie [ mailto:dj@delorie.com ]
> Sent: Friday, September 01, 2000 5:40 PM
> To: serban@digitalfountain.com
> Cc: cygwin@sourceware.cygnus.com
> Subject: Re: ld COFF processing
>
>
>
> > $ ld -o s.a -r s.obj	(produces s.a)
> >
> > My question is, to what extent is the pe-i386 format compatible with the
> > Microsoft format?
>
> The formats are compatible, but you're using the tools wrong.  The
> "ar" program creates libraries, not the "ld" program.  Please read the
> documentation for the tools for further instructions.
>


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ld COFF processing
  2000-09-08  9:54   ` Serban Simu
@ 2000-09-08 10:16     ` DJ Delorie
  0 siblings, 0 replies; 4+ messages in thread
From: DJ Delorie @ 2000-09-08 10:16 UTC (permalink / raw)
  To: serban; +Cc: cygwin

OK, It probably should work, but it's so rarely used that way that
it's likely to not work.  NT adds a lot of additional section
information that the linker barely knows about.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-09-08 10:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-01 17:37 ld COFF processing Serban Simu
2000-09-01 17:39 ` DJ Delorie
2000-09-08  9:54   ` Serban Simu
2000-09-08 10:16     ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).