This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [m68k] return values


> 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;

  ...

}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]