blob: 1446fa73405e87849fde9f7aeedc108a8449820f [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=.
7stat=0
8
9
10if 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
Behdad Esfahbod6d9a3292012-08-08 14:48:41 -040017OBJS=.libs/*.o
18if 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 Esfahbod75ec6d02014-04-09 16:33:32 -070033 if objdump -t "$obj" | grep '__cxa_'; then
Behdad Esfahbodd59e28e2012-08-28 19:08:36 -040034 echo "Ouch, $obj has lazy static C++ constructors/destructors or other such stuff"
Behdad Esfahbod45087892012-06-08 21:32:43 -040035 stat=1
36 fi
37done
38
39exit $stat