From 326c193e0aa221c7836adfa16a3ec85857d7d8b7 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Fri, 21 Jun 2013 01:11:48 +0000 Subject: [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 --- tools/yaml2obj/yaml2elf.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'tools/yaml2obj') 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 &Symbols, ELFState &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); -- cgit v1.2.3