This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


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

PATCH [Re: unexpected behaviour of ld with --start-group]


On Tue, Feb 20, 2001 at 03:21:44PM +0100, Bryan White wrote:
> A) I'm having problems in trying to link a program. As part of my
> experimentation I want to define a start/end group, but I am unable to
> include the libraries that I want.
> 
> I have simplified the problem down to the following:
> 
> [15:00:25 bwhi@ws2 sdk]$ld -o deleteme -lc
> ld: warning: cannot find entry symbol _start; not setting start address  //
> ignore this - it's expected
> [15:00:58 bwhi@ws2 sdk]$ld -o deleteme --start-group -lc --end-group
> ld: cannot find -lc                         // this is the problem
> [15:01:07 bwhi@ws2 sdk]$ld -v
> GNU ld version 2.10.90 (with BFD 2.10.0.18) // confirm which ld i'm using
> [15:01:10 bwhi@ws2 sdk]$whereis libc
> libc: /usr/lib/libc.a /usr/lib/libc.so      // confirm that they exist
> [15:01:17 bwhi@ws2 sdk]$

I am enclosing a patch here. The problem is /usr/libc/libc.so is a
linker script under Linux. The linker will do

# ld -o deleteme --start-group -lc --end-group --verbose
...
attempt to open /usr/lib/libc.so succeeded
opened script file /usr/lib/libc.so
attempt to open /lib/libc.so.6 succeeded
/lib/libc.so.6
attempt to open /usr/lib/libc_nonshared.a succeeded
attempt to open /usr/lib/lib/usr/lib/libc.so.so failed
attempt to open /usr/lib/lib/usr/lib/libc.so.a failed
attempt to open /lib/lib/usr/lib/libc.so.so failed
attempt to open /lib/lib/usr/lib/libc.so.a failed
attempt to open /usr/lib/lib/usr/lib/libc.so.so failed
attempt to open /usr/lib/lib/usr/lib/libc.so.a failed
attempt to open /usr/local/lib/lib/usr/lib/libc.so.so failed
attempt to open /usr/local/lib/lib/usr/lib/libc.so.a failed
attempt to open /usr/i386-redhat-linux/lib/lib/usr/lib/libc.so.so failed
attempt to open /usr/i386-redhat-linux/lib/lib/usr/lib/libc.so.a failed
ld: cannot find -lc

We have to scan a linker script twice to get the correct behavior.
"--start-group -lc --end-group" means we have a linker script inside
another linker script. We didn't handle this case well. With my
patch, I got

# ld -o deleteme --start-group -lc --end-group --verbose
...
attempt to open /usr/lib/libc.so succeeded
opened script file /usr/lib/libc.so
attempt to open /lib/libc.so.6 succeeded
/lib/libc.so.6
attempt to open /usr/lib/libc_nonshared.a succeeded
attempt to open /usr/lib/libc.so succeeded
opened script file /usr/lib/libc.so
attempt to open /lib/libc.so.6 succeeded
/lib/libc.so.6
attempt to open /usr/lib/libc_nonshared.a succeeded
ld-linux.so.2 needed by /lib/libc.so.6
found ld-linux.so.2 at /lib/ld-linux.so.2
/work/build/gnu/bin/binutils-debug/ld/ld-new: warning: cannot find entry symbol
_start; not setting start address

Ian, do you have any comments?



> 
> B) I also have a problem with libc.
> Newsgroups gnu.glibc.bug (and similar) seem dormant to the point of
> extinction, and a posting to gnats@gnu.org has been automatically
> acknowledged as libc/2092, but nothing else has happened (AFAIK). Is there
> another method I should be using for reporting libc problems?

http://sourceware.cygnus.com/glibc/

> 
> 

Thanks.


H.J.
----
2001-02-20  H.J. Lu  <hjl@gnu.org>

	* emultempl/elf32.em (gld${EMULATION_NAME}_open_dynamic_archive):
	Set entry->search_dirs_flag to false if we found the file.

Index: emultempl/elf32.em
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emultempl/elf32.em,v
retrieving revision 1.34
diff -u -p -r1.34 elf32.em
--- emultempl/elf32.em	2001/02/03 23:13:20	1.34
+++ emultempl/elf32.em	2001/02/20 18:53:19
@@ -962,6 +962,10 @@ gld${EMULATION_NAME}_open_dynamic_archiv
       bfd_elf_set_dt_needed_name (entry->the_bfd, needed_name);
     }
 
+  /* We have found the file.  We don't need to search directories
+     again. */
+  entry->search_dirs_flag = false;
+
   return true;
 }
 


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