tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Question about in-memory compilation target


From: grischka
Subject: Re: [Tinycc-devel] Question about in-memory compilation target
Date: Thu, 18 Jan 2024 22:09:04 +0100
User-agent: Mozilla/5.0 (Windows NT 6.0; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

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;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]