aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2018-08-16 12:23:22 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2018-08-16 12:23:22 +0000
commitd9d671112daf6f955d52e35f5b0e4ccff1242030 (patch)
treeade4c4dc816ee4e140c282bafb8fcedcd342d93f
parentfd2bee90f5b74bad4d2de3f11bb7aa1160dcc21c (diff)
[yaml2elf] - Simplify code, add a test. NFC.
This simplifies the code allowing to set the sh_info for relocations sections. And adds a missing test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339870 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/tools/yaml2obj/reloc-sec-info.yaml25
-rw-r--r--tools/yaml2obj/yaml2elf.cpp10
2 files changed, 29 insertions, 6 deletions
diff --git a/test/tools/yaml2obj/reloc-sec-info.yaml b/test/tools/yaml2obj/reloc-sec-info.yaml
new file mode 100644
index 00000000000..8810bd72afc
--- /dev/null
+++ b/test/tools/yaml2obj/reloc-sec-info.yaml
@@ -0,0 +1,25 @@
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj -sections %t | FileCheck %s
+
+# CHECK: Name: .rela.text
+# CHECK: Type: SHT_RELA
+# CHECK: Flags [
+# CHECK: ]
+# CHECK: Address:
+# CHECK: Offset:
+# CHECK: Size:
+# CHECK: Link:
+# CHECK: Info: 12345
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .rela.text
+ Type: SHT_RELA
+ Link: .symtab
+ Info: 12345
+ Relocations:
diff --git a/tools/yaml2obj/yaml2elf.cpp b/tools/yaml2obj/yaml2elf.cpp
index ec8cec151ed..99f55d11cff 100644
--- a/tools/yaml2obj/yaml2elf.cpp
+++ b/tools/yaml2obj/yaml2elf.cpp
@@ -261,12 +261,10 @@ bool ELFState<ELFT>::initSectionHeaders(std::vector<Elf_Shdr> &SHeaders,
SHeader.sh_link = getDotSymTabSecNo();
unsigned Index;
- if (SN2I.lookup(S->Info, Index)) {
- if (S->Info.getAsInteger(0, Index)) {
- WithColor::error() << "Unknown section referenced: '" << S->Info
- << "' at YAML section '" << S->Name << "'.\n";
- return false;
- }
+ if (SN2I.lookup(S->Info, Index) && !to_integer(S->Info, Index)) {
+ WithColor::error() << "Unknown section referenced: '" << S->Info
+ << "' at YAML section '" << S->Name << "'.\n";
+ return false;
}
SHeader.sh_info = Index;