summaryrefslogtreecommitdiff
path: root/orc/orccodemem.c
diff options
context:
space:
mode:
authorDoug Nazar <nazard@nazar.ca>2019-08-25 14:27:23 -0400
committerSebastian Dröge <slomo@coaxion.net>2019-09-08 07:58:54 +0000
commitff9190b1850720a3f4cf72a038b28bcd4c9487cf (patch)
treeaf920eb73aad05c40301722cdda6fa50692905fe /orc/orccodemem.c
parent8c7c61d2014a9190fec4c6c97f8a759916ca9fc7 (diff)
downloadorc-ff9190b1850720a3f4cf72a038b28bcd4c9487cf.tar.gz
orccodemem: Mark exec mapping writable if debugging
gdb needs the mapping to be writable to set breakpoints.
Diffstat (limited to 'orc/orccodemem.c')
-rw-r--r--orc/orccodemem.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/orc/orccodemem.c b/orc/orccodemem.c
index 58bc6d1..14aadbd 100644
--- a/orc/orccodemem.c
+++ b/orc/orccodemem.c
@@ -200,6 +200,10 @@ orc_code_region_allocate_codemem_dual_map (OrcCodeRegion *region,
int n;
char *filename;
mode_t mask;
+ int exec_prot = PROT_READ | PROT_EXEC;
+
+ if (_orc_compiler_flag_debug)
+ exec_prot |= PROT_WRITE;
filename = malloc (strlen ("/orcexec..") +
strlen (dir) + 6 + 1);
@@ -224,8 +228,7 @@ orc_code_region_allocate_codemem_dual_map (OrcCodeRegion *region,
return FALSE;
}
- region->exec_ptr = mmap (NULL, SIZE, PROT_READ|PROT_EXEC,
- MAP_SHARED, fd, 0);
+ region->exec_ptr = mmap (NULL, SIZE, exec_prot, MAP_SHARED, fd, 0);
if (region->exec_ptr == MAP_FAILED) {
ORC_WARNING("failed to create exec map");
close (fd);