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)
Thu, Sep 3, 11:10 PM
Unknown Object (File)
Thu, Sep 3, 4:21 PM
Unknown Object (File)
Wed, Sep 2, 10:54 PM
Unknown Object (File)
Wed, Sep 2, 8:32 PM
Unknown Object (File)
Sun, Aug 30, 2:25 PM
Unknown Object (File)
Sat, Aug 29, 3:48 AM
Unknown Object (File)
Fri, Aug 28, 11:10 PM
Unknown Object (File)
Fri, Aug 28, 11:09 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