This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v3 2/9] Use gcc attribute ifunc in libc_ifunc macro instead of inline assembly due to false debuginfo.


On 08/29/2016 10:16 PM, Paul E. Murphy wrote:


On 08/24/2016 09:04 AM, Stefan Liebler wrote:


This way there is no trouble with the internal __GI_* symbols.
Glibc builds fine with this construct and the debuginfo is "correct".
For functions without a __GI_* symbol like memccpy this redirection is not needed.

Should memccpy read mempcpy?  Also, is the reason why you are able to remove the
libc_hidden_def usage later on in this patch?

Sorry. This comment means sysdeps/s390/multiarch/memccpy.c. There is also a weak alias but no __GI_* symbol.

Regarding mempcpy in powerpc:
Before this patch there were two __GI_mempcpy symbols in powerpc-build:
readelf -s string/mempcpy.os | grep __GI_mempcpy
    16: 0000000000000000   156 IFUNC   WEAK   HIDDEN     7 __GI_mempcpy

readelf -s string/mempcpy-ppc64.os | grep __GI_mempcpy
    13: 0000000000000000    64 FUNC    GLOBAL DEFAULT    6 __GI_mempcpy

This only works as the IFUNC-one is weak. The resulting libc.so uses the non-IFUNC-one:
readelf -s libc.so | grep _mempcpy
  4716: 00000000001d8580    64 FUNC    LOCAL  DEFAULT   27 __GI_mempcpy
  5360: 00000000001d8580    64 FUNC    LOCAL  DEFAULT   27 __mempcpy_ppc
...

With the redirection I can remove the libc_hidden_def (mempcpy) in sysdeps/powerpc/powerpc64/multiarch/mempcpy.c and sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy.c. Now it is obvious that the libc_hidden_def in sysdeps/powerpc/powerpc64/multiarch/mempcpy-ppc64.c and sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c is used.

--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */

+#define __finite __redirect___finite
+#define __finitef __redirect___finitef
+#define __finitel __redirect___finitel
finitef and finitel don't seem to be needed here.

If I omit the the redirection of finitef and finitel the following error occurs (See my further comments below):
gcc ../sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c -c ...
In file included from <command-line>:0:0:
../include/math.h:15:15: error: ‘__finitef’ undeclared here (not in a function)
 hidden_proto (__finitef)
               ^
./../include/libc-symbols.h:409:27: note: in definition of macro ‘__hidden_proto’ extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
                           ^
../include/math.h:15:1: note: in expansion of macro ‘hidden_proto’
 hidden_proto (__finitef)
 ^
../include/math.h:20:15: error: ‘__finitel’ undeclared here (not in a function)
 hidden_proto (__finitel)
               ^
./../include/libc-symbols.h:409:27: note: in definition of macro ‘__hidden_proto’ extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
                           ^
../include/math.h:20:1: note: in expansion of macro ‘hidden_proto’
 hidden_proto (__finitel)
 ^
In file included from ../sysdeps/powerpc/fpu/math_private.h:26:0,
                 from ../sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h:40,
from ../sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c:23: ../sysdeps/generic/math_private.h:325:12: error: ‘__finitel’ redeclared as different kind of symbol
 extern int __finitel (long double);
            ^
In file included from <command-line>:0:0:
../include/math.h:20:15: note: previous declaration of ‘__finitel’ was here
 hidden_proto (__finitel)
               ^
./../include/libc-symbols.h:409:33: note: in definition of macro ‘__hidden_proto’ extern thread __typeof (name) name __asm__ (__hidden_asmname (#internal)) \
                                 ^
../include/math.h:20:1: note: in expansion of macro ‘hidden_proto’
 hidden_proto (__finitel)



Due to the mechanism in math.h (see below) the redirection of __finite leads to also redirecting the definition of __finitef, __finitel as it is also used in those __MATHDECL_1 usages in math/bits/mathcalls.h but not in include/math.h when using hidden_proto (__finite[fl]).
Thus I also have to redirect the float and long double versions.
This also applies to __isinf, __isnan.

include/math.h:
 3: #include <math/math.h>
15: hidden_proto (__finitef)
20: hidden_proto (__finitel)

math/math.h:
96: #define __MATHDECL_1(type, function,suffix, args) \
  extern type __MATH_PRECNAME(function,suffix) args __THROW
104, 125, 172: #include <bits/mathcalls.h>
(for float, double, long double math functions)

math/bits/mathcalls.h:
194:__MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__)); 197: __MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__)); 236: __MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));



 #include <math.h>
 #include <math_ldbl_opt.h>
 #include <shlib-compat.h>
@@ -23,11 +26,14 @@

 extern __typeof (__finite) __finite_ppc32 attribute_hidden;
 extern __typeof (__finite) __finite_power7 attribute_hidden;
-
-libc_ifunc (__finite,
-	    (hwcap & PPC_FEATURE_ARCH_2_06)
-	    ? __finite_power7
-            : __finite_ppc32);
+#undef __finite
+#undef __finitef
+#undef __finitel
Likewise.


diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c
index 506c111..fe6c912 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isinf.c
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */

+#define __isinf __redirect___isinf
+#define __isinff __redirect___isinff
+#define __isinfl __redirect___isinfl
Similarly, __isinff and __isinfl don't seem to need indirect.

Same reason as in comment for sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c.
 #include <math.h>
 #include <math_ldbl_opt.h>
 #include <shlib-compat.h>
@@ -23,11 +26,14 @@

 extern __typeof (__isinf) __isinf_ppc32 attribute_hidden;
 extern __typeof (__isinf) __isinf_power7 attribute_hidden;
-
-libc_ifunc (__isinf,
-	    (hwcap & PPC_FEATURE_ARCH_2_06)
-	    ? __isinf_power7
-            : __isinf_ppc32);
+#undef __isinf
+#undef __isinff
+#undef __isinfl
Likewise.


diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c
index 8f848d7..3655b81 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_isnan.c
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */

+#define __isnan __redirect___isnan
+#define __isnanf __redirect___isnanf
+#define __isnanl __redirect___isnanl
__isnanf and __isnanl don't appear to need overrides too.

Same reason as in comment for sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c.
 #include <math.h>
 #include <math_ldbl_opt.h>
 #include <shlib-compat.h>
@@ -25,15 +28,18 @@ extern __typeof (__isnan) __isnan_ppc32 attribute_hidden;
 extern __typeof (__isnan) __isnan_power5 attribute_hidden;
 extern __typeof (__isnan) __isnan_power6 attribute_hidden;
 extern __typeof (__isnan) __isnan_power7 attribute_hidden;
-
-libc_ifunc (__isnan,
-	    (hwcap & PPC_FEATURE_ARCH_2_06)
-	    ? __isnan_power7 :
-	      (hwcap & PPC_FEATURE_ARCH_2_05)
-	      ? __isnan_power6 :
-		(hwcap & PPC_FEATURE_POWER5)
-		? __isnan_power5
-            : __isnan_ppc32);
+#undef __isnan
+#undef __isnanf
+#undef __isnanl
Likewise.

diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c
index 067edc2..c7d67f1 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */

+#define __finite __redirect___finite
+#define __finitef __redirect___finitef
+#define __finitel __redirect___finitel
__finitef and __finitel redirection doesn't seem necessary here.

Same reason as in comment for sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c.
 #include <math.h>
 #include <math_ldbl_opt.h>
 #include <shlib-compat.h>
@@ -24,13 +27,16 @@
 extern __typeof (__finite) __finite_ppc64 attribute_hidden;
 extern __typeof (__finite) __finite_power7 attribute_hidden;
 extern __typeof (__finite) __finite_power8 attribute_hidden;
-
-libc_ifunc (__finite,
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
-	    ? __finite_power8 :
-	      (hwcap & PPC_FEATURE_ARCH_2_06)
-	      ? __finite_power7
-            : __finite_ppc64);
+#undef __finite
+#undef __finitef
+#undef __finitel
Likewise.


diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c
index 07e159d..a13ec27 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isinf.c
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */

+#define __isinf __redirect___isinf
+#define __isinff __redirect___isinff
+#define __isinfl __redirect___isinfl
__isinff __isinfl don't seem to need redirection here.

Same reason as in comment for sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c.
 #include <math.h>
 #include <math_ldbl_opt.h>
 #include <shlib-compat.h>
@@ -24,13 +27,16 @@
 extern __typeof (__isinf) __isinf_ppc64 attribute_hidden;
 extern __typeof (__isinf) __isinf_power7 attribute_hidden;
 extern __typeof (__isinf) __isinf_power8 attribute_hidden;
-
-libc_ifunc (__isinf,
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
-	    ? __isinf_power8 :
-	      (hwcap & PPC_FEATURE_ARCH_2_06)
-	      ? __isinf_power7
-            : __isinf_ppc64);
+#undef __isinf
+#undef __isinff
+#undef __isinfl
Likewise.

diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c
index a614f25..fce3c9d 100644
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/s_isnan.c
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */

+#define __isnan __redirect___isnan
+#define __isnanf __redirect___isnanf
+#define __isnanl __redirect___isnanl
Is __isnanf or __isnanl redirection necessary here?

Same reason as in comment for sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_finite.c.
 #include <math.h>
 #include <math_ldbl_opt.h>
 #include <shlib-compat.h>
@@ -27,19 +30,22 @@ extern __typeof (__isnan) __isnan_power6 attribute_hidden;
 extern __typeof (__isnan) __isnan_power6x attribute_hidden;
 extern __typeof (__isnan) __isnan_power7 attribute_hidden;
 extern __typeof (__isnan) __isnan_power8 attribute_hidden;
-
-libc_ifunc (__isnan,
-	    (hwcap2 & PPC_FEATURE2_ARCH_2_07)
-	    ? __isnan_power8 :
-	      (hwcap & PPC_FEATURE_ARCH_2_06)
-	      ? __isnan_power7 :
-		(hwcap & PPC_FEATURE_POWER6_EXT)
-		? __isnan_power6x :
-		  (hwcap & PPC_FEATURE_ARCH_2_05)
-		    ? __isnan_power6 :
-		    (hwcap & PPC_FEATURE_POWER5)
-		      ? __isnan_power5
-            : __isnan_ppc64);
+#undef __isnan
+#undef __isnanf
+#undef __isnanl
Likewise.

diff --git a/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c b/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
index 3c77b5f..36ec954 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c

-libc_hidden_def (mempcpy)
These removals are allowed because of the behavior you've mentioned in changelog?
See "Regarding mempcpy in powerpc:" above.


Otherwise, the ppc bits of this patch are OK with the removal of the extra redirections.

Thanks for reviewing.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]