Re: [BUG] [man syscall] x86_64 error code / return value must be placed in rdi

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jun 23, 2019 at 10:17 AM Dmitry V. Levin <ldv@xxxxxxxxxxxx> wrote:
>
> Hi,
>
> On Sun, Jun 23, 2019 at 09:03:31AM -0700, Naveen Iyer wrote:
> > Hi,
> >
> > As suggested by
> > https://www.kernel.org/doc/man-pages/reporting_bugs.html , I looked up
> > the online man page as well:
> > http://man7.org/linux/man-pages/man2/syscall.2.html
> >
> > In the table in "Architecture calling conventions" section:
> > arch/ABI    instruction           syscall #  retval  error    Notes
> > ────────────────────────────────────
> > x86-64       syscall                   rax        rax        -        [5]
> >
> > Retval must be placed in rdi
>
> Why?
>
> > as per the following link:
> > https://w3challs.com/syscalls/?arch=x86_64
>
> This link doesn't claim that.
>
The link states that rdi contains the int error_code. I am able to
return whatever int I want to return by placing the int value of my
choice in rdi.
Why do you say that this link doesn't claim that when it clearly does?
Am I misreading it?

> > }
> >
> > Step 2) Compile and execute:
> > $ gcc -nostdlib -c startup.c
> > $ ld startup.o -o startup
> > $ ./startup
> > $ echo $?
> > 97
>
> So your test invokes "exit" syscall with 97 as its first argument.
> The return value of this syscall has no meaning because it does not return.
> Most of syscalls do return and their return value is in %rax on x86_64.
I am checking for the program's return status and not the return of
syscall itself.




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux