linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Naveen Iyer <iyernaveenr@gmail.com>
To: "Dmitry V. Levin" <ldv@altlinux.org>
Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org
Subject: Re: [BUG] [man syscall] x86_64 error code / return value must be placed in rdi
Date: Sun, 1 Sep 2019 14:43:22 -0700	[thread overview]
Message-ID: <CAAAu3Xt6S5ODyn_d1Yu-H8q89zTYfSicMfhKsGAgVzhLo2XGbg@mail.gmail.com> (raw)
In-Reply-To: <20190623171706.GA23943@altlinux.org>

On Sun, Jun 23, 2019 at 10:17 AM Dmitry V. Levin <ldv@altlinux.org> 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.

       reply	other threads:[~2019-09-01 21:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAAAu3XtbB=Y0s2emVJoj5Vt4UXSjvk_3EBw_f=gRKssVxbK0=A@mail.gmail.com>
     [not found] ` <CAAAu3XtsLqvVEnMO5A_LMEF5qP64pJFB2+aey4yhCnhvY_F79Q@mail.gmail.com>
     [not found]   ` <20190623171706.GA23943@altlinux.org>
2019-09-01 21:43     ` Naveen Iyer [this message]
2019-09-01 22:25       ` [BUG] [man syscall] x86_64 error code / return value must be placed in rdi Dmitry V. Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAAu3Xt6S5ODyn_d1Yu-H8q89zTYfSicMfhKsGAgVzhLo2XGbg@mail.gmail.com \
    --to=iyernaveenr@gmail.com \
    --cc=ldv@altlinux.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).