aboutsummaryrefslogtreecommitdiff
path: root/tests/standalone/init-fini-arrays/run.sh
blob: 1b973d65465cdfe8cb3bf0bfa1259ed38e92f327 (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

# See README for details.

LIBFILE=libfoo.so

# Compile shared library
#

$CXX $LDFLAGS $CXXFLAGS -shared -o $LIBFILE foo.cpp
if [ $? != 0 ]; then
    echo "ERROR: Can't build shared library!"
    exit 1
fi

# Check that there is no .ctors section
${PREFIX}readelf -S libfoo.so | grep -q -e .ctors
if [ $? = 0 ]; then
    echo "ERROR: Shared library should not have a .ctors section!"
    exit 1
fi

# Check that there is no .dtors section
${PREFIX}readelf -S libfoo.so | grep -q -e .dtors
if [ $? = 0 ]; then
    echo "ERROR: Shared library should not have a .dtors section!"
    exit 1
fi

# Check that there is an .init_array section
${PREFIX}readelf -S $LIBFILE | grep -q -e .init_array
if [ $? != 0 ]; then
    echo "ERROR: Shared library is missing an .init_array section!"
    exit 1
fi

# Check that there is a .fini_array section
${PREFIX}readelf -S $LIBFILE | grep -q -e .fini_array
if [ $? != 0 ]; then
    echo "ERROR: Shared library is missing an .fini_array section!"
    exit 1
fi

# Everything's good
echo "Shared library is ok."
exit 0