From 86c090b77fb07bcad60a47779a9228b04ef3c366 Mon Sep 17 00:00:00 2001 From: Eric Astor Date: Mon, 21 Dec 2020 16:32:39 -0500 Subject: [PATCH] Do not build core_handler unless memfd_create is available Restores build compatibility with glibc < 2.27. Change-Id: I1e58ab5e15d7691ad076769a52260fa01c9cfd06 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2597562 Reviewed-by: Mike Frysinger --- Makefile.am | 4 ++++ Makefile.in | 18 +++++++++--------- configure | 18 ++++++++++++++++-- configure.ac | 5 +++-- src/config.h.in | 6 ++++++ 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Makefile.am b/Makefile.am index fd9875b4..2a2e7e47 100644 --- a/Makefile.am +++ b/Makefile.am @@ -365,9 +365,11 @@ if X86_HOST bin_PROGRAMS += \ src/tools/mac/dump_syms/dump_syms_mac endif +if HAVE_MEMFD_CREATE libexec_PROGRAMS += \ src/tools/linux/core_handler/core_handler endif +endif endif LINUX_HOST @@ -576,11 +578,13 @@ src_tools_linux_core2md_core2md_SOURCES = \ src_tools_linux_core2md_core2md_LDADD = \ src/client/linux/libbreakpad_client.a +if HAVE_MEMFD_CREATE src_tools_linux_core_handler_core_handler_SOURCES = \ src/tools/linux/core_handler/core_handler.cc src_tools_linux_core_handler_core_handler_LDADD = \ src/client/linux/libbreakpad_client.a +endif src_tools_linux_pid2md_pid2md_SOURCES = \ src/tools/linux/pid2md/pid2md.cc diff --git a/Makefile.in b/Makefile.in index 24cbfc26..212e3f32 100644 --- a/Makefile.in +++ b/Makefile.in @@ -165,8 +165,8 @@ EXTRA_PROGRAMS = $(am__EXEEXT_1) @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@@X86_HOST_TRUE@am__append_14 = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@@X86_HOST_TRUE@ src/tools/mac/dump_syms/dump_syms_mac -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am__append_15 = \ -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/core_handler/core_handler +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@am__append_15 = \ +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@ src/tools/linux/core_handler/core_handler @DISABLE_PROCESSOR_FALSE@am__append_16 = \ @DISABLE_PROCESSOR_FALSE@ src/common/test_assembler_unittest \ @@ -307,7 +307,7 @@ am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libexecdir)" \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/md2core/minidump_2_core_unittest$(EXEEXT) @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@@X86_HOST_TRUE@am__EXEEXT_8 = src/common/mac/macho_reader_unittest$(EXEEXT) @DISABLE_PROCESSOR_FALSE@@SELFTEST_TRUE@am__EXEEXT_9 = src/processor/stackwalker_selftest$(EXEEXT) -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am__EXEEXT_10 = src/tools/linux/core_handler/core_handler$(EXEEXT) +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@am__EXEEXT_10 = src/tools/linux/core_handler/core_handler$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) $(libexec_PROGRAMS) $(noinst_PROGRAMS) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ @@ -1451,10 +1451,10 @@ src_tools_linux_core2md_core2md_OBJECTS = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_core2md_core2md_DEPENDENCIES = src/client/linux/libbreakpad_client.a am__src_tools_linux_core_handler_core_handler_SOURCES_DIST = \ src/tools/linux/core_handler/core_handler.cc -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@am_src_tools_linux_core_handler_core_handler_OBJECTS = src/tools/linux/core_handler/core_handler.$(OBJEXT) +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@am_src_tools_linux_core_handler_core_handler_OBJECTS = src/tools/linux/core_handler/core_handler.$(OBJEXT) src_tools_linux_core_handler_core_handler_OBJECTS = \ $(am_src_tools_linux_core_handler_core_handler_OBJECTS) -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_DEPENDENCIES = src/client/linux/libbreakpad_client.a +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_DEPENDENCIES = src/client/linux/libbreakpad_client.a am__src_tools_linux_dump_syms_dump_syms_SOURCES_DIST = \ src/common/dwarf_cfi_to_module.cc \ src/common/dwarf_cu_to_module.cc \ @@ -2777,11 +2777,11 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS) @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_core2md_core2md_LDADD = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/client/linux/libbreakpad_client.a -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_SOURCES = \ -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/core_handler/core_handler.cc +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_SOURCES = \ +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@ src/tools/linux/core_handler/core_handler.cc -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_LDADD = \ -@DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/client/linux/libbreakpad_client.a +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@src_tools_linux_core_handler_core_handler_LDADD = \ +@DISABLE_TOOLS_FALSE@@HAVE_MEMFD_CREATE_TRUE@@LINUX_HOST_TRUE@ src/client/linux/libbreakpad_client.a @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@src_tools_linux_pid2md_pid2md_SOURCES = \ @DISABLE_TOOLS_FALSE@@LINUX_HOST_TRUE@ src/tools/linux/pid2md/pid2md.cc diff --git a/configure b/configure index 59fe0aad..64fea815 100755 --- a/configure +++ b/configure @@ -650,6 +650,8 @@ LINUX_HOST_FALSE LINUX_HOST_TRUE WARN_CXXFLAGS HAVE_CXX11 +HAVE_MEMFD_CREATE_FALSE +HAVE_MEMFD_CREATE_TRUE HAVE_GETCONTEXT_FALSE HAVE_GETCONTEXT_TRUE PTHREAD_CFLAGS @@ -6651,7 +6653,7 @@ fi done -for ac_header in a.out.h sys/random.h +for ac_header in a.out.h sys/mman.h sys/random.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -6664,7 +6666,7 @@ fi done -for ac_func in arc4random getcontext getrandom +for ac_func in arc4random getcontext getrandom memfd_create do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -6684,6 +6686,14 @@ else HAVE_GETCONTEXT_FALSE= fi + if test "x$ac_cv_func_memfd_create" = xyes; then + HAVE_MEMFD_CREATE_TRUE= + HAVE_MEMFD_CREATE_FALSE='#' +else + HAVE_MEMFD_CREATE_TRUE='#' + HAVE_MEMFD_CREATE_FALSE= +fi + ax_cxx_compile_cxx11_required=true @@ -7886,6 +7896,10 @@ if test -z "${HAVE_GETCONTEXT_TRUE}" && test -z "${HAVE_GETCONTEXT_FALSE}"; then as_fn_error $? "conditional \"HAVE_GETCONTEXT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${HAVE_MEMFD_CREATE_TRUE}" && test -z "${HAVE_MEMFD_CREATE_FALSE}"; then + as_fn_error $? "conditional \"HAVE_MEMFD_CREATE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${LINUX_HOST_TRUE}" && test -z "${LINUX_HOST_FALSE}"; then as_fn_error $? "conditional \"LINUX_HOST\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/configure.ac b/configure.ac index 08513687..b62b8fe5 100644 --- a/configure.ac +++ b/configure.ac @@ -72,9 +72,10 @@ AC_ARG_ENABLE(m32, AC_HEADER_STDC AC_SYS_LARGEFILE AX_PTHREAD -AC_CHECK_HEADERS([a.out.h sys/random.h]) -AC_CHECK_FUNCS([arc4random getcontext getrandom]) +AC_CHECK_HEADERS([a.out.h sys/mman.h sys/random.h]) +AC_CHECK_FUNCS([arc4random getcontext getrandom memfd_create]) AM_CONDITIONAL([HAVE_GETCONTEXT], [test "x$ac_cv_func_getcontext" = xyes]) +AM_CONDITIONAL([HAVE_MEMFD_CREATE], [test "x$ac_cv_func_memfd_create" = xyes]) AX_CXX_COMPILE_STDCXX(11, noext, mandatory) diff --git a/src/config.h.in b/src/config.h.in index 0553a24b..ba6c520f 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -18,6 +18,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H +/* Define to 1 if you have the `memfd_create' function. */ +#undef HAVE_MEMFD_CREATE + /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H @@ -36,6 +39,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MMAN_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_RANDOM_H