public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Nobody in the world understands Gnu's 'ld'.
@ 1997-03-25 12:55 Ian Lance Taylor
  1997-03-25 20:52 ` Mr Taylor surely understands ld: a correction to my previous post root
  1997-03-25 23:17 ` Nobody in the world understands Gnu's 'ld' Fergus Henderson
  0 siblings, 2 replies; 24+ messages in thread
From: Ian Lance Taylor @ 1997-03-25 12:55 UTC (permalink / raw)
  To: root; +Cc: gnu-win32

In gnu-win32 root@jacob.remcomp.fr writes:

>Since several months people here report that Cygnus's linker is flawed.
>I think that it is just plain that Cygnus doesn't have the
>know-how to repair it, since Steve Chamberlain, the guy that
>wrote most of it, hasn't posted anything here since ages and
>he was very active before.

Let's not get carried away here.  I understand the linker perfectly
well, and so do a number of other people.

It's true that Steve Chamberlain left Cygnus a while ago.

If you look at the ChangeLog files, you can see who has been working
on the linker and other parts of BFD.  You'll see that although Steve
wrote most of the original code several years ago, he hasn't been
heavily involved with BFD or the linker for quite some time.

>Just to give you an idea, ld is supposed to link an object file
>from sun's unix format with some code from windows 95 and with
>some code of hp Unix. Of course this is ridiculous and it will never
>work, but this is how 'ld' is designed: an incredible complexity
>that (to me) seems completely unwarranted.

It's true that it is rare for people to link together different object
file formats.  However, you have missed the actual reasons for the
complexity.

The first reason is that the linker is able to generate an object file
format which is different from the input file formats.  For example,
this permits the linker to directly generate S-record output without
requiring a convertor.  This may not be too useful for native
programmers, but it is useful for embedded systems programmers.

The second reason is that a single linker binary can serve as the
linker for different targets.  The Linux people use this, for example:
the binary binutils distribution for Linux is built to support all the
various Linux targets in a single binary.

>It has a full blown LANGUAGE
>(with lex+yacc parser/lexer!) that is supposed to recognize linker
>commands. Obviously nobody ever uses it, but to understand
>what the linker is doing you have to go through yet another layer
>of complexity.

In fact, many people use the linker script language.  I can't imagine
why you think that nobody uses it.  Moreover, this is hardly a unique
or even unusual feature of the GNU linker: most linkers have a
scripting language, and the one used by the GNU linker is based on the
one used by the SVR3 linker.

>Then you have the 'BFD' format, that is supposed to be an universal
>binary format designed by GNU that will abstract the binary format
>of all machines in the western world into ONE format. Obviously
>it doesn't work, but then you have not only to understand what
>binary format you have in windows (what is difficult enough) but
>you have to understand BFD too.

In fact, BFD works quite well.  I don't know why you think that it
doesn't work.

It's not quite correct to describe BFD as abtracting all binary
formats into one format.  What it actually does is provide a library
interface which may be used to examine and generate an object file in
any format.

Mind you, I'm not going to defend the way that BFD is written.  There
is definitely a very steep learning curve before being able to program
using BFD.  I've tried to clean up some of the more egregious
problems.  Unfortunately, the cost of rewriting BFD is high.

>And to crown this beatiful construction there is NO DOCUMENTATION
>whatsoever about anything I have told you in this message. I inferred
>this from reading THE C CODE!!!

I'd love to have some documentation if you care to write some and
contribute it.  This is, after all, free software.  It improves by
contributions.

>That is why this linker can't even recognize MSVC object code
>format and use the MSVC .LIBs. Because nobody in the world
>is able to modify it. Of course we do not need compatibility
>with SUN or HP Unix under Windows 95. We would need MSVC
>compatibility. But to do that we would have to find somebody
>that understands 'ld'...

Well, all you need to do is add support for the object code format to
BFD.  I'm sorry you think that is impossible.  In fact, BFD supports a
number of object file formats already, including a.out, COFF, ELF,
IEEE-695, XCOFF, SOM, etc.  Adding another one is really not all that
difficult if you know what you are doing.

I'm always willing to answer specific questions about BFD and the
linker.  I'm not willing to give a tutorial on how to program it,
because I simply don't have the time.

I suppose I should add that my personal interest in adding MSVC object
support is nil.  I do work at Cygnus, but I don't work on gnu-win32,
and I have no idea whether Cygnus has any plans to do anything in this
area.

Ian
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 24+ messages in thread
* RE: Nobody in the world understands Gnu's 'ld'.
@ 1997-03-27  8:16 dahms
  0 siblings, 0 replies; 24+ messages in thread
From: dahms @ 1997-03-27  8:16 UTC (permalink / raw)
  To: jeff; +Cc: gnu-win32, dahms

Hi Jeff, you wrote:

:  I wrote some tools to convert any BFD supported object format into
: 'resources' for the USR Pilot PDA device
[snip]
Probably not really relevant for this thread, but anyway I'm curious
what this device is, please...


Bye, Heribert (dahms@ifk20.mach.uni-karlsruhe.de)
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 24+ messages in thread
* RE: Nobody in the world understands Gnu's 'ld'.
@ 1997-03-26  1:11 Sean McNeil
  0 siblings, 0 replies; 24+ messages in thread
From: Sean McNeil @ 1997-03-26  1:11 UTC (permalink / raw)
  To: gnu-win32, 'Tim Iverson'

I may take a stab at fixing the offset problem.  But since this feature
would only be used for a limited time here, I won't waste more than a few
hours on it.  If you really need this feature, don't hold your breath for a
patch from me.

Try the following:

*** gas/config/obj-coff.c~      Wed Dec 31 16:01:33 1969
--- gas/config/obj-coff.c       Sun Mar 23 14:20:52 1997
***************
*** 3176,3183 ****
--- 3176,3185 ----
      {
        long size;

+ #ifndef TE_PE
        segment_info[i].scnhdr.s_paddr = addr;
        segment_info[i].scnhdr.s_vaddr = addr;
+ #endif

        if (segment_info[i].scnhdr.s_name[0])
        {

-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 24+ messages in thread
[parent not found: <m0w9QZx-000AK1C.cygnus.gnu-win32@jacob.remcomp.fr>]
* Nobody in the world understands Gnu's 'ld'.
@ 1997-03-25 16:08 D. Jeff Dionne
  0 siblings, 0 replies; 24+ messages in thread
From: D. Jeff Dionne @ 1997-03-25 16:08 UTC (permalink / raw)
  To: gnu-win32

[stuff chopped]
> Since several months people here report that Cygnus's linker is flawed.
> I think that it is just plain that Cygnus doesn't have the
> know-how to repair it, since Steve Chamberlain, the guy that
> wrote most of it, hasn't posted anything here since ages and
> he was very active before.
> 

If this is indeed the case, this is IMHO unfortunate.  I wonder if
the departure has anything to do with the license nonsense Cygnus is
engaged in of late...  But on to 'ld' specific stuff...

[chop]
> 
> Just to give you an idea, ld is supposed to link an object file
> from sun's unix format with some code from windows 95 and with
> some code of hp Unix. Of course this is ridiculous and it will never
> work, but this is how 'ld' is designed: 

Oh rubbish.  The fact that 'ld' (or more correctly, BFD) supports _many_
file formats is absolutely _useful_.  On 68k I've used just about 
everything BFD has to offer, and would still be messing around with
little bits of custom code if it did'nt!

> an incredible complexity
> that (to me) seems completely unwarranted. It has a full blown LANGUAGE
> (with lex+yacc parser/lexer!) that is supposed to recognize linker
> commands. Obviously nobody ever uses it, but to understand
> what the linker is doing you have to go through yet another layer
> of complexity.

I must admit if I could find some docs on it, I'd be happy.  I could
always go read the yacc code, but I get on with it reasonably well so
far without.  This again is a _great_ thing, very useful.  Ppl (like
me) _do_ use it.

> 
> Then you have the 'BFD' format, that is supposed to be an universal
> binary format designed by GNU that will abstract the binary format
> of all machines in the western world into ONE format. Obviously
> it doesn't work, 

Not format.  Set of 'back ends' to any and all file formats with a consistant 
interface.  Works quite well, very useful.

> but then you have not only to understand what
> binary format you have in windows (what is difficult enough) but
> you have to understand BFD too.

Nonsense.  If you only need to understand the interface that BFD provides,
and in most cases not even the file format you're working with.  If you
just had a bunch of random functions that mess about with your file
format, you'd need to understand those and you've gained absolutly nothing.
Next file format, next set of nonsense.  BFD solves that.  It's not 
fundamentally BFD's fault if the Win32 implementation it has is broken...

[chop]
> 
> And to crown this beatiful construction there is NO DOCUMENTATION
> whatsoever about anything I have told you in this message. I inferred
> this from reading THE C CODE!!!

Actually, IMHO the construction _is_ nice, but the lack of accessable 
documentation is a hinderance to ppl using this stuff.  I wrote some
tools to convert any BFD supported object format into 'resources' for
the USR Pilot PDA device and had to rely on code from something else,
and a look at the headers to figure out what functions in libbfd.a to
call :-(  I would prefer to just build this stuff into BFD, but...
If the documentation does exist, it would be a great help if it could
be made more accessable (perhaps stick a pointer to it somewhere we
can find it easily)?

[chop]
> I think that anybody using 'ld' is living very dangerously...

'ld' is not perfect, and BFD seems to have a few inconsistant things in
the way it handles even (nornal) COFF files, and the situation is
frustrated by not being able to locate documenetation.  That having
been said, 'ld' (and BFD and the rest of binutils) are things I can't
live without when doing something more than just... ho hum... build
me an executable for a standard supported target.  When doing a new target
(like for instance the USR Pilot, or an embedded system), the flexibility
'ld' gives with it's little 'linker' language means I can build an 'ld'
_OUT OF THE BOX_ and produce _TARGET SPECIFIC_ output without modification
to it's code.  This is a plus.  I don't need to mess about with funny
conversion programs (they are taking about this over on the mc68332
list today) to make any kind of file format I want, or 5 of them, thanks
to BFD.  We need to get those docs accessable, though.

Jeff.

> 
> -- 
> Jacob Navia	Logiciels/Informatique
> 41 rue Maurice Ravel			Tel 01 48.23.51.44
> 93430 Villetaneuse 			Fax 01 48.23.95.39
> France
> -
> For help on using this list, send a message to
> "gnu-win32-request@cygnus.com" with one line of text: "help".
> 

-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 24+ messages in thread
* Re: Windows API calls that don't work? (Was RE: Stupid stupid question :/)
@ 1997-03-24  5:44 Jim Balter
  1997-03-25  0:50 ` Nobody in the world understands Gnu's 'ld' root
  0 siblings, 1 reply; 24+ messages in thread
From: Jim Balter @ 1997-03-24  5:44 UTC (permalink / raw)
  To: Colin Peters; +Cc: 'A. Phillip Smith', DRS, 'GNU-Win32'

Colin Peters wrote:
> 
> A. Phillip Smith[SMTP:asmith@www.aeinc.com] wrote:
> [snip]
> >of fact that the mere INCLUSION of a particular Win32 call caused the
> >GUI portion of a program to apparently fail (silent death). Note that
> >the code was NEVER invoked, as I stated, so usage errors are not at
> >issue.
> >
> >This is further complicted on Windows NT by the fact that unless you strip
> >the executable, the binary will not run. Hence you have no VCC++ debugging OR
> >gdb debugging capability. Here's another simple program in it's entirety.
> >Compile it per the gcc line. It works fine. Now uncomment the statement
> >containing the GetFullPathName call, and rebuild. If you get something
> >other than the "silent death" behaviour, please share it. This seems like
> >a bug to me, unless there's some other link options of which I'm unaware...
> [snip - Code example]
> 
> It doesn't seem to be a code generation problem, or at least not an easy
> one to reproduce. I must point out that I compiled with Mingw32 and not
> the normal Cygnus libraries, so there is some chance (small though it may
> be) that the Mingw32 environment removes or influences this bug in some
> strange way. Another possibility is that it is an NT thing, since I did
> the compile on 95 (where you don't have to strip to get a working exec
> either, so debugging is possible with GDB). Anyway the point is that it
> works, both ways, no problem. (The compile line under Mingw32 is slightly
> different, but essentially comes down to the same arguments for cc1 and
> ld).
> 
> Are you using a completely vanilla version of GNU-Win32 or have you made
> changes to things (like the startup code for example)? Could you send me
> a copy of your silently failing binary?
> 
> Colin (If it is a compiler bug lets find it and fix it) Peters.
> 
> PS. Any confirmations on that statement about NT from other readers?
>     Does stripping an executable make it work? Do you *have* to strip
>     on NT? Is there a difference between the -s link option and using
>     strip after linking?

Under NT 4.0, the program dies just by virtue of *referencing*
GetFullPathName, without calling it (as APS said).  The following
is enough to cause the access violation:

  #include <windows.h>

  void (*xxx)() = GetFullPathName;

  int STDCALL
  WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow)
  {
        return 0;
  }

I've tracked this down, and have determined that it dies with a SIGSEGV
which doesn't get printed anywhere because cygwin.dll prints it to
STD_ERROR_HANDLE, which isn't valid.  Clearly it should do better,
at the very least writing it to the strace output if that is a file, and
a
MessageBox would be nice.  A useful option would be to not set the
exception handler, so that the windows debugger would get it.
APS' complaint that silent exit is a bug is quite valid, but it isn't
something to be surprised about from alpha software like cygwin.dll.

The point at which it dies is the at the very beggining of main()
from libcmain.cc, when it calls GetModuleHandle.  That call goes to a
jump instruction that goes
through an indirect pointer that appears to contain the wrong
address, since it is the address of some code.  The jump uses the
content of that code as the "location" to go to, and so it
dies.  Perhaps to someone who knows about Windows dll's and jump tables,
the problem here might be obvious, but I know nothing of those things.
But it sure looks like a serious screwup by ld.

If someone wants to pursue this who can run the MS debugger under NT
4.0,
the easiest way is to build a version of cygwin.dll with the
init_exceptions call in dcrt0.cc commented out (or ignored based
upon an environment variable, so you can control it dynamically).


A word about the comments from drs@inxpress.net:

>>... I merely stated a point
>> of fact that the mere INCLUSION of a particular Win32 call caused the
>> GUI portion of a program to apparently fail (silent death). Note that
>> the code was NEVER invoked, as I stated, so usage errors are not at
>> issue.
>
> I would have to see this to believe it.

He gave an example.  His WinMain never gets called,
let alone the GetFullPathName call that triggers the problem.

>> Compile it per the gcc line. It works fine. Now uncomment the statement
>> containing the GetFullPathName call, and rebuild. If you get something
>> other than the "silent death" behaviour, please share it. This seems like
>> a bug to me, unless there's some other link options of which I'm unaware...
>
> The code you posted failed to work as expected, Phillip, because you 
> are not using it correctly. What you posted works exactly as advertized
> by the SDK. The API puts the path and the file-name together. That's it.
> It does not verify the presence of the file name. It is not a "search" 
> api at all. Granted, this is a pretty stupid behaviour, but then I'm not 
> an MS apologist. The API in question works correctly and compiles
> correctly
> under gnu-win32. You simply don't know how to use it.

Your arrogance is unwarranted and unearned.
His usage was perfectly reasonable, even if his comment that refers to
"search" is misleading.  In any case, his use or misuse is irrelevant
when the complaint was that the code died silently.  There is nothing
in any SDK that would indicate that MessageBoxes should never show up,
with not even a Dr. Watson popup.  The fact that the code works as
advertised on *your* system is irrelevant when the behavior of the code
on *APS's* system was described ("silent death") and is incorrect.

--
<J Q B>
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

end of thread, other threads:[~1997-03-29  0:06 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-25 12:55 Nobody in the world understands Gnu's 'ld' Ian Lance Taylor
1997-03-25 20:52 ` Mr Taylor surely understands ld: a correction to my previous post root
1997-03-27  8:16   ` Fergus Henderson
1997-03-25 23:17 ` Nobody in the world understands Gnu's 'ld' Fergus Henderson
1997-03-26 10:43   ` Joel Dinolt
1997-03-27  9:46     ` Fergus Henderson
1997-03-27 20:59   ` Pedro A. Aranda Gutiirrez
1997-03-27  9:46     ` Ian Lance Taylor
1997-03-28 10:32       ` Commercial Licensing David Essex
1997-03-28 19:43         ` Jim Balter
1997-03-29  0:06         ` Geoffrey Noer
1997-03-27 22:51   ` Nobody in the world understands Gnu's 'ld' Ian Lance Taylor
  -- strict thread matches above, loose matches on Subject: below --
1997-03-27  8:16 dahms
1997-03-26  1:11 Sean McNeil
     [not found] <m0w9QZx-000AK1C.cygnus.gnu-win32@jacob.remcomp.fr>
1997-03-25 20:11 ` Stan Shebs
1997-03-26  1:11   ` Jim Balter
1997-03-26 17:32     ` David Dyck
1997-03-26  5:02   ` Hans Zuidam
1997-03-26 17:32     ` Marcus G. Daniels
1997-03-26 17:58     ` Marcus G. Daniels
1997-03-25 16:08 D. Jeff Dionne
1997-03-24  5:44 Windows API calls that don't work? (Was RE: Stupid stupid question :/) Jim Balter
1997-03-25  0:50 ` Nobody in the world understands Gnu's 'ld' root
1997-03-25 16:08   ` Tim Iverson
1997-03-26  9:44   ` Fergus Henderson

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).