public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: David Mosberger <davidm@napali.hpl.hp.com>
To: Roland McGrath <roland@redhat.com>
Cc: davidm@hpl.hp.com, libc-hacker@sources.redhat.com
Subject: Re: [PATCH] move __gmon_start__ call out of .init section
Date: Thu, 07 Nov 2002 14:08:00 -0000	[thread overview]
Message-ID: <15818.58477.531836.650663@napali.hpl.hp.com> (raw)
In-Reply-To: <200211072145.gA7Ljlb28956@magilla.sf.frob.com>

>>>>> On Thu, 7 Nov 2002 13:45:47 -0800, Roland McGrath <roland@redhat.com> said:

  >> The patch below changes the ia64 initfini.c such that the call to
  >> __gmon_start__ is done via the .init_array section (if
  >> available).  The idea here is to keep the .init/.fini empty
  >> (apart from prologue/epilogue) so as to ensure that the unwind
  >> info is always correct.

  Roland> Can you elaborate a bit on the problem you are addressing
  Roland> here?

The problem is that the unwind info for the .init/.fini section will
be incorrect if it contains any function call.  It's easiest to make a
concrete example:

 - on ia64, if there is no explicit unwind info for a piece of code,
   the assumption is that the return address is stored in branch
   register b0

 - if .init contains a call, then the value in the return address
   register (b0) needs to be saved somewhere (normally on the memory
   stack); but since .init is created "dynamically" by the linker, the
   unwind info for .init will be wrong and the fact that b0 has been
   saved on the memory stack won't be recorded anywhere

Of course, one could hack the linker to correct the unwind info but
this would be fragile and ugly, so the preferred solution is to
deprecate .init/.fini alltogether and to use .init_array/.fini_array
instead (which is much easier to use anyhow).

  Roland> This seems wrong to me, in that the user program might put
  Roland> some code into the .init section and then __gmon_start__
  Roland> would come after it instead of before.

That's true, but .init is deprecated on ia64 anyhow.  If legacy code
doesn't get profiled because it was using .init, I doubt that's a big
loss.

Perhaps the call could be moved into .preinit_array?  I'm not entirely
sure whether that would be safe though.

	--david

  reply	other threads:[~2002-11-07 22:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-30  7:00 David Mosberger
2002-11-07 13:45 ` Roland McGrath
2002-11-07 14:08   ` David Mosberger [this message]
2002-11-07 14:27     ` Roland McGrath
2002-11-07 14:32       ` David Mosberger
2002-11-07 17:43         ` Roland McGrath
2002-11-08  3:05           ` Andreas Schwab
2002-11-08 11:15           ` David Mosberger

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=15818.58477.531836.650663@napali.hpl.hp.com \
    --to=davidm@napali.hpl.hp.com \
    --cc=davidm@hpl.hp.com \
    --cc=libc-hacker@sources.redhat.com \
    --cc=roland@redhat.com \
    /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).