ARM gcc를 이용해 함수를 어셈블리로 작성하고 c에서 호출할 수 있을까요?

net1692의 이미지


다음과 같이 ex06_01.s 와 main.c 파일을 생성해서
main.c 에서 ex06_01.s에 있는 함수를 호출하는 프로그램을 작성하고 싶습니다.

root@ubuntu64:~/projects/arm_assembly# cat ex06_01.s
.text

.global square

square:
MUL r1, r0, r0
MOV r0, r1
MOV pc, lr

root@ubuntu64:~/projects/arm_assembly# cat main.c
#include

int square(int i);

int main(void)
{
int i;

for(i = 0; i < 10; i++)
printf("Square of %d is %d\n", i, square(i));
}

root@ubuntu64:~/projects/arm_assembly# arm-linux-gnueabi-gcc -c main.c -o main.o
root@ubuntu64:~/projects/arm_assembly# arm-linux-gnueabi-as ex06_01.s -o ex06_01.o
root@ubuntu64:~/projects/arm_assembly# arm-linux-gnueabi-gcc main.o ex06_01.o
root@ubuntu64:~/projects/arm_assembly# file a.out
a.out: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0xdbad1fc7694d9f527182f66faff8159587678436, not stripped

root@ubuntu64:~/projects/arm_assembly# qemu-arm-static ./a.out
/lib/ld-linux.so.3: No such file or directory

아래 페이지 참고하여 qemu 사용하여 프로그램을 실행시키려 해보았으나, 잘 안되네요.
혹시 ARM gcc를 이용해 함수를 어셈블리로 작성하고 c에서 호출하는 프로그램을 테스트할 수 있는 방법을 알 수 있을까요?
http://ubuntuforums.org/showthread.php?t=2010979

ap4200의 이미지

이 방법은 어때요?
어떤 어셈블러의 레이블(함수단위)를 특정위치에 지정시킬 수 있다면,
함수포인터를 이용해서 주소 넣은다음에 실행시키는것 가능한데.. 여건이 될지 모르겠네요..
아니면, 아에 시스템 콜을 이용하면 가능할것 같아요...