public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* LD problem
@ 2011-07-03 13:41 Krisztian Kocsis
  2011-07-04  6:42 ` Alan Modra
  0 siblings, 1 reply; 8+ messages in thread
From: Krisztian Kocsis @ 2011-07-03 13:41 UTC (permalink / raw)
  To: binutils

Hello!

I have a link dependency problem. If I try to link an application with
an .so file (exc. -lssl) the linker wants to link all its dependency
libraries not just libcrypto.so but libdl.so and libz.so also.

The toolchain is a crosstool-ng toolchain consists of:
- binutils-2.21
- gcc-4.5.3
- eglibc-2.14

If I add -Wl,--as-needed it does not help. There are still references in
the NEEDED entry for these libraries. I'v checked but there are no
referenced symbols from these libraries.

Do somebody know how can I restore the normal workflow, is any
configure option or something else?

BR,
Krisztian Kocsis

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

* Re: LD problem
  2011-07-03 13:41 LD problem Krisztian Kocsis
@ 2011-07-04  6:42 ` Alan Modra
  2011-07-04 10:56   ` krisztian.kocsis
  0 siblings, 1 reply; 8+ messages in thread
From: Alan Modra @ 2011-07-04  6:42 UTC (permalink / raw)
  To: Krisztian Kocsis; +Cc: binutils

On Sun, Jul 03, 2011 at 02:53:18PM +0200, Krisztian Kocsis wrote:
> Hello!
> 
> I have a link dependency problem. If I try to link an application with
> an .so file (exc. -lssl) the linker wants to link all its dependency
> libraries not just libcrypto.so but libdl.so and libz.so also.
> 
> The toolchain is a crosstool-ng toolchain consists of:
> - binutils-2.21
> - gcc-4.5.3
> - eglibc-2.14
> 
> If I add -Wl,--as-needed it does not help. There are still references in
> the NEEDED entry for these libraries. I'v checked but there are no
> referenced symbols from these libraries.

I think it most likely you have missed some reference.  Run ld under
gdb with a breakpoint on one of the following lines in elflink.c
	      add_needed = TRUE;
	      ret = elf_add_dt_needed_tag (abfd, info, soname, add_needed);
Examine "h".

> Do somebody know how can I restore the normal workflow, is any
> configure option or something else?
> 
> BR,
> Krisztian Kocsis

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: LD problem
  2011-07-04  6:42 ` Alan Modra
@ 2011-07-04 10:56   ` krisztian.kocsis
  0 siblings, 0 replies; 8+ messages in thread
From: krisztian.kocsis @ 2011-07-04 10:56 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils

Hello!

In the meanwhile I'v discovered that ld (or gcc driver) turns on the
--no-allow-shlib-undefined option. I haven't discovered the reason
(I'v checked the patches, etc. - no success) but if I add the
-Wl,--allow-shlib-undefined (ld's man page says that this is the 
default
but it seems that the opposite is the default) it corrects the 
behavior.

Thanks for the help!

BR,
Krisztian Kocsis

On Mon, 4 Jul 2011 10:24:16 +0930, Alan Modra wrote:
> On Sun, Jul 03, 2011 at 02:53:18PM +0200, Krisztian Kocsis wrote:
>> Hello!
>>
>> I have a link dependency problem. If I try to link an application 
>> with
>> an .so file (exc. -lssl) the linker wants to link all its dependency
>> libraries not just libcrypto.so but libdl.so and libz.so also.
>>
>> The toolchain is a crosstool-ng toolchain consists of:
>> - binutils-2.21
>> - gcc-4.5.3
>> - eglibc-2.14
>>
>> If I add -Wl,--as-needed it does not help. There are still 
>> references in
>> the NEEDED entry for these libraries. I'v checked but there are no
>> referenced symbols from these libraries.
>
> I think it most likely you have missed some reference.  Run ld under
> gdb with a breakpoint on one of the following lines in elflink.c
> 	      add_needed = TRUE;
> 	      ret = elf_add_dt_needed_tag (abfd, info, soname, add_needed);
> Examine "h".
>
>> Do somebody know how can I restore the normal workflow, is any
>> configure option or something else?
>>
>> BR,
>> Krisztian Kocsis

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

* Re: ld problem
  2001-04-29 17:24   ` Robert Schweikert
@ 2001-04-29 18:33     ` amodra
  0 siblings, 0 replies; 8+ messages in thread
From: amodra @ 2001-04-29 18:33 UTC (permalink / raw)
  To: Robert Schweikert; +Cc: binutils

On Sun, Apr 29, 2001 at 08:24:11PM -0400, Robert Schweikert wrote:
> 
> The EXTERN statements are all I have in the linker script, is this
> insufficient?

Hmm, I've never tried such a cut-down linker script.  I suspect that
omitting a SECTIONS command won't work very well.  I suggest you copy
the appropriate system link script (from $prefix/$target/lib/ldscripts
where $prefix and $target are the values you gave when configuring
binutils), and modify it.  See the comment around line 75 of
ld/genscripts.sh if you don't know which script to choose.

Alan

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

* Re: ld problem
  2001-04-29  2:39 ` amodra
@ 2001-04-29 17:24   ` Robert Schweikert
  2001-04-29 18:33     ` amodra
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Schweikert @ 2001-04-29 17:24 UTC (permalink / raw)
  To: amodra; +Cc: binutils, rjschwei

On Sun, 29 Apr 2001 amodra@one.net.au wrote:

> On Mon, Apr 23, 2001 at 10:26:23AM -0400, Robert Schweikert wrote:
> >
> > Now if I use the same link command with the exception of replacing the
> > link script name with a -u uexternaldb_ everything works as expected.
> > What am I messing up here?
>
> Possibly just the location of your `EXTERN' statements.  Put them near
> the start of your linker script.
>
> Alan Modra
>
Alan,

The EXTERN statements are all I have in the linker script, is this
insufficient?

Thanks,
Robert

Robert Schweikert                   MAY THE SOURCE BE WITH YOU
                                              LINUX


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

* Re: ld problem
  2001-04-23  7:26 ld problem Robert Schweikert
@ 2001-04-29  2:39 ` amodra
  2001-04-29 17:24   ` Robert Schweikert
  0 siblings, 1 reply; 8+ messages in thread
From: amodra @ 2001-04-29  2:39 UTC (permalink / raw)
  To: Robert Schweikert; +Cc: binutils

On Mon, Apr 23, 2001 at 10:26:23AM -0400, Robert Schweikert wrote:
> 
> Now if I use the same link command with the exception of replacing the
> link script name with a -u uexternaldb_ everything works as expected.
> What am I messing up here?

Possibly just the location of your `EXTERN' statements.  Put them near
the start of your linker script.

Alan Modra

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

* ld problem
@ 2001-04-23  7:26 Robert Schweikert
  2001-04-29  2:39 ` amodra
  0 siblings, 1 reply; 8+ messages in thread
From: Robert Schweikert @ 2001-04-23  7:26 UTC (permalink / raw)
  To: binutils

Hi,

I am trying to generate a shared library by linking an object file (.o)
an archive (.a) and some other shared library (.so) on a linux system.
When linking the object code (.o) file I want to force some symbols to
be undefined, such that they are linked from the archive, where they are
defined. If I use the -u option this is working. However, since I have a
number of symbols and don't want to list them all on the command line I
wanted to use a linker script, and that is not working for me at all.
The script basically has a bunch of EXTERN definitions in it, and
according to the documentation this is the same as -u on the command
line. Here is a snippet.

EXTERN(ucorr_);
EXTERN(uel_);
EXTERN(uexpan_);
EXTERN(uexternaldb_);
EXTERN(ufield_);
EXTERN(ufluid_);

There are no complaints during linking, but when I try to load the
library created with this linker script I get the following error.

error while loading shared libraries: undefined symbol: uexternaldb_

Now if I use the same link command with the exception of replacing the
link script name with a -u uexternaldb_ everything works as expected.
What am I messing up here?

The info pages state the following:

`EXTERN(SYMBOL SYMBOL ...)'
     Force SYMBOL to be entered in the output file as an undefined
     symbol.  Doing this may, for example, trigger linking of additional

     modules from standard libraries.  You may list several SYMBOLs for
     each `EXTERN', and you may use `EXTERN' multiple times.  This
     command has the same effect as the `-u' command-line option.

Any help is much appreciated. This is on a SuSE 7.1 and RedHat 6.2
system

SuSE:
ld -v
GNU ld version 2.10.91 (with BFD 2.10.0.33)

RedHat:
ld -v
GNU ld version 2.9.5 (with BFD 2.9.5.0.22)


Thanks,
Robert

--
Robert Schweikert                   MAY THE SOURCE BE WITH YOU
                                              LINUX



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

* ld problem
@ 2000-08-10 19:12 Aner Fust
  0 siblings, 0 replies; 8+ messages in thread
From: Aner Fust @ 2000-08-10 19:12 UTC (permalink / raw)
  To: binutils

hi,
   
 i get this message when compling a foo.cpp file: 
 /usr/bin/ld: warning: libc.so.6, needed by /usr/libc/libstdc++.so, may 
 conflict with libc.so.5 
 
In addition the program (i think this it is related, since it is a simple  hello world prog) when run reoports a segmentation fault(copre dump) message. 
(ps my there are no problems with a foo.c files)
thanks
aner 

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

end of thread, other threads:[~2011-07-04  9:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-03 13:41 LD problem Krisztian Kocsis
2011-07-04  6:42 ` Alan Modra
2011-07-04 10:56   ` krisztian.kocsis
  -- strict thread matches above, loose matches on Subject: below --
2001-04-23  7:26 ld problem Robert Schweikert
2001-04-29  2:39 ` amodra
2001-04-29 17:24   ` Robert Schweikert
2001-04-29 18:33     ` amodra
2000-08-10 19:12 Aner Fust

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