summaryrefslogtreecommitdiff
path: root/testsuite/symbols-test
blob: 01ca30ceea4853ae096414a0e4acf61db0e1827a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /bin/sh

# Check that all exported symbols use the nettle prefix.

if [ -z "$srcdir" ] ; then
  srcdir=`pwd`
fi

: ${NM:=nm}

# * nm on aix seems to generate bogus output including random binary
#   data. Using -g is a workaround to get rid of that. But nm -g
#   doesn't work on Solaris-2.4, so try nm -g first, and plain nm if
#   -g isn't recognized.
#
# * gcc on x86 generates functions like __i686.get_pc_thunk.bx in pic
#   code.
# * LLVM shipped with Xcode/CLT 10+ on macOS builds the symbol
#   ____chkstk_darwin into the majority of binaries/libraries, including
#   both the libraries checked here.

( $NM -g ../libnettle.a || $NM ../libnettle.a ) \
    | grep ' [DRT] ' | egrep -v '( |^|\.)(\.?_?(_?nettle_)|get_pc_thunk|(_*chkstk_darwin))' \
    | sort -k3 > test1.out

if [ -s test1.out ] ; then
    echo Exported symbols in libnettle.a, lacking the nettle prefix:
    cat test1.out
    exit 1
fi

if [ -s ../libhogweed.a ] ; then
    PATTERN='\.?_?_?nettle_|get_pc_thunk|(_*chkstk_darwin)'
    if grep '^#define.*NETTLE_USE_MINI_GMP.*1$' ../version.h >/dev/null ; then
	PATTERN="$PATTERN|_?(mp_|mpz_|mpn_)"
    fi
    ( $NM -g ../libhogweed.a || $NM ../libhogweed.a ) \
	| grep ' [DRT] ' | egrep -v "( |^|\.)($PATTERN)" \
	| sort -k3 > test1.out

    if [ -s test1.out ] ; then
	echo Exported symbols in libhogweed.a, lacking the nettle prefix:
	cat test1.out
	exit 1
    fi
fi

exit 0