def _cat_linux_arm(filepath, out_fd): return (open_file(filepath), 'mov r8, r0\ncat_helper1:', read_stack('r8', 48, False), 'cmp r0, #0\nble cat_helper2', write_stack(out_fd, 'r0'), 'b cat_helper1\ncat_helper2:')
def _cat_amd64(filepath, out_fd, use_sendfile): if use_sendfile: return open_file(filepath), sendfile('rax', out_fd) else: return (open_file(filepath), "xchg ebp, eax\ncat_helper1:", read_stack('rbp', 48, False), "test eax, eax\njle cat_helper2", write_stack(out_fd, 'rax'), "jmp cat_helper1\ncat_helper2:")