Wednesday October 04, 2006 | Surfing With a Linker Alien Rod Evans's Weblog |
|
Changing Search Paths with crle(1) - they are a replacement
A developer who wished to add
# crle -l /usr/sfw/lib
# ls
ld.so.1: ls: fatal: libsec.so.1: open failed: No such file or directory
Killed
The problem was that
crle(1),in this basic form, created a system wide configuration file.
This configuration file defined that the default runtime search path for
shared object dependencies is You can determine the standard search path defaults using crle(1).For example, without any system wide configuration file, the following defaults might exist:
$ crle
Default configuration file (/var/ld/ld.config) not found
Platform: 32-bit LSB 80386
Default Library Path (ELF): /lib:/usr/lib (system default)
Trusted Directories (ELF): /lib/secure:/usr/lib/secure (system default)
This user had effectively removed the system default search paths, and hence the runtime linker, ld.so.1,had been unable to find the basic dependencies required by all applications. The new configuration file revealed:
$ crle
Configuration file [version 4]: /var/ld/ld.config
Platform: 32-bit LSB 80386
Default Library Path (ELF): /usr/sfw/lib
Trusted Directories (ELF): /lib/secure:/usr/lib/secure (system default)
Command line:
crle -c /var/ld/ld.config -l /usr/sfw/lib
The
-l dir
....
Use of this option replaces the default search path.
Therefore, a -l option is normally required to specify
the original system default in relation to any new paths
that are being applied. ....
Therefore, to prepend the new search path to the existing defaults you should specify each search path:
# crle -l /usr/sfw/lib -l /lib -l /usr/lib
# ls
devices/ lib/ proc/
....
An alternative is to use the
# crle -u -l /usr/sfw/lib
# crle
Configuration file [version 4]: /var/ld/ld.config
Platform: 32-bit LSB 80386
Default Library Path (ELF): /lib:/usr/lib:/usr/sfw/lib
Trusted Directories (ELF): /lib/secure:/usr/lib/secure (system default)
Command line:
crle -c /var/ld/ld.config -l /lib:/usr/lib:/usr/sfw/lib
Note that the usage message from crle(1) is a little misleading, as it implies that the new search path is an addition:
# crle -X
crle: illegal option -- X
....
[-l dir] add default search directory
....
We'll get the usage message updated to be more precise.
Remember, should you ever get in trouble with
crle(1)
configuration files, you can always instruct the runtime linker to
ignore processing the configuration file by setting the environment
variable # crle -l /does/not/exist # ls ld.so.1: ls: fatal: libsec.so.1: open failed: No such file or directory Killed # LD_NOCONFIG=yes ls devices/ lib/ proc/ .... # LD_NOCONFIG=yes rm /var/ld/ld.config # ls devices/ lib/ proc/ ....
It is recommended that when creating a new configuration file, you first
create the file in a temporary location. The environment variable
Note. crle(1) should not be crippled by blowing away the system default search paths:
# crle -l /does/not/exist
# crle
Configuration file [version 4]: /var/ld/ld.config
Platform: 32-bit MSB SPARC
Default Library Path (ELF): /does/not/exist
Trusted Directories (ELF): /lib/secure:/usr/lib/secure (system default)
Command line:
crle -c /var/ld/ld.config -l /does/not/exist
# elfdump -d /usr/bin/crle | fgrep RPATH
ld.so.1: fgrep: fatal: libc.so.1: open failed: No such file or directory
ksh: 18184 Killed
# LD_NOCONFIG=yes; export LD_NOCONFIG
# elfdump -d /usr/bin/crle | fgrep RPATH
[6] RPATH 0x61b $ORIGIN/../lib
Using $ORIGIN within a runpath provides crle(1) with a level of protection against insufficient configuration file information.
Technorati Tag: OpenSolaris Technorati Tag: Solaris (2006-10-04 14:48:41.0) Permalink Comments [1] Post a Comment: Comments are closed for this entry. |
|
||||
Note that it *is* possible to un-brickify a box in this state... Boot single-user, make sure /var is mounted read-write then zero out the config file:-
# > /var/ld/ld.config
At least that worked prior to Solaris 10... Now that /sbin/sh is dynamically linked I'm not so sure.
Posted by Pete on October 05, 2006 at 06:16 AM PDT #