socsvn commit: r269046 - in soc2014/op: docs/gcc tests/ifunc-vs-kpatch

op at FreeBSD.org op at FreeBSD.org
Wed Jun 4 09:53:09 UTC 2014


Author: op
Date: Wed Jun  4 09:53:08 2014
New Revision: 269046
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269046

Log:
  moved the file  tests/ifunc-vs-kpatch/NOTES to  docs/gcc/ifunc.txt
  
  Signed-off-by: Oliver Pinter <oliver.pntr at gmail.com>
  
  

Added:
  soc2014/op/docs/gcc/
  soc2014/op/docs/gcc/ifunc.txt
     - copied unchanged from r269045, soc2014/op/tests/ifunc-vs-kpatch/NOTES
Deleted:
  soc2014/op/tests/ifunc-vs-kpatch/NOTES

Copied: soc2014/op/docs/gcc/ifunc.txt (from r269045, soc2014/op/tests/ifunc-vs-kpatch/NOTES)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2014/op/docs/gcc/ifunc.txt	Wed Jun  4 09:53:08 2014	(r269046, copy of r269045, soc2014/op/tests/ifunc-vs-kpatch/NOTES)
@@ -0,0 +1,29 @@
+https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Function-Attributes.html
+	-- 8< --
+	ifunc ("resolver")
+	    The ifunc attribute is used to mark a function as an indirect function using the STT_GNU_IFUNC symbol type extension to the ELF standard. This allows the resolution of the symbol value to be determined dynamically at load time, and an optimized version of the routine can be selected for the particular processor or other system characteristics determined then. To use this attribute, first define the implementation functions available, and a resolver function that returns a pointer to the selected implementation function. The implementation functions' declarations must match the API of the function being implemented, the resolver's declaration is be a function returning pointer to void function returning void:
+
+		      void *my_memcpy (void *dst, const void *src, size_t len)
+		      {
+			...
+		      }
+		      
+		      static void (*resolve_memcpy (void)) (void)
+		      {
+			return my_memcpy; // we'll just always select this routine
+		      }
+		 
+
+	    The exported header file declaring the function the user calls would contain:
+
+		      extern void *memcpy (void *, const void *, size_t);
+		 
+
+	    allowing the user to call this as a regular function, unaware of the implementation. Finally, the indirect function needs to be defined in the same translation unit as the resolver function:
+
+		      void *memcpy (void *, const void *, size_t)
+			   __attribute__ ((ifunc ("resolve_memcpy")));
+		 
+
+	    Indirect functions cannot be weak, and require a recent binutils (at least version 2.20.1), and GNU C library (at least version 2.11.1). 
+	-- 8< --


More information about the svn-soc-all mailing list