diff options
author | George Rimar <grimar@accesssoftek.com> | 2019-06-27 11:08:42 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2019-06-27 11:08:42 +0000 |
commit | 687d47c2b0cebf17773def27291fcb8524f4313b (patch) | |
tree | 1500ea930d13892414e8728a27deb2b6b36c5944 /llvm/tools/yaml2obj | |
parent | 7eeeb5947ec0920460b2e32025c4cc8ccffc7719 (diff) | |
download | llvm-687d47c2b0cebf17773def27291fcb8524f4313b.zip llvm-687d47c2b0cebf17773def27291fcb8524f4313b.tar.gz llvm-687d47c2b0cebf17773def27291fcb8524f4313b.tar.bz2 |
[yaml2obj] - Allow overriding e_shentsize, e_shoff, e_shnum and e_shstrndx fields in the YAML.
This allows setting different values for e_shentsize, e_shoff, e_shnum
and e_shstrndx fields and is useful for producing broken inputs for various
test cases.
Differential revision: https://reviews.llvm.org/D63771
llvm-svn: 364517
Diffstat (limited to 'llvm/tools/yaml2obj')
-rw-r--r-- | llvm/tools/yaml2obj/yaml2elf.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp index f3f7800..e093ed8 100644 --- a/llvm/tools/yaml2obj/yaml2elf.cpp +++ b/llvm/tools/yaml2obj/yaml2elf.cpp @@ -208,12 +208,18 @@ void ELFState<ELFT>::initELFHeader(Elf_Ehdr &Header) { Header.e_ehsize = sizeof(Elf_Ehdr); Header.e_phentsize = sizeof(Elf_Phdr); Header.e_phnum = Doc.ProgramHeaders.size(); - Header.e_shentsize = sizeof(Elf_Shdr); + + Header.e_shentsize = + Doc.Header.SHEntSize ? (uint16_t)*Doc.Header.SHEntSize : sizeof(Elf_Shdr); // Immediately following the ELF header and program headers. Header.e_shoff = - sizeof(Header) + sizeof(Elf_Phdr) * Doc.ProgramHeaders.size(); - Header.e_shnum = SN2I.size() + 1; - Header.e_shstrndx = SN2I.get(".shstrtab"); + Doc.Header.SHOffset + ? (uint16_t)*Doc.Header.SHOffset + : sizeof(Header) + sizeof(Elf_Phdr) * Doc.ProgramHeaders.size(); + Header.e_shnum = + Doc.Header.SHNum ? (uint16_t)*Doc.Header.SHNum : SN2I.size() + 1; + Header.e_shstrndx = Doc.Header.SHStrNdx ? (uint16_t)*Doc.Header.SHStrNdx + : SN2I.get(".shstrtab"); } template <class ELFT> |