Ticket #220: emxomf-no-export-locals.diff

File emxomf-no-export-locals.diff, 4.2 KB (added by dmik, 14 years ago)
  • emxomf.h

     
    3030void *xrealloc (void *ptr, size_t n);
    3131char *xstrdup (const char *s);
    3232extern const struct nlist *find_symbol (const char *name);
    33 extern const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext);
     33extern const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext, int fpub_only);
    3434extern void set_hll_type (int index, int hll_type);
    3535
    3636/* These variables are defined in emxomf.c. */
  • stabshll.c

     
    598598
    599599  if (!psym)
    600600    {
    601       psym = find_symbol_ex (name, -1, ext);
     601      psym = find_symbol_ex (name, -1, ext, 0);
    602602      if (!psym)
    603603        {
    604604          char *psz = alloca (len + 2);
    605605          *psz = '_';
    606606          memcpy(psz + 1, name, len + 1);
    607           psym = find_symbol_ex (psz, -1, ext);
     607          psym = find_symbol_ex (psz, -1, ext, 0);
    608608        }
    609609    }
    610610  if (psym)
     
    35653565              && *index >= 1
    35663566              && symbol[-1].n_type == 0xfe)
    35673567            {
    3568               sym2 = find_symbol_ex (symbol[-1].n_un.n_strx + str_ptr, *index - 1, 1);
     3568              sym2 = find_symbol_ex (symbol[-1].n_un.n_strx + str_ptr, *index - 1, 1, 0);
    35693569              if (!sym2)
    35703570                {
    35713571                  warning ("Cannot find address of communal/external variable %s", name);
  • emxomf.c

     
    540540   array pointed to by sym_ptr) is returned.  If the symbol is not
    541541   found, NULL is returned.
    542542   NOT_ENTRY is an entry index which is not to be found.
    543    FEXT is an indicator on whether or not we can find external symbols or
    544    not.  */
    545 const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext)
     543   FEXT is an indicator on whether or not we can find external symbols.
     544   FPUBONLY is an indicator of whether or not the search is restricted to
     545   public symbols defined in this module. */
     546const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext,
     547                                    int fpub_only)
    546548{
    547549  int i, j, n, len, t;
    548550  const byte *s;
     
    564566          for (j = 0; j < n; ++j)
    565567            if (sym_ptr[j].n_un.n_strx == sym_ofs && j != not_entry)
    566568              {
     569                if (fpub_only && !(sym_ptr[j].n_type & N_EXT))
     570                  continue;
    567571                t = sym_ptr[j].n_type & ~N_EXT;
    568572                if (   t == N_TEXT || t == N_DATA || t == N_BSS
    569573                    || (fext && sym_ptr[j].n_type == N_EXT)
     
    583587   found, NULL is returned. */
    584588const struct nlist *find_symbol (const char *name)
    585589{
    586   return find_symbol_ex (name, -1, 0);
     590  return find_symbol_ex (name, -1, 0, 0);
    587591}
    588592
    589593
     
    764768
    765769
    766770/* Calculates the hash for a string using the original djb2 aglorithm. */
    767  
     771
    768772static unsigned hash_string(const char *pch, size_t cch)
    769773{
    770774    unsigned uHash;
     
    774778}
    775779
    776780/* Formats a 64-bit number with a fixed with. The purpose is to encode
    777    a unique number as tiny as possible while keeping within what any 
    778    linker should accept. The width is fixed, and the string is clipped 
     781   a unique number as tiny as possible while keeping within what any
     782   linker should accept. The width is fixed, and the string is clipped
    779783   or padded with zeros to satisfy that. The return value is psz + cchWidth. */
    780784
    781785static char *format_u64(uint64_t u64, char *psz, unsigned uRadix, int cchWidth)
     
    10051009  if (*pstarted)
    10061010    {
    10071011      size_t cchEncodedName = strlen(name);
    1008       if (   cchEncodedName > SYMBOL_MAX_LENGTH 
     1012      if (   cchEncodedName > SYMBOL_MAX_LENGTH
    10091013          && !strstr(name + SYMBOL_MAX_LENGTH - SYMBOL_WEAK_LENGTH, "$w$"))
    10101014        cchEncodedName = SYMBOL_MAX_LENGTH + SYMBOL_HASH_LENGTH;
    10111015      if (!fits(cchEncodedName + 3 + (type > 127)))
     
    27032707    memcpy(pszSym, pszSymbol, cchSymbol);
    27042708    pszSym[cchSymbol] = '\0';
    27052709
    2706     pSym = find_symbol(pszSym);
     2710    pSym = find_symbol_ex(pszSym, -1, 0, 1);
    27072711    if (pSym)
    27082712    {
    27092713        /*