public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RFA: Adding feature for putting system libraries for pe-coff targets   as last in link order
@ 2009-09-14  7:39 Kai Tietz
  2009-09-14  8:39 ` Dave Korn
  0 siblings, 1 reply; 4+ messages in thread
From: Kai Tietz @ 2009-09-14  7:39 UTC (permalink / raw)
  To: Dave Korn, Binutils

Hello,

it is a pretty common issue, that symbols in system libraries are
possibly replacing own runtime functions, when users are specifying
additional system libraries by -l option to ld. AFAIK there is at the
moment no way to say, that a specific library should be imported at
tail of chain, and not at possition specified.
Therefore I would like to ask, if there is interest in an extension to
linker for this. I would suggest for this an linker option -sys-l, or
-tail-l.

Regards,
Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

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

* Re: RFA: Adding feature for putting system libraries for pe-coff  targets as last in link order
  2009-09-14  7:39 RFA: Adding feature for putting system libraries for pe-coff targets as last in link order Kai Tietz
@ 2009-09-14  8:39 ` Dave Korn
  2009-09-14  8:56   ` Kai Tietz
  0 siblings, 1 reply; 4+ messages in thread
From: Dave Korn @ 2009-09-14  8:39 UTC (permalink / raw)
  To: Kai Tietz; +Cc: Dave Korn, Binutils

Kai Tietz wrote:
> Hello,
> 
> it is a pretty common issue, that symbols in system libraries are
> possibly replacing own runtime functions, when users are specifying
> additional system libraries by -l option to ld. AFAIK there is at the
> moment no way to say, that a specific library should be imported at
> tail of chain, and not at possition specified.

  Can you give us an example to demonstrate why the solution to the problem
isn't just to tell people "write the libraries in the order you want, rather
than in the wrong order that you don't want, on the command line"?

> Therefore I would like to ask, if there is interest in an extension to
> linker for this. I would suggest for this an linker option -sys-l, or
> -tail-l.

  I'm not sure whether this should really be considered a problem with the
linker, rather than a problem with the GCC driver or wherever the flags are
coming from.  I can't think of a situation where I've ever needed this sort of
option and wished it existed, so I'll reserve judgment until I see what kind
of example usage you're envisaging.

    cheers,
      DaveK

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

* Re: RFA: Adding feature for putting system libraries for pe-coff   targets as last in link order
  2009-09-14  8:39 ` Dave Korn
@ 2009-09-14  8:56   ` Kai Tietz
  2009-09-15  4:38     ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Kai Tietz @ 2009-09-14  8:56 UTC (permalink / raw)
  To: Dave Korn; +Cc: Binutils

2009/9/14 Dave Korn <dave.korn.cygwin@googlemail.com>:
> Kai Tietz wrote:
>> Hello,
>>
>> it is a pretty common issue, that symbols in system libraries are
>> possibly replacing own runtime functions, when users are specifying
>> additional system libraries by -l option to ld. AFAIK there is at the
>> moment no way to say, that a specific library should be imported at
>> tail of chain, and not at possition specified.
>
>  Can you give us an example to demonstrate why the solution to the problem
> isn't just to tell people "write the libraries in the order you want, rather
> than in the wrong order that you don't want, on the command line"?
>
>> Therefore I would like to ask, if there is interest in an extension to
>> linker for this. I would suggest for this an linker option -sys-l, or
>> -tail-l.
>
>  I'm not sure whether this should really be considered a problem with the
> linker, rather than a problem with the GCC driver or wherever the flags are
> coming from.  I can't think of a situation where I've ever needed this sort of
> option and wished it existed, so I'll reserve judgment until I see what kind
> of example usage you're envisaging.
>
>    cheers,
>      DaveK
>

Well, as example (btw this could be done also in gcc driver but I
think a linker option for this is easier) the command 'gcc -o tst my.c
-lmsvcrt'. For this example the import library of libmsvcrt.a will be
linked before the libmingwex.a (specified by gcc spec).
For code of my.c:
#include <math.h>
#include <stdio.h>

int main (int argc, char **argv)
{
  printf ("Pow(%d)=%g\n", argc, pow ((double) argc, 2.0));
  return 0;
}

For this example above the function 'pow' will be taken from
msvcrt.dll. If you omit the -lmsvcrt option, it is taken from
libmingwex.a.

Cheers,
Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

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

* Re: RFA: Adding feature for putting system libraries for pe-coff   targets as last in link order
  2009-09-14  8:56   ` Kai Tietz
@ 2009-09-15  4:38     ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2009-09-15  4:38 UTC (permalink / raw)
  To: Kai Tietz; +Cc: Dave Korn, Binutils

Kai Tietz <ktietz70@googlemail.com> writes:

> Well, as example (btw this could be done also in gcc driver but I
> think a linker option for this is easier) the command 'gcc -o tst my.c
> -lmsvcrt'. For this example the import library of libmsvcrt.a will be
> linked before the libmingwex.a (specified by gcc spec).
> For code of my.c:
> #include <math.h>
> #include <stdio.h>
>
> int main (int argc, char **argv)
> {
>   printf ("Pow(%d)=%g\n", argc, pow ((double) argc, 2.0));
>   return 0;
> }
>
> For this example above the function 'pow' will be taken from
> msvcrt.dll. If you omit the -lmsvcrt option, it is taken from
> libmingwex.a.

I think that for special purposes the right approach is to use gcc's
-nodefaultlibs option and specify the library yourself.

For general purpose it seems to me that a gcc spec patch would be
appropriate.

Ian

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

end of thread, other threads:[~2009-09-15  4:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-14  7:39 RFA: Adding feature for putting system libraries for pe-coff targets as last in link order Kai Tietz
2009-09-14  8:39 ` Dave Korn
2009-09-14  8:56   ` Kai Tietz
2009-09-15  4:38     ` Ian Lance Taylor

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