Permalink
Browse files

core, bugfix: use check_c_source_compiles to check glibc_2.2.5, fix a…

…lpine compile error.
  • Loading branch information...
xicilion committed Nov 8, 2017
1 parent ad39cae commit c301b9085cc2cb7e567a2da81f92f040eb0c5416
Showing with 20 additions and 14 deletions.
  1. +7 −1 fibjs/CMakeLists.txt
  2. +12 −13 fibjs/src/base/fuck_sym.cpp
  3. +1 −0 fibjs/tools/config.h.in
View
@@ -19,7 +19,13 @@ set(BIN_DIR ${PROJECT_SOURCE_DIR}/../bin/${OS}_${ARCH}_${BUILD_TYPE})
set(EXECUTABLE_OUTPUT_PATH ${BIN_DIR})
include(CheckIncludeFiles)
include(CheckCSourceCompiles)
check_include_files(iconv.h HAVE_ICONV_H)
check_c_source_compiles("#include <string.h>
__asm__(\".symver memcpy,memcpy@GLIBC_2.2.5\");
void main(void){char buf[4]; memcpy(buf, \"1234\", 4);}" HAVE_GLIB_C_225_H)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tools/gitinfo.h.in ${CMAKE_CURRENT_BINARY_DIR}/gitinfo.h)
@@ -54,7 +60,7 @@ if(${BUILD_TYPE} STREQUAL "release")
set(link_flags "${link_flags} ${BUILD_OPTION}")
add_definitions(-DNDEBUG=1)
if(${OS} STREQUAL "Linux" AND ${ARCH} STREQUAL "amd64")
if(HAVE_GLIB_C_225_H)
set(link_flags "${link_flags} -Wl,--wrap=memcpy")
endif()
@@ -1,39 +1,40 @@
#include <exlib/include/osconfig.h>
#include "config.h"
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef Linux
extern "C" {
#if defined(amd64)
#ifdef HAVE_GLIB_C_225_H
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
void* __wrap_memcpy(void* dest, const void* src, size_t n)
{
return memcpy(dest, src, n);
}
#endif
void __longjmp_chk()
// GLIBC_2.7
size_t __fread_chk(void*, size_t, size_t, size_t, FILE*)
{
puts("unexpected __longjmp_chk.");
puts("unexpected __fread_chk.");
exit(-1);
return 0;
}
size_t __fread_chk(void*, size_t, size_t, size_t, FILE*)
// GLIBC_2.11
void __longjmp_chk()
{
puts("unexpected __fread_chk.");
puts("unexpected __longjmp_chk.");
exit(-1);
return 0;
}
int32_t __isoc99_sscanf(const char* s, const char* format, ...)
// GLIBC_2.11
int __isoc99_sscanf(const char* s, const char* format, ...)
{
va_list arg;
int32_t done;
int done;
va_start(arg, format);
done = vsscanf(s, format, arg);
@@ -42,5 +43,3 @@ int32_t __isoc99_sscanf(const char* s, const char* format, ...)
return done;
}
}
#endif
View
@@ -1,3 +1,4 @@
#cmakedefine HAVE_ICONV_H 1
#cmakedefine HAVE_GLIB_C_225_H 1

0 comments on commit c301b90

Please sign in to comment.