Skip to content

Instantly share code, notes, and snippets.

@nicky-zs
Created November 19, 2013 06:31
Show Gist options
  • Save nicky-zs/7541169 to your computer and use it in GitHub Desktop.
Save nicky-zs/7541169 to your computer and use it in GitHub Desktop.
One way to solve the glibc compatibility problem. In my case, when building a program with libthrift.a on linux with glibc version 2.15, ld always links memcpy@GLIBC_2.14 which cannot be found on systems with glibc version < 2.14. So, use this file to define a symbol __wrap_memcpy and use -Wl,--wrap=memcpy to tell ld using this symbol when meeti…
#include <string.h>
void *__memcpy_glibc_2_2_5(void *, const void *, size_t);
asm(".symver __memcpy_glibc_2_2_5, memcpy@GLIBC_2.2.5");
void *__wrap_memcpy(void *dest, const void *src, size_t n)
{
return __memcpy_glibc_2_2_5(dest, src, n);
}
@nicky-zs
Copy link
Author

@rockeet
Copy link

rockeet commented Jun 5, 2017

We also trapped by this issue, glibc authors are brain damaged son of bitch!

@foundkey
Copy link

if build with g++, should around extern "C" {}, resolve undefine reference error

extern "C"{
void *__memcpy_glibc_2_2_5(void *, const void *, size_t);
}

asm(".symver __memcpy_glibc_2_2_5, memcpy@GLIBC_2.2.5");

extern "C" {
void *__wrap_memcpy(void *dest, const void *src, size_t n)
{
    return __memcpy_glibc_2_2_5(dest, src, n); 
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment