llvm.org GIT mirror llvm / dba0a79
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355591 91177308-0d34-0410-b5e6-96231b3b80d8 George Rimar 7 months ago
3 changed file(s) with 19 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
231231 void ScalarEnumerationTraits::enumeration(
232232 IO &IO, ELFYAML::ELF_ELFDATA &Value) {
233233 #define ECase(X) IO.enumCase(Value, #X, ELF::X)
234 // Since the semantics of ELFDATANONE is "invalid", just don't accept it
235 // here.
234 // ELFDATANONE is an invalid data encoding, but we accept it because
235 // we want to be able to produce invalid binaries for the tests.
236 ECase(ELFDATANONE);
236237 ECase(ELFDATA2LSB);
237238 ECase(ELFDATA2MSB);
238239 #undef ECase
0 ## We have a YAML file describing an invalid data type.
1 ## Check we are able to produce the invalid binary.
2
3 # RUN: yaml2obj %s -o %t.o
4
5 ## Check that EI_DATA field is ELFDATANONE(0)
6 # RUN: od -b %t.o +5 | FileCheck %s
7 # CHECK: 0000005 000
8
9 --- !ELF
10 FileHeader:
11 Class: ELFCLASS64
12 Data: ELFDATANONE
13 Type: ET_REL
14 Machine: EM_X86_64
206206 Header.e_ident[EI_MAG2] = 'L';
207207 Header.e_ident[EI_MAG3] = 'F';
208208 Header.e_ident[EI_CLASS] = ELFT::Is64Bits ? ELFCLASS64 : ELFCLASS32;
209 bool IsLittleEndian = ELFT::TargetEndianness == support::little;
210 Header.e_ident[EI_DATA] = IsLittleEndian ? ELFDATA2LSB : ELFDATA2MSB;
209 Header.e_ident[EI_DATA] = Doc.Header.Data;
211210 Header.e_ident[EI_VERSION] = EV_CURRENT;
212211 Header.e_ident[EI_OSABI] = Doc.Header.OSABI;
213212 Header.e_ident[EI_ABIVERSION] = Doc.Header.ABIVersion;