[PATCH] D38418: Add ELFOSABI_FIRST_ARCH, ELFOSABI_LAST_ARCH and start using those in llvm-readobj

Tony Tye via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 29 15:58:02 PDT 2017


t-tye requested changes to this revision.
t-tye added inline comments.
This revision now requires changes to proceed.


================
Comment at: include/llvm/BinaryFormat/ELF.h:356
   ELFOSABI_CLOUDABI = 17,     // Nuxi CloudABI
+  ELFOSABI_FIRST_ARCH = 64,   // First architecture-specific ABI
   ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
----------------
```
// First architecture-specific OS ABI
```


================
Comment at: include/llvm/BinaryFormat/ELF.h:357-360
   ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
   ELFOSABI_AMDGPU_HSA = 64,   // AMD HSA runtime
   ELFOSABI_C6000_LINUX = 65,  // Linux TMS320C6000
   ELFOSABI_ARM = 97,          // ARM
----------------
Suggest group by architecture.


================
Comment at: include/llvm/BinaryFormat/ELF.h:362
+  ELFOSABI_STANDALONE = 255,  // Standalone (embedded) application
+  ELFOSABI_LAST_ARCH = 255    // Last Architecture-specific ABI
 };
----------------
```
// Last architecture-specific OS ABI
```


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:3525
+                    makeArrayRef(AMDGPUElfOSABI));
       else
         W.printEnum("OS/ABI", e->e_ident[ELF::EI_OSABI],
----------------
Should the range checking also apply to the other architecture cases:

```
  ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
  ELFOSABI_C6000_LINUX = 65,  // Linux TMS320C6000
  ELFOSABI_ARM = 97,          // ARM
```

Not sure where ELFOSABI_STANDALONE belongs so maybe treat it as a non-architecture value even though it is in the range.

For example:

```
      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_ARM:
          OSABI = makeArrayRef(ARMElfOSABI);
          break;
        case ELF::EM_TI_C6000:
          OSABI = makeArrayRef(C6000ElfOSABI);
          break;
        case ELF::EM_AMDGPU:
          OSABI = makeArrayRef(AMDGPUElfOSABI);
          break;
        }
      }
      W.printEnum("OS/ABI", e->e_ident[ELF::EI_OSABI], OSABI);
```


https://reviews.llvm.org/D38418





More information about the llvm-commits mailing list