[all-commits] [llvm/llvm-project] d75a56: [asan] Always skip first object from dl_iterate_phdr
Michael Forney via All-commits
all-commits at lists.llvm.org
Fri Feb 11 14:49:39 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d75a5650dbdc595f836db4711f2a480f87243593
https://github.com/llvm/llvm-project/commit/d75a5650dbdc595f836db4711f2a480f87243593
Author: Michael Forney <mforney at mforney.org>
Date: 2022-02-11 (Fri, 11 Feb 2022)
Changed paths:
M compiler-rt/lib/asan/asan_linux.cpp
Log Message:
-----------
[asan] Always skip first object from dl_iterate_phdr
All platforms return the main executable as the first dl_phdr_info.
FreeBSD, NetBSD, Solaris, and Linux-musl place the executable name
in the dlpi_name field of this entry. It appears that only Linux-glibc
uses the empty string.
To make this work generically on all platforms, unconditionally skip the first
object (like is currently done for FreeBSD and NetBSD). This fixes first DSO
detection on Linux-musl with clang -shared-libsan/-shared-libasan and GCC's
default. It also would likely fix detection on Solaris/Illumos if it were to
gain PIE support (since dlpi_addr would not be NULL).
Additionally, only skip the Linux VDSO on linux.
Finally, use the empty string as the "seen first dl_phdr_info"
marker rather than (char *)-1. If there was no other object, we
would try to dereference it for a string comparison.
Reviewed By: MaskRay, vitalybuka
Differential Revision: https://reviews.llvm.org/D119515
More information about the All-commits
mailing list