[yaml2obj][ELF] Allow expressing undefined symbols.

Previously we unconditionally enforced that section references in
symbols in the YAML had a name that was a section name present in the
object, and linked the references to that section. Now, permit empty
section names (already the default, if the `Section` key is not
provided) to indicate SHN_UNDEF.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184513 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sean Silva
2013-06-21 01:11:48 +00:00
parent 552d7cd31a
commit 326c193e0a
2 changed files with 13 additions and 7 deletions

View File

@@ -184,13 +184,15 @@ addSymbols(const std::vector<ELFYAML::Symbol> &Symbols, ELFState<ELFT> &State,
if (!Sym.Name.empty())
Symbol.st_name = State.getStringTable().addString(Sym.Name);
Symbol.setBindingAndType(SymbolBinding, Sym.Type);
unsigned Index;
if (State.getSN2I().lookupSection(Sym.Section, Index)) {
errs() << "error: Unknown section referenced: '" << Sym.Section
<< "' by YAML symbol " << Sym.Name << ".\n";
exit(1);
}
Symbol.st_shndx = Index;
if (!Sym.Section.empty()) {
unsigned Index;
if (State.getSN2I().lookupSection(Sym.Section, Index)) {
errs() << "error: Unknown section referenced: '" << Sym.Section
<< "' by YAML symbol " << Sym.Name << ".\n";
exit(1);
}
Symbol.st_shndx = Index;
} // else Symbol.st_shndex == SHN_UNDEF (== 0), since it was zero'd earlier.
Symbol.st_value = Sym.Value;
Symbol.st_size = Sym.Size;
Syms.push_back(Symbol);