public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: Shaun Jackman <sjackman@gmail.com>
Cc: binutils@sources.redhat.com
Subject: Re: Finding the start and end of memory areas
Date: Thu, 23 Dec 2004 11:15:00 -0000	[thread overview]
Message-ID: <41CAAA76.8060400@redhat.com> (raw)
In-Reply-To: <7f45d93904122216217855ef5f@mail.gmail.com>

Hi Shaun,

> First off, this posting is somewhat off-topic. My apologies in
> advance. If anyone knows of a better forum for this topic, I'd
> appreciate being pointed in the right direction. 

Actually this is the right forum for this kind of question.

> I'd like to find the start and end of the following memory areas
> during run-time...
> 
> text
> data
> bss - &__bss_start to &__bss_end
> heap - &__bss_end to sbrk(0)
> (gap)
> stack - stack pointer to ?

The simplest way is to have the cooperation of the linker script used to 
create your executable.  If the script places symbols at the start and 
end of each of these sections then you can easily access them at run-time.

If you cannot modify the linker script then you are going to have to 
locate the executable on disk (presumably via argv[0]) and then load and 
process the ELF headers and section tables themselves.

Cheers
   Nick

  reply	other threads:[~2004-12-23 11:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-23  0:22 Shaun Jackman
2004-12-23 11:15 ` Nick Clifton [this message]
2004-12-23 19:39   ` Shaun Jackman

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=41CAAA76.8060400@redhat.com \
    --to=nickc@redhat.com \
    --cc=binutils@sources.redhat.com \
    --cc=sjackman@gmail.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).