This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] A few sh fixes
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Fri, 27 Sep 2002 16:04:39 +0200
- Subject: [RFA] A few sh fixes
- Reply-to: gdb-patches at sources dot redhat dot com
Hi,
the below patch contains the following fixes for sh:
- Add some missing big/little endian stuff
- Try to match sh_use_struct_convention() more closely to the ABI.
Corinna
* sh-tdep.c (sh_use_struct_convention): Use definition according to ABI.
(sh_push_arguments): Store in register with correct endianess.
(sh_default_store_return_value): Ditto.
Index: sh-tdep.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/sh-tdep.c,v
retrieving revision 2.125.2.2
diff -u -p -r2.125.2.2 sh-tdep.c
--- sh-tdep.c 2002/09/26 13:57:06 2.125.2.2
+++ sh-tdep.c 2002/09/27 11:46:07
@@ -906,7 +906,14 @@ sh_saved_pc_after_call (struct frame_inf
static int
sh_use_struct_convention (int gcc_p, struct type *type)
{
+#if 0
return (TYPE_LENGTH (type) > 1);
+#else
+ int len = TYPE_LENGTH (type);
+ int nelem = TYPE_NFIELDS (type);
+ return ((len != 1 && len != 2 && len != 4 && len != 8) || nelem != 1) &&
+ (len != 8 || TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) != 4);
+#endif
}
static int
@@ -2067,8 +2074,11 @@ sh_push_arguments (int nargs, struct val
if (len < 4)
{
/* value gets right-justified in the register or stack word */
- memcpy (valbuf + (4 - len),
- (char *) VALUE_CONTENTS (args[argnum]), len);
+ if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
+ memcpy (valbuf + (4 - len),
+ (char *) VALUE_CONTENTS (args[argnum]), len);
+ else
+ memcpy (valbuf, (char *) VALUE_CONTENTS (args[argnum]), len);
val = valbuf;
}
else
@@ -2479,8 +2489,11 @@ sh_default_store_return_value (struct ty
{
/* Add leading zeros to the value. */
memset (buf, 0, REGISTER_RAW_SIZE (R0_REGNUM));
- memcpy (buf + REGISTER_RAW_SIZE (R0_REGNUM) - TYPE_LENGTH (type),
- valbuf, TYPE_LENGTH (type));
+ if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
+ memcpy (buf + REGISTER_RAW_SIZE (R0_REGNUM) - TYPE_LENGTH (type),
+ valbuf, TYPE_LENGTH (type));
+ else
+ memcpy (buf, valbuf, TYPE_LENGTH (type));
write_register_bytes (REGISTER_BYTE (R0_REGNUM), buf,
REGISTER_RAW_SIZE (R0_REGNUM));
}
--
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen@redhat.com