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
F116857775: D25257.id73070.diff
Sun, May 11, 2:31 AM
Unknown Object (File)
Tue, May 6, 6:40 AM
Unknown Object (File)
Mar 25 2025, 8:40 PM
Unknown Object (File)
Mar 11 2025, 11:51 PM
Unknown Object (File)
Feb 15 2025, 11:01 AM
Unknown Object (File)
Feb 13 2025, 2:44 PM
Unknown Object (File)
Feb 13 2025, 2:40 PM
Unknown Object (File)
Feb 2 2025, 6:35 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