]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
GCC 5.1 is too smart. Disable Identical Code Folding for preload libs.
authorMark Wielaard <mark@klomp.org>
Tue, 2 Jun 2015 20:23:06 +0000 (20:23 +0000)
committerMark Wielaard <mark@klomp.org>
Tue, 2 Jun 2015 20:23:06 +0000 (20:23 +0000)
We want to disabled Identical Code Folding for the tools preload shared
objects to get better backraces. For GCC 5.1 -fipa-icf is enabled by
default at -O2.

    The optimization reduces code size and may disturb
    unwind stacks by replacing a function by equivalent
    one with a different name.

Add a configure check to see if GCC supports -fno-ipa-icf.
If it does then add the flag to AM_CFLAGS_PSO_BASE.

Without this GCC will notice some of the preload replacement functions
in vg_replace_strmem are identical and fold them all into one picking
a random (existing) function name. This causes backtraces showing
completely unexpected function names.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15305

Makefile.all.am
configure.ac

index d58754823f1f8a3ab306fc07916e90867283d757..a04cb4afb1a26a62c18253c953a32f16b03820c7 100644 (file)
@@ -133,10 +133,10 @@ endif
 if VGCONF_OS_IS_DARWIN
 AM_CFLAGS_PSO_BASE = -dynamic \
                     -O -g -fno-omit-frame-pointer -fno-strict-aliasing \
-                    -fpic -fPIC -fno-builtin
+                    -fpic -fPIC -fno-builtin @FLAG_FNO_IPA_ICF@
 else
 AM_CFLAGS_PSO_BASE = -O -g -fno-omit-frame-pointer -fno-strict-aliasing \
-                    -fpic -fno-builtin
+                    -fpic -fno-builtin @FLAG_FNO_IPA_ICF@
 endif
 
 
index eac62cd19dc3303c33c64d9ce72ca710b144bfec..6a62e5792af6cd62dbd9b9879001380591a92197 100644 (file)
@@ -1811,6 +1811,33 @@ CFLAGS=$safe_CFLAGS
 
 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
 
+# Does GCC support disabling Identical Code Folding?
+# We want to disabled Identical Code Folding for the
+# tools preload shared objects to get better backraces.
+# For GCC 5.1+ -fipa-icf is enabled by default at -O2.
+# "The optimization reduces code size and may disturb
+#  unwind stacks by replacing a function by equivalent
+#  one with a different name."
+AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
+
+safe_CFLAGS=$CFLAGS
+CFLAGS="-fno-ipa-icf"
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+  return 0;
+]])], [
+no_ipa_icf=yes
+FLAG_FNO_IPA_ICF="-fno-ipa-icf"
+AC_MSG_RESULT([yes])
+], [
+no_ipa_icf=no
+FLAG_FNO_IPA_ICF=""
+AC_MSG_RESULT([no])
+])
+CFLAGS=$safe_CFLAGS
+
+AC_SUBST(FLAG_FNO_IPA_ICF)
+
 
 # Does this compiler support -fsanitize=undefined?
 # Only checked for if --enable-ubsan was given.