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