From 450f0fa6967f35a888d24c9ad37585f4e4134a1b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 17 Jun 2019 09:24:45 +0200 Subject: [PATCH] winebuild: Don't import standard C functions in Unix mode. Signed-off-by: Alexandre Julliard --- tools/winebuild/build.h | 2 + tools/winebuild/import.c | 90 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 382829cd68b..ad6e2a8289d 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -38,6 +38,8 @@ #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) + typedef enum { TYPE_VARIABLE, /* variable */ diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 6c68dbd4f0a..7cf065577b0 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -38,6 +38,93 @@ #include "wine/list.h" #include "build.h" +/* standard C functions that are also exported from ntdll */ +static const char *stdc_names[] = +{ + "abs", + "atan", + "atoi", + "atol", + "bsearch", + "ceil", + "cos", + "fabs", + "floor", + "isalnum", + "isalpha", + "iscntrl", + "isdigit", + "isgraph", + "islower", + "isprint", + "ispunct", + "isspace", + "isupper", + "iswalpha", + "iswctype", + "iswdigit", + "iswlower", + "iswspace", + "iswxdigit", + "isxdigit", + "labs", + "log", + "mbstowcs", + "memchr", + "memcmp", + "memcpy", + "memmove", + "memset", + "pow", + "qsort", + "sin", + "sprintf", + "sqrt", + "sscanf", + "strcat", + "strchr", + "strcmp", + "strcpy", + "strcspn", + "strlen", + "strncat", + "strncmp", + "strncpy", + "strnlen", + "strpbrk", + "strrchr", + "strspn", + "strstr", + "strtol", + "strtoul", + "swprintf", + "tan", + "tolower", + "toupper", + "towlower", + "towupper", + "vsprintf", + "wcscat", + "wcschr", + "wcscmp", + "wcscpy", + "wcscspn", + "wcslen", + "wcsncat", + "wcsncmp", + "wcsncpy", + "wcspbrk", + "wcsrchr", + "wcsspn", + "wcsstr", + "wcstok", + "wcstol", + "wcstombs", + "wcstoul" +}; + +static struct strarray stdc_functions = { stdc_names, ARRAY_SIZE(stdc_names), ARRAY_SIZE(stdc_names) }; + struct import_func { const char *name; @@ -566,7 +653,8 @@ void read_undef_symbols( DLLSPEC *spec, char **argv ) add_undef_import( p + strlen( import_func_prefix ), 0 ); else if (!strncmp( p, import_ord_prefix, strlen(import_ord_prefix) )) add_undef_import( p + strlen( import_ord_prefix ), 1 ); - else strarray_add( &undef_symbols, xstrdup( p ), NULL ); + else if (!unix_lib || !find_name( p, &stdc_functions )) + strarray_add( &undef_symbols, xstrdup( p ), NULL ); } if ((err = pclose( f ))) warning( "%s failed with status %d\n", cmd, err ); free( cmd );