[PATCH] Fix IFUNC symbols assembly mode.

Roman Divacky rdivacky at freebsd.org
Sat Jan 4 06:49:28 PST 2014


Hi,

.globl  memcpy
.type   memcpy, @gnu_indirect_function
.set    memcpy,resolve_memcpy

is currently misassembled (the memcpy is of type STT_FUNC instead of
STT_GNU_IFUNC). 

This patch fixes it:

Index: lib/MC/ELFObjectWriter.cpp
===================================================================
--- lib/MC/ELFObjectWriter.cpp  (revision 198480)
+++ lib/MC/ELFObjectWriter.cpp  (working copy)
@@ -546,6 +546,9 @@
   // Binding and Type share the same byte as upper and lower nibbles
   uint8_t Binding = MCELF::GetBinding(OrigData);
   uint8_t Type = MCELF::GetType(Data);
+  // Keep IFUNC type.
+  if (Type == ELF::STT_FUNC && MCELF::GetType(OrigData) == ELF::STT_GNU_IFUNC)
+    Type = ELF::STT_GNU_IFUNC;
   uint8_t Info = (Binding << ELF_STB_Shift) | (Type << ELF_STT_Shift);

   // Other and Visibility share the same byte with Visibility using the lower
Index: test/MC/ELF/type.s
===================================================================
--- test/MC/ELF/type.s  (revision 198480)
+++ test/MC/ELF/type.s  (working copy)
@@ -22,9 +22,9 @@
         .type func, at function
         .type func, at object

-ifunc:  
         .global ifunc
         .type ifunc, at gnu_indirect_function
+        .set ifunc,func

 tls:
         .global tls

I track this in #18372. Is the patch ok to commit?

Roman



More information about the llvm-commits mailing list