[llvm] r205173 - [yaml2obj] Add support for ELF e_flags.
Sean Silva
silvas at purdue.edu
Mon Mar 31 10:37:33 PDT 2014
Thanks for giving yaml2elf some love!
On Mon, Mar 31, 2014 at 5:44 AM, Daniel Sanders
<daniel.sanders at imgtec.com>wrote:
> Author: dsanders
> Date: Mon Mar 31 04:44:05 2014
> New Revision: 205173
>
> URL: http://llvm.org/viewvc/llvm-project?rev=205173&view=rev
> Log:
> [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
>
> Added:
> llvm/trunk/test/Object/yaml2obj-elf-file-headers-with-e_flags.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=205173&r1=205172&r2=205173&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Object/ELFYAML.h (original)
> +++ llvm/trunk/include/llvm/Object/ELFYAML.h Mon Mar 31 04:44:05 2014
> @@ -37,6 +37,8 @@ LLVM_YAML_STRONG_TYPEDEF(uint32_t, ELF_E
> LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFCLASS)
> LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFDATA)
> LLVM_YAML_STRONG_TYPEDEF(uint8_t, ELF_ELFOSABI)
> +// Just use 64, since it can hold 32-bit values too.
> +LLVM_YAML_STRONG_TYPEDEF(uint64_t, ELF_EF)
> 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)
> @@ -50,6 +52,7 @@ struct FileHeader {
> ELF_ELFOSABI OSABI;
> ELF_ET Type;
> ELF_EM Machine;
> + ELF_EF Flags;
> llvm::yaml::Hex64 Entry;
> };
> struct Symbol {
> @@ -118,6 +121,11 @@ struct ScalarEnumerationTraits<ELFYAML::
> };
>
> template <>
> +struct ScalarBitSetTraits<ELFYAML::ELF_EF> {
> + static void bitset(IO &IO, ELFYAML::ELF_EF &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=205173&r1=205172&r2=205173&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Object/ELFYAML.cpp (original)
> +++ llvm/trunk/lib/Object/ELFYAML.cpp Mon Mar 31 04:44:05 2014
> @@ -237,6 +237,48 @@ void ScalarEnumerationTraits<ELFYAML::EL
> #undef ECase
> }
>
> +void ScalarBitSetTraits<ELFYAML::ELF_EF>::bitset(IO &IO,
> + ELFYAML::ELF_EF &Value) {
> +#define BCase(X) IO.bitSetCase(Value, #X, ELF::X);
> + BCase(EF_ARM_SOFT_FLOAT)
> + BCase(EF_ARM_VFP_FLOAT)
> + BCase(EF_ARM_EABI_UNKNOWN)
> + BCase(EF_ARM_EABI_VER1)
> + BCase(EF_ARM_EABI_VER2)
> + BCase(EF_ARM_EABI_VER3)
> + BCase(EF_ARM_EABI_VER4)
> + BCase(EF_ARM_EABI_VER5)
> + BCase(EF_ARM_EABIMASK)
> + BCase(EF_MIPS_NOREORDER)
> + BCase(EF_MIPS_PIC)
> + BCase(EF_MIPS_CPIC)
> + BCase(EF_MIPS_ABI2)
> + BCase(EF_MIPS_32BITMODE)
> + BCase(EF_MIPS_ABI_O32)
> + BCase(EF_MIPS_MICROMIPS)
> + BCase(EF_MIPS_ARCH_ASE_M16)
> + BCase(EF_MIPS_ARCH_1)
> + BCase(EF_MIPS_ARCH_2)
> + BCase(EF_MIPS_ARCH_3)
> + BCase(EF_MIPS_ARCH_4)
> + BCase(EF_MIPS_ARCH_5)
> + BCase(EF_MIPS_ARCH_32)
> + BCase(EF_MIPS_ARCH_64)
> + BCase(EF_MIPS_ARCH_32R2)
> + BCase(EF_MIPS_ARCH_64R2)
> + BCase(EF_MIPS_ARCH)
> + BCase(EF_HEXAGON_MACH_V2)
> + BCase(EF_HEXAGON_MACH_V3)
> + BCase(EF_HEXAGON_MACH_V4)
> + BCase(EF_HEXAGON_MACH_V5)
> + BCase(EF_HEXAGON_ISA_MACH)
> + BCase(EF_HEXAGON_ISA_V2)
> + BCase(EF_HEXAGON_ISA_V3)
> + BCase(EF_HEXAGON_ISA_V4)
> + BCase(EF_HEXAGON_ISA_V5)
> +#undef BCase
> +}
> +
> void ScalarEnumerationTraits<ELFYAML::ELF_SHT>::enumeration(
> IO &IO, ELFYAML::ELF_SHT &Value) {
> #define ECase(X) IO.enumCase(Value, #X, ELF::X);
> @@ -299,6 +341,7 @@ void MappingTraits<ELFYAML::FileHeader>:
> IO.mapOptional("OSABI", FileHdr.OSABI, ELFYAML::ELF_ELFOSABI(0));
> IO.mapRequired("Type", FileHdr.Type);
> IO.mapRequired("Machine", FileHdr.Machine);
> + IO.mapOptional("Flags", FileHdr.Flags, ELFYAML::ELF_EF(0));
> IO.mapOptional("Entry", FileHdr.Entry, Hex64(0));
> }
>
>
> Added: llvm/trunk/test/Object/yaml2obj-elf-file-headers-with-e_flags.yaml
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/yaml2obj-elf-file-headers-with-e_flags.yaml?rev=205173&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/Object/yaml2obj-elf-file-headers-with-e_flags.yaml
> (added)
> +++ llvm/trunk/test/Object/yaml2obj-elf-file-headers-with-e_flags.yaml Mon
> Mar 31 04:44:05 2014
> @@ -0,0 +1,16 @@
> +# RUN: yaml2obj -format=elf %s | llvm-readobj -file-headers - | FileCheck
> %s
> +!ELF
> +FileHeader:
> + Class: ELFCLASS32
> + Data: ELFDATA2LSB
> + Type: ET_REL
> + Machine: EM_MIPS
> + Flags: [ EF_MIPS_NOREORDER, EF_MIPS_ABI_O32 ]
> +
> +# CHECK: Format: ELF32-mips
> +# CHECK: Arch: mipsel
> +# CHECK: Machine: EM_MIPS
> +# CHECK: Flags [ (0x1001)
> +# CHECK-NEXT: 0x1
> +# CHECK-NEXT: 0x1000
> +# CHECK-NEXT: ]
>
> Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=205173&r1=205172&r2=205173&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
> +++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Mon Mar 31 04:44:05 2014
> @@ -261,6 +261,7 @@ static int writeELF(raw_ostream &OS, con
> Header.e_machine = Hdr.Machine;
> Header.e_version = EV_CURRENT;
> Header.e_entry = Hdr.Entry;
> + Header.e_flags = Hdr.Flags;
> Header.e_ehsize = sizeof(Elf_Ehdr);
>
> // TODO: Flesh out section header support.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140331/09a62a1a/attachment.html>
More information about the llvm-commits
mailing list