blob: def25c70143add8ce6f322bef5d0502b72143530 [file] [log] [blame]
Behdad Esfahbod45087892012-06-08 21:32:43 -04001#!/bin/sh
2
3LC_ALL=C
4export LC_ALL
5
6test -z "$srcdir" && srcdir=.
Ebrahim Byagowi72bec1c2018-01-05 12:42:20 +03307test -z "$libs" && libs=.libs
Behdad Esfahbod45087892012-06-08 21:32:43 -04008stat=0
9
Behdad Esfahbod45087892012-06-08 21:32:43 -040010if which objdump 2>/dev/null >/dev/null; then
11 :
12else
13 echo "check-static-inits.sh: 'objdump' not found; skipping test"
14 exit 77
15fi
16
Ebrahim Byagowi5ed26fc2018-01-04 10:11:34 +033017OBJS=$libs/*.o
Behdad Esfahbod6d9a3292012-08-08 14:48:41 -040018if 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
21fi
22
Behdad Esfahbod45087892012-06-08 21:32:43 -040023echo "Checking that no object file has static initializers"
Behdad Esfahbod6d9a3292012-08-08 14:48:41 -040024for obj in $OBJS; do
Behdad Esfahbod22723182014-10-01 11:56:07 -040025 if objdump -t "$obj" | grep '[.][cd]tors' | grep -v '\<00*\>'; then
Behdad Esfahbodb695a3d2014-10-01 11:55:14 -040026 echo "Ouch, $obj has static initializers/finalizers"
Behdad Esfahbod45087892012-06-08 21:32:43 -040027 stat=1
28 fi
29done
30
Behdad Esfahbodd59e28e2012-08-28 19:08:36 -040031echo "Checking that no object file has lazy static C++ constructors/destructors or other such stuff"
Behdad Esfahbod6d9a3292012-08-08 14:48:41 -040032for obj in $OBJS; do
Behdad Esfahbod48398072018-09-24 13:11:34 -040033 if objdump -t "$obj" | grep -q '__cxa_' && ! objdump -t "$obj" | grep -q __ubsan_handle; then
34 objdump -t "$obj" | grep '__cxa_'
Behdad Esfahbodd59e28e2012-08-28 19:08:36 -040035 echo "Ouch, $obj has lazy static C++ constructors/destructors or other such stuff"
Behdad Esfahbod45087892012-06-08 21:32:43 -040036 stat=1
37 fi
38done
39
40exit $stat