Bug 105542

Summary: on amd64, ldd(1) produces bogus output for i386 executables
Product: Base System Reporter: David Sanderson <dws>
Component: binAssignee: freebsd-amd64 (Nobody) <amd64>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description David Sanderson 2006-11-14 21:20:02 UTC
The problem seems to be that ldd isn't setting LD_32_* environment variables
along with the LD_* environment variables that it already sets:

: compute-6-29; ldd /usr/pan/bin/tclsh8.3
ldd: /usr/pan/bin/tclsh8.3: can't read program header
ldd: /usr/pan/bin/tclsh8.3: not a dynamic executable
: compute-6-29; ldd32 /usr/pan/bin/tclsh8.3
        libtcl83.so => /usr/pan/lib/libtcl83.so (0x28077000)
        libm.so.4 => /usr/lib32/libm.so.4 (0x280fb000)
        libc.so.6 => /usr/lib32/libc.so.6 (0x28112000)
: compute-6-29; cat $HOME/scripts/ldd32
#!/bin/sh
#-------
# This lets us see what's going on with loading 32-bit shared objects
# on FreeBSD 6.
#-------
export LD_32_TRACE_LOADED_OBJECTS; LD_32_TRACE_LOADED_OBJECTS=1
exec "$@"

Fix: 

The fix would presumably be to go through the ldd code and have it
set LD_32_* in addition to LD_*, for each LD_* variable it currently
sets.  Some adjustments to how ldd examines the program header may also
be necessary.
How-To-Repeat: Use ldd on a dynamically loaded i386 executable on an amd64 freebsd6
system.
Comment 1 Remko Lodder freebsd_committer freebsd_triage 2007-11-28 13:15:03 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-amd64

Make this more visible in the amd64 queue
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2008-06-23 15:30:55 UTC
State Changed
From-To: open->closed

A patch can be found in bin/124906