diff options
-rw-r--r-- | hw/xfree86/loader/elfloader.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/hw/xfree86/loader/elfloader.c b/hw/xfree86/loader/elfloader.c index a9fcfdf7b..d25ef44c6 100644 --- a/hw/xfree86/loader/elfloader.c +++ b/hw/xfree86/loader/elfloader.c @@ -921,7 +921,7 @@ ELFCreateGOT(ELFModulePtr elffile, int maxalign) ErrorF("ELFCreateGOT() Unable to reallocate memory!!!!\n"); return FALSE; } -# if defined(linux) && defined(__ia64__) || defined(__OpenBSD__) +# if defined(linux) || defined(__OpenBSD__) { unsigned long page_size = getpagesize(); unsigned long round; @@ -2760,10 +2760,16 @@ ELFCollectSections(ELFModulePtr elffile, int pass, int *totalsize, elffile->lsection[j].size = SecSize(i); elffile->lsection[j].flags = flags; switch (SecType(i)) { -#ifdef __OpenBSD__ +#if defined(linux) || defined(__OpenBSD__) case SHT_PROGBITS: - mprotect(elffile->lsection[j].saddr, SecSize(i), - PROT_READ | PROT_WRITE | PROT_EXEC); + { + unsigned long page_size = getpagesize(); + unsigned long round; + + round = (unsigned long)elffile->lsection[j].saddr & (page_size -1); + mprotect( (char *)elffile->lsection[j].saddr - round, + SecSize(i) + round, PROT_READ | PROT_WRITE | PROT_EXEC); + } break; #endif case SHT_SYMTAB: @@ -2958,7 +2964,7 @@ ELFLoadModule(loaderPtr modrec, int elffd, LOOKUP **ppLookup) ErrorF("Unable to allocate ELF sections\n"); return NULL; } -# if defined(linux) && defined(__ia64__) || defined(__OpenBSD__) +# if defined(linux) || defined(__OpenBSD__) { unsigned long page_size = getpagesize(); unsigned long round; |