public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Vladimir Prus <vladimir@codesourcery.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sources.redhat.com
Subject: Re: m68k-elf return value registers
Date: Tue, 26 Apr 2011 11:58:00 -0000	[thread overview]
Message-ID: <201104261558.22776.vladimir@codesourcery.com> (raw)
In-Reply-To: <201101251949.15840.vladimir@codesourcery.com>

[-- Attachment #1: Type: Text/Plain, Size: 665 bytes --]

On Tuesday, January 25, 2011 19:49:15 Vladimir Prus wrote:

> How about this split:
> 
> - Register used to return structures
> - Logic used to decide whether a structure is returned in register
> - Adjusting register used for returning pointers

And here's the patch that adjusts the register used to return structures.

Earlier, you said:

> > Also, you should make sure that that code doesn't get used for
> > OpenBSD/m68k a.out, since it will be wrong.

but I've lost track of what bit of the patch you meant. Could you clarify
that, as part of reviewing whatever individual patch is applicable?

- Volodya

-- 
Vladimir Prus
Mentor Graphics
+7 (812) 677-68-40

[-- Attachment #2: struct_return_register.diff --]
[-- Type: text/x-patch, Size: 2610 bytes --]

commit 6dfd0b7446fce82dba3ae07e24fadb89b9908455
Author: Vladimir Prus <vladimir@codesourcery.com>
Date:   Fri Jan 14 00:10:12 2011 +0300

    Use the right structure and pointer return registers on m68k-elf.
    
    	* m68k-tdep.c (m68k_gdbarch_init): Use A0 for structure
    	returns on ELF targets, A1 otherwise.
    	(m68k_svr4_init_abi): No need to specify %a0 for structure
    	returns here.
    	* m68kbsd-tdep.c (m68kbsd_elf_init_abi): Use A1 for struct return on OpenBSD.

diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index 736bf5b..accffc8 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -1114,8 +1114,7 @@ m68k_svr4_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* SVR4 uses a different calling convention.  */
   set_gdbarch_return_value (gdbarch, m68k_svr4_return_value);
 
-  /* SVR4 uses %a0 instead of %a1.  */
-  tdep->struct_value_regnum = M68K_A0_REGNUM;
+  tdep->ptr_value_regnum = M68K_A0_REGNUM;
 
   tdep->ptr_value_regnum = M68K_A0_REGNUM;
 }
@@ -1291,7 +1290,16 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Function call & return.  */
   set_gdbarch_push_dummy_call (gdbarch, m68k_push_dummy_call);
   set_gdbarch_return_value (gdbarch, m68k_return_value);
+  tdep->struct_return = reg_struct_return;
 
+  /* These register numbers may be overridden by an OSABI
+     sniffer.  */
+  if (info.abfd == NULL)
+    tdep->struct_value_regnum = M68K_A0_REGNUM;
+  else if (bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
+    tdep->struct_value_regnum = M68K_A0_REGNUM;
+  else
+    tdep->struct_value_regnum = M68K_A1_REGNUM;
   tdep->ptr_value_regnum = M68K_D0_REGNUM;
 
   /* Disassembler.  */
@@ -1303,8 +1311,6 @@ m68k_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 #else
   tdep->jb_pc = -1;
 #endif
-  tdep->struct_value_regnum = M68K_A1_REGNUM;
-  tdep->struct_return = reg_struct_return;
 
   /* Frame unwinder.  */
   set_gdbarch_dummy_id (gdbarch, m68k_dummy_id);
diff --git a/gdb/m68kbsd-tdep.c b/gdb/m68kbsd-tdep.c
index 3b5f5e0..f5bfa1a 100644
--- a/gdb/m68kbsd-tdep.c
+++ b/gdb/m68kbsd-tdep.c
@@ -234,6 +234,15 @@ m68kbsd_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   /* NetBSD ELF uses SVR4-style shared libraries.  */
   set_solib_svr4_fetch_link_map_offsets
     (gdbarch, svr4_ilp32_fetch_link_map_offsets);
+
+  /* OpenBSD uses %a1to return structures.  */
+  if (info.abfd)
+    {
+      enum gdb_osabi osabi = gdbarch_lookup_osabi (info.abfd);
+
+      if (osabi == GDB_OSABI_OPENBSD_ELF)
+	tdep->struct_value_regnum = M68K_A1_REGNUM;
+    }
 }
 \f
 

      parent reply	other threads:[~2011-04-26 11:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-13 23:04 Vladimir Prus
2011-01-14 11:00 ` Mark Kettenis
2011-01-25 17:01   ` Vladimir Prus
2011-04-26 11:37     ` Vladimir Prus
2011-06-11 18:50       ` Vladimir Prus
2011-04-26 11:50     ` Vladimir Prus
2011-04-26 11:58     ` Vladimir Prus [this message]

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=201104261558.22776.vladimir@codesourcery.com \
    --to=vladimir@codesourcery.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=mark.kettenis@xs4all.nl \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).