title: How to allocate a memory with execute permissions?
body: <p>I want to allocate a memory with execute permissions.
  So I use mprotect to change the permissions.. To get a page aligned memory I use a <code>valloc</code> function.</p>
  
  <pre><code>void * temp = (void *) valloc(x);
  </code></pre>
  
  <p>and then</p>
  
  <pre><code>if( mprotect(temp, BLOCK_SIZE, (PROT_READ | PROT_WRITE |PROT_EXEC))) {
     exit(-1);
  }
  </code></pre>
  
  <p>Now I want to add more memory to this allocated block. Hence I use a <code>realloc</code> function.</p>
  
  <pre><code>void * new_temp = (void *) realloc(temp, 1024);
  </code></pre>
  
  <p>Will this reallocate automatically change the permissions of the allocated memory to the ones I had set earlier ?? In case <code>realloc</code> moves the entire block to a different location, what be the permissions of allocated memory earlier and the newly allocated memory?</p>
  
  <p>Should <code>mprotect</code> be used again to get execute permissions memory. And is there a API to <code>realloc</code> on page size boundary like <code>valloc</code>. ?</p>