Ld 40
ld.so from SunOS 4.0
Binary: ld.so.sunos4.0 (24,576 bytes)
- Format: a.out SunOS mc68020 demand paged shared library
- Source: SunOS 4.0 Sun-3 install tape (tape1, segment 08), path
./lib/ld.so - Archive: Soupwizard SunOS Sun2 Archive (
sunos_4.0_sun3.tar.7z) - Release date: December 1988
Source and extraction
The binary was extracted from the SunOS 4.0 Sun-3 install tape archived on the Internet Archive as part of the Soupwizard SunOS Sun2 Archive.
Download
curl -L -o sunos_4.0_sun3.tar.7z \
https://archive.org/download/Soupwizard_SunOS_Sun2_Archive/sunos_4.0_sun3.tar.7z
Tape structure
The archive is a 7-zip compressed tar file containing raw dump tape segments:
sunos_4.0_sun3.tar.7z
sunos_4.0_sun3.tar
tape1/01..16 (boot blocks, miniroot FFS images, usr filesystem tarballs)
tape2/01..09 (additional filesystem dumps)
Each numbered segment is either a UFS filesystem image, a tar archive, or raw data. ld.so lives in the /usr filesystem dump on tape1/08.
Extraction
# Decompress the 7z archive
7z x sunos_4.0_sun3.tar.7z
# Extract ld.so from the usr tarball
mkdir extracted
cd extracted
bsdtar xf ../sunos_4.0_sun3/tape1/08 ./lib/ld.so
The resulting file is ./lib/ld.so (24,576 bytes), an a.out mc68020 demand paged shared library.
Verification
$ file lib/ld.so
lib/ld.so: a.out SunOS mc68020 demand paged shared library
$ strings lib/ld.so | grep LD_PRELOAD
LD_PRELOAD
LD_PRELOAD support
LD_PRELOAD is present in the binary (December 1988) as an undocumented debugging tool. It does not appear in any SunOS 4.0 man page -- the ld(1) / ld.so(1) documentation lists only LD_LIBRARY_PATH and LD_OPTIONS as supported environment variables. The source comment confirming this comes from SunOS 4.1.4 (November 1994), six years later.
The SunOS 4.1.4 source code confirms this explicitly. In lang/rtld/rtld.c, the preload handling code carries this comment:
/*
* If we're letting the user freelance, then see if the user has
* specified any files to be dynamically loaded. If so, build
* link-object data structures for them and get them.
* N.B. THIS IS FOR DEBUGGING ONLY. IT IS NOT SUPPORTED NOR
* IS IT TO BE DOCUMENTED!
*/
if ((cp = preload))
- Source: calmsacibis995/sunos-414-src — lang/rtld/rtld.c
- Source (mirror): Arquivotheca/SunOS-4.1.4 — lang/rtld/rtld.c
The feature was later documented starting with SunOS 4.1 / Solaris 2.x and became a well-known interposition mechanism.
Environment variables
The binary recognizes these environment variables:
| Variable | Description |
|---|---|
LD_PRELOAD |
Space-separated list of shared objects to load before all others |
LD_SYMBOLS_PUBLIC |
Makes all symbols globally visible during binding |
LD_LIBRARY_PATH |
Colon-separated list of directories to search for shared libraries |
LD_TRACE_LOADED_OBJECTS |
List dependencies and exit (like ldd) |
LD_PROFILE |
Profile a shared library |
Internal symbols
Key internal symbols found in the binary:
| Symbol | Role |
|---|---|
_ld_preload |
Preload list pointer |
_preload |
Preload state |
ld_$preload_ |
Dynamic preload symbol |
_ld_library_path |
Library path state |
_ld_symbols_public |
Symbols-public flag |
_ld_trace |
Trace mode flag |
_ld_profile |
Profile state |
_rtbinder / _binder |
Runtime binder interface |
_rtmalloc / _heap_malloc |
Internal memory allocation |
_cached_symbol / _lo_cache |
Symbol cache |
_use_cache |
Cache enable flag |
_is_secure |
Secure mode flag |
_secure_objects |
Set-user-ID/set-group-ID object list |
Error messages
ld.so: no error
ld.so: invalid dlopen mode
ld.so: invalid object
ld.so: object could not be mapped
ld.so: undefined symbol
ld.so: unsupported crt interface version of %d
ld.so: obsolete crt interface
ld.so: error %d on main text write-protect
ld.so: write protect error %d
ld.so: swap space exhausted for %s of %s
ld.so: %s error (%d) for %s
ld.so: can't read struct exec for %s
ld.so: %s is not for this machine type
ld.so: lib%s.so.%d: not found
ld.so: open error %d for %s
ld.so: __DYNAMIC version %d not supported
ld.so: mangled lm object list.
ld.so: Undefined symbol: %s
ld.so: unidentifiable procedure reference at 0x%x
ld.so: call to undefined procedure %s from 0x%x
ld.so: mangled dl object list.
ld.so: warning: %s has older revision than expected %d
Library search paths
/usr/lib
/usr/local/lib
/usr/5lib
/etc/ld.so.cache
dlopen/dlsym support
The binary includes support for dlopen, dlclose, dlsym, and dlerror via a companion library /usr/lib/libdl.so.1.0.
Pre-4.0: no ld.so, no shared libraries
SunOS 3.5 (January 1988) is the last release before 4.0. It has no ld.so and no shared libraries. All binaries are statically linked. This was confirmed by:
- Searching all tarballs in the SunOS 3.5 Sun-3 install tape (
sunos_3.5_sun3.tar.7zfrom the same Internet Archive archive) -- nold.sofound - The SunOS 3.5 manual has no
ld.soman page and theld(1)page has no mention of dynamic linking - PoC-Net SunOS 3.5 knowledgebase: "There are no shared libraries"
ld.so, shared libraries, dynamic linking, and LD_PRELOAD all first appeared in SunOS 4.0 (December 1988). There is no 3.x predecessor to check.
Notes
This is the mc68020 (Sun-3) variant. The Sun-2 and Sun386i tapes contain their own architecture-specific ld.so binaries. The SPARC variant first appeared in SunOS 4.0.3c.