This is the mail archive of the
mailing list for the binutils project.
Re: finding libraries from linker via $ORIGIN
- From: Oliver Kiddle <okiddle at yahoo dot co dot uk>
- To: binutils <binutils at sourceware dot org>
- Date: Fri, 12 Apr 2013 00:12:05 +0200
- Subject: Re: finding libraries from linker via $ORIGIN
- References: <19133 dot 1365611488 at thecus dot kiddle dot eu> <20130411060556 dot GE363 at bubble dot grove dot modra dot org>
Alan Modra wrote:
> On Wed, Apr 10, 2013 at 06:31:28PM +0200, Oliver Kiddle wrote:
> > It seems the bfd linker reads in all shared libraries from transitive
> > library dependencies. When using --no-copy-dt-needed-entries this is
> > surely fairly pointless?
> Well, no, because as you found:
> > it then fails because of symbols in ld-linux-x86-64.so.2 needed
> > by libc.so.6.
> It might be reasonable to omit loading DT_NEEDED libraries if both
> --no-copy-dt-needed-entries *and* --allow-shlib-undefined is specified.
That makes sense, thanks. It seems to work well as far as my testing
goes. I've put the corresponding small patch below. Is there any chance
of this change or a similar one being included?
I'd also be happy to put together a patch for expanding $ORIGIN when
searching for DT_NEEDED libraries if there's any willingness to include
such a change(?). Judging from a web search other people have also had
my original issue (but used -rpath-link to resolve it).
Thanks also to John Reiser for the hint regarding spec files.
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.242
diff -u -r1.242 elf32.em
--- ld/emultempl/elf32.em 4 Apr 2013 14:38:47 -0000 1.242
+++ ld/emultempl/elf32.em 11 Apr 2013 21:34:13 -0000
@@ -1183,7 +1183,8 @@
DT_NEEDED entres. */
if (l->by != NULL
&& ((bfd_elf_get_dyn_lib_class (l->by) & DYN_AS_NEEDED) != 0
- || (!link_info.executable
+ || ((!link_info.executable
+ || link_info.unresolved_syms_in_shared_libs == RM_IGNORE)
&& bfd_elf_get_dyn_lib_class (l->by) & DYN_NO_ADD_NEEDED) != 0))