]> git.cworth.org Git - fips/blob - extract-wrapped-symbols
Add explicit link to libpthread, to work around debugging issues
[fips] / extract-wrapped-symbols
1 #!/bin/sh
2
3 # Extract symbols from the fips source code for functions that are wrapped.
4
5 # Output is a version script, (suitable to be passed to the linker
6 # through a compiler flag -f -Wl,--version-script=<foo>), which
7 # indicates that the extracted symbols should be exported from
8 # libfips, while all other symbols are private.
9
10 # We have two different patterns for identifying wrapped
11 # functions. The first is a call to one of the DEFER macros
12 # (GLWRAP_DEFER, TIMED_DEFER, WGLWRAP_DEFER_WITH_RETURN, etc.). In
13 # this case, the name of the wrapped function appears as the first or
14 # second argument to the macro, (second for the case of of
15 # _WITH_RETURN macro).
16
17 deferred=`grep 'DEFER[ (]*e*gl' $@ | sed -s 's/.*DEFER *(\([^,)]*\).*/\1/'`
18
19 deferred_return=`grep 'DEFER_WITH_RETURN *([^,]*, *e*gl' $@ | sed -s 's/.*DEFER_WITH_RETURN *([^,]*, *\([^,)]*\).*/\1/'`
20
21 # The second-case is functions for which we either implement or call
22 # the underlying "real" function. In these cases, the code uses the
23 # convention of having a function or a function-pointer with a name of
24 # the form *wrap_real_<function>
25
26 wrapped=`grep wrap_real_ $@ | sed -e 's/.*wrap_real_\([a-zA-Z0-9_]*\).*/\1/'`
27
28 # With those two lists collected, all we need is a simple template for
29 # a version script, along with alphabetic sorting and uniquifying of
30 # the list, (and adding tabs for nice-looking indentation and ';'
31 # separators).
32
33 cat <<EOF
34 {
35 global:
36 EOF
37
38 echo "$deferred
39 $deferred_return
40 $wrapped" | sort | uniq | sed -e 's/\(.*\)/     \1;/'
41
42 cat <<EOF
43 local:
44         *;
45 };
46 EOF