|
|
|
@ -244,22 +244,22 @@ _try_make_writable_inplace_unix (hb_blob_t *blob) |
|
|
|
|
|
|
|
|
|
if ((uintptr_t) -1L == pagesize) { |
|
|
|
|
(void) (HB_DEBUG_BLOB && |
|
|
|
|
fprintf (stderr, "%p %s: failed to get pagesize: %s\n", blob, HB_FUNC, strerror (errno))); |
|
|
|
|
fprintf (stderr, "%p %s: failed to get pagesize: %s\n", (void *) blob, HB_FUNC, strerror (errno))); |
|
|
|
|
return FALSE; |
|
|
|
|
} |
|
|
|
|
(void) (HB_DEBUG_BLOB && |
|
|
|
|
fprintf (stderr, "%p %s: pagesize is %lu\n", blob, HB_FUNC, (unsigned long) pagesize)); |
|
|
|
|
fprintf (stderr, "%p %s: pagesize is %lu\n", (void *) blob, HB_FUNC, (unsigned long) pagesize)); |
|
|
|
|
|
|
|
|
|
mask = ~(pagesize-1); |
|
|
|
|
addr = (const char *) (((uintptr_t) blob->data) & mask); |
|
|
|
|
length = (const char *) (((uintptr_t) blob->data + blob->length + pagesize-1) & mask) - addr; |
|
|
|
|
(void) (HB_DEBUG_BLOB && |
|
|
|
|
fprintf (stderr, "%p %s: calling mprotect on [%p..%p] (%lu bytes)\n", |
|
|
|
|
blob, HB_FUNC, |
|
|
|
|
(void *) blob, HB_FUNC, |
|
|
|
|
addr, addr+length, (unsigned long) length)); |
|
|
|
|
if (-1 == mprotect ((void *) addr, length, PROT_READ | PROT_WRITE)) { |
|
|
|
|
(void) (HB_DEBUG_BLOB && |
|
|
|
|
fprintf (stderr, "%p %s: %s\n", blob, HB_FUNC, strerror (errno))); |
|
|
|
|
fprintf (stderr, "%p %s: %s\n", (void *) blob, HB_FUNC, strerror (errno))); |
|
|
|
|
return FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -267,7 +267,7 @@ _try_make_writable_inplace_unix (hb_blob_t *blob) |
|
|
|
|
|
|
|
|
|
(void) (HB_DEBUG_BLOB && |
|
|
|
|
fprintf (stderr, "%p %s: successfully made [%p..%p] (%lu bytes) writable\n", |
|
|
|
|
blob, HB_FUNC, |
|
|
|
|
(void *) blob, HB_FUNC, |
|
|
|
|
addr, addr+length, (unsigned long) length)); |
|
|
|
|
return TRUE; |
|
|
|
|
#else |
|
|
|
@ -279,13 +279,13 @@ static bool |
|
|
|
|
_try_writable_inplace (hb_blob_t *blob) |
|
|
|
|
{ |
|
|
|
|
(void) (HB_DEBUG_BLOB && |
|
|
|
|
fprintf (stderr, "%p %s: making writable inplace\n", blob, HB_FUNC)); |
|
|
|
|
fprintf (stderr, "%p %s: making writable inplace\n", (void *) blob, HB_FUNC)); |
|
|
|
|
|
|
|
|
|
if (_try_make_writable_inplace_unix (blob)) |
|
|
|
|
return TRUE; |
|
|
|
|
|
|
|
|
|
(void) (HB_DEBUG_BLOB && |
|
|
|
|
fprintf (stderr, "%p %s: making writable -> FAILED\n", blob, HB_FUNC)); |
|
|
|
|
fprintf (stderr, "%p %s: making writable -> FAILED\n", (void *) blob, HB_FUNC)); |
|
|
|
|
|
|
|
|
|
/* Failed to make writable inplace, mark that */ |
|
|
|
|
blob->mode = HB_MEMORY_MODE_READONLY; |
|
|
|
@ -309,7 +309,7 @@ _try_writable (hb_blob_t *blob) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(void) (HB_DEBUG_BLOB && |
|
|
|
|
fprintf (stderr, "%p %s -> %p\n", blob, HB_FUNC, blob->data)); |
|
|
|
|
fprintf (stderr, "%p %s -> %p\n", (void *) blob, HB_FUNC, blob->data)); |
|
|
|
|
|
|
|
|
|
char *new_data; |
|
|
|
|
|
|
|
|
@ -318,7 +318,7 @@ _try_writable (hb_blob_t *blob) |
|
|
|
|
return FALSE; |
|
|
|
|
|
|
|
|
|
(void) (HB_DEBUG_BLOB && |
|
|
|
|
fprintf (stderr, "%p %s: dupped successfully -> %p\n", blob, HB_FUNC, blob->data)); |
|
|
|
|
fprintf (stderr, "%p %s: dupped successfully -> %p\n", (void *) blob, HB_FUNC, blob->data)); |
|
|
|
|
|
|
|
|
|
memcpy (new_data, blob->data, blob->length); |
|
|
|
|
_hb_blob_destroy_user_data (blob); |
|
|
|
|