From 014fc8c05133bd0bc138f7fee0d43a506e992d5c Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 13 Oct 2005 15:51:12 +0000 Subject: [PATCH] Use an soname of libc.so* for libc redirects so that we catch a wider range of libc's such as uclibc as well as glibc. Fixes bug 114289. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4916 --- coregrind/m_replacemalloc/vg_replace_malloc.c | 78 +++++++++---------- memcheck/mac_replace_strmem.c | 44 +++++------ 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index a86b063281..e6db6afb3f 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -55,7 +55,7 @@ /* Some handy Z-encoded names */ #define m_libstc_plus_plus_star libstdcZpZpZa // libstdc++* -#define m_libc_dot_so_dot_6 libcZdsoZd6 // libc.so.6 +#define m_libc_dot_so_star libcZdsoZa // libc.so* //#define m_libpgc_dot_so libpgcZdso // libpgc.so /* 2 Apr 05: the Portland Group compiler, which uses cfront/ARM style @@ -127,7 +127,7 @@ static void init(void) __attribute__((constructor)); { \ void* v; \ \ - MALLOC_TRACE(#fnname "(%llu)", (ULong)n ); \ + MALLOC_TRACE(#fnname "(%llu)", (ULong)n ); \ if (!init_done) init(); \ \ v = (void*)VALGRIND_NON_SIMD_CALL1( info.tl_##vg_replacement, n ); \ @@ -146,27 +146,27 @@ static void init(void) __attribute__((constructor)); // malloc ALLOC_or_NULL(m_libstc_plus_plus_star, malloc, malloc); -ALLOC_or_NULL(m_libc_dot_so_dot_6, malloc, malloc); +ALLOC_or_NULL(m_libc_dot_so_star, malloc, malloc); //ALLOC_or_NULL(m_libpgc_dot_so, malloc, malloc); // operator new(unsigned int), unmangled for some bizarre reason ALLOC_or_BOMB(m_libstc_plus_plus_star, builtin_new, __builtin_new); -ALLOC_or_BOMB(m_libc_dot_so_dot_6, builtin_new, __builtin_new); +ALLOC_or_BOMB(m_libc_dot_so_star, builtin_new, __builtin_new); ALLOC_or_BOMB(m_libstc_plus_plus_star, __builtin_new, __builtin_new); -ALLOC_or_BOMB(m_libc_dot_so_dot_6, __builtin_new, __builtin_new); +ALLOC_or_BOMB(m_libc_dot_so_star, __builtin_new, __builtin_new); // operator new(unsigned int), GNU mangling, 32-bit platforms // operator new(unsigned long), GNU mangling, 64-bit platforms #if VG_WORDSIZE == 4 ALLOC_or_BOMB(m_libstc_plus_plus_star, _Znwj, __builtin_new); - ALLOC_or_BOMB(m_libc_dot_so_dot_6, _Znwj, __builtin_new); + ALLOC_or_BOMB(m_libc_dot_so_star, _Znwj, __builtin_new); #endif #if VG_WORDSIZE == 8 ALLOC_or_BOMB(m_libstc_plus_plus_star, _Znwm, __builtin_new); - ALLOC_or_BOMB(m_libc_dot_so_dot_6, _Znwm, __builtin_new); + ALLOC_or_BOMB(m_libc_dot_so_star, _Znwm, __builtin_new); #endif @@ -178,28 +178,28 @@ ALLOC_or_BOMB(m_libc_dot_so_dot_6, __builtin_new, __builtin_new); // operator new(unsigned long, std::nothrow_t const&), GNU mangling, 64-bit #if VG_WORDSIZE == 4 ALLOC_or_NULL(m_libstc_plus_plus_star, _ZnwjRKSt9nothrow_t, __builtin_new); - ALLOC_or_NULL(m_libc_dot_so_dot_6, _ZnwjRKSt9nothrow_t, __builtin_new); + ALLOC_or_NULL(m_libc_dot_so_star, _ZnwjRKSt9nothrow_t, __builtin_new); #endif #if VG_WORDSIZE == 8 ALLOC_or_NULL(m_libstc_plus_plus_star, _ZnwmRKSt9nothrow_t, __builtin_new); - ALLOC_or_NULL(m_libc_dot_so_dot_6, _ZnwmRKSt9nothrow_t, __builtin_new); + ALLOC_or_NULL(m_libc_dot_so_star, _ZnwmRKSt9nothrow_t, __builtin_new); #endif // operator new[](unsigned int), unmangled for some bizarre reason ALLOC_or_BOMB(m_libstc_plus_plus_star, __builtin_vec_new, __builtin_vec_new ); -ALLOC_or_BOMB(m_libc_dot_so_dot_6, __builtin_vec_new, __builtin_vec_new ); +ALLOC_or_BOMB(m_libc_dot_so_star, __builtin_vec_new, __builtin_vec_new ); // operator new[](unsigned int), GNU mangling, 32-bit platforms // operator new[](unsigned long), GNU mangling, 64-bit platforms #if VG_WORDSIZE == 4 ALLOC_or_BOMB(m_libstc_plus_plus_star, _Znaj, __builtin_vec_new ); - ALLOC_or_BOMB(m_libc_dot_so_dot_6, _Znaj, __builtin_vec_new ); + ALLOC_or_BOMB(m_libc_dot_so_star, _Znaj, __builtin_vec_new ); #endif #if VG_WORDSIZE == 8 ALLOC_or_BOMB(m_libstc_plus_plus_star, _Znam, __builtin_vec_new ); - ALLOC_or_BOMB(m_libc_dot_so_dot_6, _Znam, __builtin_vec_new ); + ALLOC_or_BOMB(m_libc_dot_so_star, _Znam, __builtin_vec_new ); #endif @@ -207,11 +207,11 @@ ALLOC_or_BOMB(m_libc_dot_so_dot_6, __builtin_vec_new, __builtin_vec_new ); // operator new[](unsigned long, std::nothrow_t const&), GNU mangling, 64-bit #if VG_WORDSIZE == 4 ALLOC_or_NULL(m_libstc_plus_plus_star, _ZnajRKSt9nothrow_t, __builtin_vec_new ); - ALLOC_or_NULL(m_libc_dot_so_dot_6, _ZnajRKSt9nothrow_t, __builtin_vec_new ); + ALLOC_or_NULL(m_libc_dot_so_star, _ZnajRKSt9nothrow_t, __builtin_vec_new ); #endif #if VG_WORDSIZE == 8 ALLOC_or_NULL(m_libstc_plus_plus_star, _ZnamRKSt9nothrow_t, __builtin_vec_new ); - ALLOC_or_NULL(m_libc_dot_so_dot_6, _ZnamRKSt9nothrow_t, __builtin_vec_new ); + ALLOC_or_NULL(m_libc_dot_so_star, _ZnamRKSt9nothrow_t, __builtin_vec_new ); #endif @@ -232,33 +232,33 @@ ALLOC_or_BOMB(m_libc_dot_so_dot_6, __builtin_vec_new, __builtin_vec_new ); // free FREE(m_libstc_plus_plus_star, free, free ); -FREE(m_libc_dot_so_dot_6, free, free ); +FREE(m_libc_dot_so_star, free, free ); // cfree FREE(m_libstc_plus_plus_star, cfree, free ); -FREE(m_libc_dot_so_dot_6, cfree, free ); +FREE(m_libc_dot_so_star, cfree, free ); // do we really need these? FREE(m_libstc_plus_plus_star, __builtin_delete, __builtin_delete ); -FREE(m_libc_dot_so_dot_6, __builtin_delete, __builtin_delete ); +FREE(m_libc_dot_so_star, __builtin_delete, __builtin_delete ); // operator delete(void*), GNU mangling FREE(m_libstc_plus_plus_star, _ZdlPv, __builtin_delete ); -FREE(m_libc_dot_so_dot_6, _ZdlPv, __builtin_delete ); +FREE(m_libc_dot_so_star, _ZdlPv, __builtin_delete ); // operator delete(void*, std::nothrow_t const&), GNU mangling FREE(m_libstc_plus_plus_star, _ZdlPvRKSt9nothrow_t, __builtin_delete ); -FREE(m_libc_dot_so_dot_6, _ZdlPvRKSt9nothrow_t, __builtin_delete ); +FREE(m_libc_dot_so_star, _ZdlPvRKSt9nothrow_t, __builtin_delete ); // operator delete[](void*), GNU mangling FREE(m_libstc_plus_plus_star, __builtin_vec_delete, __builtin_vec_delete ); -FREE(m_libc_dot_so_dot_6, __builtin_vec_delete, __builtin_vec_delete ); +FREE(m_libc_dot_so_star, __builtin_vec_delete, __builtin_vec_delete ); FREE(m_libstc_plus_plus_star, _ZdaPv, __builtin_vec_delete ); -FREE(m_libc_dot_so_dot_6, _ZdaPv, __builtin_vec_delete ); +FREE(m_libc_dot_so_star, _ZdaPv, __builtin_vec_delete ); // operator delete[](void*, std::nothrow_t const&), GNU mangling FREE(m_libstc_plus_plus_star, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); -FREE(m_libc_dot_so_dot_6, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); +FREE(m_libc_dot_so_star, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); #define CALLOC(soname, fnname) \ @@ -276,7 +276,7 @@ FREE(m_libc_dot_so_dot_6, _ZdaPvRKSt9nothrow_t, __builtin_vec_delete ); return v; \ } -CALLOC(m_libc_dot_so_dot_6, calloc); +CALLOC(m_libc_dot_so_star, calloc); #define REALLOC(soname, fnname) \ @@ -291,9 +291,9 @@ CALLOC(m_libc_dot_so_dot_6, calloc); if (ptrV == NULL) \ /* We need to call a malloc-like function; so let's use \ one which we know exists. */ \ - return VG_REPLACE_FUNCTION(libcZdsoZd6,malloc) (new_size); \ + return VG_REPLACE_FUNCTION(libcZdsoZa,malloc) (new_size); \ if (new_size <= 0) { \ - VG_REPLACE_FUNCTION(libcZdsoZd6,free)(ptrV); \ + VG_REPLACE_FUNCTION(libcZdsoZa,free)(ptrV); \ MALLOC_TRACE(" = 0"); \ return NULL; \ } \ @@ -303,7 +303,7 @@ CALLOC(m_libc_dot_so_dot_6, calloc); return v; \ } -REALLOC(m_libc_dot_so_dot_6, realloc); +REALLOC(m_libc_dot_so_star, realloc); #define MEMALIGN(soname, fnname) \ @@ -329,7 +329,7 @@ REALLOC(m_libc_dot_so_dot_6, realloc); return v; \ } -MEMALIGN(m_libc_dot_so_dot_6, memalign); +MEMALIGN(m_libc_dot_so_star, memalign); #define VALLOC(soname, fnname) \ @@ -337,10 +337,10 @@ MEMALIGN(m_libc_dot_so_dot_6, memalign); void* VG_REPLACE_FUNCTION(soname,fnname) ( SizeT size ); \ void* VG_REPLACE_FUNCTION(soname,fnname) ( SizeT size ) \ { \ - return VG_REPLACE_FUNCTION(libcZdsoZd6,memalign)(VKI_PAGE_SIZE, size); \ + return VG_REPLACE_FUNCTION(libcZdsoZa,memalign)(VKI_PAGE_SIZE, size); \ } -VALLOC(m_libc_dot_so_dot_6, valloc); +VALLOC(m_libc_dot_so_star, valloc); /* Various compatibility wrapper functions, for glibc and libstdc++. */ @@ -355,7 +355,7 @@ VALLOC(m_libc_dot_so_dot_6, valloc); return 1; \ } -MALLOPT(m_libc_dot_so_dot_6, mallopt); +MALLOPT(m_libc_dot_so_star, mallopt); #define POSIX_MEMALIGN(soname, fnname) \ @@ -371,7 +371,7 @@ MALLOPT(m_libc_dot_so_dot_6, mallopt); || (alignment & (alignment - 1)) != 0) \ return VKI_EINVAL; \ \ - mem = VG_REPLACE_FUNCTION(libcZdsoZd6,memalign)(alignment, size); \ + mem = VG_REPLACE_FUNCTION(libcZdsoZa,memalign)(alignment, size); \ \ if (mem != NULL) { \ *memptr = mem; \ @@ -381,7 +381,7 @@ MALLOPT(m_libc_dot_so_dot_6, mallopt); return VKI_ENOMEM; \ } -POSIX_MEMALIGN(m_libc_dot_so_dot_6, posix_memalign); +POSIX_MEMALIGN(m_libc_dot_so_star, posix_memalign); #define MALLOC_USABLE_SIZE(soname, fnname) \ @@ -403,7 +403,7 @@ POSIX_MEMALIGN(m_libc_dot_so_dot_6, posix_memalign); return pszB; \ } -MALLOC_USABLE_SIZE(m_libc_dot_so_dot_6, malloc_usable_size); +MALLOC_USABLE_SIZE(m_libc_dot_so_star, malloc_usable_size); /* Bomb out if we get any of these. */ @@ -423,11 +423,11 @@ static void panic(const char *str) panic(#fnname); \ } -PANIC(m_libc_dot_so_dot_6, pvalloc); -PANIC(m_libc_dot_so_dot_6, malloc_stats); -PANIC(m_libc_dot_so_dot_6, malloc_trim); -PANIC(m_libc_dot_so_dot_6, malloc_get_state); -PANIC(m_libc_dot_so_dot_6, malloc_set_state); +PANIC(m_libc_dot_so_star, pvalloc); +PANIC(m_libc_dot_so_star, malloc_stats); +PANIC(m_libc_dot_so_star, malloc_trim); +PANIC(m_libc_dot_so_star, malloc_get_state); +PANIC(m_libc_dot_so_star, malloc_set_state); // mi must be static; if it is auto then Memcheck thinks it is // uninitialised when used by the caller of this function, because Memcheck @@ -444,7 +444,7 @@ PANIC(m_libc_dot_so_dot_6, malloc_set_state); return mi; \ } -MALLINFO(m_libc_dot_so_dot_6, mallinfo); +MALLINFO(m_libc_dot_so_star, mallinfo); /* All the code in here is unused until this function is called */ diff --git a/memcheck/mac_replace_strmem.c b/memcheck/mac_replace_strmem.c index 87f313a3ad..16301ff9f0 100644 --- a/memcheck/mac_replace_strmem.c +++ b/memcheck/mac_replace_strmem.c @@ -118,7 +118,7 @@ void complain3 ( Char* s, void* dst, const void* src, int n ) } // Some handy Z-encoded names -#define m_libc_so_6 libcZdsoZd6 // libc.so.6 +#define m_libc_so_star libcZdsoZa // libc.so* #define m_ld_linux_so_2 ldZhlinuxZdsoZd2 // ld-linux.so.2 #define m_ld_linux_x86_64_so_2 ldZhlinuxZhx86Zh64ZdsoZd2 // ld-linux-x86-64.so.2 @@ -138,8 +138,8 @@ void complain3 ( Char* s, void* dst, const void* src, int n ) } // Apparently rindex() is the same thing as strrchr() -STRRCHR(m_libc_so_6, strrchr) -STRRCHR(m_libc_so_6, rindex) +STRRCHR(m_libc_so_star, strrchr) +STRRCHR(m_libc_so_star, rindex) STRRCHR(m_ld_linux_so_2, rindex) @@ -157,10 +157,10 @@ STRRCHR(m_ld_linux_so_2, rindex) } // Apparently index() is the same thing as strchr() -STRCHR(m_libc_so_6, strchr) +STRCHR(m_libc_so_star, strchr) STRCHR(m_ld_linux_so_2, strchr) STRCHR(m_ld_linux_x86_64_so_2, strchr) -STRCHR(m_libc_so_6, index) +STRCHR(m_libc_so_star, index) STRCHR(m_ld_linux_so_2, index) STRCHR(m_ld_linux_x86_64_so_2, index) @@ -186,7 +186,7 @@ STRCHR(m_ld_linux_x86_64_so_2, index) return dst_orig; \ } -STRCAT(m_libc_so_6, strcat) +STRCAT(m_libc_so_star, strcat) #define STRNCAT(soname, fnname) \ @@ -212,7 +212,7 @@ STRCAT(m_libc_so_6, strcat) return dst_orig; \ } -STRNCAT(m_libc_so_6, strncat) +STRNCAT(m_libc_so_star, strncat) #define STRNLEN(soname, fnname) \ @@ -224,7 +224,7 @@ STRNCAT(m_libc_so_6, strncat) return i; \ } -STRNLEN(m_libc_so_6, strnlen) +STRNLEN(m_libc_so_star, strnlen) // Note that this replacement often doesn't get used because gcc inlines @@ -240,7 +240,7 @@ STRNLEN(m_libc_so_6, strnlen) return i; \ } -STRLEN(m_libc_so_6, strlen) +STRLEN(m_libc_so_star, strlen) STRLEN(m_ld_linux_so_2, strlen) STRLEN(m_ld_linux_x86_64_so_2, strlen) @@ -266,7 +266,7 @@ STRLEN(m_ld_linux_x86_64_so_2, strlen) return dst_orig; \ } -STRCPY(m_libc_so_6, strcpy) +STRCPY(m_libc_so_star, strcpy) #define STRNCPY(soname, fnname) \ @@ -287,7 +287,7 @@ STRCPY(m_libc_so_6, strcpy) return dst_orig; \ } -STRNCPY(m_libc_so_6, strncpy) +STRNCPY(m_libc_so_star, strncpy) #define STRNCMP(soname, fnname) \ @@ -308,7 +308,7 @@ STRNCPY(m_libc_so_6, strncpy) } \ } -STRNCMP(m_libc_so_6, strncmp) +STRNCMP(m_libc_so_star, strncmp) #define STRCMP(soname, fnname) \ @@ -329,7 +329,7 @@ STRNCMP(m_libc_so_6, strncmp) return 0; \ } -STRCMP(m_libc_so_6, strcmp) +STRCMP(m_libc_so_star, strcmp) STRCMP(m_ld_linux_x86_64_so_2, strcmp) @@ -345,7 +345,7 @@ STRCMP(m_ld_linux_x86_64_so_2, strcmp) return NULL; \ } -MEMCHR(m_libc_so_6, memchr) +MEMCHR(m_libc_so_star, memchr) #define MEMCPY(soname, fnname) \ @@ -391,7 +391,7 @@ MEMCHR(m_libc_so_6, memchr) return dst; \ } -MEMCPY(m_libc_so_6, memcpy) +MEMCPY(m_libc_so_star, memcpy) #define MEMCMP(soname, fnname) \ @@ -417,8 +417,8 @@ MEMCPY(m_libc_so_6, memcpy) return 0; \ } -MEMCMP(m_libc_so_6, memcmp) -MEMCMP(m_libc_so_6, bcmp) +MEMCMP(m_libc_so_star, memcmp) +MEMCMP(m_libc_so_star, bcmp) /* Copy SRC to DEST, returning the address of the terminating '\0' in @@ -444,7 +444,7 @@ MEMCMP(m_libc_so_6, bcmp) return dst; \ } -STPCPY(m_libc_so_6, stpcpy) +STPCPY(m_libc_so_star, stpcpy) STPCPY(m_ld_linux_so_2, stpcpy) STPCPY(m_ld_linux_x86_64_so_2, stpcpy) @@ -461,7 +461,7 @@ STPCPY(m_ld_linux_x86_64_so_2, stpcpy) return s; \ } -MEMSET(m_libc_so_6, memset) +MEMSET(m_libc_so_star, memset) #define MEMMOVE(soname, fnname) \ @@ -483,7 +483,7 @@ MEMSET(m_libc_so_6, memset) return dst; \ } -MEMMOVE(m_libc_so_6, memmove) +MEMMOVE(m_libc_so_star, memmove) /* Find the first occurrence of C in S or the final NUL byte. */ @@ -500,7 +500,7 @@ MEMMOVE(m_libc_so_6, memmove) } \ } -GLIBC232_STRCHRNUL(m_libc_so_6, strchrnul) +GLIBC232_STRCHRNUL(m_libc_so_star, strchrnul) /* Find the first occurrence of C in S. */ @@ -516,7 +516,7 @@ GLIBC232_STRCHRNUL(m_libc_so_6, strchrnul) } \ } -GLIBC232_RAWMEMCHR(m_libc_so_6, rawmemchr) +GLIBC232_RAWMEMCHR(m_libc_so_star, rawmemchr) /*--------------------------------------------------------------------*/ -- 2.47.3