This is the mail archive of the mailing list for the GCC 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: [PATCH, driver] -Wl, passing empty strings to ld

On Thu, 2010-04-15 at 12:09 +0200, Paolo Bonzini wrote:
> I don't follow, it would be a 0 character string in argv. '' or "" is 
> exactly how you put a zero-length string on the command-line.

If you give a command like "ld -o '' tmp.o" then you will get

The command "gcc -Wl,-o, tmp.o" will give

There is a big difference here.  The second one has a zero-length string
as argv[2].  The first one doesn't.  It is this zero-length string that
is the problem, as it is confusing ld.  It is impossible to get a
zero-length string in argv[] from a shell command line, so ld has no
support for it.

> That's just how the shell works.  You can pass s/abc// or s,abc,, to sed 
> or vi and it does exactly what you'd think, I don't see why gcc's 
> -W[alp],arg1,arg2,...,argN options should be different.

There are two major differences here.
1) s/abc// has a well defined and useful meaning.  -Wl,, does not have a
well defined meaning, and has no useful meaning.
2) sed handles s/abc// internally without error.  gcc does not handle
-Wl,, internally without error, it constructs a broken argv array that
gets passed to ld, triggering an error in ld.

The problem can not be fixed in ld, as all ld can see is that it has an
broken argv array.  The only place where we can reasonably handle this
is inside gcc, by not passing a broken argv array to the linker in the
first place.

I'm having trouble understanding why you can't see this.  I think if you
take a look at what is actually happening in the code, as I have, it
should be clear that it is broken, and that it has to be fixed in gcc.
It isn't easy to see the problem by simply looking at this from a high
level point of view.


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