• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2017 Google Inc.  All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
7 
8 #include <string.h>
9 
10 // On x86-64 Linux with glibc, we link against the 2.2.5 version of memcpy so
11 // that we avoid depending on the 2.14 version of the symbol. This way,
12 // distributions that are using pre-2.14 versions of glibc can successfully use
13 // the gem we distribute
14 // (https://github.com/protocolbuffers/protobuf/issues/2783).
15 //
16 // This wrapper is enabled by passing the linker flags -Wl,-wrap,memcpy in
17 // extconf.rb.
18 #ifdef __linux__
19 #if defined(__x86_64__) && defined(__GNU_LIBRARY__)
20 __asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
__wrap_memcpy(void * dest,const void * src,size_t n)21 void *__wrap_memcpy(void *dest, const void *src, size_t n) {
22   return memcpy(dest, src, n);
23 }
24 #else
__wrap_memcpy(void * dest,const void * src,size_t n)25 void *__wrap_memcpy(void *dest, const void *src, size_t n) {
26   return memmove(dest, src, n);
27 }
28 #endif
29 #endif
30