Page MenuHomeFreeBSD

Fix ldd for PIE binaries after rtld stopped accepting binaries for dlopen.
ClosedPublic

Authored by kib on Jun 13 2020, 3:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 11, 5:00 PM
Unknown Object (File)
Wed, Oct 8, 12:48 AM
Unknown Object (File)
Tue, Oct 7, 3:06 AM
Unknown Object (File)
Fri, Sep 26, 4:09 AM
Unknown Object (File)
Sep 6 2025, 8:55 AM
Unknown Object (File)
Sep 1 2025, 4:18 AM
Unknown Object (File)
Aug 17 2025, 12:18 PM
Unknown Object (File)
Aug 4 2025, 10:42 PM
Subscribers

Details

Summary

ldd proclaims ET_DYN objects as shared libraries and tries to dlopen(RTLD_TRACE) them to get dependencies. Since PIE binaries are ET_DYN | DF_1_PIE, refusal to dlopen such binaries breaks ldd.

Fix it by reading and parsing dynamic segment looking for DF_FLAG_1 and taking DF_1_PIE into account when deciding between binary and library.

Reported by: Dewayne Geraghty <dewayne@heuristicsystems.com.au>

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Jun 13 2020, 3:30 PM
usr.bin/ldd/ldd.c
377 ↗(On Diff #73070)

Why bother to do this work if e_type == ET_EXEC?

kib marked an inline comment as done.

Only parse dynamic for ET_DYN.

This revision is now accepted and ready to land.Jun 13 2020, 5:09 PM