diff options
author | George Rimar <grimar@accesssoftek.com> | 2018-08-16 12:23:22 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2018-08-16 12:23:22 +0000 |
commit | 7f2df7df4597772407307d44d8d02cc0f07e35c3 (patch) | |
tree | 844d4971a4c8fc7a00a26adb5abeb9ce698153f8 | |
parent | 560c7338159a8b78ef2e58b73389714c5b859347 (diff) | |
download | bcm5719-llvm-7f2df7df4597772407307d44d8d02cc0f07e35c3.tar.gz bcm5719-llvm-7f2df7df4597772407307d44d8d02cc0f07e35c3.zip |
[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.
llvm-svn: 339870
-rw-r--r-- | llvm/test/tools/yaml2obj/reloc-sec-info.yaml | 25 | ||||
-rw-r--r-- | llvm/tools/yaml2obj/yaml2elf.cpp | 10 |
2 files changed, 29 insertions, 6 deletions
diff --git a/llvm/test/tools/yaml2obj/reloc-sec-info.yaml b/llvm/test/tools/yaml2obj/reloc-sec-info.yaml new file mode 100644 index 00000000000..8810bd72afc --- /dev/null +++ b/llvm/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/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp index ec8cec151ed..99f55d11cff 100644 --- a/llvm/tools/yaml2obj/yaml2elf.cpp +++ b/llvm/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; |