I found the following working solution. First create file memcpy.c:
#include <string.h>
/* some systems do not have newest memcpy@@GLIBC_2.14 - stay with old good one */
asm (".symver memcpy, memcpy@GLIBC_2.2.5");
void *__wrap_memcpy(void *dest, const void *src, size_t n)
{
return memcpy(dest, src, n);
}
No additional CFLAGS needed to compile this file. Then link your program with -Wl,–wrap=memcpy.
Related Contents:
- Why does the order of ‘-l’ option in gcc matter? [duplicate]
- Why do I have to define LD_LIBRARY_PATH with an export every time I run my application?
- Why does the C preprocessor interpret the word “linux” as the constant “1”?
- Build .so file from .c file using gcc command line
- Is errno thread-safe?
- How to print the ld(linker) search path
- What is the advantage of GCC’s __builtin_expect in if else statements?
- Where is PATH_MAX defined in Linux?
- Ask GDB to list all functions in a program
- How to set up a cron job to run an executable every hour?
- Compilation fails with “relocation R_X86_64_32 against `.rodata.str1.8′ can not be used when making a shared object”
- Finding out what the GCC include path is [duplicate]
- Where is the header file on Linux? Why can’t I find ? [duplicate]
- Why does malloc initialize the values to 0 in gcc?
- How can I find the header files of the C programming language in Linux?
- Floating point exception ( SIGFPE ) on ‘int main(){ return(0); }’
- How to use gdb with LD_PRELOAD
- Invoking GCC as “cc” versus “gcc”
- How can I get what my main function has returned?
- Hide password input on terminal
- How does the C preprocessor handle circular dependencies?
- Weak symbol aliases on OS X similar to those on Linux, or a closest equivalent?
- Can I mix static and shared-object libraries when linking?
- How to check if a given file descriptor stored in a variable is still valid?
- When / How does Linux load shared libraries into address space?
- Merge multiple .so shared libraries
- Query on -ffunction-section & -fdata-sections options of gcc
- How can I suppress “unused parameter” warnings in C?
- Where does gcc look for C and C++ header files?
- How do I pass a command line argument while starting up GDB in Linux? [duplicate]
- Static assert in C
- What does [ N … M ] mean in C aggregate initializers?
- Proper way to create unique_ptr that holds an allocated array
- How to solve “ptrace operation not permitted” when trying to attach GDB to a process?
- How do I compile the asm generated by GCC?
- Recommended GCC warning options for C [closed]
- How to get 100% CPU usage from a C program
- The difference between stdout and STDOUT_FILENO
- Why is this code using strlen heavily 6.5x slower with GCC optimizations enabled?
- Why is memcmp(a, b, 4) only sometimes optimized to a uint32 comparison?
- Tell gcc to specifically unroll a loop
- Does free() set errno?
- Why does declaring main as an array compile?
- When to use pthread_exit() and when to use pthread_join() in Linux?
- What is -ffreestanding option in gcc?
- how to find gcc version on mac
- Cannot find libcrypto in Ubuntu
- Why does this memory address %fs:0x28 ( fs[0x28] ) have a random value?
- C header files and compilation/linking
- C Linking Error: undefined reference to ‘main’