[PATCH] D75793: [llvm-objdump] --syms: print 'i' for STT_GNU_IFUNC

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 6 19:18:45 PST 2020


MaskRay created this revision.
MaskRay added reviewers: grimar, Higuoxing, jhenderson, rupprecht.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
MaskRay added a comment.

`llvm::object::BasicSymbolRef::SF_Indirect` exists but I don't think it is suitable.

In theory, `I` may be possible, but I cannot find any binutils test for `I`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75793

Files:
  llvm/test/tools/llvm-objdump/symbol-table-ifunc.test
  llvm/tools/llvm-objdump/llvm-objdump.cpp


Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1896,6 +1896,10 @@
     bool Absolute = Flags & SymbolRef::SF_Absolute;
     bool Common = Flags & SymbolRef::SF_Common;
     bool Hidden = Flags & SymbolRef::SF_Hidden;
+    char Indirect = ' ';
+    if (auto *ELF = dyn_cast<ELFObjectFileBase>(O))
+      if (ELFSymbolRef(*I).getELFType() == ELF::STT_GNU_IFUNC)
+        Indirect = 'i';
 
     char GlobLoc = ' ';
     if ((Section != O->section_end() || Absolute) && !Weak)
@@ -1918,7 +1922,7 @@
            << (Weak ? 'w' : ' ') // Weak?
            << ' ' // Constructor. Not supported yet.
            << ' ' // Warning. Not supported yet.
-           << ' ' // Indirect reference to another symbol.
+           << Indirect // Indirect reference to another symbol.
            << Debug // Debugging (d) or dynamic (D) symbol.
            << FileFunc // Name of function (F), file (f) or object (O).
            << ' ';
Index: llvm/test/tools/llvm-objdump/symbol-table-ifunc.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-objdump/symbol-table-ifunc.test
@@ -0,0 +1,28 @@
+## Test that we print 'i' for STT_GNU_IFUNC.
+
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objdump -t %t | FileCheck %s
+
+# CHECK:      SYMBOL TABLE:
+# CHECK-NEXT: 0000000000000000 l   i   .text  0000000000000000 ifunc_local
+# CHECK-NEXT: 0000000000000000 g   i   .text  0000000000000000 ifunc_global
+
+!ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name:  .text
+    Type:  SHT_PROGBITS
+    Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+Symbols:
+  - Name:    ifunc_local
+    Type:    STT_GNU_IFUNC
+    Binding: STB_LOCAL
+    Section: .text
+  - Name:    ifunc_global
+    Type:    STT_GNU_IFUNC
+    Binding: STB_GLOBAL
+    Section: .text


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75793.248879.patch
Type: text/x-patch
Size: 2012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200307/1264dfd1/attachment.bin>


More information about the llvm-commits mailing list