copy code_size_ instead of setting 0

This commit is contained in:
kotori0 2020-12-19 16:24:38 +08:00
parent ca6348c007
commit 83e1212a05
1 changed files with 4 additions and 4 deletions

View File

@ -131,10 +131,10 @@ void *genTrampoline(void *toMethod, void *entrypoint) {
size_t size = entrypoint == NULL ? sizeof(trampoline) : sizeof(trampolineForBackup);
// TODO: make use of thread_local to avoid frequent memory allocate
char *targetAddr = doInitHookCap(size + 8);
// 8 bytes for AOT header.
memset(targetAddr, 0, 8);
targetAddr += 8;
char *targetAddr = doInitHookCap(size + 4);
// 4 bytes for AOT header, then copy code_size_.
memcpy(targetAddr, toMethod - 4, 4);
targetAddr += 4;
if (targetAddr == NULL) return NULL;