Changeset 727


Ignore:
Timestamp:
Sep 25, 2003, 8:44:48 PM (22 years ago)
Author:
bird
Message:

#456: More global variable hacking. Improved error messages.

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.26 to 1.27
    r726 r727  
    184184 * Link386              support HLL v3 (?)
    185185 */
    186 int hll_version = 6;
     186int hll_version = 4;
    187187
    188188/* Private variables. */
     
    559559   NAME.  On success, a pointer to the symbol table entry (in the
    560560   array pointed to by sym_ptr) is returned.  If the symbol is not
    561    found, NULL is returned. */
    562 const struct nlist *find_symbol (const char *name)
     561   found, NULL is returned.
     562   NOT_ENTRY is an entry index which is not to be found.
     563   FEXT is an indicator on whether or not we can find external symbols or
     564   not.  */
     565const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext)
    563566{
    564567  int i, j, n, len, t;
     
    580583          n = sym_count;
    581584          for (j = 0; j < n; ++j)
    582             if (sym_ptr[j].n_un.n_strx == sym_ofs)
     585            if (sym_ptr[j].n_un.n_strx == sym_ofs && j != not_entry)
    583586              {
    584587                t = sym_ptr[j].n_type & ~N_EXT;
    585                 if (t == N_TEXT || t == N_DATA || t == N_BSS
    586                     /* kso #465 2003-06-04: Find weak symbols too. */
     588                if (   t == N_TEXT || t == N_DATA || t == N_BSS
     589                    || (fext && sym_ptr[j].n_type == N_EXT)
    587590                    || (sym_ptr[j].n_type >= N_WEAKA && sym_ptr[j].n_type <= N_WEAKB)
    588591                    || (t == 0 && sym_ptr[j].n_value != 0))
     
    593596    }
    594597  return NULL;                  /* Symbol not found */
     598}
     599
     600/* Find an a.out symbol.  The underscore character `_' is prepended to
     601   NAME.  On success, a pointer to the symbol table entry (in the
     602   array pointed to by sym_ptr) is returned.  If the symbol is not
     603   found, NULL is returned. */
     604const struct nlist *find_symbol (const char *name)
     605{
     606  return find_symbol_ex (name, -1, 0);
    595607}
    596608
     
    10991111  for (i = 0; i < sym_count; ++i)
    11001112    if (sym_ptr[i].n_type == (N_INDR|N_EXT))
    1101       {
    1102         if (!strstr(str_ptr + sym_ptr[i].n_un.n_strx, "$hll$"))
    1103           ++i;                    /* Skip immediately following entry */
    1104       }
     1113      ++i;                       /* Skip immediately following entry */
    11051114    else if (sym_ptr[i].n_type == N_EXT && sym_ptr[i].n_value == 0)
    11061115      {
     
    40234032      case 'h':
    40244033        hll_version = optarg ? atoi(optarg) : 4;
    4025         if (hll_version != 4 && hll_version != 3)
     4034        if (hll_version != 4 && hll_version != 3 && hll_version != 6)
    40264035          {
    40274036            printf ("syntax error: Invalid HLL version specified (%d)\n", hll_version);
  • trunk/src/emx/src/emxomf/emxomf.h

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r726 r727  
    3131char *xstrdup (const char *s);
    3232extern const struct nlist *find_symbol (const char *name);
     33extern const struct nlist *find_symbol_ex (const char *name, int not_entry, int fext);
    3334
    3435/* These variables are defined in emxomf.c. */
  • trunk/src/emx/src/emxomf/stabshll.c

    • Property cvs2svn:cvs-rev changed from 1.20 to 1.21
    r726 r727  
    2727#include <stdlib.h>
    2828#include <string.h>
     29#include <stdarg.h>
    2930#include <time.h>
    3031#include <alloca.h>
     
    373374
    374375/* kso #456 2003-06-11: Reversed quiet workaround. */
    375 #define no_warning warning
     376#define no_warning warning_parse
    376377
    377378
     
    380381*******************************************************************************/
    381382static void parse_typedef (int *index);
    382 
    383 
     383static void warning_parse (const char *pszFormat, ...);
     384
     385
     386/**
     387 * Report an warning in which might be connecting to parsing.
     388 *
     389 * @param   pszFormat   Message string.
     390 * @param   ...         More arguments
     391 */
     392static void warning_parse (const char *pszFormat, ...)
     393{
     394  va_list args;
     395
     396  va_start (args, pszFormat);
     397  fprintf (stderr, "emxomf warning: ");
     398  vfprintf (stderr, pszFormat, args);
     399  va_end (args);
     400  fputc ('\n', stderr);
     401
     402  if (parse_ptr && parse_start && parse_ptr >= parse_start)
     403    fprintf (stderr, "emxomf info: Currently parsing '%c' at position %ld in\n%s\n",
     404             *parse_ptr, parse_ptr - parse_start, parse_start);
     405}
    384406
    385407
     
    23322354
    23332355    case 'a':
    2334 
    23352356      /* An array: ar<index_type>;<lower_bound>;<upper_bound>;<el_type> */
    23362357
     
    24412462  if (tp->index == -2)
    24422463    {
    2443       no_warning ("Cycle detected by make_type");
     2464      warning_parse ("Cycle detected by make_type.");
    24442465      RETURN (0);
    24452466    }
     
    24532474      if (t1 == NULL)
    24542475        {
    2455           no_warning ("Undefined stabs type %d referenced", tp->d.stabs_ref);
     2476          warning_parse ("Undefined stabs type %d referenced", tp->d.stabs_ref);
    24562477          RETURN (0x82);        /* 32 bit signed */
    24572478        }
     
    32363257      printf ("%s %s\n", msg, str);
    32373258#endif
     3259
    32383260      parse_start = parse_ptr = p + 1;
    32393261      switch (*parse_ptr)
     
    32483270            }
    32493271          if (symbol->n_value == -12357)
    3250             { /* Special hack for unresolved external variables.
     3272            { /* Special hack for external and communials variables.
    32513273                 We expect the previous two symbols to be an alias for the
    32523274                 undefined symbol. The first of them will then have the name
    3253                  of this record with an $hll$ suffix. */
     3275                 of this record with an $hll$.* suffix. */
     3276              ++parse_ptr;
     3277              ti = hll_type ();
     3278
    32543279              if (   *index >= 2
    32553280                  && symbol[-2].n_type == (N_INDR | N_EXT)
     
    32573282                  && strstr(str_ptr + symbol[-2].n_un.n_strx, "$hll$"))
    32583283                {
    3259                   ++parse_ptr;
    3260                   ti = hll_type ();
     3284                  const struct nlist *sym2;
     3285                  int fext = !strstr(str_ptr + symbol[-2].n_un.n_strx, "$hll$comm$");
     3286
    32613287#if defined (HLL_DEBUG)
    32623288                  printf ("  type=%#x\n", ti);
    32633289#endif
    3264                   sst_static (name, 0, ti, *index - 1, 1);
     3290                  sym2 = find_symbol_ex (symbol[-1].n_un.n_strx + str_ptr, *index - 1, fext);
     3291                  if (sym2)
     3292                    {
     3293                      if (sym2->n_type == N_EXT)
     3294                        sst_static (name, 0, ti, sym2 - sym_ptr, 1);
     3295                      else
     3296                        sst_static (name, sym2->n_value, ti, sym2->n_type, 0);
     3297                      break;
     3298                    }
    32653299                }
    3266               else
    3267                 {
    3268                   warning ("Cannot find address of external variable %s", name);
    3269                   return;
    3270                 }
    3271               break;
     3300              warning ("Cannot find address of external variable %s", name);
     3301              return;
    32723302            }
    32733303          /* fall thru */
Note: See TracChangeset for help on using the changeset viewer.