On 15.01.2024 00:51, Brad Robinson via Tinycc-devel wrote:
Questions:
1. Is it possible to keep, use and then release the compiled code after the
initial compiler instance has been deleted
FYI below some version of libtcc_test.c to run without state.
Note the LoadDll is needed only when the exe itself was not
linked with msvcrt, i.e. to prevent it from being unloaded
in tccelf_delete.
-- gr
void *mem; int size; HANDLE dll; DWORD xxx;
if ((size = tcc_relocate(s, NULL)) < 0)
return 1;
tcc_relocate(s, mem = malloc(size));
if (!(func = tcc_get_symbol(s, "foo")))
return 1;
dll = LoadLibrary("msvcrt.dll");
tcc_delete(s);
func(32);
FreeLibrary(dll);
VirtualProtect(mem, size, PAGE_READWRITE, &xxx);
#if _WIN64
RtlDeleteFunctionTable(*(RUNTIME_FUNCTION**)mem);
#endif
free(mem);
return 0;
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel