summaryrefslogtreecommitdiffstats
path: root/loader
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-12-03 20:26:00 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-12-03 20:26:00 +0000
commit190f0807911663b82006f86134715bed99a2238e (patch)
tree0a92a33db2ad3676a4c7ad07dbeb0c4a132539ff /loader
parent80439005c72d6f48fb4eb9753b37fe0288914576 (diff)
downloadmpv-190f0807911663b82006f86134715bed99a2238e.tar.bz2
mpv-190f0807911663b82006f86134715bed99a2238e.tar.xz
mmap memory area for generated code to avoid crashes on machines which
support noexec git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21478 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'loader')
-rw-r--r--loader/win32.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/loader/win32.c b/loader/win32.c
index 60b35d724f..aacd71ed4f 100644
--- a/loader/win32.c
+++ b/loader/win32.c
@@ -70,6 +70,9 @@ for DLL to know too much about its environment.
#include <kstat.h>
#endif
+#include <sys/mman.h>
+#include "osdep/mmap_anon.h"
+
#if HAVE_VSSCANF
int vsscanf( const char *str, const char *format, va_list ap);
#else
@@ -5299,14 +5302,18 @@ static void ext_stubs(void)
#define MAX_STUB_SIZE 0x60
#define MAX_NUM_STUBS 200
static int pos=0;
-static char extcode[MAX_NUM_STUBS * MAX_STUB_SIZE];
+static char *extcode = NULL;
static void* add_stub(void)
{
int i;
int found = 0;
// generated code in runtime!
- char* answ = extcode + pos * MAX_STUB_SIZE;
+ char* answ;
+ if (!extcode)
+ extcode = mmap_anon(NULL, MAX_NUM_STUBS * MAX_STUB_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, 0);
+ answ = extcode + pos * MAX_STUB_SIZE;
if (pos >= MAX_NUM_STUBS) {
printf("too many stubs, expect crash\n");
return NULL;