How to access an applications ELF program header and ELF section header at runtime

Bharath Ramesh bramesh@vt.edu
Mon Jan 4 21:03:00 GMT 2010


On Fri, Oct 23, 2009 at 11:02:55AM -0400, Carlos O'Donell wrote:
> On Thu, Oct 22, 2009 at 4:49 PM, Bharath Ramesh <bramesh@vt.edu> wrote:
> > I am trying to play around with the symbols __data_start and __bss_start
> > to access the location of the .data and .bss section. Is there any way I
> > need to typecast these symbols so that I can get the information from
> > these symbols.
> 
> extern const char __symbol __attribute__((weak));
> #define symbol ((unsigned long)&__symbol)
> 

As mentioned in earlier emails to this thread [1] I need to access the
.data and .bss sections of an application. I need to access this from
the constructor of my shared library. I am not of the reason, but I am
an unable to get access to __data_start. It always has a value of NULL
address to it. I am able to get valid value for _edata, __bss_start and
_end. When I use nm to list the symbols of the application __data_start
does exist with an offset, but __data_start symbol for the shared
library doesnt have any offset. Is there something I am missing, is
there any way I can make sure that I get the valid address for these
symbols from the constructor of the shared library.

Regards,

Bharath

[1] http://sourceware.org/ml/libc-help/2009-08/msg00032.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2245 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-help/attachments/20100104/88fe9c49/attachment.bin>


More information about the Libc-help mailing list