[PATCH] D62596: [AARCH64][ELF][llvm-readobj] Add support for BTI and PAC dynamic tags

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 31 01:10:29 PDT 2019


grimar added inline comments.


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:1842
+    }
+  }
+
----------------
I'd suggest to make the code more explicit and isolated from the switch below:


```
  switch (ObjF->getELFFile()->getHeader()->e_machine) {
  case EM_AARCH64:
    switch (Type) {
    case DT_AARCH64_BTI_PLT:
    case DT_AARCH64_PAC_PLT:
      OS << Value;
      return;
    default:
      break;
    }
  case EM_HEXAGON:
    switch (Type) {
    case DT_HEXAGON_VER:
      OS << Value;
      return;
    case DT_HEXAGON_SYMSZ:
    case DT_HEXAGON_PLT:
      OS << format(ConvChar, Value);
      return;
    default:
      break;
    }
  case EM_MIPS:
    switch (Type) {
    case DT_MIPS_RLD_VERSION:
    case DT_MIPS_LOCAL_GOTNO:
    case DT_MIPS_SYMTABNO:
    case DT_MIPS_UNREFEXTNO:
      <place missing mips tags here>
      OS << Value;
      return;
    case DT_MIPS_FLAGS:
      <and here (and seems one more case is also needed)>
      printFlags(Value, makeArrayRef(ElfDynamicDTMipsFlags), OS);
      return;
    default:
      break;
    }
  default:
    break;
  }
```

I.e. idea is that we try to handle target specific flags first and either return or fall back to the switch for
common tags below if flag was not handled.
No need to do checks like `Type >= DT_LOPROC && Type < DT_AUXILIARY` or have any printing logic in `default:` case I think.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62596/new/

https://reviews.llvm.org/D62596





More information about the llvm-commits mailing list