Jonathan Davis wrote:
> To get packages to correctly located libraries do I always have to use
> libdir=/lib64 or alter their makefiles - even if the package does not
> compile any new libraries?  Do the  -m32 and -64 flags for gcc tell it
> where to look?  Or is there some other way that the package determines
> where to go hunting for libraries when it compiles?
-m32 and -m64 affect the parameters passed to ld (linker). Your spec
file contains the info for how gcc links.

[EMAIL PROTECTED] ~ $ gcc -dumpspecs | grep link: -A1
*link:
%{!static:--eh-frame-hdr} %{!m32:-m elf_x86_64} %{m32:-m elf_i386}  
%{shared:-shared}   %{!shared:     %{!static:      
%{rdynamic:-export-dynamic}      
%{m32:%{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}}      
%{!m32:%{!dynamic-linker:-dynamic-linker
/lib64/ld-linux-x86-64.so.2}}}     %{static:-static}}

the -m elf_x86_64 or -m elf_i386 is passed to the linker which chooses
which linker script to use. They're in  /usr/lib/ldscripts on both
multilib and non-multilib systems. Those linker scripts specify the
default search paths for libraries.

/usr/lib/ldscripts/elf_i386.x:6:SEARCH_DIR("/usr/i386-unknown-linux-gnu/lib");
SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
/usr/lib/ldscripts/elf_x86_64.x:6:SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64");
SEARCH_DIR("/usr/local/lib64"); SEARCH_DIR("/lib64");
SEARCH_DIR("/usr/lib64");
SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib");
SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");

The dynamic linker (runtime linker) is the only one with a hard-coded
path. It's a static library that loads the libraries found in the
executables header. The path to the dynamic linker is passed to ld when
linking also.

[EMAIL PROTECTED] ~ $ readelf -d /bin/bash

Dynamic section at offset 0x8c0b0 contains 24 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library:
[libreadline.so.5.1]
 0x0000000000000001 (NEEDED)             Shared library: [libhistory.so.5.1]
 0x0000000000000001 (NEEDED)             Shared library: [libncurses.so.5]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
[Snip 19 lines]

As for how ld-linux.so knows where to look for the libraries. A default
path is hard coded into the library (defaults to /lib:/usr/lib or
/lib64:/usr/lib64 or /lib32:/usr/lib32 and can be changed when building
binutils as it is for /tools). And it uses the dirs in /etc/ld.so.conf too.

Well, that's a mouth full.
_______________________________________________
Clfs-support mailing list
[email protected]
http://lists.cross-lfs.org/cgi-bin/mailman/listinfo/clfs-support

Reply via email to