symbols-test 1.37 KB
Newer Older
1 2 3 4 5 6 7 8
#! /bin/sh

# Check that all exported symbols use the nettle prefix.

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

9
: ${NM:=nm}
Niels Möller's avatar
Niels Möller committed
10

Niels Möller's avatar
Niels Möller committed
11
# * nm on aix seems to generate bogus output including random binary
12 13 14 15
#   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.
#
16 17
# * gcc on x86 generates functions like __i686.get_pc_thunk.bx in pic
#   code.
18 19 20
# * 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.
21

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

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

if [ -s ../libhogweed.a ] ; then
33
    PATTERN='\.?_?_?nettle_|get_pc_thunk|(_*chkstk_darwin)'
34
    if grep '^#define.*NETTLE_USE_MINI_GMP.*1$' ../version.h >/dev/null ; then
35
	PATTERN="$PATTERN|_?(mp_|mpz_|mpn_)"
36
    fi
37
    ( $NM -g ../libhogweed.a || $NM ../libhogweed.a ) \
Niels Möller's avatar
Niels Möller committed
38
	| grep ' [DRT] ' | egrep -v "( |^|\.)($PATTERN)" \
39 40 41 42 43 44 45 46 47 48 49
	| 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