[llvm] r184268 - [yaml2obj][ELF] Support ELFOSABI_* enum.
Sean Silva
silvas at purdue.edu
Tue Jun 18 17:55:29 PDT 2013
Author: silvas
Date: Tue Jun 18 19:55:28 2013
New Revision: 184268
URL: http://llvm.org/viewvc/llvm-project?rev=184268&view=rev
Log:
[yaml2obj][ELF] Support ELFOSABI_* enum.
Added:
llvm/trunk/test/Object/yaml2obj-elf-file-headers.yaml
Modified:
llvm/trunk/include/llvm/Object/ELFYAML.h
llvm/trunk/lib/Object/ELFYAML.cpp
llvm/trunk/tools/yaml2obj/yaml2elf.cpp
Modified: llvm/trunk/include/llvm/Object/ELFYAML.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFYAML.h?rev=184268&r1=184267&r2=184268&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFYAML.h (original)
+++ llvm/trunk/include/llvm/Object/ELFYAML.h Tue Jun 18 19:55:28 2013
@@ -36,6 +36,7 @@ LLVM_YAML_STRONG_TYPEDEF(uint16_t, ELF_E
LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_EM)
LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFCLASS)
LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFDATA)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFOSABI)
LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_SHT)
// Just use 64, since it can hold 32-bit values too.
LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_SHF)
@@ -47,6 +48,7 @@ LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ST
struct FileHeader {
ELF_ELFCLASS Class;
ELF_ELFDATA Data;
+ ELF_ELFOSABI OSABI;
ELF_ET Type;
ELF_EM Machine;
llvm::yaml::Hex64 Entry;
@@ -102,6 +104,11 @@ struct ScalarEnumerationTraits<ELFYAML::
};
template <>
+struct ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI> {
+ static void enumeration(IO &IO, ELFYAML::ELF_ELFOSABI &Value);
+};
+
+template <>
struct ScalarEnumerationTraits<ELFYAML::ELF_SHT> {
static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value);
};
Modified: llvm/trunk/lib/Object/ELFYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFYAML.cpp?rev=184268&r1=184267&r2=184268&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ELFYAML.cpp (original)
+++ llvm/trunk/lib/Object/ELFYAML.cpp Tue Jun 18 19:55:28 2013
@@ -212,6 +212,33 @@ void ScalarEnumerationTraits<ELFYAML::EL
#undef ECase
}
+void ScalarEnumerationTraits<ELFYAML::ELF_ELFOSABI>::enumeration(
+ IO &IO, ELFYAML::ELF_ELFOSABI &Value) {
+#define ECase(X) IO.enumCase(Value, #X, ELF::X);
+ ECase(ELFOSABI_NONE)
+ ECase(ELFOSABI_HPUX)
+ ECase(ELFOSABI_NETBSD)
+ ECase(ELFOSABI_GNU)
+ ECase(ELFOSABI_GNU)
+ ECase(ELFOSABI_HURD)
+ ECase(ELFOSABI_SOLARIS)
+ ECase(ELFOSABI_AIX)
+ ECase(ELFOSABI_IRIX)
+ ECase(ELFOSABI_FREEBSD)
+ ECase(ELFOSABI_TRU64)
+ ECase(ELFOSABI_MODESTO)
+ ECase(ELFOSABI_OPENBSD)
+ ECase(ELFOSABI_OPENVMS)
+ ECase(ELFOSABI_NSK)
+ ECase(ELFOSABI_AROS)
+ ECase(ELFOSABI_FENIXOS)
+ ECase(ELFOSABI_C6000_ELFABI)
+ ECase(ELFOSABI_C6000_LINUX)
+ ECase(ELFOSABI_ARM)
+ ECase(ELFOSABI_STANDALONE)
+#undef ECase
+}
+
void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
IO &IO, ELFYAML::ELF_SHT &Value) {
#define ECase(X) IO.enumCase(Value, #X, ELF::X);
@@ -278,6 +305,7 @@ void MappingTraits<ELFYAML::FileHeader>:
ELFYAML::FileHeader &FileHdr) {
IO.mapRequired("Class", FileHdr.Class);
IO.mapRequired("Data", FileHdr.Data);
+ IO.mapOptional("OSABI", FileHdr.OSABI, ELFYAML::ELF_ELFOSABI(0));
IO.mapRequired("Type", FileHdr.Type);
IO.mapRequired("Machine", FileHdr.Machine);
IO.mapOptional("Entry", FileHdr.Entry, Hex64(0));
Added: llvm/trunk/test/Object/yaml2obj-elf-file-headers.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/yaml2obj-elf-file-headers.yaml?rev=184268&view=auto
==============================================================================
--- llvm/trunk/test/Object/yaml2obj-elf-file-headers.yaml (added)
+++ llvm/trunk/test/Object/yaml2obj-elf-file-headers.yaml Tue Jun 18 19:55:28 2013
@@ -0,0 +1,10 @@
+# RUN: yaml2obj -format=elf %s | llvm-readobj -file-headers - | FileCheck %s
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_GNU
+ Type: ET_REL
+ Machine: EM_X86_64
+
+# CHECK: OS/ABI: GNU/Linux
Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=184268&r1=184267&r2=184268&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Tue Jun 18 19:55:28 2013
@@ -194,8 +194,7 @@ static int writeELF(raw_ostream &OS, con
bool IsLittleEndian = ELFT::TargetEndianness == support::little;
Header.e_ident[EI_DATA] = IsLittleEndian ? ELFDATA2LSB : ELFDATA2MSB;
Header.e_ident[EI_VERSION] = EV_CURRENT;
- // TODO: Implement ELF_ELFOSABI enum.
- Header.e_ident[EI_OSABI] = ELFOSABI_NONE;
+ Header.e_ident[EI_OSABI] = Hdr.OSABI;
Header.e_ident[EI_ABIVERSION] = 0;
Header.e_type = Hdr.Type;
Header.e_machine = Hdr.Machine;
More information about the llvm-commits
mailing list