Commit 36048242 authored by Alexandre Julliard's avatar Alexandre Julliard

If supported by the linker, prevent the ELF loader from calling the

dll constructors at load time and call them from the dll entry point instead.
parent 925a2f93
......@@ -13649,6 +13649,72 @@ echo "${ECHO_T}$ac_cv_c_dll_zdefs" >&6
LDDLL="$LDDLL,-z,defs"
fi
echo "$as_me:$LINENO: checking whether the linker accepts -init and -fini" >&5
echo $ECHO_N "checking whether the linker accepts -init and -fini... $ECHO_C" >&6
if test "${ac_cv_c_dll_init_fini+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_wine_try_cflags_saved=$CFLAGS
CFLAGS="$CFLAGS -fPIC -shared -Wl,-Bsymbolic,-init,__wine_spec_init,-fini,__wine_spec_fini"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_c_dll_init_fini="yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_c_dll_init_fini="no"
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ac_wine_try_cflags_saved
fi
echo "$as_me:$LINENO: result: $ac_cv_c_dll_init_fini" >&5
echo "${ECHO_T}$ac_cv_c_dll_init_fini" >&6
if test "$ac_cv_c_dll_init_fini" = "yes"
then
cat >>confdefs.h <<\_ACEOF
#define HAVE_LINKER_INIT_FINI 1
_ACEOF
LDDLL="$LDDLL,-init,__wine_spec_init,-fini,__wine_spec_fini"
fi
echo "$as_me:$LINENO: checking whether the linker accepts --export-dynamic" >&5
echo $ECHO_N "checking whether the linker accepts --export-dynamic... $ECHO_C" >&6
if test "${ac_cv_c_export_dynamic+set}" = set; then
......
......@@ -880,6 +880,15 @@ case $host_os in
LDDLL="$LDDLL,-z,defs"
fi
AC_CACHE_CHECK([whether the linker accepts -init and -fini], ac_cv_c_dll_init_fini,
[WINE_TRY_CFLAGS([-fPIC -shared -Wl,-Bsymbolic,-init,__wine_spec_init,-fini,__wine_spec_fini],
ac_cv_c_dll_init_fini="yes",ac_cv_c_dll_init_fini="no")])
if test "$ac_cv_c_dll_init_fini" = "yes"
then
AC_DEFINE(HAVE_LINKER_INIT_FINI,1,[Define if the linker supports renaming the init and fini functions])
LDDLL="$LDDLL,-init,__wine_spec_init,-fini,__wine_spec_fini"
fi
AC_CACHE_CHECK([whether the linker accepts --export-dynamic], ac_cv_c_export_dynamic,
[WINE_TRY_CFLAGS([-fPIC -Wl,--export-dynamic],
ac_cv_c_export_dynamic="yes",ac_cv_c_export_dynamic="no")])
......
......@@ -618,9 +618,12 @@ static BOOL process_init( char *argv[], char **environ )
RTL_USER_PROCESS_PARAMETERS *params;
PEB *peb = NtCurrentTeb()->Peb;
HANDLE hstdin, hstdout, hstderr;
extern void __wine_dbg_kernel32_init(void);
PTHREAD_Init();
__wine_dbg_kernel32_init(); /* hack: register debug channels early */
setbuf(stdout,NULL);
setbuf(stderr,NULL);
setlocale(LC_CTYPE,"");
......
......@@ -1956,8 +1956,10 @@ void __wine_process_init( int argc, char *argv[] )
NTSTATUS status;
ANSI_STRING func_name;
void (* DECLSPEC_NORETURN init_func)();
extern void __wine_dbg_ntdll_init(void);
thread_init();
__wine_dbg_ntdll_init(); /* hack: register debug channels early */
/* setup the load callback and create ntdll modref */
wine_dll_set_callback( load_builtin_callback );
......
......@@ -462,6 +462,11 @@
#undef HAVE_LIBXXSHM
/*
Define if the linker supports renaming the init
and fini functions */
#undef HAVE_LINKER_INIT_FINI
/*
Define to 1 if you have the <link.h>
header file. */
#undef HAVE_LINK_H
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment