summaryrefslogtreecommitdiff
path: root/tools/yaml2obj/yaml2elf.cpp
diff options
context:
space:
mode:
authorSean Silva <silvas@purdue.edu>2013-06-21 01:11:48 +0000
committerSean Silva <silvas@purdue.edu>2013-06-21 01:11:48 +0000
commit326c193e0aa221c7836adfa16a3ec85857d7d8b7 (patch)
tree37850acc56eaa7426c17c9fc2264c7e3e89b6c49 /tools/yaml2obj/yaml2elf.cpp
parent552d7cd31a0f6eb0e1434981196f477ae741a184 (diff)
downloadllvm-326c193e0aa221c7836adfa16a3ec85857d7d8b7.tar.gz
llvm-326c193e0aa221c7836adfa16a3ec85857d7d8b7.tar.bz2
llvm-326c193e0aa221c7836adfa16a3ec85857d7d8b7.tar.xz
[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
Diffstat (limited to 'tools/yaml2obj/yaml2elf.cpp')
-rw-r--r--tools/yaml2obj/yaml2elf.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp
index f9bc566f73..ac6b330e66 100644
--- a/tools/yaml2obj/yaml2elf.cpp
+++ b/tools/yaml2obj/yaml2elf.cpp
@@ -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);