[PATCH] D59082: [yaml2obj] - Allow producing ELFDATANONE ELFs
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 7 04:10:35 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa5a0a0f0493c: [yaml2obj] - Allow producing ELFDATANONE ELFs (authored by grimar).
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D59082?vs=189687&id=189690#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59082/new/
https://reviews.llvm.org/D59082
Files:
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/test/tools/yaml2obj/elf-header-elfdatanone.yaml
llvm/tools/yaml2obj/yaml2elf.cpp
Index: llvm/tools/yaml2obj/yaml2elf.cpp
===================================================================
--- llvm/tools/yaml2obj/yaml2elf.cpp
+++ llvm/tools/yaml2obj/yaml2elf.cpp
@@ -207,8 +207,7 @@
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;
Index: llvm/test/tools/yaml2obj/elf-header-elfdatanone.yaml
===================================================================
--- /dev/null
+++ 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
Index: llvm/lib/ObjectYAML/ELFYAML.cpp
===================================================================
--- llvm/lib/ObjectYAML/ELFYAML.cpp
+++ llvm/lib/ObjectYAML/ELFYAML.cpp
@@ -232,8 +232,9 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59082.189690.patch
Type: text/x-patch
Size: 1959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190307/6b36a61c/attachment.bin>
More information about the llvm-commits
mailing list