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, Feb 15, 11:01 AM
Unknown Object (File)
Thu, Feb 13, 2:44 PM
Unknown Object (File)
Thu, Feb 13, 2:40 PM
Unknown Object (File)
Feb 2 2025, 6:35 PM
Unknown Object (File)
Jan 21 2025, 3:44 AM
Unknown Object (File)
Nov 21 2024, 8:13 AM
Unknown Object (File)
Oct 19 2024, 4:55 PM
Unknown Object (File)
Sep 26 2024, 4:18 AM
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