Use SHLIB_COMPAT for libc symbols only if building libc.so
diff mbox

Message ID 20140318055403.GR1850@spoyarek.pnq.redhat.com
State New
Headers show

Commit Message

Siddhesh Poyarekar March 18, 2014, 5:54 a.m. UTC
Hi,

SHLIB_COMPAT implicitly assumes that IS_IN_$(lib) is defined for the
library it is called for, which is not always true.  When building
libm.so and libpthread.so, one would encounter SHLIB_COMPAT calls for
libc, which gets called without IS_IN_libc being defined, which raises
a warning with -Wundef.

One way to fix this would have been to change the conditional in
SHLIB_COMPAT definition to use if defined IS_IN_##lib, but I chose the
more explicit path, which was to mark only callers that would
encounter this problem, i.e. code where SHLIB_COMPAT(libc,...) is used
outside of libc.so.

I took a sha1sum of all generated binaries and verified that they're
the same before and after.

Siddhesh

	* libio/libio.h [defined _LIBC && defined SHARED]: Call
	SHLIB_COMPAT only when building libc.so.
	* nptl/forward.c: Likewise.

Comments

Roland McGrath March 18, 2014, 10:48 p.m. UTC | #1
This seems worse to me.  I've been vaguely noodling about some centralized
macro regime to make the NOT_IN_*/IS_IN_* cases #if-friendly.  Let's figure
out what we want to do about those in general before considering
SHLIB_COMPAT.  I tend to think that it's a more maintainable interface to
have '#if SHLIB_COMPAT (libfoo, ...)' be a standalone test that encompasses
the IS_IN_libfoo test (just as it encompasses the SHARED test).


Thanks,
ROland
Siddhesh Poyarekar March 19, 2014, 2:10 a.m. UTC | #2
On Tue, Mar 18, 2014 at 03:48:14PM -0700, Roland McGrath wrote:
> This seems worse to me.  I've been vaguely noodling about some centralized
> macro regime to make the NOT_IN_*/IS_IN_* cases #if-friendly.  Let's figure
> out what we want to do about those in general before considering
> SHLIB_COMPAT.  I tend to think that it's a more maintainable interface to
> have '#if SHLIB_COMPAT (libfoo, ...)' be a standalone test that encompasses
> the IS_IN_libfoo test (just as it encompasses the SHARED test).

Agreed, I wasn't expecting this patch to go through at all and just
wanted a general idea of how we expect these bits to look.  I briefly
thought about NOT_IN_*/IS_IN_* too, but decided that it would take up
much more time than I'm willing to invest into it right now.

Siddhesh

Patch
diff mbox

diff --git a/libio/libio.h b/libio/libio.h
index 6077f5c..060b5f5 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -482,7 +482,7 @@  extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW;
    versions.  */
 #  if defined _LIBC && defined SHARED
 #   include <shlib-compat.h>
-#   if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+#   if !defined NOT_IN_libc && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
 #    define _IO_fwide_maybe_incompatible \
   (__builtin_expect (&_IO_stdin_used == NULL, 0))
 extern const int _IO_stdin_used;
diff --git a/nptl/forward.c b/nptl/forward.c
index 6355c23..ff4c6e5 100644
--- a/nptl/forward.c
+++ b/nptl/forward.c
@@ -58,7 +58,7 @@  name decl								      \
 
 FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_1)
+#if !defined NOT_IN_libc && SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_1)
 FORWARD (__pthread_attr_init_2_0, (pthread_attr_t *attr), (attr), 0)
 compat_symbol (libc, __pthread_attr_init_2_0, pthread_attr_init, GLIBC_2_0);
 #endif
@@ -98,7 +98,7 @@  FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
 FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
 FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+#if !defined NOT_IN_libc && SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
 FORWARD2 (__pthread_cond_broadcast_2_0, int attribute_compat_text_section,
 	  (pthread_cond_2_0_t *cond), (cond), return 0)
 compat_symbol (libc, __pthread_cond_broadcast_2_0, pthread_cond_broadcast,
@@ -108,7 +108,7 @@  FORWARD (__pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
 versioned_symbol (libc, __pthread_cond_broadcast, pthread_cond_broadcast,
 		  GLIBC_2_3_2);
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+#if !defined NOT_IN_libc && SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
 FORWARD2 (__pthread_cond_destroy_2_0, int attribute_compat_text_section,
 	  (pthread_cond_2_0_t *cond), (cond), return 0)
 compat_symbol (libc, __pthread_cond_destroy_2_0, pthread_cond_destroy,
@@ -118,7 +118,7 @@  FORWARD (__pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
 versioned_symbol (libc, __pthread_cond_destroy, pthread_cond_destroy,
 		  GLIBC_2_3_2);
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+#if !defined NOT_IN_libc && SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
 FORWARD2 (__pthread_cond_init_2_0, int attribute_compat_text_section,
 	  (pthread_cond_2_0_t *cond, const pthread_condattr_t *cond_attr),
 	  (cond, cond_attr), return 0)
@@ -129,7 +129,7 @@  FORWARD (__pthread_cond_init,
 	 (cond, cond_attr), 0)
 versioned_symbol (libc, __pthread_cond_init, pthread_cond_init, GLIBC_2_3_2);
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+#if !defined NOT_IN_libc && SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
 FORWARD2 (__pthread_cond_signal_2_0, int attribute_compat_text_section,
 	  (pthread_cond_2_0_t *cond), (cond), return 0)
 compat_symbol (libc, __pthread_cond_signal_2_0, pthread_cond_signal,
@@ -139,7 +139,7 @@  FORWARD (__pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
 versioned_symbol (libc, __pthread_cond_signal, pthread_cond_signal,
 		  GLIBC_2_3_2);
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+#if !defined NOT_IN_libc && SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
 FORWARD2 (__pthread_cond_wait_2_0, int attribute_compat_text_section,
 	  (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex), (cond, mutex),
 	  return 0)
@@ -151,7 +151,7 @@  FORWARD (__pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
 versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait,
 		  GLIBC_2_3_2);
 
-#if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
+#if !defined NOT_IN_libc && SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
 FORWARD2 (__pthread_cond_timedwait_2_0, int attribute_compat_text_section,
 	  (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex,
 	   const struct timespec *abstime), (cond, mutex, abstime),