From patchwork Tue Apr 9 14:24:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1921420 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=DykdiN3k; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VDSwv5J9Bz1yYT for ; Wed, 10 Apr 2024 00:27:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 008A83844073 for ; Tue, 9 Apr 2024 14:27:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by sourceware.org (Postfix) with ESMTPS id 60CCC3858288 for ; Tue, 9 Apr 2024 14:24:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 60CCC3858288 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 60CCC3858288 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712672681; cv=none; b=Cpd58GplRp1syr1RZZTsA39HimAxgp8QxNvyfaq22xdVKjoXqAOvvg6LMyWdvz5E6w7/HkJS4kNAqgwYfTRepzqAVYetJnfm5y9g6yerk1NO3R0KPHy6Mp6DaZdaU9cpJxnfM+BUBF0t5/DmsbGZM+ENu0E1lT9roTuJBlboMa4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712672681; c=relaxed/simple; bh=CgLJ8/LPFpRv3pIWSDWhQ5jC7CJ2Bw6gIy6M8Rhhwqw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UJIsMf89lrqu9Ubi8b4dhIY9W/b86c3fiPAHtF5OgmVuCIeknC7SLOPrrOJoS0C/XQ1seAGk7WnvKyv2BGMnEGMZr7hxX3PldBleSjKv0zqtE+E/65KC2YWQNL59NZ2li6dGftc/TknWZIBzOoDDYS2kiq1VRdrLOCBdImU5U/g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-22fa18566adso358137fac.0 for ; Tue, 09 Apr 2024 07:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712672677; x=1713277477; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=j9dh3oUn/QLoYwWhSB7z6iSS0R3yh0KSCEByO2OZaCg=; b=DykdiN3kguuMsfKdIgazD6S7zqt5IxHTcNH/lOrB9LIvBbdKUKwBjhujB9HdPtbZy7 dNYOIa1qafUxOLWy/Ozj/o7uDbvLwAwOoe2XhtuQs9iZ6+O0mbB51EHuwJDdJhoPMJJy T1oNbTfffffXxMqIZcjRQjqqtRcGteca4PxaW+FyfTMxJHs0tO5tDKnzTmJJwZ/6QuYc 2DTMuBkoo9l0ME9D/XVB8bzU1/2CyPzfLLqjZC5dyP8TXegUwf8x3VrqlhneTiiCgStZ Et/Sg4seDUIhVap85vcILWzFPEvTeH2jHIkaXOPJZXieJqvFyFz3jXjyP/H24bZqHfdw PBJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712672677; x=1713277477; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=j9dh3oUn/QLoYwWhSB7z6iSS0R3yh0KSCEByO2OZaCg=; b=X/qW6Fh66jAcstJyFWI3q4/I9rlyTECm9ZZoB7PXkvbOVHQFaffjR7UnOOlgFbdRga jAjqzUnSC+d/FalcM7RshriPH2HeB9wjwZmZOpGieRTIuo4tRABk13PpR9hRDGey9TrG ZKPk8wFYO5B6kRO37HmckrZ/PJpAIZg3RmGIQUvKUdhG+2MWVk/aB6IaMfncaq86ajP8 K+OPnbUtFii4TSNy8h2zzeakcQdr28NhSsmGIdFvc6esHjmNVyZCYCspqTQ5oHdQediP fByZMErm/I7DggZY7IaZT7RYNxxtquEFVRzvnTNP6wmAZBdVen4Am+sS8+pEJ6fT0vAl xoyw== X-Forwarded-Encrypted: i=1; AJvYcCWQWRBw8kMf64NPC8wiibUQCPxghBR4CZykiGAy3mKf6qwZYYlFbSdED+XQbPy0ENBrKXkkmqH9aOO5bBJPVKlxVucGMUnzpw== X-Gm-Message-State: AOJu0Yze+nx5TpyBgdHdpIlOh1nwoZbatCw9k4c6J9LfXDWKZFkQdxEk qkzJ3WDbf2PgbhsGpVaVM318Z8W9RELOMyealp+O4TyffRQPl0aiXoPmXVEf X-Google-Smtp-Source: AGHT+IFdk764qF3nTjrjFVRGwQGp61hpdKmt8IjtRzVdSpu11RU8L565dU4LAv5iLxnln+P4U+v/Ew== X-Received: by 2002:a05:6870:82a2:b0:22e:b354:f5ee with SMTP id q34-20020a05687082a200b0022eb354f5eemr12428248oae.15.1712672677126; Tue, 09 Apr 2024 07:24:37 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.56.169.48]) by smtp.gmail.com with ESMTPSA id m65-20020a633f44000000b005dc816b2369sm8168014pga.28.2024.04.09.07.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 07:24:36 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 6DD65740751; Tue, 9 Apr 2024 07:24:35 -0700 (PDT) From: "H.J. Lu" To: binutils@sourceware.org Cc: amodra@gmail.com, gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] mmap: Avoid the sanitizer configure check failure Date: Tue, 9 Apr 2024 07:24:34 -0700 Message-ID: <20240409142435.1708867-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409142435.1708867-1-hjl.tools@gmail.com> References: <20240409142435.1708867-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3020.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org When -fsanitize=address,undefined is used to build, the mmap configure check failed with ================================================================= ==231796==ERROR: LeakSanitizer: detected memory leaks Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x5750c7f6d72b in main /home/alan/build/gas-san/all/bfd/conftest.c:239 Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x5750c7f6d2e1 in main /home/alan/build/gas-san/all/bfd/conftest.c:190 SUMMARY: AddressSanitizer: 8192 byte(s) leaked in 2 allocation(s). Define GCC_AC_FUNC_MMAP with export ASAN_OPTIONS=detect_leaks=0 to avoid the sanitizer configure check failure. config/ * mmap.m4 (GCC_AC_FUNC_MMAP): New. * no-executables.m4 (AC_FUNC_MMAP): Renamed to GCC_AC_FUNC_MMAP. Change AC_FUNC_MMAP to GCC_AC_FUNC_MMAP. libiberty/ * Makefile.in (aclocal_deps): Add $(srcdir)/../config/mmap.m4. * acinclude.m4: Change AC_FUNC_MMAP to GCC_AC_FUNC_MMAP. * aclocal.m4: Regenerated. * configure: Likewise. zlib/ * acinclude.m4: Include ../config/mmap.m4. * Makefile.in: Regenerated. * configure: Likewise. --- config/mmap.m4 | 12 ++++++++++++ config/no-executables.m4 | 4 ++-- libiberty/Makefile.in | 1 + libiberty/acinclude.m4 | 2 +- libiberty/aclocal.m4 | 1 + libiberty/configure | 5 +++++ zlib/Makefile.in | 2 +- zlib/acinclude.m4 | 1 + zlib/configure | 7 ------- 9 files changed, 24 insertions(+), 11 deletions(-) diff --git a/config/mmap.m4 b/config/mmap.m4 index fba0d9d3657..5ebdb90e4ee 100644 --- a/config/mmap.m4 +++ b/config/mmap.m4 @@ -95,3 +95,15 @@ if test $gcc_cv_func_mmap_anon = yes; then [Define if mmap with MAP_ANON(YMOUS) works.]) fi ]) + +dnl +dnl Avoid the sanitizer run-time memory leak failure in the mmap configure +dnl test. +dnl +AC_DEFUN([GCC_AC_FUNC_MMAP], + save_ASAN_OPTIONS="$ASAN_OPTIONS" + ASAN_OPTIONS=detect_leaks=0 + export ASAN_OPTIONS + m4_defn([AC_FUNC_MMAP]) + ASAN_OPTIONS="$save_ASAN_OPTIONS" +) diff --git a/config/no-executables.m4 b/config/no-executables.m4 index 6842f84fba3..e8e2537bde5 100644 --- a/config/no-executables.m4 +++ b/config/no-executables.m4 @@ -49,14 +49,14 @@ m4_defn([AC_LINK_IFELSE])) dnl This is a shame. We have to provide a default for some link tests, dnl similar to the default for run tests. -m4_define([AC_FUNC_MMAP], +m4_define([GCC_AC_FUNC_MMAP], if test x$gcc_no_link = xyes; then if test "x${ac_cv_func_mmap_fixed_mapped+set}" != xset; then ac_cv_func_mmap_fixed_mapped=no fi fi if test "x${ac_cv_func_mmap_fixed_mapped}" != xno; then - m4_defn([AC_FUNC_MMAP]) + m4_defn([GCC_AC_FUNC_MMAP]) fi) m4_divert_pop()dnl diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in index 85c4b6b6ef8..b77a41c781c 100644 --- a/libiberty/Makefile.in +++ b/libiberty/Makefile.in @@ -508,6 +508,7 @@ aclocal_deps = \ $(srcdir)/../config/cet.m4 \ $(srcdir)/../config/enable.m4 \ $(srcdir)/../config/gcc-plugin.m4 \ + $(srcdir)/../config/mmap.m4 \ $(srcdir)/../config/no-executables.m4 \ $(srcdir)/../config/override.m4 \ $(srcdir)/../config/picflag.m4 \ diff --git a/libiberty/acinclude.m4 b/libiberty/acinclude.m4 index 9974dcd4ec5..d08e31bc0b5 100644 --- a/libiberty/acinclude.m4 +++ b/libiberty/acinclude.m4 @@ -19,7 +19,7 @@ dnl On some versions of SunOS4 at least, strncmp reads a word at a time dnl but erroneously reads past the end of strings. This can cause dnl a SEGV in some cases. AC_DEFUN([libiberty_AC_FUNC_STRNCMP], -[AC_REQUIRE([AC_FUNC_MMAP]) +[AC_REQUIRE([GCC_AC_FUNC_MMAP]) AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works, [AC_TRY_RUN([ /* Test by Jim Wilson and Kaveh Ghazi. diff --git a/libiberty/aclocal.m4 b/libiberty/aclocal.m4 index 364fb6bc3b4..9678b0acaba 100644 --- a/libiberty/aclocal.m4 +++ b/libiberty/aclocal.m4 @@ -17,6 +17,7 @@ m4_include([../config/cet.m4]) m4_include([../config/enable.m4]) m4_include([../config/gcc-plugin.m4]) m4_include([../config/hwcaps.m4]) +m4_include([../config/mmap.m4]) m4_include([../config/no-executables.m4]) m4_include([../config/override.m4]) m4_include([../config/picflag.m4]) diff --git a/libiberty/configure b/libiberty/configure index 5c69fee56c1..18e98b84bb5 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -7724,6 +7724,9 @@ if test x$gcc_no_link = xyes; then fi fi if test "x${ac_cv_func_mmap_fixed_mapped}" != xno; then + save_ASAN_OPTIONS="$ASAN_OPTIONS" + ASAN_OPTIONS=detect_leaks=0 + export ASAN_OPTIONS for ac_func in getpagesize do : @@ -7902,6 +7905,8 @@ $as_echo "#define HAVE_MMAP 1" >>confdefs.h fi rm -f conftest.mmap conftest.txt + ASAN_OPTIONS="$save_ASAN_OPTIONS" + fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strncmp" >&5 diff --git a/zlib/Makefile.in b/zlib/Makefile.in index dd8a21deba1..951260ac4c5 100644 --- a/zlib/Makefile.in +++ b/zlib/Makefile.in @@ -98,7 +98,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \ $(top_srcdir)/../config/override.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ - $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/../config/mmap.m4 \ $(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ diff --git a/zlib/acinclude.m4 b/zlib/acinclude.m4 index 9a5f5485716..3b8be00d702 100644 --- a/zlib/acinclude.m4 +++ b/zlib/acinclude.m4 @@ -1,3 +1,4 @@ +sinclude(../config/mmap.m4) sinclude(../config/no-executables.m4) sinclude(../libtool.m4) dnl The lines below arrange for aclocal not to bring libtool.m4 diff --git a/zlib/configure b/zlib/configure index 2d551360683..0e8a28a09a8 100755 --- a/zlib/configure +++ b/zlib/configure @@ -11245,12 +11245,6 @@ if test -n "$with_cross_host"; then # We ignore --with-system-zlib in this case. target_all=libzgcj.la else - if test x$gcc_no_link = xyes; then - if test "x${ac_cv_func_mmap_fixed_mapped+set}" != xset; then - ac_cv_func_mmap_fixed_mapped=no - fi -fi -if test "x${ac_cv_func_mmap_fixed_mapped}" != xno; then @@ -11452,7 +11446,6 @@ $as_echo "#define HAVE_MMAP 1" >>confdefs.h fi rm -f conftest.mmap conftest.txt -fi for ac_func in memcpy strerror do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` From patchwork Tue Apr 9 14:24:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1921419 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=WWzh8Sy/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VDSvH4XW2z1yYT for ; Wed, 10 Apr 2024 00:26:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E2F8386101D for ; Tue, 9 Apr 2024 14:26:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 0545E385842A for ; Tue, 9 Apr 2024 14:24:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0545E385842A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0545E385842A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712672681; cv=none; b=oQTFfFqX6xh1O20cdF1b4KWNKYtodixTBhKFJz+V+jYJplmQEqobLV0KJ0sTzwUJ8ttnf3C3/sT5ygCych111Q7SDlG6ny0mKMrOxfdCHbqvpWnrtnvjImCjW075AXxMU+kzqV0MNfckhsfP2TzPrH5BgsxBmLHX7QXc8R2y1qI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712672681; c=relaxed/simple; bh=24Gz8bttvX4442YWasSr6hxl1ORidi02NQGwFrHJieA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Gnd80HMkq6orITcXyoAZ1uDrorHtIWeHm7nnKDJvODxgaGQapQ5p3++yHrocAfViCTbhbLlwLYpXc+rTOibcRUmICQ0TuRevW45SfoQff1FudO0P0qXo+PDCESUXsQYgknZAaj0noBCZv4/OH4dD684fFhWRzANwam5Ryrekx9s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1e3c7549078so24368475ad.0 for ; Tue, 09 Apr 2024 07:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712672677; x=1713277477; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=auJLqmGcNJlt+FYp6vtKa02jNtZw8eNRuRa4zAgrN0E=; b=WWzh8Sy/cMVsexHc/S7RT7dmsCCKiOpjlZGeS8y3kr33r7Q7a9zmkUfoeY8VHkHCDD Ui+VgyHBGPfr+TdUtkerLqgnbwULAqT7rhhrgTMrbjpAu3hWkjpYku1aZUiAXIjatMy7 5l0YEs5B1nHn/7QYFyIPyt0m6Jg8CR5KDcKINO/xw9SN+ojjdl3dyK5o3GrMZ4sE9PF/ ZpDB4jF3nM1/HkUOlS6xPwUDI0wUDdF7fbTD12WR6KH3mDZnwfOfQkur+N6OAGF7/OS/ z3ZLfcR+LtkAxB0K8+SfJNDlVW0+uBsx55+xeqdbMxJjYBK1fsomWHZziih7wlZ57C/A E/lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712672677; x=1713277477; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=auJLqmGcNJlt+FYp6vtKa02jNtZw8eNRuRa4zAgrN0E=; b=P+zH8e7JJ2Gidwy8TT76ChW6hrG5+QY+hN7BvwNbWBhOfcpuKb1Sfpd3e7lHv7oui+ VQTRIU9ComVLQVkYSsJyuSQFfQ1JgowYA47h1iK65qbKwVqqtshTlKOAVFpNihqQioX2 PHiwhFYt/qij6R2ECODjiCSmRP6S/vhhwCORFBnpkTHD2XqXSJ4JS85gar3DC0ZlWnA7 ny5v05qnDQ3+WXkwyq0AI29DCby1ZAAuGEOIb9fI0KuZKxRyjo25UwQiKy8D3jqMrZuH JS3SOEaff7kd+zJ3HCuHKxdWHQNVr4HVbqIuAjg5wOZGfmPgOSl2ut4/GASzA+UyAcKk 3CGA== X-Forwarded-Encrypted: i=1; AJvYcCX+EcmrVD6jbC2KktiDZWyI72F1gfWFc/CvQF0YoKGlU37oAyffshKdCW/HuU9vr4pkeDZwvNFFraig7Y/uwzMw5dvRVU+1rw== X-Gm-Message-State: AOJu0YzzXK5YMscn8iyYpc/rYSMa/fOOzyetgOSdnwcFGhdQcHXGhwxs tMWtp0wt4KMgLGxILdECvkjsRVXV5AABiLEVF/S3dC082ImWzwwzspiSK7tg X-Google-Smtp-Source: AGHT+IFy0G6naPuw+wHvJmXBw6ADkMS5pk6qpBn641YdbFtLVQvrjJ4xt7jAyb+O2FyAlsu2EXpcgg== X-Received: by 2002:a17:902:ea01:b0:1e0:c3b5:196 with SMTP id s1-20020a170902ea0100b001e0c3b50196mr3781576plg.20.1712672677363; Tue, 09 Apr 2024 07:24:37 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.56.169.48]) by smtp.gmail.com with ESMTPSA id u16-20020a17090341d000b001e268c9e38asm8903025ple.43.2024.04.09.07.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 07:24:36 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 7AC5B74078A; Tue, 9 Apr 2024 07:24:35 -0700 (PDT) From: "H.J. Lu" To: binutils@sourceware.org Cc: amodra@gmail.com, gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] mmap: Avoid the sanitizer configure check failure Date: Tue, 9 Apr 2024 07:24:35 -0700 Message-ID: <20240409142435.1708867-3-hjl.tools@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409142435.1708867-1-hjl.tools@gmail.com> References: <20240409142435.1708867-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3020.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org When -fsanitize=address,undefined is used to build, the mmap configure check failed with ================================================================= ==231796==ERROR: LeakSanitizer: detected memory leaks Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x5750c7f6d72b in main /home/alan/build/gas-san/all/bfd/conftest.c:239 Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7cdd3d0defdf in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69 #1 0x5750c7f6d2e1 in main /home/alan/build/gas-san/all/bfd/conftest.c:190 SUMMARY: AddressSanitizer: 8192 byte(s) leaked in 2 allocation(s). Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP to avoid the sanitizer configure check failure. bfd/ * configure.ac: Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure: Likewise. binutils/ * configure.ac: Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure: Likewise. ld/ * configure.ac: Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure: Likewise. libctf/ * configure.ac: Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure: Likewise. libsframe/ * configure.ac: Replace AC_FUNC_MMAP with GCC_AC_FUNC_MMAP. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure: Likewise. --- bfd/Makefile.in | 2 +- bfd/aclocal.m4 | 1 + bfd/configure | 5 +++++ bfd/configure.ac | 2 +- binutils/Makefile.in | 2 +- binutils/aclocal.m4 | 1 + binutils/configure | 5 +++++ binutils/configure.ac | 2 +- ld/Makefile.in | 2 +- ld/aclocal.m4 | 1 + ld/configure | 5 +++++ ld/configure.ac | 2 +- libctf/Makefile.in | 2 +- libctf/aclocal.m4 | 1 + libctf/configure | 5 +++++ libctf/configure.ac | 2 +- libsframe/Makefile.in | 1 + libsframe/aclocal.m4 | 1 + libsframe/configure | 5 +++++ libsframe/configure.ac | 2 +- 20 files changed, 40 insertions(+), 9 deletions(-) diff --git a/bfd/Makefile.in b/bfd/Makefile.in index faaa0c424b8..3092bff2935 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -125,7 +125,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../config/lib-ld.m4 \ $(top_srcdir)/../config/lib-link.m4 \ $(top_srcdir)/../config/lib-prefix.m4 \ - $(top_srcdir)/../config/nls.m4 \ + $(top_srcdir)/../config/mmap.m4 $(top_srcdir)/../config/nls.m4 \ $(top_srcdir)/../config/override.m4 \ $(top_srcdir)/../config/pkg.m4 \ $(top_srcdir)/../config/plugins.m4 \ diff --git a/bfd/aclocal.m4 b/bfd/aclocal.m4 index 4b3fd56cfc9..8364b5dba69 100644 --- a/bfd/aclocal.m4 +++ b/bfd/aclocal.m4 @@ -1180,6 +1180,7 @@ m4_include([../config/lead-dot.m4]) m4_include([../config/lib-ld.m4]) m4_include([../config/lib-link.m4]) m4_include([../config/lib-prefix.m4]) +m4_include([../config/mmap.m4]) m4_include([../config/nls.m4]) m4_include([../config/override.m4]) m4_include([../config/pkg.m4]) diff --git a/bfd/configure b/bfd/configure index 210550ae042..89fe4388171 100755 --- a/bfd/configure +++ b/bfd/configure @@ -17332,6 +17332,9 @@ done +save_ASAN_OPTIONS="$ASAN_OPTIONS" + ASAN_OPTIONS=detect_leaks=0 + export ASAN_OPTIONS for ac_func in getpagesize do : @@ -17510,6 +17513,8 @@ $as_echo "#define HAVE_MMAP 1" >>confdefs.h fi rm -f conftest.mmap conftest.txt + ASAN_OPTIONS="$save_ASAN_OPTIONS" + for ac_func in madvise mprotect do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/bfd/configure.ac b/bfd/configure.ac index 02d8ba96318..29ede92b993 100644 --- a/bfd/configure.ac +++ b/bfd/configure.ac @@ -1029,7 +1029,7 @@ AC_MSG_RESULT($bfd_file_ptr) AC_SUBST(bfd_file_ptr) AC_SUBST(bfd_ufile_ptr) -AC_FUNC_MMAP +GCC_AC_FUNC_MMAP AC_CHECK_FUNCS(madvise mprotect) case ${want_mmap}+${ac_cv_func_mmap_fixed_mapped} in true+yes ) AC_DEFINE(USE_MMAP, 1, [Use mmap if it's available?]) ;; diff --git a/binutils/Makefile.in b/binutils/Makefile.in index 842a6d99b54..67fa5b3b8d9 100644 --- a/binutils/Makefile.in +++ b/binutils/Makefile.in @@ -152,7 +152,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ $(top_srcdir)/../config/lib-ld.m4 \ $(top_srcdir)/../config/lib-link.m4 \ $(top_srcdir)/../config/lib-prefix.m4 \ - $(top_srcdir)/../config/nls.m4 \ + $(top_srcdir)/../config/mmap.m4 $(top_srcdir)/../config/nls.m4 \ $(top_srcdir)/../config/override.m4 \ $(top_srcdir)/../config/pkg.m4 \ $(top_srcdir)/../config/plugins.m4 \ diff --git a/binutils/aclocal.m4 b/binutils/aclocal.m4 index 1238894b07b..eb1433a68bd 100644 --- a/binutils/aclocal.m4 +++ b/binutils/aclocal.m4 @@ -1200,6 +1200,7 @@ m4_include([../config/lead-dot.m4]) m4_include([../config/lib-ld.m4]) m4_include([../config/lib-link.m4]) m4_include([../config/lib-prefix.m4]) +m4_include([../config/mmap.m4]) m4_include([../config/nls.m4]) m4_include([../config/override.m4]) m4_include([../config/pkg.m4]) diff --git a/binutils/configure b/binutils/configure index 2b9f52720c3..5d87b6b3e66 100755 --- a/binutils/configure +++ b/binutils/configure @@ -15231,6 +15231,9 @@ done +save_ASAN_OPTIONS="$ASAN_OPTIONS" + ASAN_OPTIONS=detect_leaks=0 + export ASAN_OPTIONS for ac_func in getpagesize do : @@ -15409,6 +15412,8 @@ $as_echo "#define HAVE_MMAP 1" >>confdefs.h fi rm -f conftest.mmap conftest.txt + ASAN_OPTIONS="$save_ASAN_OPTIONS" + for ac_func in fseeko fseeko64 getc_unlocked mkdtemp mkstemp utimensat utimes do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` diff --git a/binutils/configure.ac b/binutils/configure.ac index dac72c1bdd4..ac3e418392f 100644 --- a/binutils/configure.ac +++ b/binutils/configure.ac @@ -199,7 +199,7 @@ AC_SUBST(DEMANGLER_NAME) AC_CHECK_HEADERS(fcntl.h inttypes.h stdint.h sys/file.h \ sys/stat.h sys/time.h sys/types.h unistd.h) AC_HEADER_SYS_WAIT -AC_FUNC_MMAP +GCC_AC_FUNC_MMAP AC_CHECK_FUNCS(fseeko fseeko64 getc_unlocked mkdtemp mkstemp utimensat utimes) AC_MSG_CHECKING([for mbstate_t]) diff --git a/ld/Makefile.in b/ld/Makefile.in index abb0565718f..8350f00a521 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -126,7 +126,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ $(top_srcdir)/../config/lib-ld.m4 \ $(top_srcdir)/../config/lib-link.m4 \ $(top_srcdir)/../config/lib-prefix.m4 \ - $(top_srcdir)/../config/nls.m4 \ + $(top_srcdir)/../config/mmap.m4 $(top_srcdir)/../config/nls.m4 \ $(top_srcdir)/../config/override.m4 \ $(top_srcdir)/../config/pkg.m4 \ $(top_srcdir)/../config/plugins.m4 \ diff --git a/ld/aclocal.m4 b/ld/aclocal.m4 index d9feb988d64..01c2dc2694d 100644 --- a/ld/aclocal.m4 +++ b/ld/aclocal.m4 @@ -1202,6 +1202,7 @@ m4_include([../config/lead-dot.m4]) m4_include([../config/lib-ld.m4]) m4_include([../config/lib-link.m4]) m4_include([../config/lib-prefix.m4]) +m4_include([../config/mmap.m4]) m4_include([../config/nls.m4]) m4_include([../config/override.m4]) m4_include([../config/pkg.m4]) diff --git a/ld/configure b/ld/configure index 96ef1f8bb65..ba0024699d4 100755 --- a/ld/configure +++ b/ld/configure @@ -18802,6 +18802,9 @@ done +save_ASAN_OPTIONS="$ASAN_OPTIONS" + ASAN_OPTIONS=detect_leaks=0 + export ASAN_OPTIONS for ac_func in getpagesize do : @@ -18980,6 +18983,8 @@ $as_echo "#define HAVE_MMAP 1" >>confdefs.h fi rm -f conftest.mmap conftest.txt + ASAN_OPTIONS="$save_ASAN_OPTIONS" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 $as_echo_n "checking for library containing dlopen... " >&6; } diff --git a/ld/configure.ac b/ld/configure.ac index 4a11787ae71..0d4aa4c2373 100644 --- a/ld/configure.ac +++ b/ld/configure.ac @@ -401,7 +401,7 @@ BFD_BINARY_FOPEN AC_CHECK_DECLS([asprintf, environ, stpcpy]) -AC_FUNC_MMAP +GCC_AC_FUNC_MMAP AC_SEARCH_LIBS([dlopen], [dl]) diff --git a/libctf/Makefile.in b/libctf/Makefile.in index 1cdf105a323..54f5daa79ee 100644 --- a/libctf/Makefile.in +++ b/libctf/Makefile.in @@ -145,7 +145,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ $(top_srcdir)/../config/lib-ld.m4 \ $(top_srcdir)/../config/lib-link.m4 \ $(top_srcdir)/../config/lib-prefix.m4 \ - $(top_srcdir)/../config/nls.m4 \ + $(top_srcdir)/../config/mmap.m4 $(top_srcdir)/../config/nls.m4 \ $(top_srcdir)/../config/override.m4 \ $(top_srcdir)/../config/po.m4 \ $(top_srcdir)/../config/progtest.m4 \ diff --git a/libctf/aclocal.m4 b/libctf/aclocal.m4 index e64180daf89..fc2b7d7ddcc 100644 --- a/libctf/aclocal.m4 +++ b/libctf/aclocal.m4 @@ -1240,6 +1240,7 @@ m4_include([../config/lead-dot.m4]) m4_include([../config/lib-ld.m4]) m4_include([../config/lib-link.m4]) m4_include([../config/lib-prefix.m4]) +m4_include([../config/mmap.m4]) m4_include([../config/nls.m4]) m4_include([../config/override.m4]) m4_include([../config/po.m4]) diff --git a/libctf/configure b/libctf/configure index 3701bd8e796..778c141571e 100755 --- a/libctf/configure +++ b/libctf/configure @@ -15989,6 +15989,9 @@ done +save_ASAN_OPTIONS="$ASAN_OPTIONS" + ASAN_OPTIONS=detect_leaks=0 + export ASAN_OPTIONS for ac_func in getpagesize do : @@ -16167,6 +16170,8 @@ $as_echo "#define HAVE_MMAP 1" >>confdefs.h fi rm -f conftest.mmap conftest.txt + ASAN_OPTIONS="$save_ASAN_OPTIONS" + # Needed for BFD capability checks. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlsym" >&5 $as_echo_n "checking for library containing dlsym... " >&6; } diff --git a/libctf/configure.ac b/libctf/configure.ac index e4e430615bd..f327d48f249 100644 --- a/libctf/configure.ac +++ b/libctf/configure.ac @@ -65,7 +65,7 @@ AM_MAINTAINER_MODE AM_INSTALL_LIBBFD ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_libctf_warn_cflags]) -AC_FUNC_MMAP +GCC_AC_FUNC_MMAP # Needed for BFD capability checks. AC_SEARCH_LIBS(dlsym, dl) AM_ZLIB diff --git a/libsframe/Makefile.in b/libsframe/Makefile.in index 9e3d268902b..111d6a30c98 100644 --- a/libsframe/Makefile.in +++ b/libsframe/Makefile.in @@ -126,6 +126,7 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ $(top_srcdir)/../config/depstand.m4 \ $(top_srcdir)/../config/jobserver.m4 \ $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/mmap.m4 \ $(top_srcdir)/../config/override.m4 \ $(top_srcdir)/../config/warnings.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \ diff --git a/libsframe/aclocal.m4 b/libsframe/aclocal.m4 index b0cdd6b184d..8804d9fb42b 100644 --- a/libsframe/aclocal.m4 +++ b/libsframe/aclocal.m4 @@ -1233,6 +1233,7 @@ m4_include([../config/dejagnu.m4]) m4_include([../config/depstand.m4]) m4_include([../config/jobserver.m4]) m4_include([../config/lead-dot.m4]) +m4_include([../config/mmap.m4]) m4_include([../config/override.m4]) m4_include([../config/warnings.m4]) m4_include([../libtool.m4]) diff --git a/libsframe/configure b/libsframe/configure index 1d9e5e10695..8a9018c493e 100755 --- a/libsframe/configure +++ b/libsframe/configure @@ -12520,6 +12520,9 @@ done +save_ASAN_OPTIONS="$ASAN_OPTIONS" + ASAN_OPTIONS=detect_leaks=0 + export ASAN_OPTIONS for ac_func in getpagesize do : @@ -12698,6 +12701,8 @@ $as_echo "#define HAVE_MMAP 1" >>confdefs.h fi rm -f conftest.mmap conftest.txt + ASAN_OPTIONS="$save_ASAN_OPTIONS" + for ac_header in byteswap.h endian.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` diff --git a/libsframe/configure.ac b/libsframe/configure.ac index 733517a978f..d63f27070eb 100644 --- a/libsframe/configure.ac +++ b/libsframe/configure.ac @@ -112,7 +112,7 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") AM_MAINTAINER_MODE AM_INSTALL_LIBBFD -AC_FUNC_MMAP +GCC_AC_FUNC_MMAP AC_CHECK_HEADERS(byteswap.h endian.h) dnl Check for bswap_{16,32,64}