[PATCH] D93044: [llvm-readobj/elf] - AArch64: Handle AARCH64_VARIANT_PCS for GNUStyle

Adhemerval Zanella via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 10 08:36:50 PST 2020


zatrazz created this revision.
zatrazz added reviewers: jhenderson, MaskRay, rupprecht.
Herald added subscribers: danielkiss, kristof.beyls.
zatrazz requested review of this revision.
Herald added a project: LLVM.

It mimics the GNU readelf where it prints a [VARIANT_PCS] for symbols
with st_other with STO_AARCH64_VARIANT_PCS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93044

Files:
  llvm/include/llvm/BinaryFormat/DynamicTags.def
  llvm/tools/llvm-readobj/ELFDumper.cpp


Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -2471,6 +2471,7 @@
     switch (Type) {
     case DT_AARCH64_BTI_PLT:
     case DT_AARCH64_PAC_PLT:
+    case DT_AARCH64_VARIANT_PCS:
       return std::to_string(Value);
     default:
       break;
@@ -4033,9 +4034,22 @@
       printEnum(Symbol.getBinding(), makeArrayRef(ElfSymbolBindings));
   Fields[5].Str =
       printEnum(Symbol.getVisibility(), makeArrayRef(ElfSymbolVisibilities));
-  if (Symbol.st_other & ~0x3)
-    Fields[5].Str +=
-        " [<other: " + to_string(format_hex(Symbol.st_other, 2)) + ">]";
+
+  if (Symbol.st_other & ~0x3) {
+    if (this->Obj.getHeader().e_machine == ELF::EM_AARCH64) {
+      uint8_t other = Symbol.st_other & ~0x3;
+      if (other & STO_AARCH64_VARIANT_PCS) {
+        other &= ~STO_AARCH64_VARIANT_PCS;
+        Fields[5].Str += " [VARIANT_PCS";
+        if (other != 0)
+          Fields[5].Str.append(" | " + to_hexString(other, false));
+        Fields[5].Str.append("]");
+      }
+    } else {
+      Fields[5].Str +=
+          " [<other: " + to_string(format_hex(Symbol.st_other, 2)) + ">]";
+    }
+  }
 
   Fields[6].Column += NonVisibilityBitsUsed ? 13 : 0;
   Fields[6].Str = getSymbolSectionNdx(Symbol, SymIndex);
Index: llvm/include/llvm/BinaryFormat/DynamicTags.def
===================================================================
--- llvm/include/llvm/BinaryFormat/DynamicTags.def
+++ llvm/include/llvm/BinaryFormat/DynamicTags.def
@@ -120,6 +120,7 @@
 // AArch64 specific dynamic table entries
 AARCH64_DYNAMIC_TAG(AARCH64_BTI_PLT, 0x70000001)
 AARCH64_DYNAMIC_TAG(AARCH64_PAC_PLT, 0x70000003)
+AARCH64_DYNAMIC_TAG(AARCH64_VARIANT_PCS, 0x70000005)
 
 // Hexagon specific dynamic table entries
 HEXAGON_DYNAMIC_TAG(HEXAGON_SYMSZ, 0x70000000)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93044.310915.patch
Type: text/x-patch
Size: 1911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201210/e15d2081/attachment.bin>


More information about the llvm-commits mailing list