SUMMARY: /usr/sbin/static

From: Mitarbeiter EM C14 (c14@uebemc.siemens.de)
Date: Mon Oct 04 1993 - 18:13:05 CDT


Thanks a lot to following persons:

blymn@mulga.awadi.com.AU (Brett Lymn)
Andrew Watson <ajw@ansa.co.uk>
Richard.Czech@gmd.de (Richard Czech)
Andrew Benson <drew@mtu.edu>
rlyle@nl.oracle.com (Rob Lyle Wizard of Ozje)
Dan Stromberg - OAC-DCS <strombrg@hydra.acs.uci.edu>
Joseph C. Konczal <konczal@mail-gw.ncsl.nist.gov>
poffen@sj.ate.slb.com (Russ Poffenberger)
bern@kleopatra.Uni-Trier.DE (Jochen Bern)
guy@auspex.com (Guy Harris)
Pauline van Winsen - Uniq Professional Services <pauline@uniq.com.au>
perryh@pluto.rain.com (Perry Hutchison)
" (Dr Gareth Barker)" <gareth@nmr.ion.bpmf.ac.uk>
jsoares@porthos.inescn.pt (Joaquim Fernando Soares)

>> Here my problem:
>> in the directory /usr/sbin/static are placed 3 files
>> -r-xr-xr-x 1 bin bin 112364 Mar 27 15:07 mv
>> -r-sr-xr-x 1 root bin 501988 Mar 27 12:08 rcp
>> -r-xr-xr-x 1 bin bin 534140 Mar 27 16:11 tar
>> and the documentation let us know:
>> ".../usr/sbin/static used to recover from broken dynamic linking"

These executables are linked statically - they don't need any shared libraries
to run and can thus be executed even when the rest of the system is stuffed!

They are functionally equivalent, but one would require that dynamic linking
be operational, the other does not.

>>
>> My questions:
>> Does anybody know, in which cases the system use this files ?

I think they're intended for you (not the system) to use
in emergencies.

Hardly ever - you only need them in emergencies when dynamic binding with
shared libraries is broken.

The system generally won't use these files, unless someone has the path
before the usual path in their "path". They are there for a sysadmin to
recover from a dynamic linking problem (like corrupted ld.so). Since fixing
the dynamic problem probably involves rcp of a "good" file from another
system (or untarring from tape), and "mv"ing the new file into place, if
there were no static version of these files it would not be possible since
they would fail to run.

>> Which kind of "broken dynamic linking" describes the doc
>> (Linking of files /hard- or softlinks/ or linking of lib's during
>> the execution) ?
>> Is there any relation between /usr/sbin/static/[mv,rcp,tar] and
>> /usr/(s)bin/[mv,rcp,tar] or are they independent?

Linking of libraries during the execution; if a new version of a shared
library such as the "libc" shared library has been installed, and it
doesn't work, it's a little hard to run most utilities under SunOS 5.x
(or SunOS 4.x, for that matter!), because they're linked with the shared
library in question and depend on it.

They have exactly the same functionality, but are linked differently. Try
file /usr/sbin/static/mv and file /usr/sbin/mv to see what I mean.

They're probably just built with different compiler options - i.e., the
ones in "/usr/sbin/static" are built with the compiler option that says
"don't dynamically link this", i.e., "-B static" or something such as
that.

The statically linked versions of mv, rcp & tar are used when a person
has broken the shared libraries. For example, ldd, which reports a dynamically
linked executables dependencies on shared libraries, shows that /usr/bin/mv
is dependent on the following libraries being present.

# ldd /usr/bin/mv
        libintl.so.1 => /usr/lib/libintl.so.1
        libc.so.1 => /usr/lib/libc.so.1
        libw.so.1 => /usr/lib/libw.so.1
        libdl.so.1 => /usr/lib/libdl.so.1

ldd on the static version reports no dependencies.

# ldd /usr/sbin/static/mv
ldd: /usr/sbin/static/mv: file is not a dynamic executable or shared object

Thus if any of the shared libraries reported were not present or corrupted
in some way, /usr/bin/mv would not run where /usr/sbin/static/mv would work.
The programs are functionally the same, just that the statically linked
executable doesn't depend on the libraries being present.

Now what breaks shared libraries? Generally people trying to install new
versions of the libraries & getting it wrong.
You'll find that most executables are dynamically linked to libc, so installing
a new version & getting it wrong renders a system useless.
The statically linked version of mv, rcp & tar allow for easier recovery
if there are problems. You can mv your backup copies of the original libc back
into place (assuming you made a backup 8-)). Unless you're installing patches
or customised libc's, there's no real need to worry & if you follow the
instructions you should have no problems.

For more information see the man pages for "ld" (the loader)
"ldd" and, if you are on SunOS 4.x, "ldconfig".

==== Joerg Bruchertseifer
==== jb@uebemc.siemens.de



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:08:20 CDT