[PATCH] D131162: [MC][ELF] Mark GNU ABI if ifunc are used

Adhemerval Zanella via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 4 06:28:58 PDT 2022


zatrazz created this revision.
zatrazz added reviewers: MaskRay, joerg, jrtc27.
Herald added subscribers: StephenFan, hiraditya, emaste.
Herald added a project: All.
zatrazz requested review of this revision.
Herald added a project: LLVM.

Similar to D107861 <https://reviews.llvm.org/D107861>.  Some tools required the GNU ABI mark to output
the symbol is a IFUNC type correctly (for instance binutils readelf).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131162

Files:
  llvm/lib/MC/MCELFStreamer.cpp
  llvm/test/MC/ELF/ifunc-gnu.s


Index: llvm/test/MC/ELF/ifunc-gnu.s
===================================================================
--- /dev/null
+++ llvm/test/MC/ELF/ifunc-gnu.s
@@ -0,0 +1,22 @@
+# REQUIRES: x86-registered-target
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux-gnu %s -o -| llvm-readelf -hs - | FileCheck %s
+
+.text
+
+.type  foo_impl, at function
+foo_impl:
+  ret
+
+.type  foo_resolver, at function
+foo_resolver:
+  mov $foo_impl, %rax
+  ret
+
+.type  foo, at gnu_indirect_function
+.set   foo,foo_resolver
+
+## ELFOSABI_NONE is changed to ELFOSABI_GNU. Other OSABI values are unchanged.
+# CHECK:      OS/ABI: UNIX - GNU
+# CHECK:      FUNC    LOCAL  DEFAULT    2 foo_impl
+# CHECK-NEXT: FUNC    LOCAL  DEFAULT    2 foo_resolver
+# CHECK-NEXT: IFUNC   LOCAL  DEFAULT    2 foo
Index: llvm/lib/MC/MCELFStreamer.cpp
===================================================================
--- llvm/lib/MC/MCELFStreamer.cpp
+++ llvm/lib/MC/MCELFStreamer.cpp
@@ -263,6 +263,7 @@
 
   case MCSA_ELF_TypeIndFunction:
     Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_GNU_IFUNC));
+    getAssembler().getWriter().markGnuAbi();
     break;
 
   case MCSA_ELF_TypeObject:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131162.449953.patch
Type: text/x-patch
Size: 1170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220804/7db79472/attachment.bin>


More information about the llvm-commits mailing list