9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Michael Teichgräber" <mt@wmipf.in-berlin.de>
To: 9fans@9fans.net
Subject: [9fans] getcallerpc on arm7
Date: Thu, 27 Mar 2008 11:25:18 +0100	[thread overview]
Message-ID: <47EB760E.30804@wmipf.in-berlin.de> (raw)

Hi,

trying to adapt the getcallerpc function - that
exists on Plan9 and p9p - to the arm7 using the arm-elf-gcc
compiler, I realized that this would not be easy, as
most function arguments are put into registers
(the return value into lr), and only pushed on the
stack on demand - so it seems one can not expect to find
the return address at a fixed position starting with
the first argument's address.

(Looking at runtime some ulongs around &firstarg I
actually can see the return address, but it is a varying
number of longs upwards (not downwards) of &firstarg)

I wonder under what conditions plan9port's
"return ((ulong*)x)[-2]" for arm-linux/gcc actually works.

So far I found out that I could implement getcallerpc as
a macro using gcc's __builtin_return_address(0), but this would
not fit getcallerpc's normal behaviour (which I suppose
only depends on &firstarg, not the current function
context).

Although I know that the Plan9 compilers and gcc organize
function calls differently, I thought it would be helpful to
understand what /sys/src/libc/arm/getcallerpc.s does -
after having a look at A Manual for the Plan 9 assembler:

	MOVW	0(R13), R0
	RET

Does this mean that it is just returning the contents of the
first word on the Stack (R13) - and not interpreting &firstarg
at all?

Thanks for any hint,

Michael


             reply	other threads:[~2008-03-27 10:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-27 10:25 Michael Teichgräber [this message]
2008-03-31 16:24 ` Russ Cox
2008-03-31 17:23   ` Michael Teichgräber
2008-03-31 19:09   ` Charles Forsyth
2008-03-31 22:34     ` Michael Teichgräber

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=47EB760E.30804@wmipf.in-berlin.de \
    --to=mt@wmipf.in-berlin.de \
    --cc=9fans@9fans.net \
    /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 NNTP newsgroup(s).