arch/sim: Remove executable bit from the normal heap

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
dongjiuzhu1 2023-10-13 22:34:55 +08:00 committed by Xiang Xiao
parent 861220f649
commit 6efdd50d5a
5 changed files with 9 additions and 8 deletions

View File

@ -60,18 +60,18 @@ static atomic_int g_uordblks;
* *
****************************************************************************/ ****************************************************************************/
void *host_allocheap(size_t sz) void *host_allocheap(size_t size, bool exec)
{ {
void *p; void *p;
#if defined(CONFIG_HOST_MACOS) && defined(CONFIG_HOST_ARM64) #if defined(CONFIG_HOST_MACOS) && defined(CONFIG_HOST_ARM64)
/* see: https://developer.apple.com/forums/thread/672804 */ /* see: https://developer.apple.com/forums/thread/672804 */
p = host_uninterruptible(mmap, NULL, sz, PROT_READ | PROT_WRITE, p = host_uninterruptible(mmap, NULL, size, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_SHARED, -1, 0); MAP_ANON | MAP_SHARED, -1, 0);
#else #else
p = host_uninterruptible(mmap, NULL, sz, p = host_uninterruptible(mmap, NULL, size, PROT_READ | PROT_WRITE |
PROT_READ | PROT_WRITE | PROT_EXEC, (exec ? PROT_EXEC : 0),
MAP_ANON | MAP_PRIVATE, -1, 0); MAP_ANON | MAP_PRIVATE, -1, 0);
#endif #endif

View File

@ -475,7 +475,7 @@ void up_allocate_heap(void **heap_start, size_t *heap_size)
* ARCH_HAVE_TEXT_HEAP mechanism can be an alternative. * ARCH_HAVE_TEXT_HEAP mechanism can be an alternative.
*/ */
uint8_t *sim_heap = host_allocheap(SIM_HEAP_SIZE); uint8_t *sim_heap = host_allocheap(SIM_HEAP_SIZE, false);
*heap_start = sim_heap; *heap_start = sim_heap;
*heap_size = SIM_HEAP_SIZE; *heap_size = SIM_HEAP_SIZE;

View File

@ -216,7 +216,7 @@ int host_waitpid(pid_t pid);
/* sim_hostmemory.c *********************************************************/ /* sim_hostmemory.c *********************************************************/
void *host_allocheap(size_t sz); void *host_allocheap(size_t sz, bool exec);
void host_freeheap(void *mem); void host_freeheap(void *mem);
void *host_allocshmem(const char *name, size_t size, int master); void *host_allocshmem(const char *name, size_t size, int master);
void host_freeshmem(void *mem); void host_freeshmem(void *mem);

View File

@ -49,7 +49,8 @@ void *up_textheap_memalign(size_t align, size_t size)
{ {
if (g_textheap == NULL) if (g_textheap == NULL)
{ {
g_textheap = mm_initialize("textheap", host_allocheap(SIM_HEAP_SIZE), g_textheap = mm_initialize("textheap",
host_allocheap(SIM_HEAP_SIZE, true),
SIM_HEAP_SIZE); SIM_HEAP_SIZE);
} }

View File

@ -36,7 +36,7 @@
* *
****************************************************************************/ ****************************************************************************/
void *host_allocheap(size_t sz) void *host_allocheap(size_t sz, bool exec)
{ {
return _aligned_malloc(sz, 8); return _aligned_malloc(sz, 8);
} }