Use old memcpy for wrappers
diff --git a/BUILD b/BUILD
index c40ee51..92d0e69 100644
--- a/BUILD
+++ b/BUILD
@@ -96,6 +96,7 @@
"src/core/support/time_precise.c",
"src/core/support/time_win32.c",
"src/core/support/tls_pthread.c",
+ "src/core/support/wrap_memcpy.c",
],
hdrs = [
"include/grpc/support/alloc.h",
@@ -1171,6 +1172,7 @@
"src/core/support/time_precise.c",
"src/core/support/time_win32.c",
"src/core/support/tls_pthread.c",
+ "src/core/support/wrap_memcpy.c",
],
hdrs = [
"include/grpc/support/alloc.h",
diff --git a/Makefile b/Makefile
index 794778d..53974d1 100644
--- a/Makefile
+++ b/Makefile
@@ -2247,6 +2247,7 @@
src/core/support/time_precise.c \
src/core/support/time_win32.c \
src/core/support/tls_pthread.c \
+ src/core/support/wrap_memcpy.c \
PUBLIC_HEADERS_C += \
include/grpc/support/alloc.h \
@@ -3884,15 +3885,15 @@
$(LIBDIR)/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP)
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_csharp_ext.def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext-imp.a -o $(LIBDIR)/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS)
+ $(Q) $(LD) $(LDFLAGS) -Wl,-wrap,memcpy -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=$(LIBDIR)/$(CONFIG)/grpc_csharp_ext.def -Wl,--out-implib=$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext-imp.a -o $(LIBDIR)/$(CONFIG)/grpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS)
else
$(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT): $(LIBGRPC_CSHARP_EXT_OBJS) $(ZLIB_DEP) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_DEP)
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
ifeq ($(SYSTEM),Darwin)
- $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name libgrpc_csharp_ext.$(SHARED_EXT) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS)
+ $(Q) $(LD) $(LDFLAGS) -Wl,-wrap,memcpy -L$(LIBDIR)/$(CONFIG) -install_name libgrpc_csharp_ext.$(SHARED_EXT) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS)
else
- $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.0 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS)
+ $(Q) $(LD) $(LDFLAGS) -Wl,-wrap,memcpy -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.0 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.$(SHARED_EXT) $(LIBGRPC_CSHARP_EXT_OBJS) $(LDLIBS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS)
$(Q) ln -sf libgrpc_csharp_ext.$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.so.0
$(Q) ln -sf libgrpc_csharp_ext.$(SHARED_EXT) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext.so
endif
diff --git a/binding.gyp b/binding.gyp
index 133f8f4..0e4181c 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -528,6 +528,7 @@
'src/core/support/time_precise.c',
'src/core/support/time_win32.c',
'src/core/support/tls_pthread.c',
+ 'src/core/support/wrap_memcpy.c',
],
"conditions": [
['OS == "mac"', {
@@ -743,6 +744,11 @@
"boringssl",
"z",
]
+ }],
+ ['OS=="linux"', {
+ 'ldflags': [
+ '-Wl,-wrap,memcpy'
+ ]
}]
],
"target_name": "grpc_node",
diff --git a/build.yaml b/build.yaml
index f8d18fb..41b09aa 100644
--- a/build.yaml
+++ b/build.yaml
@@ -511,6 +511,7 @@
- src/core/support/time_precise.c
- src/core/support/time_win32.c
- src/core/support/tls_pthread.c
+ - src/core/support/wrap_memcpy.c
filegroups:
- grpc_codegen
secure: false
@@ -872,6 +873,7 @@
deps:
- grpc
- gpr
+ LDFLAGS: -Wl,-wrap,memcpy
deps_linkage: static
dll: only
vs_config_type: DynamicLibrary
diff --git a/gRPC.podspec b/gRPC.podspec
index 30b2787..70e33ed 100644
--- a/gRPC.podspec
+++ b/gRPC.podspec
@@ -163,6 +163,7 @@
'src/core/support/time_precise.c',
'src/core/support/time_win32.c',
'src/core/support/tls_pthread.c',
+ 'src/core/support/wrap_memcpy.c',
'src/core/security/auth_filters.h',
'src/core/security/base64.h',
'src/core/security/credentials.h',
diff --git a/grpc.gemspec b/grpc.gemspec
index 585d3ec..13e79d5 100755
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -146,6 +146,7 @@
s.files += %w( src/core/support/time_precise.c )
s.files += %w( src/core/support/time_win32.c )
s.files += %w( src/core/support/tls_pthread.c )
+ s.files += %w( src/core/support/wrap_memcpy.c )
s.files += %w( include/grpc/grpc_security.h )
s.files += %w( include/grpc/byte_buffer.h )
s.files += %w( include/grpc/byte_buffer_reader.h )
diff --git a/package.json b/package.json
index 0a3440e..f47a363 100644
--- a/package.json
+++ b/package.json
@@ -503,6 +503,7 @@
"src/core/support/time_precise.c",
"src/core/support/time_win32.c",
"src/core/support/tls_pthread.c",
+ "src/core/support/wrap_memcpy.c",
"third_party/boringssl/crypto/aes/internal.h",
"third_party/boringssl/crypto/asn1/asn1_locl.h",
"third_party/boringssl/crypto/bio/internal.h",
diff --git a/setup.py b/setup.py
index 01e9180..6699263 100644
--- a/setup.py
+++ b/setup.py
@@ -80,10 +80,19 @@
EXTENSION_LIBRARIES = ('m',)
if not "darwin" in sys.platform:
- EXTENSION_LIBRARIES += ('rt',)
+ EXTENSION_LIBRARIES += ('rt',)
DEFINE_MACROS = (('OPENSSL_NO_ASM', 1),)
+CFLAGS = (,)
+LDFLAGS = (,)
+if "linux" in sys.platform:
+ LDFLAGS += ('-Wl,-wrap,memcpy',)
+if "linux" in sys.platform or "darwin" in sys.platform:
+ CFLAGS += ('-fvisibility=hidden',)
+ DEFINE_MACROS += (('PyMODINIT_FUNC', '__attribute__((visibility ("default"))) void'),)
+
+
def cython_extensions(package_names, module_names, include_dirs, libraries,
define_macros, build_with_cython=False):
if ENABLE_CYTHON_TRACING:
diff --git a/src/core/support/wrap_memcpy.c b/src/core/support/wrap_memcpy.c
new file mode 100644
index 0000000..b191d03
--- /dev/null
+++ b/src/core/support/wrap_memcpy.c
@@ -0,0 +1,46 @@
+/*
+*
+* Copyright 2016, Google Inc.
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are
+* met:
+*
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following disclaimer
+* in the documentation and/or other materials provided with the
+* distribution.
+* * Neither the name of Google Inc. nor the names of its
+* contributors may be used to endorse or promote products derived from
+* this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+#include <string.h>
+
+/* Provide a wrapped memcpy for targets that need to be backwards
+ * compatible with older libc's.
+ *
+ * Enable by setting LDFLAGS=-Wl,-wrap,memcpy when linking.
+ */
+
+__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
+
+void *__wrap_memcpy(void *destination, const void *source, size_t num) {
+ return memcpy(destination, source, num);
+}
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 708091d..ad4714d 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -72,6 +72,7 @@
'src/core/support/time_precise.c',
'src/core/support/time_win32.c',
'src/core/support/tls_pthread.c',
+ 'src/core/support/wrap_memcpy.c',
'src/core/httpcli/httpcli_security_connector.c',
'src/core/security/base64.c',
'src/core/security/client_auth_filter.c',
diff --git a/src/ruby/ext/grpc/extconf.rb b/src/ruby/ext/grpc/extconf.rb
index 018353c..3d80985 100644
--- a/src/ruby/ext/grpc/extconf.rb
+++ b/src/ruby/ext/grpc/extconf.rb
@@ -80,6 +80,8 @@
$LDFLAGS << ' -fprofile-arcs -ftest-coverage -rdynamic'
end
+$LDFLAGS << ' -Wl,-wrap,memcpy'
+
$CFLAGS << ' -std=c99 '
$CFLAGS << ' -Wall '
$CFLAGS << ' -Wextra '
diff --git a/templates/Makefile.template b/templates/Makefile.template
index 1770d0f..a3d3780 100644
--- a/templates/Makefile.template
+++ b/templates/Makefile.template
@@ -1598,6 +1598,10 @@
if lib.language == 'c++':
common = common + ' $(LDLIBSXX) $(LDLIBS_PROTOBUF)'
+
+ ldflags = '$(LDFLAGS)'
+ if lib.get('LDFLAGS', None):
+ ldflags += ' ' + lib['LDFLAGS']
%>
% if lib.build == "all":
@@ -1605,15 +1609,15 @@
${out_base}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${mingw_lib_deps}
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
- $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=${out_base}.def -Wl,--out-implib=${out_libbase}-imp.a -o ${out_base}.$(SHARED_EXT) ${common}${mingw_libs}
+ $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,--output-def=${out_base}.def -Wl,--out-implib=${out_libbase}-imp.a -o ${out_base}.$(SHARED_EXT) ${common}${mingw_libs}
else
${out_libbase}.$(SHARED_EXT): $(LIB${lib.name.upper()}_OBJS) ${lib_deps}
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
ifeq ($(SYSTEM),Darwin)
- $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
+ $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -install_name lib${lib.name}.$(SHARED_EXT) -dynamiclib -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
else
- $(Q) ${ld} $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
+ $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.version.major} -o ${out_libbase}.$(SHARED_EXT) ${common}${libs}
$(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so.${settings.version.major}
$(Q) ln -sf lib${lib.name}.$(SHARED_EXT) ${out_libbase}.so
endif
diff --git a/templates/binding.gyp.template b/templates/binding.gyp.template
index a913585..31c9f8c 100644
--- a/templates/binding.gyp.template
+++ b/templates/binding.gyp.template
@@ -230,6 +230,11 @@
% endif
% endfor
]
+ }],
+ ['OS=="linux"', {
+ 'ldflags': [
+ '-Wl,-wrap,memcpy'
+ ]
}]
],
"target_name": "${module.name}",
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index cd49a19..1760380 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -1150,7 +1150,8 @@
src/core/support/time_posix.c \
src/core/support/time_precise.c \
src/core/support/time_win32.c \
-src/core/support/tls_pthread.c
+src/core/support/tls_pthread.c \
+src/core/support/wrap_memcpy.c
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json
index aef0023..5053855 100644
--- a/tools/run_tests/sources_and_headers.json
+++ b/tools/run_tests/sources_and_headers.json
@@ -2929,7 +2929,8 @@
"src/core/support/time_precise.c",
"src/core/support/time_precise.h",
"src/core/support/time_win32.c",
- "src/core/support/tls_pthread.c"
+ "src/core/support/tls_pthread.c",
+ "src/core/support/wrap_memcpy.c"
]
},
{
diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj b/vsprojects/vcxproj/gpr/gpr.vcxproj
index b20d6ff..2d08124 100644
--- a/vsprojects/vcxproj/gpr/gpr.vcxproj
+++ b/vsprojects/vcxproj/gpr/gpr.vcxproj
@@ -293,6 +293,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\core\support\tls_pthread.c">
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\support\wrap_memcpy.c">
+ </ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters
index 85d8ec8..1480f33 100644
--- a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters
+++ b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters
@@ -127,6 +127,9 @@
<ClCompile Include="$(SolutionDir)\..\src\core\support\tls_pthread.c">
<Filter>src\core\support</Filter>
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\core\support\wrap_memcpy.c">
+ <Filter>src\core\support</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(SolutionDir)\..\include\grpc\support\alloc.h">