Bah, l'algorithme de recherche d'un symbole de
ld-tigcc, c'est ça.
// Point the location to the appropriate symbol, if one is found.
SYMBOL *ResolveLocation (PROGRAM *Program, SECTION *Section, LOCATION *Location)
{
if (Location->Symbol)
return Location->Symbol;
else
{
SECTION *CurSection;
// For each section...
for_each (CurSection, Program->Sections)
{
SYMBOL *CurSymbol;
// For each symbol...
for_each (CurSymbol, CurSection->Symbols)
{
// If the name matches, we have found the right symbol.
if (CurSymbol->Exported && (!(strcmp (Location->SymbolName, CurSymbol->Name))))
{
// Set up the reloc accordingly, freeing its
// destination string.
Location->Symbol = CurSymbol;
FreeLocationSymbolName (Section, Location);
return CurSymbol;
}
}
}
return NULL;
}
}