mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 21:24:00 +00:00
[yaml2obj][ELF] Rename class SectionNameToIdxMap => NameToIdxMap. It can
be used for indexing not only section's names. No functional changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205687 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -94,23 +94,23 @@ public:
|
|||||||
};
|
};
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
// Used to keep track of section names, so that in the YAML file sections
|
// Used to keep track of section and symbol names, so that in the YAML file
|
||||||
// can be referenced by name instead of by index.
|
// sections and symbols can be referenced by name instead of by index.
|
||||||
namespace {
|
namespace {
|
||||||
class SectionNameToIdxMap {
|
class NameToIdxMap {
|
||||||
StringMap<int> Map;
|
StringMap<int> Map;
|
||||||
public:
|
public:
|
||||||
/// \returns true if name is already present in the map.
|
/// \returns true if name is already present in the map.
|
||||||
bool addName(StringRef SecName, unsigned i) {
|
bool addName(StringRef Name, unsigned i) {
|
||||||
StringMapEntry<int> &Entry = Map.GetOrCreateValue(SecName, -1);
|
StringMapEntry<int> &Entry = Map.GetOrCreateValue(Name, -1);
|
||||||
if (Entry.getValue() != -1)
|
if (Entry.getValue() != -1)
|
||||||
return true;
|
return true;
|
||||||
Entry.setValue((int)i);
|
Entry.setValue((int)i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/// \returns true if name is not present in the map
|
/// \returns true if name is not present in the map
|
||||||
bool lookupSection(StringRef SecName, unsigned &Idx) const {
|
bool lookup(StringRef Name, unsigned &Idx) const {
|
||||||
StringMap<int>::const_iterator I = Map.find(SecName);
|
StringMap<int>::const_iterator I = Map.find(Name);
|
||||||
if (I == Map.end())
|
if (I == Map.end())
|
||||||
return true;
|
return true;
|
||||||
Idx = I->getValue();
|
Idx = I->getValue();
|
||||||
@ -150,7 +150,7 @@ class ELFState {
|
|||||||
/// \brief The future ".shstrtab" section.
|
/// \brief The future ".shstrtab" section.
|
||||||
StringTableBuilder DotShStrtab;
|
StringTableBuilder DotShStrtab;
|
||||||
|
|
||||||
SectionNameToIdxMap SN2I;
|
NameToIdxMap SN2I;
|
||||||
const ELFYAML::Object &Doc;
|
const ELFYAML::Object &Doc;
|
||||||
|
|
||||||
bool buildSectionIndex();
|
bool buildSectionIndex();
|
||||||
@ -229,7 +229,7 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
|
|||||||
|
|
||||||
if (!Sec.Link.empty()) {
|
if (!Sec.Link.empty()) {
|
||||||
unsigned Index;
|
unsigned Index;
|
||||||
if (SN2I.lookupSection(Sec.Link, Index)) {
|
if (SN2I.lookup(Sec.Link, Index)) {
|
||||||
errs() << "error: Unknown section referenced: '" << Sec.Link
|
errs() << "error: Unknown section referenced: '" << Sec.Link
|
||||||
<< "' at YAML section '" << Sec.Name << "'.\n";
|
<< "' at YAML section '" << Sec.Name << "'.\n";
|
||||||
return false;;
|
return false;;
|
||||||
@ -295,7 +295,7 @@ void ELFState<ELFT>::addSymbols(const std::vector<ELFYAML::Symbol> &Symbols,
|
|||||||
Symbol.setBindingAndType(SymbolBinding, Sym.Type);
|
Symbol.setBindingAndType(SymbolBinding, Sym.Type);
|
||||||
if (!Sym.Section.empty()) {
|
if (!Sym.Section.empty()) {
|
||||||
unsigned Index;
|
unsigned Index;
|
||||||
if (SN2I.lookupSection(Sym.Section, Index)) {
|
if (SN2I.lookup(Sym.Section, Index)) {
|
||||||
errs() << "error: Unknown section referenced: '" << Sym.Section
|
errs() << "error: Unknown section referenced: '" << Sym.Section
|
||||||
<< "' by YAML symbol " << Sym.Name << ".\n";
|
<< "' by YAML symbol " << Sym.Name << ".\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Reference in New Issue
Block a user