1 #!/bin/sh 2 3 LC_ALL=C 4 export LC_ALL 5 6 test -z "$srcdir" && srcdir=. 7 test -z "$libs" && libs=.libs 8 stat=0 9 10 if which objdump 2>/dev/null >/dev/null; then 11 : 12 else 13 echo "check-static-inits.sh: 'objdump' not found; skipping test" 14 exit 77 15 fi 16 17 OBJS=$libs/*.o 18 if test "x`echo $OBJS`" = "x$OBJS" 2>/dev/null >/dev/null; then 19 echo "check-static-inits.sh: object files not found; skipping test" 20 exit 77 21 fi 22 23 echo "Checking that no object file has static initializers" 24 for obj in $OBJS; do 25 if objdump -t "$obj" | grep '[.][cd]tors' | grep -v '\<00*\>'; then 26 echo "Ouch, $obj has static initializers/finalizers" 27 stat=1 28 fi 29 done 30 31 echo "Checking that no object file has lazy static C++ constructors/destructors or other such stuff" 32 for obj in $OBJS; do 33 if objdump -t "$obj" | grep -q '__cxa_' && ! objdump -t "$obj" | grep -q __ubsan_handle; then 34 objdump -t "$obj" | grep '__cxa_' 35 echo "Ouch, $obj has lazy static C++ constructors/destructors or other such stuff" 36 stat=1 37 fi 38 done 39 40 exit $stat 41