Mercurial > mplayer.hg
comparison loader/pe_image.c @ 1411:db849cee5777
Pre-allocate some stack space to work around a problem with DLL alloca() code
on a linux kernel.
author | jkeil |
---|---|
date | Sun, 29 Jul 2001 10:17:53 +0000 |
parents | d8c1b0b38edc |
children | ce45cce7f7a5 |
comparison
equal
deleted
inserted
replaced
1410:eda16e490ae7 | 1411:db849cee5777 |
---|---|
882 * Load the PE main .EXE. All other loading is done by PE_LoadLibraryExA | 882 * Load the PE main .EXE. All other loading is done by PE_LoadLibraryExA |
883 * FIXME: this function should use PE_LoadLibraryExA, but currently can't | 883 * FIXME: this function should use PE_LoadLibraryExA, but currently can't |
884 * due to the PROCESS_Create stuff. | 884 * due to the PROCESS_Create stuff. |
885 */ | 885 */ |
886 | 886 |
887 #if 0 | |
888 /* | 887 /* |
889 * so this is a dirty hack. | 888 * This is a dirty hack. |
890 * Why do we need it? | 889 * The win32 DLLs contain an alloca routine, that first probes the soon |
891 * | 890 * to be allocated new memory *below* the current stack pointer in 4KByte |
892 * Disable it for now, let's see if it breaks something | 891 * increments. After the mem probing below the current %esp, the stack |
892 * pointer is finally decremented to make room for the "alloca"ed memory. | |
893 * Maybe the probing code is intended to extend the stack on a windows box. | |
894 * Anyway, the linux kernel does *not* extend the stack by simply accessing | |
895 * memory below %esp; it segfaults. | |
896 * The extend_stack_for_dll_alloca() routine just preallocates a big chunk | |
897 * of memory on the stack, for use by the DLLs alloca routine. | |
893 */ | 898 */ |
894 static void This_Is_Dirty_Hack(void) | 899 static void extend_stack_for_dll_alloca(void) |
895 { | 900 { |
896 void* mem=alloca(0x20000); | 901 void* mem=alloca(0x20000); |
897 *(int*)mem=0x1234; | 902 *(int*)mem=0x1234; |
898 } | 903 } |
899 #endif | |
900 | 904 |
901 | 905 |
902 /* Called if the library is loaded or freed. | 906 /* Called if the library is loaded or freed. |
903 * NOTE: if a thread attaches a DLL, the current thread will only do | 907 * NOTE: if a thread attaches a DLL, the current thread will only do |
904 * DLL_PROCESS_ATTACH. Only new created threads do DLL_THREAD_ATTACH | 908 * DLL_PROCESS_ATTACH. Only new created threads do DLL_THREAD_ATTACH |
937 case DLL_THREAD_ATTACH: | 941 case DLL_THREAD_ATTACH: |
938 TRACE("DLL_THREAD_ATTACH) "); | 942 TRACE("DLL_THREAD_ATTACH) "); |
939 break; | 943 break; |
940 } | 944 } |
941 TRACE("for %s\n", wm->filename); | 945 TRACE("for %s\n", wm->filename); |
942 #if 0 | 946 extend_stack_for_dll_alloca(); |
943 This_Is_Dirty_Hack(); | |
944 #endif | |
945 retv = entry( wm->module, type, lpReserved ); | 947 retv = entry( wm->module, type, lpReserved ); |
946 } | 948 } |
947 | 949 |
948 return retv; | 950 return retv; |
949 } | 951 } |