예제 #1
0
void
entry_init_public(void)
{
    STATIC_ASSERT(ARMV7_BYTECODE_SIZE <= ARMV7_ENTRY_SIZE);

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
    glvnd_byte_swap16((uint16_t *)BYTECODE_TEMPLATE,
                      entry_stub_size - TEMPLATE_OFFSETS_SIZE);
#endif
}
예제 #2
0
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;
}
예제 #3
0
파일: GLX_dummy.c 프로젝트: zgchi/libglvnd
static void patch_armv7_thumb_tsd(char *writeEntry,
                                  const char *execEntry,
                                  int stubSize)
{
#if defined(__arm__)
    char *pSawVertex3fv = (char *)&__glXSawVertex3fv;

    // Thumb bytecode
    char tmpl[] = {
        // ldr r0, 1f
        0x48, 0x02,
        // ldr r1, [r0]
        0x68, 0x01,
        // add r1, r1, #1
        0xf1, 0x01, 0x01, 0x01,
        // str r1, [r0]
        0x60, 0x01,
        // bx lr
        0x47, 0x70,
        // 1:
        0x00, 0x00, 0x00, 0x00,
    };

    int offsetAddr = sizeof(tmpl) - 4;

    if (stubSize < sizeof(tmpl)) {
        return;
    }

#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
    glvnd_byte_swap16((uint16_t *)tmpl, offsetAddr);
#endif

    *((uint32_t *)(tmpl + offsetAddr)) = (uint32_t)pSawVertex3fv;

    memcpy(writeEntry, tmpl, sizeof(tmpl));

    __builtin___clear_cache((char *) execEntry, (char *) (execEntry + sizeof(tmpl)));
#else
    assert(0); // Should not be calling this
#endif
}