From d051b143f73189311faf9cd311cc53c6f6a145db Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 17 Jun 2015 20:11:58 +0000 Subject: Fix sem_* tdelete, tfind, tsearch, twalk namespace (bug 18536). 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. --- nptl/sem_close.c | 4 ++-- nptl/sem_open.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'nptl') diff --git a/nptl/sem_close.c b/nptl/sem_close.c index 3f1ccbe240..7f1df14fc3 100644 --- a/nptl/sem_close.c +++ b/nptl/sem_close.c @@ -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)); diff --git a/nptl/sem_open.c b/nptl/sem_open.c index bfd2dea94e..ecd051a547 100644 --- a/nptl/sem_open.c +++ b/nptl/sem_open.c @@ -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 -- cgit v1.2.3