static int init_map(void) { if (exec_mem == NULL) { void *writePtr, *execPtr; if (AllocExecPages(EXEC_MAP_SIZE, &writePtr, &execPtr) == 0) { exec_mem = (unsigned char *) execPtr; write_mem = (unsigned char *) writePtr; head = 0; } } return (exec_mem != NULL); }
int InitEntrypoints(void) { if (entrypointBufferExec == NULL) { void *writeBuf, *execBuf; if (AllocExecPages(STUB_ENTRY_SIZE * GENERATED_ENTRYPOINT_MAX, &writeBuf, &execBuf) != 0) { return -1; } entrypointBufferWrite = (uint8_t *) writeBuf; entrypointBufferExec = (uint8_t *) execBuf; #if defined(USE_ARMV7_ASM) #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ glvnd_byte_swap16((uint16_t *)STUB_TEMPLATE, sizeof(STUB_TEMPLATE) - 4); #endif #endif } return 0; }