printf '#include "SYS.h"\nWSYSCALL(write,_sys_write)\nWEAK_ALIAS(_write,_sys_write)\n' >write.S WSYSYCALL becomes: VALUE VAR write = weak _sys_write = strong PSEUDO(weak,weak) write = x write = y _SYSCALL(x,y); [code for syscall] ret _SYSCALL(x,y) .text ; _ALIGN_TEXT /* really .align 4 */ 2: PIC_PROLOGUE; /* #define PIC_PROLOGUE \ pushl %ebx; \ call 1f; \ 1: \ popl %ebx; \ addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx movl PIC_GOT(CERROR), %ecx #define PIC_GOT(x) PIC_EPILOGUE; #define PIC_EPILOGUE \ popl %ebx jmp *%ecx; _SYSCALL_NOERROR(x,y) write = x write = y _SYSCALL_NOERROR(x,y) ENTRY(x); SYSTRAP(y); #define _ENTRY(x) \ .text; _ALIGN_TEXT; .globl x; .type x,@function; x: #define SYSTRAP(x) movl $(SYS_ ## x),%eax; int $0x80 jc 2b So, with that heap of code I suppose we must do something like: mywrite: .text .align 4 2: pushl %ebx call 1f; 1: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-1b],%ebx movl __cerror,%ecx popl %ebx .text .align 4 movl $4,%eax int $0x80 jc 2b cerror: ---- function f {int a ; int b} { return [+ $a $b] } function main {int argc} { int r set r [f 1 2] return 0 } ----- comp:function creates f: Now we eval {int a ; int b} (after split'ing) Now we set the locals: movl (%esi),%eax movl %eax,[get.symbol.offset a] (substituted at compile time) addl $4,%esi movl (%esi),%eax movl %eax,[get.symbol.offset b] addl $4,%esi Now eval the body. return places its result in %eax This all means that we need to handle main specially, or have our own start.