From: Ulrich Weigand via Gdb-patches <gdb-patches@sourceware.org>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
Aditya Kamath1 <Aditya.Kamath1@ibm.com>
Cc: Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>
Subject: Re: [PATCH] Fix for call feature having nine parameters or more in AIX
Date: Fri, 25 Aug 2023 11:19:43 +0000 [thread overview]
Message-ID: <0f53c04c1877d7a35200607144724d8fd774a365.camel@de.ibm.com> (raw)
In-Reply-To: <CH2PR15MB3544C780BBEC26F108C0E6E4D6E3A@CH2PR15MB3544.namprd15.prod.outlook.com>
Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:
>So, debugging further I realized that the parameters of function in AIX
>are stored in registers 3 to 10. More about this fact can be read in this
>document {https://www.ibm.com/docs/en/aix/7.2?topic=overview-register-usage-conventions}.
>If the function has more than 8 parameters then the 9th one onwards, we store
>the function parameters in the stack. This can be seen in the rs6000-aix-tdep.c
>file in the dummy_call function from line 700 and beyond. Over here we have
>this line below.
>
>write_memory (sp + 24 + (ii * 4), arg->contents ().data (), len);
>
>This the root cause of this issue.
I agree you've identified a problem, but I think your patch isn't quite complete.
For example, immediately after the code you changed follows:
ii += ((len + 3) & -4) / 4;
The intent is to always uses full stack slots even for arguments of odd sizes.
But I understand in the 64-bit ABI the stack slot size is 8 bytes, so this
should round up to the next multiple of 8.
Similarly, you need to make sure that the first loop that computes the *size*
of the stack that will be used for arguments performs the same calculations
as the code that actually fills in the arguments - or else you can overwrite
unrelated areas:
if (argbytes)
{
space += ((len - argbytes + 3) & -4);
jj = argno + 1;
}
else
jj = argno;
for (; jj < nargs; ++jj)
{
struct value *val = args[jj];
space += ((val->type ()->length ()) + 3) & -4;
}
All of this should round up to wordsize instead of 4, I guess.
Bye,
Ulrich
next prev parent reply other threads:[~2023-08-25 11:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-25 9:21 Aditya Kamath1 via Gdb-patches
2023-08-25 11:19 ` Ulrich Weigand via Gdb-patches [this message]
2023-08-25 13:35 ` Aditya Kamath1 via Gdb-patches
2023-08-25 14:13 ` Ulrich Weigand via Gdb-patches
2023-08-25 15:35 ` Aditya Kamath1 via Gdb-patches
2023-08-25 15:57 ` Ulrich Weigand via Gdb-patches
2023-08-25 16:36 ` Aditya Kamath1 via Gdb-patches
2023-08-25 16:49 ` Ulrich Weigand via Gdb-patches
2023-08-25 17:47 ` Aditya Kamath1 via Gdb-patches
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=0f53c04c1877d7a35200607144724d8fd774a365.camel@de.ibm.com \
--to=gdb-patches@sourceware.org \
--cc=Aditya.Kamath1@ibm.com \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=sangamesh.swamy@in.ibm.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