Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
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: Sun, 18 Jun 2006 05:51:00 -0000	[thread overview]
Message-ID: <200606180550.k5I5o0ni009268@elgar.sibelius.xs4all.nl> (raw)
In-Reply-To: <44897213.3070309@codesourcery.com> (message from Nathan Sidwell 	on Fri, 09 Jun 2006 14:05:23 +0100)

> Date: Fri, 09 Jun 2006 14:05:23 +0100
> From: Nathan Sidwell <nathan@codesourcery.com>
> 
> this is a reworking of my recent return value patch.  this patch
> just contains changes to select which register contains a pointer
> value, and how structure return values are located.

OK, I see your problem now.  The uCLinux ABI is quite different from
the normal Linux ABI, and different from the "standard" embedded ABI
too.  If I read the GCC code correctly, on uCLinux you end up with:

#undef PCC_STATIC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN 1
#define M68K_STRUCT_VALUE_REGNUM 8
#define FUNCTION_VALUE(VALTYPE, FUNC) gen_rtx_REG (TYPE_MODE (VALTYPE), 0)

whereas normal Linux has

#undef PCC_STATIC_STRUCT_RETURN
#define DEFAULT_PCC_STRUCT_RETURN 0
#define M68K_STRUCT_VALUE_REGNUM 9
#define FUNCTION_VALUE(VALTYPE, FUNC)  m68k_function_value (VALTYPE, FUNC)

This means that on uCLinux:

* Small structures are returned in memory.
* Pointer return values are returned in %d0.
* The memory for returning structures is passed in %a0.

whereas on normal Linux:

* Small structures are returned in registers (%d0/%d1 or %fp0).
* Pointer return values are returned in %a0.
* The memory for returning structures is passed in %a1.

I hope you can distinguish your uCLinux binaries from normal Linux
binaries, otherwise there is no way out of this mess.  You'll then
need to initialize the uCLinux gdbarch vector with something like:

static void
m68k_uclinux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

  ...

  /* uCLinux uses its own calling convention, where all return values
     are stored in %d0/%d1 and structures are returned in memory at the
     address passed in %a0.  */

  tdep->struct_value_regnum = M68K_A0_REGNUM;
  tdep->struct_return = pcc_struct_return;

  ...

}


  parent reply	other threads:[~2006-06-18  5:51 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 [this message]
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
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=200606180550.k5I5o0ni009268@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