]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix sem_* tdelete, tfind, tsearch, twalk namespace (bug 18536).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 17 Jun 2015 20:11:58 +0000 (20:11 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 17 Jun 2015 20:11:58 +0000 (20:11 +0000)
The sem_* functions bring in references to tdelete, tfind, tsearch and
twalk.  But the t* functions are XSI-shaded, while sem_* aren't.  This
patch fixes this by using __t* instead, exporting those functions from
libc at version GLIBC_PRIVATE (since sem_* are in libpthread) and
using libc_hidden_* for the benefit of calls within libc.

Tested for x86_64 and x86 (testsuite, and comparison of disassembly of
installed stripped shared libraries).  libpthread gets changes from
PLT reordering; addresses in libc change because of PLT / dynamic
symbol table changes.

[BZ #18536]
* misc/tsearch.c (__tsearch): Use libc_hidden_def.
(__tfind): Likewise.
(__tdelete): Likewise.
(__twalk): Likewise.
* misc/Versions (libc): Add __tdelete, __tfind, __tsearch and
__twalk to GLIBC_PRIVATE.
* include/search.h (__tsearch): Use libc_hidden_proto.
(__tfind): Likewise.
(__tdelete): Likewise.
(__twalk): Likewise.
* nptl/sem_close.c (sem_close): Call __twalk instead of twalk.
Call __tdelete instead of tdelete.
* nptl/sem_open.c (check_add_mapping): Call __tfind instead of
tfind.  Call __tsearch instead of tsearch.
* sysdeps/sparc/sparc32/sem_open.c (check_add_mapping): Likewise.
* conform/Makefile (test-xfail-POSIX/semaphore.h/linknamespace):
Remove variable.
(test-xfail-POSIX2008/semaphore.h/linknamespace): Likewise.

ChangeLog
NEWS
conform/Makefile
include/search.h
misc/Versions
misc/tsearch.c
nptl/sem_close.c
nptl/sem_open.c
sysdeps/sparc/sparc32/sem_open.c

index abc52cc07b8abdffc430f297bfb226a85ba982fe..d055ea3590555677c68a8372a7ddee5a009d6297 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,25 @@
 2015-06-17  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #18536]
+       * misc/tsearch.c (__tsearch): Use libc_hidden_def.
+       (__tfind): Likewise.
+       (__tdelete): Likewise.
+       (__twalk): Likewise.
+       * misc/Versions (libc): Add __tdelete, __tfind, __tsearch and
+       __twalk to GLIBC_PRIVATE.
+       * include/search.h (__tsearch): Use libc_hidden_proto.
+       (__tfind): Likewise.
+       (__tdelete): Likewise.
+       (__twalk): Likewise.
+       * nptl/sem_close.c (sem_close): Call __twalk instead of twalk.
+       Call __tdelete instead of tdelete.
+       * nptl/sem_open.c (check_add_mapping): Call __tfind instead of
+       tfind.  Call __tsearch instead of tsearch.
+       * sysdeps/sparc/sparc32/sem_open.c (check_add_mapping): Likewise.
+       * conform/Makefile (test-xfail-POSIX/semaphore.h/linknamespace):
+       Remove variable.
+       (test-xfail-POSIX2008/semaphore.h/linknamespace): Likewise.
+
        [BZ #18534]
        * stdio-common/dprintf.c (__dprintf): Use libc_hidden_def.
        (dprintf): Define as a weak alias of __dprintf, not a strong
diff --git a/NEWS b/NEWS
index a0ebe5898980c3a435eb6cfc8b5421c9f9c5a883..0b67fa2c0fb9aee26ccbf88101d7b45b82d7c6fb 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,7 +22,7 @@ Version 2.22
   18324, 18333, 18346, 18397, 18409, 18410, 18412, 18418, 18422, 18434,
   18444, 18468, 18469, 18470, 18479, 18483, 18495, 18496, 18497, 18498,
   18507, 18512, 18519, 18520, 18522, 18527, 18528, 18529, 18530, 18532,
-  18533, 18534.
+  18533, 18534, 18536.
 
 * Cache information can be queried via sysconf() function on s390 e.g. with
   _SC_LEVEL1_ICACHE_SIZE as argument.
index 9347b0f6a83aa35708eb3c564091df0a656ed4a9..873326b7c68296a1da98467fc603b6a28da52a25 100644 (file)
@@ -348,11 +348,9 @@ test-xfail-XPG3/unistd.h/linknamespace = yes
 test-xfail-XPG4/fmtmsg.h/linknamespace = yes
 test-xfail-XPG4/unistd.h/linknamespace = yes
 test-xfail-POSIX/mqueue.h/linknamespace = yes
-test-xfail-POSIX/semaphore.h/linknamespace = yes
 test-xfail-UNIX98/fmtmsg.h/linknamespace = yes
 test-xfail-UNIX98/mqueue.h/linknamespace = yes
 test-xfail-UNIX98/unistd.h/linknamespace = yes
 test-xfail-UNIX98/wchar.h/linknamespace = yes
 test-xfail-XOPEN2K/fmtmsg.h/linknamespace = yes
-test-xfail-POSIX2008/semaphore.h/linknamespace = yes
 test-xfail-XOPEN2K8/fmtmsg.h/linknamespace = yes
index 24eafc0f71c6ab6b6839dbd276dea800898f847d..a941959dbebbc611407c255a2bd7f5ee269e492c 100644 (file)
@@ -14,11 +14,15 @@ libc_hidden_proto (lfind)
 extern void __hdestroy (void);
 extern void *__tsearch (const void *__key, void **__rootp,
                        __compar_fn_t compar);
+libc_hidden_proto (__tsearch)
 extern void *__tfind (const void *__key, void *const *__rootp,
                      __compar_fn_t compar);
+libc_hidden_proto (__tfind)
 extern void *__tdelete (const void *__key, void **__rootp,
                        __compar_fn_t compar);
+libc_hidden_proto (__tdelete)
 extern void __twalk (const void *__root, __action_fn_t action);
+libc_hidden_proto (__twalk)
 extern void __tdestroy (void *__root, __free_fn_t freefct);
 #endif
 #endif
index ec5aea7b523e7041084f43c400bca42014d927fb..534d1a3fca3eae5df873d8bdb94d2167f58f26ff 100644 (file)
@@ -153,5 +153,6 @@ libc {
     __madvise;
     __mktemp;
     __libc_ifunc_impl_list;
+    __tdelete; __tfind; __tsearch; __twalk;
   }
 }
index d4052e8397f643fd5de8b4c0788d0fe0642bc82b..869dc9bec77e39ca3a6c908e7c8e1aa06006d4fd 100644 (file)
@@ -293,6 +293,7 @@ __tsearch (const void *key, void **vrootp, __compar_fn_t compar)
 
   return q;
 }
+libc_hidden_def (__tsearch)
 weak_alias (__tsearch, tsearch)
 
 
@@ -325,6 +326,7 @@ __tfind (key, vrootp, compar)
     }
   return NULL;
 }
+libc_hidden_def (__tfind)
 weak_alias (__tfind, tfind)
 
 
@@ -585,6 +587,7 @@ __tdelete (const void *key, void **vrootp, __compar_fn_t compar)
   free (unchained);
   return retval;
 }
+libc_hidden_def (__tdelete)
 weak_alias (__tdelete, tdelete)
 
 
@@ -625,6 +628,7 @@ __twalk (const void *vroot, __action_fn_t action)
   if (root != NULL && action != NULL)
     trecurse (root, action, 0);
 }
+libc_hidden_def (__twalk)
 weak_alias (__twalk, twalk)
 
 
index 3f1ccbe2404f77ebd554a606d5bce043b114aaf1..7f1df14fc3b7b7ab42819d0c704cd67e9d32590f 100644 (file)
@@ -51,7 +51,7 @@ sem_close (sem)
   /* Locate the entry for the mapping the caller provided.  */
   rec = NULL;
   the_sem = sem;
-  twalk (__sem_mappings, walker);
+  __twalk (__sem_mappings, walker);
   if  (rec != NULL)
     {
       /* Check the reference counter.  If it is going to be zero, free
@@ -59,7 +59,7 @@ sem_close (sem)
       if (--rec->refcnt == 0)
        {
          /* Remove the record from the tree.  */
-         (void) tdelete (rec, &__sem_mappings, __sem_search);
+         (void) __tdelete (rec, &__sem_mappings, __sem_search);
 
          result = munmap (rec->sem, sizeof (sem_t));
 
index bfd2dea94ec443261a3281c68b726037d03ddbd0..ecd051a547611fa540d007e80f7030198f381fba 100644 (file)
@@ -79,7 +79,8 @@ check_add_mapping (const char *name, size_t namelen, int fd, sem_t *existing)
       fake->dev = st.st_dev;
       fake->ino = st.st_ino;
 
-      struct inuse_sem **foundp = tfind (fake, &__sem_mappings, __sem_search);
+      struct inuse_sem **foundp = __tfind (fake, &__sem_mappings,
+                                          __sem_search);
       if (foundp != NULL)
        {
          /* There is already a mapping.  Use it.  */
@@ -108,7 +109,7 @@ check_add_mapping (const char *name, size_t namelen, int fd, sem_t *existing)
 
              /* Insert the new value.  */
              if (existing != MAP_FAILED
-                 && tsearch (newp, &__sem_mappings, __sem_search) != NULL)
+                 && __tsearch (newp, &__sem_mappings, __sem_search) != NULL)
                /* Successful.  */
                result = existing;
              else
index af9233c653d8f77f8d89342e9064e98a69dfe231..2698d195badfe606b7412acf1017f02cbb8a1815 100644 (file)
@@ -79,7 +79,8 @@ check_add_mapping (const char *name, size_t namelen, int fd, sem_t *existing)
       fake->dev = st.st_dev;
       fake->ino = st.st_ino;
 
-      struct inuse_sem **foundp = tfind (fake, &__sem_mappings, __sem_search);
+      struct inuse_sem **foundp = __tfind (fake, &__sem_mappings,
+                                          __sem_search);
       if (foundp != NULL)
        {
          /* There is already a mapping.  Use it.  */
@@ -108,7 +109,7 @@ check_add_mapping (const char *name, size_t namelen, int fd, sem_t *existing)
 
              /* Insert the new value.  */
              if (existing != MAP_FAILED
-                 && tsearch (newp, &__sem_mappings, __sem_search) != NULL)
+                 && __tsearch (newp, &__sem_mappings, __sem_search) != NULL)
                /* Successful.  */
                result = existing;
              else