This is an archive of the discontinued LLVM Phabricator instance.

Add ELFOSABI_FIRST_ARCH, ELFOSABI_LAST_ARCH and start using those in llvm-readobj
ClosedPublic

Authored by kzhuravl on Sep 29 2017, 12:12 PM.

Diff Detail

Event Timeline

kzhuravl created this revision.Sep 29 2017, 12:12 PM
kzhuravl updated this revision to Diff 117226.Sep 29 2017, 2:37 PM

Rebase on top of trunk

t-tye requested changes to this revision.Sep 29 2017, 3:57 PM
t-tye added inline comments.
include/llvm/BinaryFormat/ELF.h
356
// First architecture-specific OS ABI
357–360

Suggest group by architecture.

362
// Last architecture-specific OS ABI
tools/llvm-readobj/ELFDumper.cpp
3525

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);
This revision now requires changes to proceed.Sep 29 2017, 3:57 PM
kzhuravl updated this revision to Diff 117402.Oct 2 2017, 11:41 AM
kzhuravl edited edge metadata.
kzhuravl marked 4 inline comments as done.

Address review feedback.

This revision was automatically updated to reflect the committed changes.