Index: trunk/src/emx/src/emxomf/stabshll.c
===================================================================
--- trunk/src/emx/src/emxomf/stabshll.c	(revision 1884)
+++ trunk/src/emx/src/emxomf/stabshll.c	(revision 1885)
@@ -3494,46 +3494,6 @@
         case 'G':
           /* Static storage, global scope */
-#if 1 /* birds ugly hacking of 'G' allow this code path. (See dbxout.c.)  */
-          if (where == -1)
-            { /* If I got it right, dbxout.c uses N_FUN for globals in the
-                 text section.  */
-              where = symbol->n_type == N_FUN ? N_TEXT : N_DATA;
-            }
-          if (symbol->n_value == -12357)
-            { /* Special hack for external and communal variables.
-                 We expect the previous symbol to be an 0xfe entry
-                 for the symbol we're processing.  */
-              ++parse_ptr;
-              ti = hll_type ();
-
-              if (   *index >= 1
-                  && (symbol[-1].n_type == 0xfe))
-                {
-                  const struct nlist *sym2;
-
-#if defined (HLL_DEBUG)
-                  printf ("  type=%#x\n", ti);
-#endif
-                  sym2 = find_symbol_ex (symbol[-1].n_un.n_strx + str_ptr, *index - 1, 1);
-                  if (sym2)
-                    {
-                      if (sym2->n_type == N_EXT)
-                        sst_static (name, 0, ti, sym2 - sym_ptr, 1, sym2);
-                      else
-                        sst_static (name, sym2->n_value, ti, sym2->n_type, 0, sym2);
-                      break;
-                    }
-                }
-              warning ("Cannot find address of communal/external variable %s", name);
-              return;
-            }
-          /* fall thru */
-
-#else /* old code */
           {
-          char *psz;
-          int   cch;
-          const struct nlist *sym2;
-
+          const struct nlist *sym2 = NULL;
           ++parse_ptr;
           ti = hll_type ();
@@ -3541,20 +3501,58 @@
           printf ("  type=%#x\n", ti);
 #endif
-          psz = alloca(cch = strlen(name) + 2);
-          *psz = '_';
-          strcpy(psz+1, name);
-          sym2 = find_symbol (psz);
-          if (sym2 == NULL)
+
+          /* Check for a ugly hack in dbxout.c which allow us to resolve
+             communal and global variables more accuratly. The n_value is -12357
+             and the previous entry is 0xfe. What the previous entry contains
+             is the assembly name of the symbol.
+
+             Another part of that hack is that n_value is contains the
+             symbol value so we don't need to look up the symbol for that
+             reason (but as it turns out we have to look it up to see where
+             it is in most cases, bah). */
+          if (   symbol->n_value == -12357
+              && *index >= 1
+              && symbol[-1].n_type == 0xfe)
             {
-              no_warning ("Cannot find address of global variable %s (%s)", name, psz);
-              return;
+              sym2 = find_symbol_ex (symbol[-1].n_un.n_strx + str_ptr, *index - 1, 1);
+              if (!sym2)
+                {
+                  warning ("Cannot find address of communal/external variable %s", name);
+                  return;
+                }
             }
-          if (sym2->n_type == N_EXT)
-            sst_static (name, 0, ti, sym2 - sym_ptr, 1, sym2);
+          else if (where == -1)
+            { /* This is not very nice, we have to look up the symbol
+                 like we used to do in order to the the segment right.
+                 Should probably just use the external/communal hack above
+                 for everything or change the n_type of the 'G' stab... However,
+                 this will work for most cases and it will be compatible with
+                 the unmodified dbxout.c code. */
+              if (symbol->n_type == N_FUN) /* in case GCC change... */
+                  where = N_TEXT;
+              else
+                {
+                  size_t cch = strlen (name);
+                  char *psz = alloca (cch + 2);
+                  *psz = '_';
+                  memcpy (psz + 1, name, cch + 1);
+                  sym2 = find_symbol (psz);
+                  if (!sym2)
+                    sym2 = find_symbol (psz + 1);
+                  where = N_DATA;
+                }
+            }
+          /* if we're lucky we've got a symbol... */
+          if (sym2)
+            {
+              if (sym2->n_type == N_EXT)
+                sst_static (name, 0, ti, sym2 - sym_ptr, 1, sym2);
+              else
+                sst_static (name, sym2->n_value, ti, sym2->n_type, 0, sym2);
+            }
           else
-            sst_static (name, sym2->n_value, ti, sym2->n_type, 0, sym2);
+            sst_static (name, symbol->n_value, ti, where, 0, NULL);
           break;
           }
-#endif /* new / old 'G' handling. */
 
         case 'S':
