aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2020-12-11 13:06:44 -0400
committerDavid Bremner <david@tethera.net>2020-12-13 08:23:42 -0400
commit82faa059b8c98a3af016778734be329557d4217d (patch)
treeff1efcccea5365275cffd4df70c79ae1672e70f9
parentc7e1910235d06dcb2e7931b187483fc2528ab714 (diff)
test/T360-symbol-hiding: use readelf in place of nm
It turns out that using nm -P isn't as portable as hoped. In particular with some ELF ABIs (e.g. ppc64 ELFv1), the desired symbols end up in the data section instead of text. The test is currently only functional on ELF based architectures, so I think it's legit to depend on readelf instead of nm. The switch to readelf has the advantage that we can explicitely ask for all of the symbols with global visibility, rather than grepping for notmuch. That seems a more robust approach since it will catch any strangely named global symbols.
-rwxr-xr-xtest/T360-symbol-hiding.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/T360-symbol-hiding.sh b/test/T360-symbol-hiding.sh
index b34f1e54..3f00dd38 100755
--- a/test/T360-symbol-hiding.sh
+++ b/test/T360-symbol-hiding.sh
@@ -26,8 +26,9 @@ test_begin_subtest 'checking output'
test_expect_equal "$result" "$output"
test_begin_subtest 'comparing existing to exported symbols'
-nm -P $NOTMUCH_BUILDDIR/lib/libnotmuch.so | awk '$2 == "T" && $1 ~ "^notmuch" {print $1}' | sort | uniq > ACTUAL
-sed -n 's/^\(notmuch_[a-zA-Z0-9_]*\)[[:blank:]]*(.*/\1/p' $NOTMUCH_SRCDIR/lib/notmuch.h | sort | uniq > EXPORTED
+readelf -Ws $NOTMUCH_BUILDDIR/lib/libnotmuch.so | \
+ awk '$4 == "FUNC" && $5 == "GLOBAL" && $7 != "UND" {print $8}' | sort -u > ACTUAL
+sed -n 's/^\(notmuch_[a-zA-Z0-9_]*\)[[:blank:]]*(.*/\1/p' $NOTMUCH_SRCDIR/lib/notmuch.h | sort -u > EXPORTED
test_expect_equal_file EXPORTED ACTUAL
test_done