Fixed an error: For symbols declared as extern in local scope, the name for

the external assembler symbol wasn't set.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5620 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2012-03-24 13:42:10 +00:00
parent c09d6a7299
commit 515661e5f4
3 changed files with 23 additions and 7 deletions

View File

@ -162,7 +162,7 @@ int SymIsOutputFunc (const SymEntry* Sym)
return IsTypeFunc (Sym->Type) &&
SymIsDef (Sym) &&
(Sym->Flags & (SC_REF | SC_EXTERN));
}
}
@ -209,6 +209,23 @@ void SymUseAttr (SymEntry* Sym, struct Declaration* D)
void SymSetAsmName (SymEntry* Sym)
/* Set the assembler name for an external symbol from the name of the symbol */
{
unsigned Len;
/* Cannot be used to change the name */
PRECONDITION (Sym->AsmName == 0);
/* The assembler name starts with an underline */
Len = strlen (Sym->Name);
Sym->AsmName = xmalloc (Len + 2);
Sym->AsmName[0] = '_';
memcpy (Sym->AsmName+1, Sym->Name, Len+1);
}
void CvtRegVarToAuto (SymEntry* Sym)
/* Convert a register variable to an auto variable */
{

View File

@ -252,6 +252,9 @@ INLINE int SymHasAttr (const SymEntry* Sym, DeclAttrType A)
void SymUseAttr (SymEntry* Sym, struct Declaration* D);
/* Use the attributes from the declaration for this symbol */
void SymSetAsmName (SymEntry* Sym);
/* Set the assembler name for an external symbol from the name of the symbol */
void CvtRegVarToAuto (SymEntry* Sym);
/* Convert a register variable to an auto variable */

View File

@ -710,6 +710,7 @@ SymEntry* AddLocalSym (const char* Name, const Type* T, unsigned Flags, int Offs
Entry->V.R.SaveOffs = StackPtr;
} else if ((Flags & SC_EXTERN) == SC_EXTERN) {
Entry->V.Label = Offs;
SymSetAsmName (Entry);
} else if ((Flags & SC_STATIC) == SC_STATIC) {
/* Generate the assembler name from the label number */
Entry->V.Label = Offs;
@ -809,8 +810,6 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags)
} else {
unsigned Len;
/* Create a new entry */
Entry = NewSymEntry (Name, Flags);
@ -826,10 +825,7 @@ SymEntry* AddGlobalSym (const char* Name, const Type* T, unsigned Flags)
}
/* Add the assembler name of the symbol */
Len = strlen (Name);
Entry->AsmName = xmalloc (Len + 2);
Entry->AsmName[0] = '_';
memcpy (Entry->AsmName+1, Name, Len+1);
SymSetAsmName (Entry);
/* Add the entry to the symbol table */
AddSymEntry (Tab, Entry);