From nobody Fri Feb 04 16:20:48 2022 X-Original-To: dev-commits-src-main@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 EA84319A8939; Fri, 4 Feb 2022 16:20:48 +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 4Jr1405K5tz3kcb; Fri, 4 Feb 2022 16:20:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643991648; 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=XRYmhmcKaHbtoTF/Ku/Lsah3+QeKkmpGiYPZT/rKsFY=; b=IQSDkPkhg621x0KfkT46LKu9YqkZ6iui35DYaYucSGE2vvwspfbpix/S/vZRk0sUuxZSCU npqW/c6jFoBeou70cteTC9mlWRdyui6GjzGo4HwaJOpduofSlAebGv3+1RjZb7Z4EnNjQP EsxRF5eZ721IdQoQ7FCijZGyGZE18aYscWTOApCiOCL9gfB8W5795V8wGVDFfF8v3o4kle f4zw4Uarr/wFmPUAH34DuNw3/aIoaZ6i+XiycCaE/+wh7Wu/RWuvUG8Zeo6QcTftwbEuju +hZLYlV1qYHgAJA8nkYpI33cL65dExNkHYLUP/yNc4czQOYa+CiqYJxWZXDi9w== 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 95CC46C35; Fri, 4 Feb 2022 16:20:48 +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 214GKmON007515; Fri, 4 Feb 2022 16:20:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 214GKmno007514; Fri, 4 Feb 2022 16:20:48 GMT (envelope-from git) Date: Fri, 4 Feb 2022 16:20:48 GMT Message-Id: <202202041620.214GKmno007514@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 96fe7c8ab0f6 - main - compiler-rt: support ReExec() on FreeBSD List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 96fe7c8ab0f65cf829619abd74ae6c126b21e15f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643991648; 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=XRYmhmcKaHbtoTF/Ku/Lsah3+QeKkmpGiYPZT/rKsFY=; b=I3jmLubgyYHsLKL2a2BATXxEQPkx8AqrMzxvTGK7yq1v2MsoKhWWEofTPvgXNWkQPcb/Q/ kXnDvPY7lDHZe8Bo3AGTnPkESaeTr2CQgV8DzhycRHYpkg/pVzhQS5ZZmvrs1Eh2VFlhhO RzwIg+nZejWqQukXUfQAWPR83M7LGaQslzZHrLMjGxJKLGOHqJGows3IzRz3f9/gw24QJS 7nFr6vs2G3i2cSQ9kXYWE9Lii0zEGY66jx2N5yndkQR9hHDpc7U43HF2IKpAvni6Kag4jT XLNKzOe/OEzD4XhhyKIk0CVf6ZT+cP1alAYKexazxYQNpvIvcVM3EgaKMp6mvA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643991648; a=rsa-sha256; cv=none; b=Nn/j7J4wIl8WIC0iyw2QkJb28fg5I/N4I6KDp8syFwVK6pkWfrfUBTKshrmHvz1DlcfyWN AhNLwo9BpoJk5dQn3VYsIg6vWTaTMit6ZSt2HczJz3ideL/2hpKrd6r3W+UgfHhC3mc6xk wfOKJF9cuhamgmyJ+8bZCzO7uiry3VybFUJ6QaeLZx5aY56aR6PvnVDBtONKzjTcotVMLf kT44katyHc6Q7ayGr0cjJv/5wERdxXWXweyKT/wO9UZmRAR5eOjjp9qhn2z426n7sYUFXl 9G+DlyInfzfLxIda5P3OMzKzxAA+dad110U+ANLwAgA9YQKZjU/F+RI6GrZ6wA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=96fe7c8ab0f65cf829619abd74ae6c126b21e15f commit 96fe7c8ab0f65cf829619abd74ae6c126b21e15f Author: Ed Maste AuthorDate: 2022-01-19 18:08:18 +0000 Commit: Ed Maste CommitDate: 2022-02-04 16:18:12 +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 --- .../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,