From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17772 invoked by alias); 23 Dec 2004 11:15:47 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 17743 invoked from network); 23 Dec 2004 11:15:41 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 23 Dec 2004 11:15:41 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id iBNBFfgL024156 for ; Thu, 23 Dec 2004 06:15:41 -0500 Received: from pobox.surrey.redhat.com (pobox.surrey.redhat.com [172.16.10.17]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id iBNBFer12781; Thu, 23 Dec 2004 06:15:40 -0500 Received: from [172.31.0.98] (vpnuser4.surrey.redhat.com [172.16.9.4]) by pobox.surrey.redhat.com (8.12.8/8.12.8) with ESMTP id iBNBFdge006097; Thu, 23 Dec 2004 11:15:39 GMT Message-ID: <41CAAA76.8060400@redhat.com> Date: Thu, 23 Dec 2004 11:15:00 -0000 From: Nick Clifton User-Agent: Mozilla Thunderbird 1.0RC1 (X11/20041201) MIME-Version: 1.0 To: Shaun Jackman CC: binutils@sources.redhat.com Subject: Re: Finding the start and end of memory areas References: <7f45d93904122216217855ef5f@mail.gmail.com> In-Reply-To: <7f45d93904122216217855ef5f@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2004-12/txt/msg00291.txt.bz2 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