Inline Assembler for wrapper function doesn't work for some reason

五迷三道 提交于 2019-12-02 03:02:14

it fails and goes into if (-125 <= res && res < 0)

Where did you expect it to go?

I expect the read system call to fail with -EINVAL, as you are not pasing in a valid file descriptor to it.

Update:

Where did you get an idea that SYS_read is 5?

On my system, SYS_read is 3 in 32-bit mode, and 0 in 64-bit mode:

echo "#include <syscall.h>" | gcc -xc - -dD -E | grep ' __NR_read '
#define __NR_read 0

echo "#include <syscall.h>" | gcc -xc - -dD -E -m32 | grep ' __NR_read '
#define __NR_read 3

Assuming you are on 32-bit system, you are invoking SYS_open, which is failing with -EFAULT (-14) because the first parameter to the open system call is supposed to be a filename and 0 (NULL) isn't a valid filename.

Run it under strace to see what's happening for sure, but I think your problem is that you put all the inputs in the output register list rather than the input register list...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!