public
Created

GCC ARM problem example

  • Download Gist
Makefile
Makefile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
CC=arm-linux-gnueabi-gcc
LD=arm-linux-gnueabi-ld
 
CFLAGS=-ansi -pedantic -Wall -Wextra -march=armv6 -msoft-float -fPIC -mapcs-frame
LDFLAGS=-N -Ttext=0x10000
 
kernel.elf: bootstrap.o kernel.o activate.o
 
.PHONY: clean
 
clean:
$(RM) *.elf *.o
 
.SUFFIXES: .s .o .elf
 
.s.o:
$(CC) $(CFLAGS) -o $@ -c $^
 
.o.elf:
$(LD) $(LDFLAGS) -o $@ $^
activate.s
GAS
1 2 3
.global activate
activate:
b test
bootstrap.s
GAS
1 2 3 4
.global _start
_start:
ldr sp, =0x07FFFFFF
bl main
kernel.c
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
void activate(void);
 
void test(void) {
char *s = "Yay!\n";
 
while(*s) {
*(volatile char*)0x101f1000 = *s;
s++;
}
}
 
int main(void) {
char *string = "Hello, World!\n";
char *string2 = "Done!\n";
 
while(*string) {
*(volatile char*)0x101f1000 = *string;
string++;
}
 
activate();
 
while(*string2) {
*(volatile char*)0x101f1000 = *string2;
string2++;
}
 
while(1); /* We can't exit, there's nowhere to go */
return 0;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.