Skip to content

Commit e3b68b3

Browse files
committed
Merge bitcoin#28875: build: Pass sanitize flags to instrument libsecp256k1 code
cbea49c build: Pass sanitize flags to instrument `libsecp256k1` code (Hennadii Stepanov) Pull request description: This PR is a revived bitcoin#27991 with an addressed [comment](bitcoin#27991 (comment)). Fixes bitcoin#27990. Might be tested as follows: ``` $ ./autogen.sh && ./configure --enable-fuzz --with-sanitizers=fuzzer CC=clang-13 CXX=clang++-13 $ make clean > /dev/null && make $ objdump --disassemble=secp256k1_xonly_pubkey_serialize src/test/fuzz/fuzz | grep __sanitizer_cov 1953bd0:e8 bb c6 05 ff call 9b0290 <__sanitizer_cov_trace_const_cmp8> 1953d32:e8 69 c4 05 ff call 9b01a0 <__sanitizer_cov_trace_pc_indir> 1953d58:e8 43 c4 05 ff call 9b01a0 <__sanitizer_cov_trace_pc_indir> 1953d82:e8 19 c4 05 ff call 9b01a0 <__sanitizer_cov_trace_pc_indir> ``` ACKs for top commit: fanquake: ACK cbea49c dergoegge: reACK cbea49c Tree-SHA512: 801994e75b711d20eaf0d675f378da07d693f4a7de026efd93860f5f1deabed855a83eca3561725263e4fe605fcc5f91eb73c021ec91c831864e6deb575e3885
2 parents 717103b + cbea49c commit e3b68b3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

configure.ac

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ if test "$use_sanitizers" != ""; then
381381
dnl fail if a bad argument is passed, e.g. -fsanitize=undfeined
382382
AX_CHECK_COMPILE_FLAG(
383383
[-fsanitize=$use_sanitizers],
384-
[SANITIZER_CXXFLAGS="-fsanitize=$use_sanitizers"],
384+
[SANITIZER_CXXFLAGS="-fsanitize=$use_sanitizers"
385+
SANITIZER_CFLAGS="-fsanitize=$use_sanitizers"],
385386
[AC_MSG_ERROR([compiler did not accept requested flags])])
386387

387388
dnl Some compilers (e.g. GCC) require additional libraries like libasan,
@@ -1931,6 +1932,9 @@ CPPFLAGS_TEMP="$CPPFLAGS"
19311932
unset CPPFLAGS
19321933
CPPFLAGS="$CPPFLAGS_TEMP"
19331934

1935+
if test -n "$use_sanitizers"; then
1936+
export SECP_CFLAGS="$SECP_CFLAGS $SANITIZER_CFLAGS"
1937+
fi
19341938
ac_configure_args="${ac_configure_args} --disable-shared --with-pic --enable-benchmark=no --enable-module-recovery --disable-module-ecdh"
19351939
AC_CONFIG_SUBDIRS([src/secp256k1])
19361940

@@ -1990,7 +1994,7 @@ echo " target os = $host_os"
19901994
echo " build os = $build_os"
19911995
echo
19921996
echo " CC = $CC"
1993-
echo " CFLAGS = $PTHREAD_CFLAGS $CFLAGS"
1997+
echo " CFLAGS = $PTHREAD_CFLAGS $SANITIZER_CFLAGS $CFLAGS"
19941998
echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CORE_CPPFLAGS $CPPFLAGS"
19951999
echo " CXX = $CXX"
19962000
echo " CXXFLAGS = $CORE_CXXFLAGS $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $SANITIZER_CXXFLAGS $CXXFLAGS"

test/sanitizer_suppressions/ubsan

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ implicit-integer-sign-change:secp256k1/
2323
implicit-signed-integer-truncation:*/include/c++/
2424
implicit-signed-integer-truncation:leveldb/
2525
implicit-signed-integer-truncation:secp256k1/
26+
implicit-signed-integer-truncation,implicit-integer-sign-change:secp256k1_modinv64_posdivsteps_62_var
2627
implicit-unsigned-integer-truncation:*/include/c++/
2728
implicit-unsigned-integer-truncation:leveldb/
2829
implicit-unsigned-integer-truncation:secp256k1/

0 commit comments

Comments
 (0)