Changeset 1885


Ignore:
Timestamp:
Apr 24, 2005, 4:50:52 AM (20 years ago)
Author:
bird
Message:

Refined the 'G' hack fixing globals in the text segment (wrong assumption).

File:
1 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.34 to 1.35
    r1884 r1885  
    34943494        case 'G':
    34953495          /* Static storage, global scope */
    3496 #if 1 /* birds ugly hacking of 'G' allow this code path. (See dbxout.c.)  */
    3497           if (where == -1)
    3498             { /* If I got it right, dbxout.c uses N_FUN for globals in the
    3499                  text section.  */
    3500               where = symbol->n_type == N_FUN ? N_TEXT : N_DATA;
    3501             }
    3502           if (symbol->n_value == -12357)
    3503             { /* Special hack for external and communal variables.
    3504                  We expect the previous symbol to be an 0xfe entry
    3505                  for the symbol we're processing.  */
    3506               ++parse_ptr;
    3507               ti = hll_type ();
    3508 
    3509               if (   *index >= 1
    3510                   && (symbol[-1].n_type == 0xfe))
    3511                 {
    3512                   const struct nlist *sym2;
    3513 
    3514 #if defined (HLL_DEBUG)
    3515                   printf ("  type=%#x\n", ti);
    3516 #endif
    3517                   sym2 = find_symbol_ex (symbol[-1].n_un.n_strx + str_ptr, *index - 1, 1);
    3518                   if (sym2)
    3519                     {
    3520                       if (sym2->n_type == N_EXT)
    3521                         sst_static (name, 0, ti, sym2 - sym_ptr, 1, sym2);
    3522                       else
    3523                         sst_static (name, sym2->n_value, ti, sym2->n_type, 0, sym2);
    3524                       break;
    3525                     }
    3526                 }
    3527               warning ("Cannot find address of communal/external variable %s", name);
    3528               return;
    3529             }
    3530           /* fall thru */
    3531 
    3532 #else /* old code */
    35333496          {
    3534           char *psz;
    3535           int   cch;
    3536           const struct nlist *sym2;
    3537 
     3497          const struct nlist *sym2 = NULL;
    35383498          ++parse_ptr;
    35393499          ti = hll_type ();
     
    35413501          printf ("  type=%#x\n", ti);
    35423502#endif
    3543           psz = alloca(cch = strlen(name) + 2);
    3544           *psz = '_';
    3545           strcpy(psz+1, name);
    3546           sym2 = find_symbol (psz);
    3547           if (sym2 == NULL)
     3503
     3504          /* Check for a ugly hack in dbxout.c which allow us to resolve
     3505             communal and global variables more accuratly. The n_value is -12357
     3506             and the previous entry is 0xfe. What the previous entry contains
     3507             is the assembly name of the symbol.
     3508
     3509             Another part of that hack is that n_value is contains the
     3510             symbol value so we don't need to look up the symbol for that
     3511             reason (but as it turns out we have to look it up to see where
     3512             it is in most cases, bah). */
     3513          if (   symbol->n_value == -12357
     3514              && *index >= 1
     3515              && symbol[-1].n_type == 0xfe)
    35483516            {
    3549               no_warning ("Cannot find address of global variable %s (%s)", name, psz);
    3550               return;
     3517              sym2 = find_symbol_ex (symbol[-1].n_un.n_strx + str_ptr, *index - 1, 1);
     3518              if (!sym2)
     3519                {
     3520                  warning ("Cannot find address of communal/external variable %s", name);
     3521                  return;
     3522                }
    35513523            }
    3552           if (sym2->n_type == N_EXT)
    3553             sst_static (name, 0, ti, sym2 - sym_ptr, 1, sym2);
     3524          else if (where == -1)
     3525            { /* This is not very nice, we have to look up the symbol
     3526                 like we used to do in order to the the segment right.
     3527                 Should probably just use the external/communal hack above
     3528                 for everything or change the n_type of the 'G' stab... However,
     3529                 this will work for most cases and it will be compatible with
     3530                 the unmodified dbxout.c code. */
     3531              if (symbol->n_type == N_FUN) /* in case GCC change... */
     3532                  where = N_TEXT;
     3533              else
     3534                {
     3535                  size_t cch = strlen (name);
     3536                  char *psz = alloca (cch + 2);
     3537                  *psz = '_';
     3538                  memcpy (psz + 1, name, cch + 1);
     3539                  sym2 = find_symbol (psz);
     3540                  if (!sym2)
     3541                    sym2 = find_symbol (psz + 1);
     3542                  where = N_DATA;
     3543                }
     3544            }
     3545          /* if we're lucky we've got a symbol... */
     3546          if (sym2)
     3547            {
     3548              if (sym2->n_type == N_EXT)
     3549                sst_static (name, 0, ti, sym2 - sym_ptr, 1, sym2);
     3550              else
     3551                sst_static (name, sym2->n_value, ti, sym2->n_type, 0, sym2);
     3552            }
    35543553          else
    3555             sst_static (name, sym2->n_value, ti, sym2->n_type, 0, sym2);
     3554            sst_static (name, symbol->n_value, ti, where, 0, NULL);
    35563555          break;
    35573556          }
    3558 #endif /* new / old 'G' handling. */
    35593557
    35603558        case 'S':
Note: See TracChangeset for help on using the changeset viewer.