[prev in list] [next in list] [prev in thread] [next in thread] 

List:       opensolaris-code
Subject:    Re: [tools-linking] Re: [osol-code] ELF section names for DATA and BSS
From:       Rod Evans <Rod.Evans () Sun ! com>
Date:       2006-05-16 21:23:59
Message-ID: 446A42EF.5030003 () Sun ! com
[Download RAW message or body]

vamsi krishna wrote:

>> Generally, but there are (of course) more sections that can go into
>> that. .data1, etc.  I'd think that the program headers would be a better
>> thing to rely upon, instead of the section headers.
> 
> The Elf_Phdr's seems to have sections merged in it, i.e both .data and
> .bss are merged into a 'rw-p' segment which is used by elf_loader to
> load it directly.

Correct.  Sections that are allocatable (form the memory image) and
are readable and writable, are concatenated into a "data" segment.

> But there is NO WAY I can get information on where excatly (which
> virtual address) the data starts and its size, I can get this
> information from unstripped section headers (Generally people dont
> strip section headers) from the executable even though its totally
> redundant.

Correct.  There's no specific mechanism to determine where each
section resides at runtime.   The memory image is constructed such
that individual section information is no longer required.

> Eric as you said data sections are named as 'data' , 'data1' ... why
> does'nt the linker merge all the DATA sections together, Where do all
> my application global variables (initialized) go into .data or .data1
> ??

There are many sections, output from the compilers, that are concatenated
to the "data" segment.  .data and .data1 are just two of these sections
(I think one of these holds strings and the other non-strings).

> Is it the sheer size of the DATA section causes this split for page
> alignment during loading ??

No.  Like sections are concatenated together, but sections of different
names or characteristics remain separated as the compilers provided them
to the link-editor.

>> 'elfdump -c' dumps the section headers, 'elfdump -p' dumps the program 
>> headers.
> 
> Thank you, I tested elfdump its working fine.

That's good to hear.

>> > My application tries to persist the contents of DATA and BSS and
>> > rewrite them back.
>>
>> To do what?  Is this an 'undump'-style thing, like emacs does?
> 
> Yes!! this is excatly what my program does, reads the elf_shds to
> figure out the excat begin and size of .data and .bss sections dump
> them and reload them.

dldump(3c) perhaps?   This was invented long ago for emacs.

-- 
Rod
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic