Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Jun 2014 09:50:42 GMT
From:      op@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r269045 - soc2014/op/tests/ifunc-vs-kpatch
Message-ID:  <201406040950.s549og6F049118@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: op
Date: Wed Jun  4 09:50:42 2014
New Revision: 269045
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=269045

Log:
  added NOTES to  ifunc-vs-kpatch
  
  Signed-off-by: Oliver Pinter <oliver.pntr@gmail.com>
  
  

Added:
  soc2014/op/tests/ifunc-vs-kpatch/NOTES

Added: soc2014/op/tests/ifunc-vs-kpatch/NOTES
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2014/op/tests/ifunc-vs-kpatch/NOTES	Wed Jun  4 09:50:42 2014	(r269045)
@@ -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< --



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406040950.s549og6F049118>