[PATCH] D38418: Add ELFOSABI_FIRST_ARCH, ELFOSABI_LAST_ARCH and start using those in llvm-readobj
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 2 12:21:58 PDT 2017
It is not clear where ELFOSABI_STANDALONE came from. It is not in
http://www.sco.com/developers/gabi/latest/ch4.eheader.html
We should try to delete it, but that can be a followup patch.
This LGTM.
Thanks,
Rafael
Konstantin Zhuravlyov via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:
> kzhuravl updated this revision to Diff 117402.
> kzhuravl marked 4 inline comments as done.
> kzhuravl added a comment.
>
> Address review feedback.
>
>
> https://reviews.llvm.org/D38418
>
> Files:
> include/llvm/BinaryFormat/ELF.h
> tools/llvm-readobj/ELFDumper.cpp
>
>
> Index: tools/llvm-readobj/ELFDumper.cpp
> ===================================================================
> --- tools/llvm-readobj/ELFDumper.cpp
> +++ tools/llvm-readobj/ELFDumper.cpp
> @@ -821,12 +821,22 @@
> {"AROS", "AROS", ELF::ELFOSABI_AROS},
> {"FenixOS", "FenixOS", ELF::ELFOSABI_FENIXOS},
> {"CloudABI", "CloudABI", ELF::ELFOSABI_CLOUDABI},
> - {"C6000_ELFABI", "Bare-metal C6000", ELF::ELFOSABI_C6000_ELFABI},
> - {"C6000_LINUX", "Linux C6000", ELF::ELFOSABI_C6000_LINUX},
> - {"ARM", "ARM", ELF::ELFOSABI_ARM},
> {"Standalone", "Standalone App", ELF::ELFOSABI_STANDALONE}
> };
>
> +static const EnumEntry<unsigned> AMDGPUElfOSABI[] = {
> + {"AMDGPU_HSA", "AMDGPU - HSA", ELF::ELFOSABI_AMDGPU_HSA}
> +};
> +
> +static const EnumEntry<unsigned> ARMElfOSABI[] = {
> + {"ARM", "ARM", ELF::ELFOSABI_ARM}
> +};
> +
> +static const EnumEntry<unsigned> C6000ElfOSABI[] = {
> + {"C6000_ELFABI", "Bare-metal C6000", ELF::ELFOSABI_C6000_ELFABI},
> + {"C6000_LINUX", "Linux C6000", ELF::ELFOSABI_C6000_LINUX}
> +};
> +
> static const EnumEntry<unsigned> ElfMachineType[] = {
> ENUM_ENT(EM_NONE, "None"),
> ENUM_ENT(EM_M32, "WE32100"),
> @@ -3512,13 +3522,22 @@
> makeArrayRef(ElfDataEncoding));
> W.printNumber("FileVersion", e->e_ident[ELF::EI_VERSION]);
>
> - // Handle architecture specific OS/ABI values.
> - if (e->e_machine == ELF::EM_AMDGPU &&
> - e->e_ident[ELF::EI_OSABI] == ELF::ELFOSABI_AMDGPU_HSA)
> - W.printHex("OS/ABI", "AMDGPU_HSA", ELF::ELFOSABI_AMDGPU_HSA);
> - else
> - W.printEnum("OS/ABI", e->e_ident[ELF::EI_OSABI],
> - makeArrayRef(ElfOSABI));
> + auto OSABI = makeArrayRef(ElfOSABI);
> + if (e->e_ident[ELF::EI_OSABI] >= ELF::ELFOSABI_FIRST_ARCH &&
> + e->e_ident[ELF::EI_OSABI] <= ELF::ELFOSABI_LAST_ARCH) {
> + switch (e->e_machine) {
> + case ELF::EM_AMDGPU:
> + OSABI = makeArrayRef(AMDGPUElfOSABI);
> + break;
> + case ELF::EM_ARM:
> + OSABI = makeArrayRef(ARMElfOSABI);
> + break;
> + case ELF::EM_TI_C6000:
> + OSABI = makeArrayRef(C6000ElfOSABI);
> + break;
> + }
> + }
> + W.printEnum("OS/ABI", e->e_ident[ELF::EI_OSABI], OSABI);
> W.printNumber("ABIVersion", e->e_ident[ELF::EI_ABIVERSION]);
> W.printBinary("Unused", makeArrayRef(e->e_ident).slice(ELF::EI_PAD));
> }
> Index: include/llvm/BinaryFormat/ELF.h
> ===================================================================
> --- include/llvm/BinaryFormat/ELF.h
> +++ include/llvm/BinaryFormat/ELF.h
> @@ -353,11 +353,13 @@
> ELFOSABI_AROS = 15, // AROS
> ELFOSABI_FENIXOS = 16, // FenixOS
> ELFOSABI_CLOUDABI = 17, // Nuxi CloudABI
> - ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
> + ELFOSABI_FIRST_ARCH = 64, // First architecture-specific OS ABI
> ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime
> + ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
> ELFOSABI_C6000_LINUX = 65, // Linux TMS320C6000
> ELFOSABI_ARM = 97, // ARM
> - ELFOSABI_STANDALONE = 255 // Standalone (embedded) application
> + ELFOSABI_STANDALONE = 255, // Standalone (embedded) application
> + ELFOSABI_LAST_ARCH = 255 // Last Architecture-specific OS ABI
> };
>
> #define ELF_RELOC(name, value) name = value,
>
>
> Index: tools/llvm-readobj/ELFDumper.cpp
> ===================================================================
> --- tools/llvm-readobj/ELFDumper.cpp
> +++ tools/llvm-readobj/ELFDumper.cpp
> @@ -821,12 +821,22 @@
> {"AROS", "AROS", ELF::ELFOSABI_AROS},
> {"FenixOS", "FenixOS", ELF::ELFOSABI_FENIXOS},
> {"CloudABI", "CloudABI", ELF::ELFOSABI_CLOUDABI},
> - {"C6000_ELFABI", "Bare-metal C6000", ELF::ELFOSABI_C6000_ELFABI},
> - {"C6000_LINUX", "Linux C6000", ELF::ELFOSABI_C6000_LINUX},
> - {"ARM", "ARM", ELF::ELFOSABI_ARM},
> {"Standalone", "Standalone App", ELF::ELFOSABI_STANDALONE}
> };
>
> +static const EnumEntry<unsigned> AMDGPUElfOSABI[] = {
> + {"AMDGPU_HSA", "AMDGPU - HSA", ELF::ELFOSABI_AMDGPU_HSA}
> +};
> +
> +static const EnumEntry<unsigned> ARMElfOSABI[] = {
> + {"ARM", "ARM", ELF::ELFOSABI_ARM}
> +};
> +
> +static const EnumEntry<unsigned> C6000ElfOSABI[] = {
> + {"C6000_ELFABI", "Bare-metal C6000", ELF::ELFOSABI_C6000_ELFABI},
> + {"C6000_LINUX", "Linux C6000", ELF::ELFOSABI_C6000_LINUX}
> +};
> +
> static const EnumEntry<unsigned> ElfMachineType[] = {
> ENUM_ENT(EM_NONE, "None"),
> ENUM_ENT(EM_M32, "WE32100"),
> @@ -3512,13 +3522,22 @@
> makeArrayRef(ElfDataEncoding));
> W.printNumber("FileVersion", e->e_ident[ELF::EI_VERSION]);
>
> - // Handle architecture specific OS/ABI values.
> - if (e->e_machine == ELF::EM_AMDGPU &&
> - e->e_ident[ELF::EI_OSABI] == ELF::ELFOSABI_AMDGPU_HSA)
> - W.printHex("OS/ABI", "AMDGPU_HSA", ELF::ELFOSABI_AMDGPU_HSA);
> - else
> - W.printEnum("OS/ABI", e->e_ident[ELF::EI_OSABI],
> - makeArrayRef(ElfOSABI));
> + auto OSABI = makeArrayRef(ElfOSABI);
> + if (e->e_ident[ELF::EI_OSABI] >= ELF::ELFOSABI_FIRST_ARCH &&
> + e->e_ident[ELF::EI_OSABI] <= ELF::ELFOSABI_LAST_ARCH) {
> + switch (e->e_machine) {
> + case ELF::EM_AMDGPU:
> + OSABI = makeArrayRef(AMDGPUElfOSABI);
> + break;
> + case ELF::EM_ARM:
> + OSABI = makeArrayRef(ARMElfOSABI);
> + break;
> + case ELF::EM_TI_C6000:
> + OSABI = makeArrayRef(C6000ElfOSABI);
> + break;
> + }
> + }
> + W.printEnum("OS/ABI", e->e_ident[ELF::EI_OSABI], OSABI);
> W.printNumber("ABIVersion", e->e_ident[ELF::EI_ABIVERSION]);
> W.printBinary("Unused", makeArrayRef(e->e_ident).slice(ELF::EI_PAD));
> }
> Index: include/llvm/BinaryFormat/ELF.h
> ===================================================================
> --- include/llvm/BinaryFormat/ELF.h
> +++ include/llvm/BinaryFormat/ELF.h
> @@ -353,11 +353,13 @@
> ELFOSABI_AROS = 15, // AROS
> ELFOSABI_FENIXOS = 16, // FenixOS
> ELFOSABI_CLOUDABI = 17, // Nuxi CloudABI
> - ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
> + ELFOSABI_FIRST_ARCH = 64, // First architecture-specific OS ABI
> ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime
> + ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
> ELFOSABI_C6000_LINUX = 65, // Linux TMS320C6000
> ELFOSABI_ARM = 97, // ARM
> - ELFOSABI_STANDALONE = 255 // Standalone (embedded) application
> + ELFOSABI_STANDALONE = 255, // Standalone (embedded) application
> + ELFOSABI_LAST_ARCH = 255 // Last Architecture-specific OS ABI
> };
>
> #define ELF_RELOC(name, value) name = value,
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list