aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/yaml2obj
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2019-06-27 11:08:42 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2019-06-27 11:08:42 +0000
commit687d47c2b0cebf17773def27291fcb8524f4313b (patch)
tree1500ea930d13892414e8728a27deb2b6b36c5944 /llvm/tools/yaml2obj
parent7eeeb5947ec0920460b2e32025c4cc8ccffc7719 (diff)
downloadllvm-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.cpp14
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>