arm: Provide alloca()

This provides a simple implementation of alloca for ARM (and enables
the associated testcase).  As tcc for ARM doesn't contain an assembler,
we'll have to resort using gcc for compiling it.
This commit is contained in:
Michael Matz 2014-04-05 22:54:11 +02:00
parent b0f8ca5e03
commit c4427747e6
3 changed files with 15 additions and 4 deletions

View File

@ -45,7 +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 armeabi.o
ARM_O = libtcc1.o armeabi.o alloca-arm.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
@ -104,7 +104,7 @@ $(DIR)/libtcc1.a ../libtcc1.a : $(OBJ) $(XAR)
$(DIR)/%.o : %.c
$(XCC) -c $< -o $@ $(XFLAGS)
$(DIR)/%.o : %.S
$(XCC) -c $< -o $@ $(XFLAGS)
$(CC) -c $< -o $@ $(XFLAGS)
$(DIR)/%$(EXESUF) : $(TOP)/win32/tools/%.c
$(CC) -o $@ $< $(XFLAGS) $(LDFLAGS)

11
lib/alloca-arm.S Normal file
View File

@ -0,0 +1,11 @@
.text
.align 2
.global alloca
.type alloca, %function
alloca:
rsb sp, r0, sp
bic sp, sp, #7
mov r0, sp
mov pc, lr
.size alloca, .-alloca
.section .note.GNU-stack,"",%progbits

View File

@ -2221,7 +2221,7 @@ void old_style_function(void)
void alloca_test()
{
#if defined __i386__ || defined __x86_64__
#if defined __i386__ || defined __x86_64__ || defined __arm__
char *p = alloca(16);
strcpy(p,"123456789012345");
printf("alloca: p is %s\n", p);
@ -2794,7 +2794,7 @@ double get100 () { return 100.0; }
void callsave_test(void)
{
#if defined __i386__ || defined __x86_64__
#if defined __i386__ || defined __x86_64__ || defined __arm__
int i, s; double *d; double t;
s = sizeof (double);
printf ("callsavetest: %d\n", s);