From nobody Thu Feb 10 18:18:20 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 576B219BD8A3; Thu, 10 Feb 2022 18:18:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JvlNs1GMlz4RxG; Thu, 10 Feb 2022 18:18:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644517101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/mvvVLNjDlty/iaEtO9j1tDle3SPX1gSIBNDura75GY=; b=E4lUmDfr7YgxkXMYEs+K6nDDvxqdpajSoooRG1G6JUIteLrjv2KVqpspKIVizLSMLoDaPO 0pOxIISscMrmXue4JoggNlkqPtYGviym4uyYOuRLXJYBtzYnoydejGBvQ8pVtgTr6V1BeW fQZ9SYvzehSBhzUe6vIQuqQwpmX4JFTuDtHRAoZooOugLzD9KxKCDBUXIhG2h9oVEliRou +vPXbbrt5d9mu0zNQ4WLpNCIVRntk6GJK1X4IRslwOdnuI0lPwOFqGv9RRo61/BIRzH+7X Mt2TstZs7qkgWe87KRZchVC4W2ry/WG90cMAGnwD2Ab78neFioeZNG5L3+IdVQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 02BDE252B2; Thu, 10 Feb 2022 18:18:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21AIIKVn015207; Thu, 10 Feb 2022 18:18:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21AIIKlM015206; Thu, 10 Feb 2022 18:18:20 GMT (envelope-from git) Date: Thu, 10 Feb 2022 18:18:20 GMT Message-Id: <202202101818.21AIIKlM015206@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: eb54f261fce2 - stable/13 - compiler-rt: support ReExec() on FreeBSD List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: eb54f261fce2b55e6859bc1416ee8d964aefa079 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644517101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/mvvVLNjDlty/iaEtO9j1tDle3SPX1gSIBNDura75GY=; b=A5cTcZGlxiu7E6XGZVXzhQpo+C11xhDGi5QLwgT9shtNPitF+vzOaytYhzRNPeJxLl8BVw lQ1ybXrcHB+ku7BTL3R+bwXn2ydclEN9RGgxPU85DocvEPgEDhW2ywO/Frxy9ED7jtsFB2 Z94gUX4lXD1qZoxErIOBCIcuEPb6ib9TNEvoYkGMMUVtkqfmY73RAYT1Yni3Ffl0VzNNfN ozJLVlyuNP1s6yy3wS0KOEKjKEHLnfW9MbwG+X4GULkxcAT5v36RQQw/fP27hG1kGI9tgM MA0Xf5XYgfTaJvnZyhlnYTrm1nGCWMGS9CiYtt8mxi06JDim9yIVx3fIcov0pQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644517101; a=rsa-sha256; cv=none; b=MVO/9rOriZsEyVVBpU1cBwH3vQSDC30jhJDE19bwTfjpEcAM+a9cARaFi74xD9iwaG3fti yBfl5eSxyqTjbiUKiKqFmWu0YpR80K3cAwh8gKTvwlT7CEkfll2scLEWFGEoicQWn/NEm4 cV4QLSoUv/LRWBGCIltB5iZDPMy5YqphwoM6H3GkqVLcFUN02G/I/81qsIBltRHy9rxjWl QA8pDWyiY+fVjmPD4qbfOaSAwqAkndkddHEn6j2C/K8U8sBrEIcfhV0AEWUEztderk16Uq 2i18fGoCA/coLqlNwJEuCO9qHwylc/gKXW4FVLZErzNsDq7WBYZR8RmpbSxisg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=eb54f261fce2b55e6859bc1416ee8d964aefa079 commit eb54f261fce2b55e6859bc1416ee8d964aefa079 Author: Ed Maste AuthorDate: 2022-01-19 18:08:18 +0000 Commit: Ed Maste CommitDate: 2022-02-10 18:17:39 +0000 compiler-rt: support ReExec() on FreeBSD Based on getMainExecutable() in llvm/lib/Support/Unix/Path.inc. This will need a little more work for an upstream change as it must support older FreeBSD releases that lack elf_aux_info() / AT_EXEC_PATH. No objection: dim MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33934 (cherry picked from commit 96fe7c8ab0f65cf829619abd74ae6c126b21e15f) --- .../lib/sanitizer_common/sanitizer_linux_libcdep.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp index 7ce9e25da342..59f8d5d1fec2 100644 --- a/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp +++ b/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp @@ -46,7 +46,9 @@ #if SANITIZER_FREEBSD #include +#include #include +#include #include #define pthread_getattr_np pthread_attr_get_np // The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before @@ -865,7 +867,14 @@ u64 MonotonicNanoTime() { void ReExec() { const char *pathname = "/proc/self/exe"; -#if SANITIZER_NETBSD +#if SANITIZER_FREEBSD + char exe_path[PATH_MAX]; + if (elf_aux_info(AT_EXECPATH, exe_path, sizeof(exe_path)) == 0) { + char link_path[PATH_MAX]; + if (realpath(exe_path, link_path)) + pathname = link_path; + } +#elif SANITIZER_NETBSD static const int name[] = { CTL_KERN, KERN_PROC_ARGS,