[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/2721] New: --as-needed vs. DT_NEEDED undef symbols checks

From: jakub at redhat dot com
Subject: [Bug ld/2721] New: --as-needed vs. DT_NEEDED undef symbols checks
Date: 1 Jun 2006 13:21:15 -0000

echo 'int foo1;' | gcc -shared -fpic -o /usr/lib/libfoo.so -xc - -xnone
echo 'int foo1; int foo2;' | gcc -shared -fpic -o libfoo.so -xc - -xnone
echo 'int foo (void) { extern int foo2; return foo2; }' | gcc -shared -fpic -o
libbar.so -xc - -xnone ./libfoo.so
echo 'extern int foo (void); int main (void) { return foo (); }' \
  | gcc -o test -xc - -xnone -Wl,--as-needed ./libfoo.so ./libbar.so

fails to link because foo2 is undefined.
Withouth -Wl,--as-needed this links just fine (and so does adding
-Wl,--rpath-link,.), but I don't think --as-needed should make a difference
whether something links or not and what the above script does is something
that happens quite often - a project with several libraries adds a new symbol to
one of them and as the library is explicitly listed on the command line, the
user shouldn't be really requested to supply a rpath-link as well.

The problem I'd say is in
which ignores --as-needed libraries:
  /* If this input file was an as-needed entry, and wasn't found to be
     needed at the stage it was linked, then don't say we have loaded it.  */
  if (s->as_needed
      && (s->the_bfd == NULL
          || (bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0))

I think it should in this case either load that library again (as in, call
gld${EMULATION_NAME}_try_needed on the same filename), or just mark the library
not only DYN_AS_NEEDED, but also DYN_DT_NEEDED and handle that combination of

           Summary: --as-needed vs. DT_NEEDED undef symbols checks
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: jakub at redhat dot com
                CC: bug-binutils at gnu dot org


------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]