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)
Sun, Feb 2, 6:35 PM
Unknown Object (File)
Tue, Jan 21, 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
Unknown Object (File)
Sep 25 2024, 4:12 PM
Unknown Object (File)
Sep 24 2024, 11:01 PM
Unknown Object (File)
Sep 24 2024, 4:25 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 31685

Event Timeline

kib requested review of this revision.Jun 13 2020, 3:30 PM
usr.bin/ldd/ldd.c
377

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