llvm.org GIT mirror llvm / ea94e11
[yaml2obj][ELF] Support ELFOSABI_* enum. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184268 91177308-0d34-0410-b5e6-96231b3b80d8 Sean Silva 7 years ago
4 changed file(s) with 46 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
3535 LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_EM)
3636 LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFCLASS)
3737 LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFDATA)
38 LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFOSABI)
3839 LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_SHT)
3940 // Just use 64, since it can hold 32-bit values too.
4041 LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_SHF)
4647 struct FileHeader {
4748 ELF_ELFCLASS Class;
4849 ELF_ELFDATA Data;
50 ELF_ELFOSABI OSABI;
4951 ELF_ET Type;
5052 ELF_EM Machine;
5153 llvm::yaml::Hex64 Entry;
101103 };
102104
103105 template <>
106 struct ScalarEnumerationTraits {
107 static void enumeration(IO &IO, ELFYAML::ELF_ELFOSABI &Value);
108 };
109
110 template <>
104111 struct ScalarEnumerationTraits {
105112 static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value);
106113 };
211211 #undef ECase
212212 }
213213
214 void ScalarEnumerationTraits::enumeration(
215 IO &IO, ELFYAML::ELF_ELFOSABI &Value) {
216 #define ECase(X) IO.enumCase(Value, #X, ELF::X);
217 ECase(ELFOSABI_NONE)
218 ECase(ELFOSABI_HPUX)
219 ECase(ELFOSABI_NETBSD)
220 ECase(ELFOSABI_GNU)
221 ECase(ELFOSABI_GNU)
222 ECase(ELFOSABI_HURD)
223 ECase(ELFOSABI_SOLARIS)
224 ECase(ELFOSABI_AIX)
225 ECase(ELFOSABI_IRIX)
226 ECase(ELFOSABI_FREEBSD)
227 ECase(ELFOSABI_TRU64)
228 ECase(ELFOSABI_MODESTO)
229 ECase(ELFOSABI_OPENBSD)
230 ECase(ELFOSABI_OPENVMS)
231 ECase(ELFOSABI_NSK)
232 ECase(ELFOSABI_AROS)
233 ECase(ELFOSABI_FENIXOS)
234 ECase(ELFOSABI_C6000_ELFABI)
235 ECase(ELFOSABI_C6000_LINUX)
236 ECase(ELFOSABI_ARM)
237 ECase(ELFOSABI_STANDALONE)
238 #undef ECase
239 }
240
214241 void ScalarEnumerationTraits::enumeration(
215242 IO &IO, ELFYAML::ELF_SHT &Value) {
216243 #define ECase(X) IO.enumCase(Value, #X, ELF::X);
277304 ELFYAML::FileHeader &FileHdr) {
278305 IO.mapRequired("Class", FileHdr.Class);
279306 IO.mapRequired("Data", FileHdr.Data);
307 IO.mapOptional("OSABI", FileHdr.OSABI, ELFYAML::ELF_ELFOSABI(0));
280308 IO.mapRequired("Type", FileHdr.Type);
281309 IO.mapRequired("Machine", FileHdr.Machine);
282310 IO.mapOptional("Entry", FileHdr.Entry, Hex64(0));
0 # RUN: yaml2obj -format=elf %s | llvm-readobj -file-headers - | FileCheck %s
1 !ELF
2 FileHeader:
3 Class: ELFCLASS64
4 Data: ELFDATA2LSB
5 OSABI: ELFOSABI_GNU
6 Type: ET_REL
7 Machine: EM_X86_64
8
9 # CHECK: OS/ABI: GNU/Linux
193193 bool IsLittleEndian = ELFT::TargetEndianness == support::little;
194194 Header.e_ident[EI_DATA] = IsLittleEndian ? ELFDATA2LSB : ELFDATA2MSB;
195195 Header.e_ident[EI_VERSION] = EV_CURRENT;
196 // TODO: Implement ELF_ELFOSABI enum.
197 Header.e_ident[EI_OSABI] = ELFOSABI_NONE;
196 Header.e_ident[EI_OSABI] = Hdr.OSABI;
198197 Header.e_ident[EI_ABIVERSION] = 0;
199198 Header.e_type = Hdr.Type;
200199 Header.e_machine = Hdr.Machine;