Index: trunk/src/emx/include/sys/omflib.h
===================================================================
--- trunk/src/emx/include/sys/omflib.h	(revision 713)
+++ trunk/src/emx/include/sys/omflib.h	(revision 715)
@@ -72,4 +72,5 @@
 #define CLASS_PHARLAP   0xaa            /* PharLap Format record. */
 #define CLASS_IPADATA   0xae            /* Interprocedural Analysis Data record. */
+#define CLASS_DBGPACK   0xad            /* /DBGPACK DLL name for ilink. */
 #define CLASS_IDMDLL    0xaf            /* Identifier Manipulator Dynamic Link Library. */
 
Index: trunk/src/emx/src/emxomf/emxomf.c
===================================================================
--- trunk/src/emx/src/emxomf/emxomf.c	(revision 713)
+++ trunk/src/emx/src/emxomf/emxomf.c	(revision 715)
@@ -391,4 +391,9 @@
    NULL, no IDMDLL record is written. */
 static char *idmdll_name = "INNIDM";
+
+/* the name of the debug packing DLL. This variable is not used when
+   debug info is stripped. If NULL we'll select the default for the
+   linker type (EMXOMFLD_TYPE). */
+static char *dbgpack_name = NULL;
 
 /* If this variable is TRUE (-b option), we always use the 32-bit
@@ -2725,5 +2730,5 @@
 }
 
-/* Converts dashed filenames to somewhat absolute ones assuming that 
+/* Converts dashed filenames to somewhat absolute ones assuming that
    the current directory is what they're relative to. */
 
@@ -2732,5 +2737,5 @@
   int   rc = -1;
   char *psz;
-  
+
   if (src[1] != ':' && src[0] != '\\' && src[0] != '/')
     rc = _abspath(dst, src, size);
@@ -2830,4 +2835,30 @@
       write_rec ();
     }
+}
+
+
+/* Tell ilink which dll to use when /DBGPACK is specificed. The dllname
+   is given without extension. */
+static void write_dbgpack ()
+{
+    const char *name = dbgpack_name;
+    if (!name)
+      {
+        char *type = getenv ("EMXOMFLD_TYPE");
+        if (type && !stricmp (type, "VAC308"))
+            name = "LNKOH410";
+        else if (!type || !stricmp (type, "VAC365"))
+            name = "CPPLH436";
+        /* no DLL for link386! */
+      }
+
+    if (name)
+      {
+        init_rec (COMENT);
+        put_8 (0x80);
+        put_8 (CLASS_DBGPACK);
+        put_str (name);
+        write_rec ();
+      }
 }
 
@@ -2989,5 +3020,5 @@
       memcpy(file_list[i], buf, len + 1);
     }
-  
+
   /* Compute the size of the file names table. */
 
@@ -3355,4 +3386,8 @@
   write_idmdll ();
 
+  /* Tell ilink what DBGPACK DLL to use. */
+
+  write_dbgpack ();
+
   /* Write default library requests and the debug information style
      record (COMENT records). */
@@ -3520,4 +3555,5 @@
   puts ("                     (Only used if GCC_WEAKSYMS is set.)");
   puts ("  -z                 Remove underscores from all symbol names");
+  puts ("  -P <dbgpackdll>    Name the dbgpack DLL (ilink)");
   exit (1);
 }
@@ -3926,5 +3962,5 @@
   /* Parse the command line options. */
 
-  while ((c = getopt (argc, argv, "bdD:gh:i:I:m:l::o:p:qO:r:R:tsuxwz")) != EOF)
+  while ((c = getopt (argc, argv, "bdD:gh:i:I:m:l::o:P:p:qO:r:R:tsuxwz")) != EOF)
     switch (c)
       {
@@ -3979,4 +4015,10 @@
         opt_o = optarg;
         break;
+      case 'P':
+        if (strcmp (optarg, "-") == 0)
+          dbgpack_name = NULL;
+        else
+          dbgpack_name = optarg;
+        break;
       case 'p':
         errno = 0;
Index: trunk/src/emx/src/emxomf/listomf.c
===================================================================
--- trunk/src/emx/src/emxomf/listomf.c	(revision 713)
+++ trunk/src/emx/src/emxomf/listomf.c	(revision 715)
@@ -404,5 +404,5 @@
         {
           if (foff)
-            printf ("%*s%08lx %03lx:", indent, "", 
+            printf ("%*s%08lx %03lx:", indent, "",
                     rec_pos + rec_idx - 1 + sizeof (struct omf_rec),
                     rec_idx - 1 + sizeof (struct omf_rec));
@@ -605,4 +605,10 @@
       printf (" ");
       show_ext (ext2);
+      break;
+
+    case 0xad:
+      get_string (string);
+      printf ("debug pack DLL: ");
+      show_string (string);
       break;
 
Index: trunk/src/emx/src/emxomf/stabshll.c
===================================================================
--- trunk/src/emx/src/emxomf/stabshll.c	(revision 713)
+++ trunk/src/emx/src/emxomf/stabshll.c	(revision 715)
@@ -861,6 +861,8 @@
   printf ("  type: stabs %d => HLL 0x%x\n", number, hll->index);
 #endif
+#if 0 /* not good test... as we do some types twice. */
   if (stype_list[number-1] != NULL && stype_list[number-1] != hll)
     warning ("Type stabs %d allready mapped to HLL 0x%x, new HLL 0x%x!!\n", number, stype_list[number-1]->index, hll->index);
+#endif
 
   stype_list[number-1] = hll;
@@ -2069,6 +2071,6 @@
                           pszCompCtor = strpool_addn(str_pool, "__comp_ctor", 11);
                           pszBaseCtor = strpool_addn(str_pool, "__base_ctor", 11);
-                          pszCompDtor = strpool_addn(str_pool, "__comp_dtor", 11); 
-                          pszBaseDtor = strpool_addn(str_pool, "__base_dtor", 11); 
+                          pszCompDtor = strpool_addn(str_pool, "__comp_dtor", 11);
+                          pszBaseDtor = strpool_addn(str_pool, "__base_dtor", 11);
                         }
 
@@ -3063,9 +3065,11 @@
 static void define_fun (const struct nlist *symbol)
 {
-  struct type t, *t1, *t2;
+  struct type t, *t1, *t2, *t3;
   struct relocation_info r;
   const char *str, *p;
   const char *name;
-  int n, ti;
+  int n,                                /* size of name. */
+      ti,
+      ticlass;
 
   str = str_ptr + symbol->n_un.n_strx;
@@ -3089,4 +3093,40 @@
       if (ti == -1)
         make_type (t1, &ti);
+
+      t2 = t1->d.memfunc.type;
+      if (t2 && t2->tag == ty_func && t2->d.func.domain)
+          ticlass = t2->d.func.domain->index;
+      else
+        { /* the hard way - search for the freaking string in suitable .stabs. */
+          int i;
+          for (i = 0, t3 = NULL, ticlass = -1; !t3 && i < sym_count; ++i)
+            switch (sym_ptr[i].n_type)
+              {
+              case N_LSYM:
+                {
+                  str = str_ptr + sym_ptr[i].n_un.n_strx;
+                  if ((p = strstr (str, name)) != NULL
+                   /** @todo parse the string to get the name right. */
+                   && p[-1] == ':' && p[n] == ';')
+                    {
+                      p = nextcolon (str);
+                      if (p && p[1] == 'T' && p[2] == 't')
+                        {
+                          int stab = atoi (&p[3]);
+                          t3 = stype_find (stab);
+                        }
+                    }
+                  break;
+                }
+              }
+          if (t3)
+            make_type (t3, &ticlass);
+          if (ticlass < 0)
+            {
+              warning (" Can't figure out which class method '%s' is a member of!", name);
+              ticlass = 0;
+            }
+        }
+
       sst_start (SST_memfunc);
       r.r_address = sst.size;
@@ -3097,11 +3137,5 @@
       buffer_word (&sst, 0);        /* Length of prologue */
       buffer_dword (&sst, 0);       /* Length of prologue and body */
-      t2 = t1->d.memfunc.type;
-      ti = 0;
-      if (t2 && t2->tag == ty_func && t2->d.func.domain)
-          ti = t2->d.func.domain->index;
-      else
-          warning (" Can't figure out which class method '%s' is a member of!", name);
-      buffer_word (&sst, ti);        /* Class type (for member functions) */
+      buffer_word (&sst, ticlass);  /* Class type (for member functions) */
       buffer_byte (&sst, 8);        /* 32-bit near */
       buffer_enc (&sst, name);      /* Proc name */
@@ -3543,4 +3577,7 @@
   int i;
   struct type *t1, *t2;
+#if defined (HLL_DEBUG)
+  setvbuf(stdout, NULL, _IONBF, 256);
+#endif
 
   str_pool = strpool_init ();
