mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-22 10:58:10 +01:00
bc11759dd1
The dynamic generation of the linker version script for libnotmuch exports has grown rather complicated. Reverse the visibility control by hiding symbols by default using -fvisibility=hidden, and explicitly exporting symbols in notmuch.h using #pragma GCC visibility. (We could also use __attribute__ ((visibility ("default"))) for each exported function, but the pragma is more convenient.) The above is not quite enough alone, as it would "leak" a number of weak symbols from Xapian and C++ standard library. Combine it with a small static version script that filters out everything except the notmuch_* symbols that we explicitly exposed, and the C++ RTTI typeinfo symbols for exception handling. Finally, as the symbol hiding test can no longer look at the generated symbol table, switch the test to parse the functions from notmuch.h.
33 lines
1.2 KiB
Bash
Executable file
33 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Copyright (c) 2011 David Bremner
|
|
#
|
|
|
|
# This test tests whether hiding Xapian::Error symbols in libnotmuch
|
|
# also hides them for other users of libxapian. This is motivated by
|
|
# the discussion in https://gcc.gnu.org/wiki/Visibility'
|
|
|
|
test_description='exception symbol hiding'
|
|
|
|
. ./test-lib.sh || exit 1
|
|
|
|
test_begin_subtest 'running test' run_test
|
|
mkdir -p ${PWD}/fakedb/.notmuch
|
|
$TEST_DIRECTORY/symbol-test ${PWD}/fakedb ${PWD}/nonexistent 2>&1 \
|
|
| notmuch_dir_sanitize | sed -e "s,\`,\',g" -e "s,${NOTMUCH_DEFAULT_XAPIAN_BACKEND},backend,g" > OUTPUT
|
|
|
|
cat <<EOF > EXPECTED
|
|
A Xapian exception occurred opening database: Couldn't stat 'CWD/fakedb/.notmuch/xapian'
|
|
caught No backend database found at path 'CWD/nonexistent'
|
|
EOF
|
|
test_expect_equal_file EXPECTED OUTPUT
|
|
|
|
test_begin_subtest 'checking output'
|
|
test_expect_equal "$result" "$output"
|
|
|
|
test_begin_subtest 'comparing existing to exported symbols'
|
|
nm -P $TEST_DIRECTORY/../lib/libnotmuch.so | awk '$2 == "T" && $1 ~ "^notmuch" {print $1}' | sort | uniq > ACTUAL
|
|
sed -n 's/^\(notmuch_[a-zA-Z0-9_]*\)[[:blank:]]*(.*/\1/p' $TEST_DIRECTORY/../lib/notmuch.h | sort | uniq > EXPORTED
|
|
test_expect_equal_file EXPORTED ACTUAL
|
|
|
|
test_done
|