I have a condensed format for adding new architectures with most of the details in a tabular format:
Code: Select all
#define ARCH_TEMPLATE stckptr,syscall,callnum,ret,arg1,arg2,arg3,arg4,arg5,arg6,arg7,"memory",...
#define ARCH_ALPHA sp,syscall,v0,v0,a0,a1,a2,a3,a4,a5,a6,"memory"
#define ARCH_ARM r13,swi 0x0,r7,r0,r0,r1,r2,r3,r4,r5,r6,"memory"
#define ARCH_ARM64 x13,svc 0,x8,x0,x0,x1,x2,x3,x4,x5,0,"memory", \
"x7","x9","x10","x11","x12","x13","x14","x15","x16","x17","x18"
#define ARCH_AVR32 ???,scall,
#define ARCH_BFIN SP,excpt 0x0,P0,R0,R0,R1,R2,R3,R4,R5,0,"memory" //more clobs?
#define ARCH_CRIS ??,break 13,r9,r9??,r10,r11,r12,r13,mof,srp,0,"memory"
#define ARCH_HPPA %usp,ble 0x100(%sr2,%r0),%r20,%r28,%r26,%r25,%r24,%r23,%r22,%r21,0, \
"memory","r1","r2","r20","r29","r31"
#define ARCH_IA64 ???,break 0x100000,r15,r10/r8,out0,out1,out2,out3,out4,out5,0,"memory"
#define ARCH_M68K %sp,trap &0,%d0,%d0,%d1,%d2,%d3,%d4,%d5,%a0,"memory","%d0","%d1","%a0"
#define ARCH_MBLAZ ???,brki r14, 0x8,r12,r12??,r5,r6,r7,r8,r9,r10,0,"memory","r4"
#define ARCH_MIPS $sp,syscall,$v0,$v0,$a0,$a1,$a2,$a3,$a4,$a5,$a6,"memory", \
"$at","$t0","$t1","$t2","$t3","$t4","$t5","$t6","$t7","$t8","$t9","$hi","$lo"
#define ARCH_MIPS64 $sp,syscall,$v0,$v0,$a0,$a1,$a2,$a3,$a4,$a5,$a6,"memory"
// ,"$at","$t0","$t1","$t2","$t3","$t4","$t5","$t6","$t7","$t8","$t9","$hi","$lo"
#define ARCH_OR1K ???,l.sys 1,r11,r11,r3,r4,r5,r6,r7,r8,0,"memory","r12","r13","r15","r17","r19","r21","r23","r25","r27","r29","r31"
#define ARCH_PPC ???,sc,r0,r0,r3,r4,r5,r6,,r7,r8,0,"memory","cr0","ctr","r8","r9","r10","r11","r12"
#define ARCH_PPC64 ???,sc,r0,r0,r3,r4,r5,r6,,r7,r8,0,"memory","cr0","ctr","r8","r9","r10","r11","r12"
#define ARCH_S390 ???,svc 0,r1,r2,r2,r3,r4,r5,r6,r7,0,"memory"
#define ARCH_SH ???,trapa #,r3,r3??,r4,r5,r6,r7,r0,r1,"memory" //
#define ARCH_SPARC32 ???,t 0x10,g1,o0,o0,o1,o2,o3,o4,o5,0,"memory"
#define ARCH_SPARC64 ???,t 0x6d,g1,o0,o0,o1,o2,o3,o4,o5,0,"memory"
#define ARCH_X8664 esp,syscall,rax,rax,rdi,rsi,rdx,r10,r8,r9,0,"memory","rcx","r11"
#define ARCH_X86 esp,int $128,eax,eax,ebx,ecx,edx,esi,edi,ebp,0,"memory"
#define ARCH_XTNSA ???,syscall,a2,a2??,a6,a3,a4,a5,a8,a9,0,"memory"
This table is incomplete and some architectures may be completely wrong, It was started from info at
and various ABI descriptions. If you see something wrong, let me know.
At the moment I have stripped out all the internal C functions and am defining them to use builtins (including atomic and Cilk Plus) until someone finds a need for a separate function. So far I have only needed strstr and thus strncmp (but may be able to use __builtin_memcmp?)
gcc -Os -ffreestanding -nostartfiles -nostdlib -fno-asynchronous-unwind-tables -fomit-frame-pointer -mno-accumulate-outgoing-args -finline-small-functions -finline-functions-called-once -o get get.c -s -Wl,--gc-sections,--sort-common,-s -Wall -Wextra
Note: I still need to implement socketcall for x86 (and others) and map the related calls to it if the syscall is not defined