mirror of
https://github.com/frida/tinycc
synced 2024-12-24 22:16:49 +03:00
Add __clear_cache implementation in libtcc1
Add __clear_cache function for flushing caches to libtcc1.
This commit is contained in:
parent
b7d017dec8
commit
fbb4841606
3
Makefile
3
Makefile
@ -66,7 +66,7 @@ NATIVE_DEFINES_$(CONFIG_i386) += -DTCC_TARGET_I386
|
||||
NATIVE_DEFINES_$(CONFIG_x86-64) += -DTCC_TARGET_X86_64
|
||||
NATIVE_DEFINES_$(CONFIG_WIN32) += -DTCC_TARGET_PE
|
||||
NATIVE_DEFINES_$(CONFIG_uClibc) += -DTCC_UCLIBC
|
||||
NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM -DWITHOUT_LIBTCC
|
||||
NATIVE_DEFINES_$(CONFIG_arm) += -DTCC_TARGET_ARM
|
||||
NATIVE_DEFINES_$(CONFIG_arm_eabihf) += -DTCC_ARM_EABI -DTCC_ARM_HARDFLOAT
|
||||
NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI
|
||||
NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP
|
||||
@ -122,6 +122,7 @@ LIBTCC1=libtcc1.a
|
||||
else ifeq ($(ARCH),arm)
|
||||
NATIVE_FILES=$(ARM_FILES)
|
||||
PROGS_CROSS=$(I386_CROSS) $(X64_CROSS) $(WIN32_CROSS) $(WIN64_CROSS) $(C67_CROSS)
|
||||
LIBTCC1=libtcc1.a
|
||||
endif
|
||||
|
||||
ifeq ($(TARGETOS),Darwin)
|
||||
|
11
lib/Makefile
11
lib/Makefile
@ -24,6 +24,10 @@ ifndef TARGET
|
||||
ifneq ($(TARGETOS),Darwin)
|
||||
XCC = $(CC)
|
||||
endif
|
||||
else
|
||||
ifeq ($(ARCH),arm)
|
||||
TARGET = arm
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
@ -41,6 +45,7 @@ cross : TCC = $(TOP)/$(TARGET)-tcc$(EXESUF)
|
||||
|
||||
I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BCHECK_O)
|
||||
X86_64_O = libtcc1.o alloca86_64.o
|
||||
ARM_O = libtcc1.o
|
||||
WIN32_O = $(I386_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
||||
WIN64_O = $(X86_64_O) crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o
|
||||
|
||||
@ -65,12 +70,18 @@ ifeq "$(TARGET)" "x86_64"
|
||||
OBJ = $(addprefix $(DIR)/,$(X86_64_O))
|
||||
TGT = -DTCC_TARGET_X86_64
|
||||
XCC ?= $(TCC) -B$(TOP)
|
||||
else
|
||||
ifeq "$(TARGET)" "arm"
|
||||
OBJ = $(addprefix $(DIR)/,$(ARM_O))
|
||||
TGT = -DTCC_TARGET_ARM
|
||||
XCC ?= $(TCC) -B$(TOP)
|
||||
else
|
||||
$(error libtcc1.a not supported on target '$(TARGET)')
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
XFLAGS = $(CPPFLAGS) $(CFLAGS) $(TGT)
|
||||
|
||||
|
@ -107,7 +107,7 @@ union float_long {
|
||||
};
|
||||
|
||||
/* XXX: we don't support several builtin supports for now */
|
||||
#ifndef __x86_64__
|
||||
#if !defined(__x86_64__) && !defined(__arm__)
|
||||
|
||||
/* XXX: use gcc/tcc intrinsic ? */
|
||||
#if defined(__i386__)
|
||||
@ -713,6 +713,28 @@ void __clear_cache(char *beginning, char *end)
|
||||
{
|
||||
}
|
||||
|
||||
#elif defined(__arm__)
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
void __clear_cache(char *beginning, char *end)
|
||||
{
|
||||
/* __ARM_NR_cacheflush is kernel private and should not be used in user space.
|
||||
* However, there is no ARM asm parser in tcc so we use it for now */
|
||||
#if 1
|
||||
syscall(__ARM_NR_cacheflush);
|
||||
#else
|
||||
__asm__ ("push {r7}\n\t"
|
||||
"mov r7, #0xf0002\n\t"
|
||||
"mov r2, #0\n\t"
|
||||
"swi 0\n\t"
|
||||
"pop {r7}\n\t"
|
||||
"ret");
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
#warning __clear_cache not defined for this architecture, avoid using tcc -run
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user