Changeset 806


Ignore:
Timestamp:
Oct 6, 2003, 2:05:18 AM (22 years ago)
Author:
bird
Message:

#456: Fixing major sst encoding problem, bad size field. Try get a type index on pubs and exts. Fixed a little problem with static members.

Location:
trunk/src/emx/src/emxomf
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/emxomf/emxomf.c

    • Property cvs2svn:cvs-rev changed from 1.28 to 1.29
    r805 r806  
    5757  int index;                    /* EXTDEF index */
    5858  int flags;                    /* SF_FAR16 */
     59  int hll_type;                 /* HLL type index. */
    5960};
    6061
     
    608609
    609610
     611/* Set the hll_type of a symbols. */
     612void set_hll_type (int index, int hll_type)
     613{
     614  if (index > sym_count || index < 0)
     615    error ("Internal error! Invalid index (%d) passed to set_hll_type().", index);
     616fprintf(stderr, "dbg: set_hll_type %x %s %d\n", sym_ptr[index].n_type, str_ptr + sym_ptr[index].n_un.n_strx, hll_type);
     617  sym_more[index].hll_type = hll_type;
     618}
     619
     620
    610621/* Add a symbol to 0 symbol list */
    611622
     
    909920static void put_str (const char *src)
    910921{
     922  char sz[256];
    911923  int len;
    912924
    913925  len = strlen (src);
    914926  if (len > 255)
    915     {
     927    { /* Hash the symbol to help making it unique. */
     928      const char *  psz = src;
     929      unsigned      uhash = 0;
     930      char          szhash[16];
    916931      warning ("Symbol length truncated to 255 characters for `%s'", src);
     932      for (; *psz; psz++)
     933        uhash = ((uhash << 3) ^ (*psz & 0x15)); /** @todo fix this rather bad hash algorithm. */
     934      len = sprintf(szhash, "!_%X", 0x7fffffff & uhash);
     935      memcpy(sz, src, 255);
     936      memcpy(sz + 255 - len, szhash, len + 1);
    917937      len = 255;
     938      src = &sz[0];
    918939    }
    919940  if (!fits (1+len))
     
    10711092   record.  PSTARTED points to an object keeping state. */
    10721093
    1073 static void add_extdef (int *pstarted, const char *name)
     1094static void add_extdef (int *pstarted, const char *name, int type)
    10741095{
    10751096  if (*pstarted && !fits (strlen (name)+3))
     
    10841105    }
    10851106  put_sym (name);
    1086   put_idx (0);                  /* type index */
     1107  put_idx (type);                       /* type index */
    10871108}
    10881109
     
    11151136        if (memcmp (name, "_16_", 4) == 0)
    11161137          sym_more[i].flags |= SF_FAR16;
    1117         add_extdef (&started, name);
     1138        add_extdef (&started, name, sym_more[i].hll_type);
    11181139      }
    11191140    else if (sym_ptr[i].n_type == N_WEAKU)
     
    11221143          {
    11231144            weak_zero_index = sym_index++;
    1124             add_extdef (&started, "WEAK$ZERO");
     1145            add_extdef (&started, "WEAK$ZERO", 0);
    11251146          }
    11261147        sym_more[i].index = sym_index++;
    1127         add_extdef (&started, str_ptr + sym_ptr[i].n_un.n_strx);
     1148        add_extdef (&started, str_ptr + sym_ptr[i].n_un.n_strx, sym_more[i].hll_type);
    11281149      }
    11291150#if 0 /* this isn't actually required if only the assembler could do what it's supposed to... */
     
    11341155        name = str_ptr + sym_ptr[i].n_un.n_strx;
    11351156        sym_more[i].index = sym_index++;
    1136         add_extdef (&started, name);
     1157        add_extdef (&started, name, sym_more[i].hll_type);
    11371158      }
    11381159#endif
     
    13901411                else
    13911412                  put_16 (address);
    1392                 put_idx (0);        /* type index */
     1413                put_idx (sym_more[i].hll_type); /* type index */
    13931414              }
    13941415          }
     
    14311452              else
    14321453                put_16 (address);
    1433               put_idx (0);        /* type index */
     1454              put_idx (sym_more[i].hll_type);   /* type index */
    14341455              write_rec ();
    14351456              break;
     
    32993320  byte *t;
    33003321  const struct nlist *entry_symbol;
    3301   int i;
    33023322
    33033323  /* Simplify things by reading the complete a.out module into
     
    33393359
    33403360  sym_more = xmalloc (sym_count * sizeof (struct symbol));
    3341   for (i = 0; i < sym_count; ++i)
    3342     {
    3343       sym_more[i].index = 0;
    3344       sym_more[i].flags = 0;
    3345     }
     3361  memset(sym_more, 0, sym_count * sizeof (struct symbol));
    33463362
    33473363  /* Print unknown symbol table entries if the -u option is given. */
  • trunk/src/emx/src/emxomf/emxomf.h

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r805 r806  
    3232extern const struct nlist *find_symbol (const char *name);
    3333extern const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext);
     34extern void set_hll_type (int index, int hll_type);
    3435
    3536/* These variables are defined in emxomf.c. */
  • trunk/src/emx/src/emxomf/stabshll.c

    • Property cvs2svn:cvs-rev changed from 1.26 to 1.27
    r805 r806  
    555555  grow_by (&sst_boundary_grow, 1);
    556556  sst_boundary[sst_boundary_grow.count++] = sst.size;
    557   buffer_byte (&sst, 0);        /* Length of sub-record */
    558   buffer_byte (&sst, type);     /* Type of sub-record */
     557  /* Length of sub-record - bird: not sure if HL03 likes this. */
     558  buffer_byte (&sst, 0x80);
     559  buffer_byte (&sst, 0);
     560  /* Type of sub-record */
     561  buffer_byte (&sst, type);
    559562}
    560563
     
    565568static void sst_end (void)
    566569{
    567   if (sst.size - subrec_start - 1 > 255)
     570  int len = sst.size - subrec_start - 2;
     571  if (len > 1000)
    568572    error ("sst_end: Record too big");
    569   sst.buf[subrec_start] = sst.size - subrec_start - 1;
     573  sst.buf[subrec_start] = (len >> 8) | 0x80;
     574  sst.buf[subrec_start + 1] = 0xff & len;
    570575}
    571576
     
    579584
    580585static void sst_static (const char *name, dword addr, int type_index,
    581                         int sym_seg, int ext)
     586                        int sym_seg, int ext, const struct nlist *psym)
    582587{
    583588  struct relocation_info r;
    584 
    585   sst_start (SST_static);
     589  size_t len = strlen (name);
     590
     591  if (!psym)
     592    {
     593      psym = find_symbol_ex (name, -1, ext);
     594      if (!psym)
     595        {
     596          char *psz = alloca (len + 2);
     597          *psz = '_';
     598          memcpy(psz + 1, name, len + 1);
     599          psym = find_symbol_ex (psz, -1, ext);
     600        }
     601    }
     602  if (psym)
     603    set_hll_type (psym - sym_ptr, type_index);
     604
     605  if (len > 255)
     606    sst_start (SST_CPPstatic);
     607  else
     608    sst_start (SST_static);
    586609  r.r_address = sst.size;
    587610  buffer_dword (&sst, addr);      /* Segment offset */
    588611  buffer_word (&sst, 0);          /* Segment address */
    589612  buffer_word (&sst, type_index); /* Type index */
    590   buffer_nstr (&sst, name);       /* Symbol name */
     613  if (len > 255)
     614    buffer_enc (&sst, name);      /* Symbol name - encoded. */
     615  else
     616    buffer_nstr (&sst, name);     /* Symbol name */
    591617  sst_end ();
    592618  r.r_extern = ext;
     
    22682294                      t1 = type_add (&t);
    22692295                    }
     2296                  tf->offset = offset >> 3;
    22702297                }
    22712298              tf->type = t1;
    2272               tf->offset = offset >> 3;
    22732299            }
    22742300        }
     
    32283254  n = p - str;
    32293255
    3230   /*
    3231    * The debuggers doesn't like looong names. Besides it doesn't know how to
    3232    * demangle them either. This is the place to deal with this.
    3233    * (The limit seems to be 106 bytes.)
    3234    *
    3235    * For now we'll just make sure the name ain't too long.
    3236    */
    3237   if (n > 106)
    3238     {
    3239       char szName[106];
    3240       memcpy(szName, str, sizeof(szName) - 1);
    3241       szName[sizeof(szName) - 1] = '!'; /* mark it as cut. */
    3242       name = strpool_addn(str_pool, str, sizeof(szName));
    3243     }
    3244   else
    3245     name = strpool_addn(str_pool, str, n);
    3246 
     3256  /** @todo name demangling */
     3257  name = strpool_addn (str_pool, str, n);
    32473258  proc_start_addr = symbol->n_value;
    32483259
     
    33283339      make_type (t2, &ti);
    33293340
    3330       sst_start (cplusplus_flag ? SST_CPPproc : SST_proc);
     3341      sst_start (cplusplus_flag || n > 255 ? SST_CPPproc : SST_proc);
    33313342      r.r_address = sst.size;
    33323343      buffer_dword (&sst, symbol->n_value); /* Segment offset */
     
    33383349      buffer_word (&sst, 0);        /* Class type (for member functions) */
    33393350      buffer_byte (&sst, 8);        /* 32-bit near */
    3340       if (cplusplus_flag)
     3351      if (cplusplus_flag || n > 255)
    33413352        buffer_enc (&sst, name);    /* Proc name */
    33423353      else
     
    33503361  r.r_pad = 0;
    33513362  buffer_mem (&sst_reloc, &r, sizeof (r));
     3363  set_hll_type (symbol - sym_ptr, ti);
    33523364}
    33533365
     
    34353447                    {
    34363448                      if (sym2->n_type == N_EXT)
    3437                         sst_static (name, 0, ti, sym2 - sym_ptr, 1);
     3449                        sst_static (name, 0, ti, sym2 - sym_ptr, 1, sym2);
    34383450                      else
    3439                         sst_static (name, sym2->n_value, ti, sym2->n_type, 0);
     3451                        sst_static (name, sym2->n_value, ti, sym2->n_type, 0, sym2);
    34403452                      break;
    34413453                    }
     
    34673479            }
    34683480          if (sym2->n_type == N_EXT)
    3469             sst_static (name, 0, ti, sym2 - sym_ptr, 1);
     3481            sst_static (name, 0, ti, sym2 - sym_ptr, 1, sym2);
    34703482          else
    3471             sst_static (name, sym2->n_value, ti, sym2->n_type, 0);
     3483            sst_static (name, sym2->n_value, ti, sym2->n_type, 0, sym2);
    34723484          break;
    34733485          }
     
    34903502          printf ("  type=%#x\n", ti);
    34913503#endif
    3492           sst_static (name, symbol->n_value, ti, where, 0);
     3504          sst_static (name, symbol->n_value, ti, where, 0, NULL);
    34933505          break;
    34943506
     
    38003812
    38013813  /* Check whether converting a translated C++ program. */
    3802   #if 1 /* kso #465 2003-06-04: pretend everything is C++, that symbols is no longer present. */
     3814#if 1 /* kso #465 2003-06-04: pretend everything is C++, that symbols is no longer present. */
    38033815  cplusplus_flag = 1;
    3804   #else
     3816#else
    38053817  cplusplus_flag = (find_symbol ("__gnu_compiled_cplusplus") != NULL);
    3806   #endif
     3818#endif
    38073819
    38083820
Note: See TracChangeset for help on using the changeset viewer.