[llvm] r339870 - [yaml2elf] - Simplify code, add a test. NFC.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 16 05:23:23 PDT 2018
Author: grimar
Date: Thu Aug 16 05:23:22 2018
New Revision: 339870
URL: http://llvm.org/viewvc/llvm-project?rev=339870&view=rev
Log:
[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.
Added:
llvm/trunk/test/tools/yaml2obj/reloc-sec-info.yaml
Modified:
llvm/trunk/tools/yaml2obj/yaml2elf.cpp
Added: llvm/trunk/test/tools/yaml2obj/reloc-sec-info.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/reloc-sec-info.yaml?rev=339870&view=auto
==============================================================================
--- llvm/trunk/test/tools/yaml2obj/reloc-sec-info.yaml (added)
+++ llvm/trunk/test/tools/yaml2obj/reloc-sec-info.yaml Thu Aug 16 05:23:22 2018
@@ -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:
Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=339870&r1=339869&r2=339870&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Thu Aug 16 05:23:22 2018
@@ -261,12 +261,10 @@ bool ELFState<ELFT>::initSectionHeaders(
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;
More information about the llvm-commits
mailing list