1
2# See README for details.
3
4LIBFILE=libfoo.so
5
6# Compile shared library
7#
8
9$CXX $LDFLAGS $CXXFLAGS -shared -o $LIBFILE foo.cpp
10if [ $? != 0 ]; then
11    echo "ERROR: Can't build shared library!"
12    exit 1
13fi
14
15# Check that there is no .ctors section
16${PREFIX}readelf -S libfoo.so | grep -q -e .ctors
17if [ $? = 0 ]; then
18    echo "ERROR: Shared library should not have a .ctors section!"
19    exit 1
20fi
21
22# Check that there is no .dtors section
23${PREFIX}readelf -S libfoo.so | grep -q -e .dtors
24if [ $? = 0 ]; then
25    echo "ERROR: Shared library should not have a .dtors section!"
26    exit 1
27fi
28
29# Check that there is an .init_array section
30${PREFIX}readelf -S $LIBFILE | grep -q -e .init_array
31if [ $? != 0 ]; then
32    echo "ERROR: Shared library is missing an .init_array section!"
33    exit 1
34fi
35
36# Check that there is a .fini_array section
37${PREFIX}readelf -S $LIBFILE | grep -q -e .fini_array
38if [ $? != 0 ]; then
39    echo "ERROR: Shared library is missing an .fini_array section!"
40    exit 1
41fi
42
43# Everything's good
44echo "Shared library is ok."
45exit 0
46