aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-04-09 06:39:21 -0700
committerH.J. Lu <hjl.tools@gmail.com>2024-04-10 03:57:02 -0700
commit219822fd5db6305592b45677a3b38c02b523360e (patch)
treebd623bf325da7ee47240e38443cac7100936a20b /config
parentbdefc073061ff9e9334a1306e9c70745104dc57f (diff)
downloadgdb-219822fd5db6305592b45677a3b38c02b523360e.zip
gdb-219822fd5db6305592b45677a3b38c02b523360e.tar.gz
gdb-219822fd5db6305592b45677a3b38c02b523360e.tar.bz2
mmap: Avoid the sanitizer configure check failure
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.
Diffstat (limited to 'config')
-rw-r--r--config/mmap.m422
-rw-r--r--config/no-executables.m44
2 files changed, 24 insertions, 2 deletions
diff --git a/config/mmap.m4 b/config/mmap.m4
index fba0d9d..326b97b 100644
--- a/config/mmap.m4
+++ b/config/mmap.m4
@@ -95,3 +95,25 @@ 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. This should be removed when autoconf with commit:
+dnl
+dnl commit 09b6e78d1592ce10fdc975025d699ee41444aa3f
+dnl Author: Paul Eggert <eggert@cs.ucla.edu>
+dnl Date: Fri Feb 5 21:06:20 2016 -0800
+dnl Fix memory leak in AC_FUNC_MMAP
+dnl
+dnl * lib/autoconf/functions.m4 (AC_FUNC_MMAP): Fix memory leak
+dnl in test case, found by configuring with gcc -fsanitize=address.
+dnl
+dnl is in use.
+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 6842f84..e8e2537 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