From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: nathan@codesourcery.com
Cc: gdb-patches@sourceware.org, schwab@suse.de
Subject: Re: [m68k] return values
Date: Mon, 19 Jun 2006 18:32:00 -0000 [thread overview]
Message-ID: <200606191830.k5JIUmjO025819@elgar.sibelius.xs4all.nl> (raw)
In-Reply-To: <4496C2AF.2000906@codesourcery.com> (message from Nathan Sidwell on Mon, 19 Jun 2006 16:28:47 +0100)
> Date: Mon, 19 Jun 2006 16:28:47 +0100
> From: Nathan Sidwell <nathan@codesourcery.com>
>
> Mark Kettenis wrote:
>
> > Well, I fear you've managed to confuse yourself. The current m68k
> > default target uses m68k_extract_return_value(), which reads all
> > return values from %d0.
>
> you're right. ok, the whole problem I'm trying to solve is to get
> the function return working for m68k-elf. That appears to be a
> mixture of original and svr4 features. Namely:
>
> a) returns always go in %d0 (original)
> b) small structures can be passed in registers (svr4)
> c) structure return values use the struct_return convention (svr4?)
>
> What approach do you think would be best in tackling this? The way
> I'd gone at it was to treat the m68k-elf as a variant of svr4
> (i.e. #a was the exceptional behaviour). It would be possible to
> organize it as original ABI, but with #b & #c as the exceptions.
Well, #b basically means reg_struct_return convention, which already
is the default. And with #c you probably mean that the caller
allocates the memory to store the returned structure instead of having
the callee provide it in a static buffer (which is braindead since it
is non-reentrant). The current code should cater for both, as long as
a pointer to the memory is returned in %d0. Note that for SVR4 the
pointer is returned in %a0, but that makes no sense for m68k-elf since
normal pointers are returned in %d0. So I believe that the default
m68k gdbarch vector should work just fine for m68k-elf. But perhaps
it is a good idea to verify that the value is indeed returned in %d0.
> Do you think the default should be compatible with m68k-elf, or
> should the user explicitly set the abi in that case?
I believe the default gdbarch vector should be suitable for m68k-aout,
m68k-coff and m68k-elf.
> As you may be aware, #b is implemented by GCC in a horrible way that
> is dependent on internal implementation details -- it's not just
> that the structure is 'small' or even 2^n bytes. I have a patch
> that emulate's GCC's behaviour, and I was going to post that after
> this patch was resolved.
And unfortunately GCC's implementation is almost a guaranteed to break
the ABI every now and then. So it wouldn't surprise me at all if your
GCC is broken; or at least different from the GCC that comes with the
latest OpenBSD/mac68k release, which still uses GCC 2.95.3. So it may
actually be impossible to solve this. Fortunately you're probably
fixing corner cases in what is already a corner case; structures tend
to be larger than 8 bytes.
Could you send me the testsuite output for your m68k-elf target? I'll
run the testsuite on my Quadra 800 tonight so we can compare results.
Mark
next prev parent reply other threads:[~2006-06-19 18:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-09 13:05 Nathan Sidwell
2006-06-18 1:23 ` Mark Kettenis
2006-06-18 5:51 ` Mark Kettenis
2006-06-19 14:39 ` Nathan Sidwell
2006-06-19 15:12 ` Mark Kettenis
2006-06-19 15:28 ` Nathan Sidwell
2006-06-19 18:32 ` Mark Kettenis [this message]
2006-06-22 11:02 ` Nathan Sidwell
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=200606191830.k5JIUmjO025819@elgar.sibelius.xs4all.nl \
--to=mark.kettenis@xs4all.nl \
--cc=gdb-patches@sourceware.org \
--cc=nathan@codesourcery.com \
--cc=schwab@suse.de \
/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