From: uz Date: Tue, 16 Aug 2011 12:52:56 +0000 (+0000) Subject: Track export ids of debug symbols and write the to the object file. X-Git-Tag: V2.13.3~279 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=aa1a1031549340e229638e144bfe761c0c74aa5c;p=cc65 Track export ids of debug symbols and write the to the object file. git-svn-id: svn://svn.cc65.org/cc65/trunk@5183 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/ca65/symentry.c b/src/ca65/symentry.c index 81e63df98..c9203c06e 100644 --- a/src/ca65/symentry.c +++ b/src/ca65/symentry.c @@ -94,6 +94,7 @@ SymEntry* NewSymEntry (const StrBuf* Name, unsigned Flags) S->Flags = Flags; S->DebugSymId = ~0U; S->ImportId = ~0U; + S->ExportId = ~0U; S->Expr = 0; S->ExprRefs = AUTO_COLLECTION_INITIALIZER; S->ExportSize = ADDR_SIZE_DEFAULT; @@ -680,6 +681,15 @@ 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); + return S->ExportId; +} + + + unsigned GetSymInfoFlags (const SymEntry* S, long* ConstVal) /* Return a set of flags used when writing symbol information into a file. * If the SYM_CONST bit is set, ConstVal will contain the constant value diff --git a/src/ca65/symentry.h b/src/ca65/symentry.h index 32c11ca5b..02afbcfdc 100644 --- a/src/ca65/symentry.h +++ b/src/ca65/symentry.h @@ -95,7 +95,8 @@ struct SymEntry { */ unsigned Flags; /* Symbol flags */ unsigned DebugSymId; /* Debug symbol id */ - unsigned ImportId; /* Id of import if this is one */ + unsigned ImportId; /* Id of import if this is one */ + unsigned ExportId; /* Id of export if this is one */ struct ExprNode* Expr; /* Symbol expression */ Collection ExprRefs; /* Expressions using this symbol */ unsigned char ExportSize; /* Export address size */ @@ -338,6 +339,9 @@ long GetSymVal (SymEntry* Sym); unsigned GetSymImportId (const SymEntry* Sym); /* Return the import id for the given symbol */ +unsigned GetSymExportId (const SymEntry* Sym); +/* Return the export id for the given symbol */ + unsigned GetSymInfoFlags (const SymEntry* Sym, long* ConstVal); /* Return a set of flags used when writing symbol information into a file. * If the SYM_CONST bit is set, ConstVal will contain the constant value diff --git a/src/ca65/symtab.c b/src/ca65/symtab.c index f835dc60c..b4d842661 100644 --- a/src/ca65/symtab.c +++ b/src/ca65/symtab.c @@ -592,9 +592,9 @@ void SymCheck (void) } } - /* Count exports */ + /* Count exports, assign the export ID */ if (S->Flags & SF_EXPORT) { - ++ExportCount; + S->ExportId = ExportCount++; } /* If the symbol is defined but has an unknown address size, @@ -865,10 +865,13 @@ void WriteDbgSyms (void) ObjWriteVar (Size); } - /* If the symbol is an import, write out its import id */ + /* If the symbol is an im- or export, write out the ids */ if (SYM_IS_IMPORT (SymFlags)) { ObjWriteVar (GetSymImportId (S)); } + if (SYM_IS_EXPORT (SymFlags)) { + ObjWriteVar (GetSymExportId (S)); + } /* Write the line infos */ WriteLineInfo (&S->LineInfos);