[llvm] r184513 - [yaml2obj][ELF] Allow expressing undefined symbols.
Sean Silva
silvas at purdue.edu
Thu Jun 20 18:11:49 PDT 2013
Author: silvas
Date: Thu Jun 20 20:11:48 2013
New Revision: 184513
URL: http://llvm.org/viewvc/llvm-project?rev=184513&view=rev
Log:
[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.
Modified:
llvm/trunk/test/Object/yaml2obj-elf-symbol-basic.yaml
llvm/trunk/tools/yaml2obj/yaml2elf.cpp
Modified: llvm/trunk/test/Object/yaml2obj-elf-symbol-basic.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/yaml2obj-elf-symbol-basic.yaml?rev=184513&r1=184512&r2=184513&view=diff
==============================================================================
--- llvm/trunk/test/Object/yaml2obj-elf-symbol-basic.yaml (original)
+++ llvm/trunk/test/Object/yaml2obj-elf-symbol-basic.yaml Thu Jun 20 20:11:48 2013
@@ -26,6 +26,7 @@ Sections:
Section: .text
Value: 0x1
Size: 2
+ - Name: undefined_symbol
# CHECK: Symbols [
# CHECK-NEXT: Symbol {
@@ -37,6 +38,9 @@ Sections:
# CHECK: Binding: Global
# CHECK-NEXT: Type: Function
# CHECK: Section: .text
+# CHECK: Symbol {
+# CHECK: Name: undefined_symbol
+# CHECK: Section: (0x0)
# DISASSEMBLY: Disassembly of section .text:
# DISASSEMBLY-NEXT: main:
Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=184513&r1=184512&r2=184513&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Thu Jun 20 20:11:48 2013
@@ -184,13 +184,15 @@ addSymbols(const std::vector<ELFYAML::Sy
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);
More information about the llvm-commits
mailing list