diff options
| author | George Rimar <grimar@accesssoftek.com> | 2019-03-07 12:09:19 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2019-03-07 12:09:19 +0000 |
| commit | a5a0a0f0493c981f568a9572c8adbb061dfcf829 (patch) | |
| tree | 04b0844c07b947fd380618292cba7fed5d47e8de | |
| parent | cfd32552513dbfdc88336659fc8c8e460d973cd2 (diff) | |
| download | bcm5719-llvm-a5a0a0f0493c981f568a9572c8adbb061dfcf829.tar.gz bcm5719-llvm-a5a0a0f0493c981f568a9572c8adbb061dfcf829.zip | |
[yaml2obj] - Allow producing ELFDATANONE ELFs
I need this to remove a binary from LLD test suite.
The patch also simplifies the code a bit.
Differential revision: https://reviews.llvm.org/D59082
llvm-svn: 355591
| -rw-r--r-- | llvm/lib/ObjectYAML/ELFYAML.cpp | 5 | ||||
| -rw-r--r-- | llvm/test/tools/yaml2obj/elf-header-elfdatanone.yaml | 15 | ||||
| -rw-r--r-- | llvm/tools/yaml2obj/yaml2elf.cpp | 3 |
3 files changed, 19 insertions, 4 deletions
diff --git a/llvm/lib/ObjectYAML/ELFYAML.cpp b/llvm/lib/ObjectYAML/ELFYAML.cpp index c374cc2a9e1..c8585bd3b1e 100644 --- a/llvm/lib/ObjectYAML/ELFYAML.cpp +++ b/llvm/lib/ObjectYAML/ELFYAML.cpp @@ -232,8 +232,9 @@ void ScalarEnumerationTraits<ELFYAML::ELF_ELFCLASS>::enumeration( void ScalarEnumerationTraits<ELFYAML::ELF_ELFDATA>::enumeration( IO &IO, ELFYAML::ELF_ELFDATA &Value) { #define ECase(X) IO.enumCase(Value, #X, ELF::X) - // Since the semantics of ELFDATANONE is "invalid", just don't accept it - // here. + // ELFDATANONE is an invalid data encoding, but we accept it because + // we want to be able to produce invalid binaries for the tests. + ECase(ELFDATANONE); ECase(ELFDATA2LSB); ECase(ELFDATA2MSB); #undef ECase diff --git a/llvm/test/tools/yaml2obj/elf-header-elfdatanone.yaml b/llvm/test/tools/yaml2obj/elf-header-elfdatanone.yaml new file mode 100644 index 00000000000..0e1d065ddcf --- /dev/null +++ b/llvm/test/tools/yaml2obj/elf-header-elfdatanone.yaml @@ -0,0 +1,15 @@ +## We have a YAML file describing an invalid data type. +## Check we are able to produce the invalid binary. + +# RUN: yaml2obj %s -o %t.o + +## Check that EI_DATA field is ELFDATANONE(0) +# RUN: od -b %t.o +5 | FileCheck %s +# CHECK: 0000005 000 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATANONE + Type: ET_REL + Machine: EM_X86_64 diff --git a/llvm/tools/yaml2obj/yaml2elf.cpp b/llvm/tools/yaml2obj/yaml2elf.cpp index 7b5841b5d3d..3e7234a4963 100644 --- a/llvm/tools/yaml2obj/yaml2elf.cpp +++ b/llvm/tools/yaml2obj/yaml2elf.cpp @@ -207,8 +207,7 @@ void ELFState<ELFT>::initELFHeader(Elf_Ehdr &Header) { Header.e_ident[EI_MAG2] = 'L'; Header.e_ident[EI_MAG3] = 'F'; Header.e_ident[EI_CLASS] = ELFT::Is64Bits ? ELFCLASS64 : ELFCLASS32; - bool IsLittleEndian = ELFT::TargetEndianness == support::little; - Header.e_ident[EI_DATA] = IsLittleEndian ? ELFDATA2LSB : ELFDATA2MSB; + Header.e_ident[EI_DATA] = Doc.Header.Data; Header.e_ident[EI_VERSION] = EV_CURRENT; Header.e_ident[EI_OSABI] = Doc.Header.OSABI; Header.e_ident[EI_ABIVERSION] = Doc.Header.ABIVersion; |

