llvm.org GIT mirror llvm / 002ba57
[yaml2obj] Add support for ELF e_flags. Summary: The FileHeader mapping now accepts an optional Flags sequence that accepts the EF_<arch>_<flag> constants. When not given, Flags defaults to zero. Reviewers: atanasyan Reviewed By: atanasyan CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D3213 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205173 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 5 years ago
4 changed file(s) with 68 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
3636 LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFCLASS)
3737 LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFDATA)
3838 LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFOSABI)
39 // Just use 64, since it can hold 32-bit values too.
40 LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_EF)
3941 LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_SHT)
4042 // Just use 64, since it can hold 32-bit values too.
4143 LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_SHF)
4951 ELF_ELFOSABI OSABI;
5052 ELF_ET Type;
5153 ELF_EM Machine;
54 ELF_EF Flags;
5255 llvm::yaml::Hex64 Entry;
5356 };
5457 struct Symbol {
117120 };
118121
119122 template <>
123 struct ScalarBitSetTraits {
124 static void bitset(IO &IO, ELFYAML::ELF_EF &Value);
125 };
126
127 template <>
120128 struct ScalarEnumerationTraits {
121129 static void enumeration(IO &IO, ELFYAML::ELF_SHT &Value);
122130 };
236236 #undef ECase
237237 }
238238
239 void ScalarBitSetTraits::bitset(IO &IO,
240 ELFYAML::ELF_EF &Value) {
241 #define BCase(X) IO.bitSetCase(Value, #X, ELF::X);
242 BCase(EF_ARM_SOFT_FLOAT)
243 BCase(EF_ARM_VFP_FLOAT)
244 BCase(EF_ARM_EABI_UNKNOWN)
245 BCase(EF_ARM_EABI_VER1)
246 BCase(EF_ARM_EABI_VER2)
247 BCase(EF_ARM_EABI_VER3)
248 BCase(EF_ARM_EABI_VER4)
249 BCase(EF_ARM_EABI_VER5)
250 BCase(EF_ARM_EABIMASK)
251 BCase(EF_MIPS_NOREORDER)
252 BCase(EF_MIPS_PIC)
253 BCase(EF_MIPS_CPIC)
254 BCase(EF_MIPS_ABI2)
255 BCase(EF_MIPS_32BITMODE)
256 BCase(EF_MIPS_ABI_O32)
257 BCase(EF_MIPS_MICROMIPS)
258 BCase(EF_MIPS_ARCH_ASE_M16)
259 BCase(EF_MIPS_ARCH_1)
260 BCase(EF_MIPS_ARCH_2)
261 BCase(EF_MIPS_ARCH_3)
262 BCase(EF_MIPS_ARCH_4)
263 BCase(EF_MIPS_ARCH_5)
264 BCase(EF_MIPS_ARCH_32)
265 BCase(EF_MIPS_ARCH_64)
266 BCase(EF_MIPS_ARCH_32R2)
267 BCase(EF_MIPS_ARCH_64R2)
268 BCase(EF_MIPS_ARCH)
269 BCase(EF_HEXAGON_MACH_V2)
270 BCase(EF_HEXAGON_MACH_V3)
271 BCase(EF_HEXAGON_MACH_V4)
272 BCase(EF_HEXAGON_MACH_V5)
273 BCase(EF_HEXAGON_ISA_MACH)
274 BCase(EF_HEXAGON_ISA_V2)
275 BCase(EF_HEXAGON_ISA_V3)
276 BCase(EF_HEXAGON_ISA_V4)
277 BCase(EF_HEXAGON_ISA_V5)
278 #undef BCase
279 }
280
239281 void ScalarEnumerationTraits::enumeration(
240282 IO &IO, ELFYAML::ELF_SHT &Value) {
241283 #define ECase(X) IO.enumCase(Value, #X, ELF::X);
298340 IO.mapOptional("OSABI", FileHdr.OSABI, ELFYAML::ELF_ELFOSABI(0));
299341 IO.mapRequired("Type", FileHdr.Type);
300342 IO.mapRequired("Machine", FileHdr.Machine);
343 IO.mapOptional("Flags", FileHdr.Flags, ELFYAML::ELF_EF(0));
301344 IO.mapOptional("Entry", FileHdr.Entry, Hex64(0));
302345 }
303346
0 # RUN: yaml2obj -format=elf %s | llvm-readobj -file-headers - | FileCheck %s
1 !ELF
2 FileHeader:
3 Class: ELFCLASS32
4 Data: ELFDATA2LSB
5 Type: ET_REL
6 Machine: EM_MIPS
7 Flags: [ EF_MIPS_NOREORDER, EF_MIPS_ABI_O32 ]
8
9 # CHECK: Format: ELF32-mips
10 # CHECK: Arch: mipsel
11 # CHECK: Machine: EM_MIPS
12 # CHECK: Flags [ (0x1001)
13 # CHECK-NEXT: 0x1
14 # CHECK-NEXT: 0x1000
15 # CHECK-NEXT: ]
260260 Header.e_machine = Hdr.Machine;
261261 Header.e_version = EV_CURRENT;
262262 Header.e_entry = Hdr.Entry;
263 Header.e_flags = Hdr.Flags;
263264 Header.e_ehsize = sizeof(Elf_Ehdr);
264265
265266 // TODO: Flesh out section header support.