win32 libio/gen-param fix

Mumit Khan khan@xraylith.wisc.EDU
Mon Feb 8 09:13:00 GMT 1999

The detection of VTABLE_LABEL_PREFIX breaks on win32 due to the existence 
of unique sections containing the same pattern. This is not an issue in
the release branch, where the vtables are not emitted in linkonce

Here's what happens:
  % i586-cygwin32-nm dummy.o  | grep filebuf
  00000000 d .data$_vt$7filebuf
  00000000 t .text$__tf7filebuf
  00000000 T ___tf7filebuf
  00000010 C ___ti7filebuf
  00000000 D __vt$7filebuf
  00000000 T _foo__7filebuf

The sed pattern matches the first one, .data$_vt$7filebuf, instead of the
intended one, _vt$7filebuf, and we end up with the incorrect value of

The following trivial patch simply deletes the unique sections from the nm 
output to avoid this pitfall.

Mon Feb  8 10:35:08 1999  Mumit Khan  <>

	* gen-params (VTABLE_LABEL_PREFIX): Handle windows32. 

Index: gen-params
RCS file: /mounts/sda7/src/gnu/CVSROOT/egcs-dev/libio/gen-params,v
retrieving revision
diff -u -3 -p -r1.1.1.1 gen-params
--- gen-params	1999/02/07 23:35:54
+++ gen-params	1999/02/08 16:34:58
@@ -107,7 +107,9 @@ if test -z "${NAMES_HAVE_UNDERSCORE}" -o
     if test -z "${VTABLE_LABEL_PREFIX}" ; then
       # Determine how virtual function tables are named.  This is fragile,
       # because different nm's produce output in different formats.
-      ${CONFIG_NM} dummy.o >TMP
+      # On windows32, we also need to delete the unique sections
+      # (.data$_vt$*), otherwise we get the wrong result.
+      ${CONFIG_NM} dummy.o | ${SED} -e '/\.data[$_.]_vt\$7filebuf/d' >TMP
       if [ -n "`${SED} -n -e 's/ virtual table/nope/p' <TMP`" ] ; then
 	${CONFIG_NM} --no-cplus dummy.o >TMP 2>/dev/null ||
 	  ${CONFIG_NM} --no-demangle dummy.o >TMP 2>/dev/null ||

More information about the Gcc-patches mailing list