From: uz Date: Tue, 16 Aug 2011 13:39:00 +0000 (+0000) Subject: Write imports out as debug symbols. X-Git-Tag: V2.13.3~277 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b7c4a4fe011918adb2f452817dc5addb33fd6e5c;p=cc65 Write imports out as debug symbols. git-svn-id: svn://svn.cc65.org/cc65/trunk@5185 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ca65/symentry.c b/src/ca65/symentry.c index c9203c06e..d46f21ac0 100644 --- a/src/ca65/symentry.c +++ b/src/ca65/symentry.c @@ -684,7 +684,7 @@ unsigned GetSymImportId (const SymEntry* S) unsigned GetSymExportId (const SymEntry* S) /* Return the export id for the given symbol */ { - PRECONDITION (S != 0 && (S->Flags & SF_IMPORT) && S->ExportId != ~0U); + PRECONDITION (S != 0 && (S->Flags & SF_EXPORT) && S->ExportId != ~0U); return S->ExportId; } diff --git a/src/ca65/symentry.h b/src/ca65/symentry.h index 02afbcfdc..2c098ad40 100644 --- a/src/ca65/symentry.h +++ b/src/ca65/symentry.h @@ -71,6 +71,9 @@ #define SF_DEFINED 0x4000 /* Defined */ #define SF_REFERENCED 0x8000 /* Referenced */ +/* Combined values */ +#define SF_REFIMP (SF_REFERENCED|SF_IMPORT) /* A ref'd import */ + /* Arguments for SymFind... */ #define SYM_FIND_EXISTING 0 #define SYM_ALLOC_NEW 1 diff --git a/src/ca65/symtab.c b/src/ca65/symtab.c index b4d842661..d76aad2ef 100644 --- a/src/ca65/symtab.c +++ b/src/ca65/symtab.c @@ -60,16 +60,14 @@ /*****************************************************************************/ -/* Data */ +/* Data */ /*****************************************************************************/ /* Combined symbol entry flags used within this module */ #define SF_UNDEFMASK (SF_REFERENCED | SF_DEFINED | SF_IMPORT) -#define SF_UNDEFVAL (SF_REFERENCED) -#define SF_DBGINFOMASK (SF_UNUSED | SF_DEFINED | SF_IMPORT) -#define SF_DBGINFOVAL (SF_DEFINED) +#define SF_UNDEFVAL (SF_REFERENCED) /* Symbol tables */ SymTable* CurrentScope = 0; /* Pointer to current symbol table */ @@ -89,6 +87,20 @@ static unsigned ExportCount = 0; /* Counter for export symbols */ +static int IsDbgSym (const SymEntry* S) +/* Return true if this is a debug symbol */ +{ + if ((S->Flags & (SF_DEFINED | SF_UNUSED)) == SF_DEFINED) { + /* Defined symbols are debug symbols if they aren't sizes */ + return !IsSizeOfSymbol (S); + } else { + /* Others are debug symbols if they're referenced imports */ + return ((S->Flags & SF_REFIMP) == SF_REFIMP); + } +} + + + static unsigned ScopeTableSize (unsigned Level) /* Get the size of a table for the given lexical level */ { @@ -802,8 +814,7 @@ void WriteDbgSyms (void) Count = 0; S = SymList; while (S) { - if ((S->Flags & SF_DBGINFOMASK) == SF_DBGINFOVAL && - !IsSizeOfSymbol (S)) { + if (IsDbgSym (S)) { S->DebugSymId = Count++; } S = S->List; @@ -817,8 +828,7 @@ void WriteDbgSyms (void) */ S = SymList; while (S) { - if ((S->Flags & SF_DBGINFOMASK) == SF_DBGINFOVAL && - !IsSizeOfSymbol (S)) { + if (IsDbgSym (S)) { /* Get the expression bits and the value */ long ConstVal;