Index: emxomf.h
===================================================================
--- emxomf.h	(revision 3654)
+++ emxomf.h	(working copy)
@@ -30,7 +30,7 @@
 void *xrealloc (void *ptr, size_t n);
 char *xstrdup (const char *s);
 extern const struct nlist *find_symbol (const char *name);
-extern const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext);
+extern const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext, int fpub_only);
 extern void set_hll_type (int index, int hll_type);
 
 /* These variables are defined in emxomf.c. */
Index: stabshll.c
===================================================================
--- stabshll.c	(revision 3654)
+++ stabshll.c	(working copy)
@@ -598,13 +598,13 @@
 
   if (!psym)
     {
-      psym = find_symbol_ex (name, -1, ext);
+      psym = find_symbol_ex (name, -1, ext, 0);
       if (!psym)
         {
           char *psz = alloca (len + 2);
           *psz = '_';
           memcpy(psz + 1, name, len + 1);
-          psym = find_symbol_ex (psz, -1, ext);
+          psym = find_symbol_ex (psz, -1, ext, 0);
         }
     }
   if (psym)
@@ -3565,7 +3565,7 @@
               && *index >= 1
               && symbol[-1].n_type == 0xfe)
             {
-              sym2 = find_symbol_ex (symbol[-1].n_un.n_strx + str_ptr, *index - 1, 1);
+              sym2 = find_symbol_ex (symbol[-1].n_un.n_strx + str_ptr, *index - 1, 1, 0);
               if (!sym2)
                 {
                   warning ("Cannot find address of communal/external variable %s", name);
Index: emxomf.c
===================================================================
--- emxomf.c	(revision 3654)
+++ emxomf.c	(working copy)
@@ -540,9 +540,11 @@
    array pointed to by sym_ptr) is returned.  If the symbol is not
    found, NULL is returned.
    NOT_ENTRY is an entry index which is not to be found.
-   FEXT is an indicator on whether or not we can find external symbols or
-   not.  */
-const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext)
+   FEXT is an indicator on whether or not we can find external symbols.
+   FPUBONLY is an indicator of whether or not the search is restricted to
+   public symbols defined in this module. */
+const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext,
+                                    int fpub_only)
 {
   int i, j, n, len, t;
   const byte *s;
@@ -564,6 +566,8 @@
 	  for (j = 0; j < n; ++j)
 	    if (sym_ptr[j].n_un.n_strx == sym_ofs && j != not_entry)
 	      {
+		if (fpub_only && !(sym_ptr[j].n_type & N_EXT))
+		  continue;
 		t = sym_ptr[j].n_type & ~N_EXT;
 		if (   t == N_TEXT || t == N_DATA || t == N_BSS
                     || (fext && sym_ptr[j].n_type == N_EXT)
@@ -583,7 +587,7 @@
    found, NULL is returned. */
 const struct nlist *find_symbol (const char *name)
 {
-  return find_symbol_ex (name, -1, 0);
+  return find_symbol_ex (name, -1, 0, 0);
 }
 
 
@@ -764,7 +768,7 @@
 
 
 /* Calculates the hash for a string using the original djb2 aglorithm. */
-  
+
 static unsigned hash_string(const char *pch, size_t cch)
 {
     unsigned uHash;
@@ -774,8 +778,8 @@
 }
 
 /* Formats a 64-bit number with a fixed with. The purpose is to encode
-   a unique number as tiny as possible while keeping within what any 
-   linker should accept. The width is fixed, and the string is clipped 
+   a unique number as tiny as possible while keeping within what any
+   linker should accept. The width is fixed, and the string is clipped
    or padded with zeros to satisfy that. The return value is psz + cchWidth. */
 
 static char *format_u64(uint64_t u64, char *psz, unsigned uRadix, int cchWidth)
@@ -1005,7 +1009,7 @@
   if (*pstarted)
     {
       size_t cchEncodedName = strlen(name);
-      if (   cchEncodedName > SYMBOL_MAX_LENGTH 
+      if (   cchEncodedName > SYMBOL_MAX_LENGTH
           && !strstr(name + SYMBOL_MAX_LENGTH - SYMBOL_WEAK_LENGTH, "$w$"))
         cchEncodedName = SYMBOL_MAX_LENGTH + SYMBOL_HASH_LENGTH;
       if (!fits(cchEncodedName + 3 + (type > 127)))
@@ -2703,7 +2707,7 @@
     memcpy(pszSym, pszSymbol, cchSymbol);
     pszSym[cchSymbol] = '\0';
 
-    pSym = find_symbol(pszSym);
+    pSym = find_symbol_ex(pszSym, -1, 0, 1);
     if (pSym)
     {
         /*
