]> git.cworth.org Git - fips/commitdiff
Makefile: Automatically generate libfips.sym symbol map
authorCarl Worth <cworth@cworth.org>
Thu, 30 May 2013 22:10:15 +0000 (15:10 -0700)
committerCarl Worth <cworth@cworth.org>
Mon, 10 Jun 2013 21:31:39 +0000 (14:31 -0700)
Previously, we had to manually maintain this table of symbols, (hence
it was too easy for the list to be stale). Instead, we now generate
the list automatically by examining the source code for symbols that
are wrapped.

.gitignore
Makefile.local
extract-wrapped-symbols [new file with mode: 0755]
libfips.sym [deleted file]

index f95e49bb01846a01f26f6cee35814338f7fb62b4..9bc128e2bc35d12b37b2cdbe32cf175e4ba00192 100644 (file)
@@ -5,5 +5,6 @@ config.h
 fips
 libfips-32.so
 libfips-64.so
+libfips.sym
 *.o
 *~
index c81b0768c489b92553da20207b58ffaf67faddad..123de57cef310a1cd6fde4bcf75b1793728dcf1e 100644 (file)
@@ -89,6 +89,9 @@ ifeq ($(HAVE_EGL),Yes)
 libfips_srcs += eglwrap.c
 endif
 
+libfips.sym: extract-wrapped-symbols $(libfips_srcs)
+       $(call quiet,extract-wrapped-symbols) ./extract-wrapped-symbols $(libfips_srcs) > $@
+
 libfips_32_modules = $(libfips_srcs:.c=-32.o)
 
 libfips_64_modules = $(libfips_srcs:.c=-64.o)
@@ -113,7 +116,7 @@ ifeq ($(MAKECMDGOALS), install)
 endif
 
 SRCS  := $(SRCS) $(fips_srcs) $(libfips_srcs)
-CLEAN := $(CLEAN) fips $(fips_modules) $(libfips_32_modules) $(libfips_64_modules)
+CLEAN := $(CLEAN) fips $(fips_modules) $(libfips_32_modules) $(libfips_64_modules) libfips.sym
 
 DISTCLEAN := $(DISTCLEAN) .first-build-message Makefile.config
 
diff --git a/extract-wrapped-symbols b/extract-wrapped-symbols
new file mode 100755 (executable)
index 0000000..2b9f76a
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# Extract symbols from the fips source code for functions that are wrapped.
+
+# Output is a version script, (suitable to be passed to the linker
+# through a compiler flag -f -Wl,--version-script=<foo>), which
+# indicates that the extracted symbols should be exported from
+# libfips, while all other symbols are private.
+
+# We have two different patterns for identifying wrapped
+# functions. The first is a call to a macro ending in "DEFER" (such as
+# DEFER or TIMED_DEFER). In this case, the first argument to the macro
+# is the name of the wrapped function.
+
+deferred=`grep 'DEFER[ (]*e*gl' $@ | sed -s 's/.*DEFER *(\([^,)]*\).*/\1/'`
+
+# The second-case is functions for which we either implement or call
+# the underlying "real" function. In these cases, the code uses the
+# convention of having a function or a function-pointer with a name of
+# the form *wrap_real_<function>
+
+wrapped=`grep wrap_real_ $@ | sed -e 's/.*wrap_real_\([a-zA-Z0-9_]*\).*/\1/'`
+
+# With those two lists collected, all we need is a simple template for
+# a version script, along with alphabetic sorting and uniquifying of
+# the list, (and adding tabs for nice-looking indentation and ';'
+# separators).
+
+cat <<EOF
+{
+global:
+EOF
+
+echo "$deferred
+$wrapped" | sort | uniq | sed -e 's/\(.*\)/    \1;/'
+
+cat <<EOF
+local:
+       *;
+};
+EOF
diff --git a/libfips.sym b/libfips.sym
deleted file mode 100644 (file)
index 05cdc36..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-{
-global:
-       dlopen;
-       dlsym;
-       eglSwapBuffers;
-       glBegin;
-       glBlitFramebuffer;
-       glBlitFramebufferEXT;
-       glCallList;
-       glCallLists;
-       glClear;
-       glDrawArrays;
-       glDrawArraysEXT;
-       glDrawArraysIndirect;
-       glDrawArraysInstanced;
-       glDrawArraysInstancedARB;
-       glDrawArraysInstancedBaseInstance;
-       glDrawArraysInstancedEXT;
-       glDrawElements;
-       glDrawElementsBaseVertex;
-       glDrawElementsIndirect;
-       glDrawElementsInstanced;
-       glDrawElementsInstancedARB;
-       glDrawElementsInstancedBaseInstance;
-       glDrawElementsInstancedBaseVertex;
-       glDrawElementsInstancedBaseVertexBaseInstance;
-       glDrawElementsInstancedEXT;
-       glDrawMeshArraysSUN;
-       glDrawPixels;
-       glDrawRangeElements;
-       glDrawRangeElementsBaseVertex;
-       glDrawRangeElementsEXT;
-       glEnd;
-       glEndList;
-       glMultiDrawArrays;
-       glMultiDrawArraysEXT;
-       glMultiDrawArraysIndirect;
-       glMultiDrawArraysIndirectAMD;
-       glMultiDrawElements;
-       glMultiDrawElementsBaseVertex;
-       glMultiDrawElementsEXT;
-       glMultiDrawElementsIndirect;
-       glMultiDrawElementsIndirectAMD;
-       glMultiModeDrawArraysIBM;
-       glMultiModeDrawElementsIBM;
-       glNewList;
-       glUseProgram;
-       glUseProgramObjectARB;
-       glXGetProcAddressARB;
-       glXSwapBuffers;
-local:
-       *;
-};