From: Wuweijia <wuw...@hu...> - 2018-04-04 12:43:02
|
HI Why I call the strcmp, but function stack show that the strcat is called not the strcmp, but the file is belong to the function strcmp Can you show the how to replace the strcmp with "STRCMP(VG_Z_LIBC_SONAME, strcmp)", and then I can follow the code to find out why. I can find the code you set the LD_PRELOAD , but symbol name is not match, I do not know how you replace the strcmp with STRCMP(VG_Z_LIBC_SONAME, strcmp). Can you help to point out the function do the job replace the strcmp with STRCMP(VG_Z_LIBC_SONAME, strcmp)", Valgrind 3.12. CPU:arm The source as below: #include <errno.h> #include <limits.h> #include <stdatomic.h> #include <string.h> #include <sys/cdefs.h> #include <sys/mman.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> _Atomic(unsigned int ) g_status; int main(int argc __unused , char ** argv __unused ) { unsigned int init = 1; int flag = 1; unsigned int expect = random(); unsigned int value = 2; atomic_init(&g_status, init); if (__predict_true(atomic_compare_exchange_strong_explicit(&g_status, &expect, value, memory_order_acquire, memory_order_relaxed))) { flag = 0; } printf("Done flag:%d cmp:%d \n", flag, strcmp("aaaa", "cccc") ); ---------this line is number 27 return 1; } Valgrind show me output : ==30141== Invalid write of size 4 ==30141== at 0x4C27CAE: strcat (strcmp.c:3) ==30141== by 0x108871: main (testClang.c:27) ==30141== Address 0xfeb445bc is on thread 1's stack ==30141== 12 bytes below stack pointer BR Owen |