[xiph-commits] r16025 - branches/theora-thusnelda/lib

giles at svn.xiph.org giles at svn.xiph.org
Sun May 24 10:03:34 PDT 2009

Author: giles
Date: 2009-05-24 10:03:32 -0700 (Sun, 24 May 2009)
New Revision: 16025

Add an awk script to build a list of exported symbols from MSVC .def files.

The Mach ld (Apple MacOS X) takes an -exported_symbols_list argument 
which, when passed a file containing a simple list of symbols, will
hide all symbols in a library which do not appear on the list. The
symbol names must be mangled.

This is, in fact, the simpler format, compared to the .def files used
my MSVC and the mingw32 compilers, or the Version script hack supported
by earlier versions of gcc. Since the MSVC build is the least flexible
in the kind of scripts is can run, it makes sense to maintain the symbol
list in .def format and derive the other two from it.

This script does that by parsing a useful subset of the .def file format 
and constructing the appropriate Mach ld formatted version.

Modified: branches/theora-thusnelda/lib/Makefile.am
--- branches/theora-thusnelda/lib/Makefile.am	2009-05-24 16:23:18 UTC (rev 16024)
+++ branches/theora-thusnelda/lib/Makefile.am	2009-05-24 17:03:32 UTC (rev 16025)
@@ -161,3 +161,7 @@
+# contstruct various symbol export list files
+%.exp : %.def defexp.awk
+	awk -f defexp.awk $< > $@

Added: branches/theora-thusnelda/lib/defexp.awk
--- branches/theora-thusnelda/lib/defexp.awk	                        (rev 0)
+++ branches/theora-thusnelda/lib/defexp.awk	2009-05-24 17:03:32 UTC (rev 16025)
@@ -0,0 +1,27 @@
+# awk script to convert symbol export table formats
+# converts an msvc .def file to an darwin ld export-symbols-list file
+# we only support the most basic module definition syntax
+# skip comments
+/^\w*#.*/ {next}
+/^\w*;.*/ {next}
+# remember and propagate the library name
+/LIBRARY/ {name = $2; print "\# export list for", name; next}
+# skip various other lines
+/^\w*NAME/ ||
+/^\w*VERSION/ ||
+/^\w*EXPORTS/ ||
+/^\w*HEAPSIZE/ ||
+/^\w*STACKSIZE/ ||
+/^\w*STUB/ {next}
+# todo: handle SECTIONS
+# for symbols, strip the semicolon and mangle the name
+/[a-zA-Z]+/ {sub(/\;/, ""); print "_" $1}
+# todo: warn if we see publicname=privatename mappings
+#       which other linkers don't support

More information about the commits mailing list