]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Don't give the heap execute permission - the linux kernel doesn't
authorTom Hughes <tom@compton.nu>
Wed, 2 Nov 2005 13:02:40 +0000 (13:02 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 2 Nov 2005 13:02:40 +0000 (13:02 +0000)
normally give execute permission to memory allocated from the heap
with sbrk.

This also required fixing the smc1 test for amd64 to use mmap to
allocate memory so that it can have execute permission.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4983

coregrind/m_main.c
none/tests/amd64/smc1.c

index 87cefab9ccc2148456b7dda882e3cfab125e388c..2d57828a7285bc561d41d156c218ee9ec8cbb71a 100644 (file)
@@ -669,7 +669,7 @@ static void setup_client_dataseg ( SizeT max_size )
    sres = VG_(am_mmap_anon_fixed_client)( 
              anon_start, 
              anon_size, 
-             VKI_PROT_READ|VKI_PROT_WRITE|VKI_PROT_EXEC 
+             VKI_PROT_READ|VKI_PROT_WRITE
           );
    vg_assert(!sres.isError);
    vg_assert(sres.val == anon_start);
index 1fc91ee51d50bfc89f4d3fac659fe9689eb0e178..8619c1efda8f6fe4f7a28d98c962b5a87f9eb708 100644 (file)
@@ -31,7 +31,7 @@
 
 #include <stdio.h>
 #include <assert.h>
-#include <malloc.h>
+#include <sys/mman.h>
 
 typedef unsigned long long int Addr;
 typedef unsigned char UChar;
@@ -100,8 +100,9 @@ void diversion ( void ) { }
 int main ( void )
 {
    int i;
-   code = malloc(20);
-   assert(code);
+   code = mmap(NULL, 20, PROT_READ|PROT_WRITE|PROT_EXEC,
+               MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+   assert(code != MAP_FAILED);
    for (i = 0; i < 10; i += 2) {
       set_dest ( (Addr)&p );
       //      diversion();
@@ -110,5 +111,6 @@ int main ( void )
       //      diversion();
       aa(i+1);
    }
+   munmap(code, 20);
    return 0;
 }