Subject: [Fwd: dummy frame on stack and SPARC]
To: None <port-sparc@netbsd.org>
From: Andrew Cagney <cagney@mac.com>
List: port-sparc
Date: 03/05/2003 23:17:45
This is a multi-part message in MIME format.
--------------050207060508090007080708
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Anyone got an answer to:
> The only thing I'm not sure about is exactly when a SPARC will recognize the segmentation violation and abort. It, thanks to the delayed branch code, could be a cycle too early :-(
--------------050207060508090007080708
Content-Type: message/rfc822;
name="dummy frame on stack and SPARC"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="dummy frame on stack and SPARC"
From gdb-return-12948-cagney=gnu.org@sources.redhat.com Wed Mar 5 14:55:26 2003
by localhost.redhat.com (Postfix) with ESMTP id A30D72A9C
for <cagney@localhost>; Wed, 5 Mar 2003 14:55:26 -0500 (EST)
Envelope-to: cagney@gnu.org
Delivery-date: Wed, 05 Mar 2003 14:52:48 -0500
by localhost with IMAP (fetchmail-6.2.1)
for cagney@localhost (single-drop); Wed, 05 Mar 2003 14:55:26 -0500 (EST)
by fencepost.gnu.org with esmtp (Exim 4.10)
id 18qewa-0006SO-00
for cagney@gnu.org; Wed, 05 Mar 2003 14:52:48 -0500
id 18qetl-0003el-00
for cagney@gnu.org; Wed, 05 Mar 2003 14:49:54 -0500
by monty-python.gnu.org with smtp (Exim 4.10.13)
id 18qerL-0002cn-00
for cagney@gnu.org; Wed, 05 Mar 2003 14:47:23 -0500
Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm
List-Unsubscribe: <mailto:gdb-unsubscribe-cagney=gnu.org@sources.redhat.com>
List-Subscribe: <mailto:gdb-subscribe@sources.redhat.com>
List-Archive: <http://sources.redhat.com/ml/gdb/>
List-Post: <mailto:gdb@sources.redhat.com>
List-Help: <mailto:gdb-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
Sender: gdb-owner@sources.redhat.com
by 172.16.49.205 with SMTP; 5 Mar 2003 19:47:18 -0000
by localhost.redhat.com (Postfix) with ESMTP id D40082A9C
for <gdb@sources.redhat.com>; Wed, 5 Mar 2003 14:47:14 -0500 (EST)
Message-ID: <3E665442.2070007@redhat.com>
Date: Wed, 05 Mar 2003 14:47:14 -0500
From: Andrew Cagney <ac131313@redhat.com>
User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223
MIME-Version: 1.0
To: gdb@sources.redhat.com
Subject: dummy frame on stack and SPARC
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
tests=FROM_ENDS_IN_NUMS,SPAM_PHRASE_00_01,USER_AGENT,
USER_AGENT_MOZILLA_UA,X_ACCEPT_LANG
version=2.41
(thinking out loud)
The sparc architecture, when calling a struct return function has a
sequence like:
call struct_return_function, return address = pc + 8
nop
.word sizeof returned object
return_address:
... next instruction ....
That is, the return address is several instructions beyond the call
instruction and, more importantly, one of those "instructions" is an a
word to inform the callee of additional ABI information (from memory,
how much space the return structure needs).
When correctly implemeting sparc dummy calls, this behavior needs to be
implemented. Hence the call needs 2 words (the struct return size and
the breakpoint)instead of just one (the breakpoint) and the code dummy
no longer fits in _start. Conseqently, the SPARC, by default, pushes
the code dummy on the stack.
Problem is, this assumes that the target has an executable stack
(security?). As a consequence, the SPARC either:
- writes a two word code dummy onto the stack and correctly handls
struct return
- writes a one word code dummy into _start and fails when given a struct
return function
Instead of doing this, would it be possible to always write the code
dummy onto the stack and, when the stack isn't executable, recognize the
sigseg (?) as an attempt to return to the call dummy?
The only thing I'm not sure about is exactly when a SPARC will recognize
the segmentation violation and abort. It, thanks to the delayed branch
code, could be a cycle too early :-(
Andrew
--------------050207060508090007080708--