diff options
author | Sean Silva <silvas@purdue.edu> | 2013-06-10 23:44:15 +0000 |
---|---|---|
committer | Sean Silva <silvas@purdue.edu> | 2013-06-10 23:44:15 +0000 |
commit | 5918b7a03d4d6a52e18f7c102250c9cfd6ae52dd (patch) | |
tree | 0b504cae7496e7c519b6ac722286e70ffed66b3f /lib | |
parent | 9bdd78501484a1add2d8a757fd29960dd9fc9de7 (diff) | |
download | external_llvm-5918b7a03d4d6a52e18f7c102250c9cfd6ae52dd.zip external_llvm-5918b7a03d4d6a52e18f7c102250c9cfd6ae52dd.tar.gz external_llvm-5918b7a03d4d6a52e18f7c102250c9cfd6ae52dd.tar.bz2 |
[yaml2obj] Initial ELF support.
Currently, only emitting the ELF header is supported (no sections or
segments).
The ELFYAML code organization is broadly similar to the COFFYAML code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183711 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Object/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/Object/ELFYAML.cpp | 228 |
2 files changed, 229 insertions, 0 deletions
diff --git a/lib/Object/CMakeLists.txt b/lib/Object/CMakeLists.txt index e24f78a..cec0e28 100644 --- a/lib/Object/CMakeLists.txt +++ b/lib/Object/CMakeLists.txt @@ -4,6 +4,7 @@ add_llvm_library(LLVMObject COFFObjectFile.cpp COFFYAML.cpp ELFObjectFile.cpp + ELFYAML.cpp Error.cpp MachOObjectFile.cpp Object.cpp diff --git a/lib/Object/ELFYAML.cpp b/lib/Object/ELFYAML.cpp new file mode 100644 index 0000000..c4f3fc1 --- /dev/null +++ b/lib/Object/ELFYAML.cpp @@ -0,0 +1,228 @@ +//===- ELFYAML.cpp - ELF YAMLIO implementation ----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines classes for handling the YAML representation of ELF. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Object/ELFYAML.h" + +namespace llvm { +namespace yaml { + +void +ScalarEnumerationTraits<ELFYAML::ELF_ET>::enumeration(IO &IO, + ELFYAML::ELF_ET &Value) { +#define ECase(X) IO.enumCase(Value, #X, ELF::X); + ECase(ET_NONE) + ECase(ET_REL) + ECase(ET_EXEC) + ECase(ET_DYN) + ECase(ET_CORE) +#undef ECase +} + +void +ScalarEnumerationTraits<ELFYAML::ELF_EM>::enumeration(IO &IO, + ELFYAML::ELF_EM &Value) { +#define ECase(X) IO.enumCase(Value, #X, ELF::X); + ECase(EM_NONE) + ECase(EM_M32) + ECase(EM_SPARC) + ECase(EM_386) + ECase(EM_68K) + ECase(EM_88K) + ECase(EM_486) + ECase(EM_860) + ECase(EM_MIPS) + ECase(EM_S370) + ECase(EM_MIPS_RS3_LE) + ECase(EM_PARISC) + ECase(EM_VPP500) + ECase(EM_SPARC32PLUS) + ECase(EM_960) + ECase(EM_PPC) + ECase(EM_PPC64) + ECase(EM_S390) + ECase(EM_SPU) + ECase(EM_V800) + ECase(EM_FR20) + ECase(EM_RH32) + ECase(EM_RCE) + ECase(EM_ARM) + ECase(EM_ALPHA) + ECase(EM_SH) + ECase(EM_SPARCV9) + ECase(EM_TRICORE) + ECase(EM_ARC) + ECase(EM_H8_300) + ECase(EM_H8_300H) + ECase(EM_H8S) + ECase(EM_H8_500) + ECase(EM_IA_64) + ECase(EM_MIPS_X) + ECase(EM_COLDFIRE) + ECase(EM_68HC12) + ECase(EM_MMA) + ECase(EM_PCP) + ECase(EM_NCPU) + ECase(EM_NDR1) + ECase(EM_STARCORE) + ECase(EM_ME16) + ECase(EM_ST100) + ECase(EM_TINYJ) + ECase(EM_X86_64) + ECase(EM_PDSP) + ECase(EM_PDP10) + ECase(EM_PDP11) + ECase(EM_FX66) + ECase(EM_ST9PLUS) + ECase(EM_ST7) + ECase(EM_68HC16) + ECase(EM_68HC11) + ECase(EM_68HC08) + ECase(EM_68HC05) + ECase(EM_SVX) + ECase(EM_ST19) + ECase(EM_VAX) + ECase(EM_CRIS) + ECase(EM_JAVELIN) + ECase(EM_FIREPATH) + ECase(EM_ZSP) + ECase(EM_MMIX) + ECase(EM_HUANY) + ECase(EM_PRISM) + ECase(EM_AVR) + ECase(EM_FR30) + ECase(EM_D10V) + ECase(EM_D30V) + ECase(EM_V850) + ECase(EM_M32R) + ECase(EM_MN10300) + ECase(EM_MN10200) + ECase(EM_PJ) + ECase(EM_OPENRISC) + ECase(EM_ARC_COMPACT) + ECase(EM_XTENSA) + ECase(EM_VIDEOCORE) + ECase(EM_TMM_GPP) + ECase(EM_NS32K) + ECase(EM_TPC) + ECase(EM_SNP1K) + ECase(EM_ST200) + ECase(EM_IP2K) + ECase(EM_MAX) + ECase(EM_CR) + ECase(EM_F2MC16) + ECase(EM_MSP430) + ECase(EM_BLACKFIN) + ECase(EM_SE_C33) + ECase(EM_SEP) + ECase(EM_ARCA) + ECase(EM_UNICORE) + ECase(EM_EXCESS) + ECase(EM_DXP) + ECase(EM_ALTERA_NIOS2) + ECase(EM_CRX) + ECase(EM_XGATE) + ECase(EM_C166) + ECase(EM_M16C) + ECase(EM_DSPIC30F) + ECase(EM_CE) + ECase(EM_M32C) + ECase(EM_TSK3000) + ECase(EM_RS08) + ECase(EM_SHARC) + ECase(EM_ECOG2) + ECase(EM_SCORE7) + ECase(EM_DSP24) + ECase(EM_VIDEOCORE3) + ECase(EM_LATTICEMICO32) + ECase(EM_SE_C17) + ECase(EM_TI_C6000) + ECase(EM_TI_C2000) + ECase(EM_TI_C5500) + ECase(EM_MMDSP_PLUS) + ECase(EM_CYPRESS_M8C) + ECase(EM_R32C) + ECase(EM_TRIMEDIA) + ECase(EM_HEXAGON) + ECase(EM_8051) + ECase(EM_STXP7X) + ECase(EM_NDS32) + ECase(EM_ECOG1) + ECase(EM_ECOG1X) + ECase(EM_MAXQ30) + ECase(EM_XIMO16) + ECase(EM_MANIK) + ECase(EM_CRAYNV2) + ECase(EM_RX) + ECase(EM_METAG) + ECase(EM_MCST_ELBRUS) + ECase(EM_ECOG16) + ECase(EM_CR16) + ECase(EM_ETPU) + ECase(EM_SLE9X) + ECase(EM_L10M) + ECase(EM_K10M) + ECase(EM_AARCH64) + ECase(EM_AVR32) + ECase(EM_STM8) + ECase(EM_TILE64) + ECase(EM_TILEPRO) + ECase(EM_MICROBLAZE) + ECase(EM_CUDA) + ECase(EM_TILEGX) + ECase(EM_CLOUDSHIELD) + ECase(EM_COREA_1ST) + ECase(EM_COREA_2ND) + ECase(EM_ARC_COMPACT2) + ECase(EM_OPEN8) + ECase(EM_RL78) + ECase(EM_VIDEOCORE5) + ECase(EM_78KOR) + ECase(EM_56800EX) + ECase(EM_MBLAZE) +#undef ECase +} + +void ScalarEnumerationTraits<ELFYAML::ELF_ELFCLASS>::enumeration( + IO &IO, ELFYAML::ELF_ELFCLASS &Value) { +#define ECase(X) IO.enumCase(Value, #X, ELF::X); + // Since the semantics of ELFCLASSNONE is "invalid", just don't accept it + // here. + ECase(ELFCLASS32) + ECase(ELFCLASS64) +#undef ECase +} + +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. + ECase(ELFDATA2LSB) + ECase(ELFDATA2MSB) +#undef ECase +} + +void MappingTraits<ELFYAML::Header>::mapping(IO &IO, ELFYAML::Header &Header) { + IO.mapRequired("Class", Header.Class); + IO.mapRequired("Data", Header.Data); + IO.mapRequired("Type", Header.Type); + IO.mapRequired("Machine", Header.Machine); + IO.mapOptional("Entry", Header.Entry, Hex64(0)); +} + +void MappingTraits<ELFYAML::Object>::mapping(IO &IO, ELFYAML::Object &Object) { + IO.mapRequired("Header", Object.Header); +} + +} // end namespace yaml +} // end namespace llvm |