the question about PT_DYNAMIC's p_offset value in elf file for mips platform

eagle_zhou@ali.com.tw eagle_zhou@ali.com.tw
Tue Oct 26 09:10:00 GMT 2004



hi Nick,

I think that .dynamic section should be the first section of dynamic
segment.

I have studied source codes in glibc(dynamic loader part), it's flow is :
find program header firstly,
then find PT_DYNAMIC segment,
finally find other dynamic section by searching PT_DYNAMIC
segment(regarding it as a array of struct Elf32_Dyn).

If .dynamic section is not the first section in dynamic segment,
how can i get other dynamic section information?
and isn't glibc source perfect?

thanks.






Nick Clifton <nickc@redhat.com> on 2004-10-26 16:30:11

To:   Eagle Zhou/ALI_SHA/ACER@ACER
cc:   binutils@sources.redhat.com

Subject:  Re: the question about PT_DYNAMIC's p_offset value in elf file
      for mips platform



Hi Eagle,

 > I do not know why PT_DYNAMIC's p_offset is 0x0000ac. I think the
 > correct value should be 0x1008.

The PT_DYNAMIC segment includes more than just the .dynamic section.  It
also includes sections like .hash, .dynsym etc.  Hence the segment
starts at the lowest offset of all of these sections, which in this case
is the .hash section.

If you have a look at the section to segment mapping output from readelf:

>       Section to Segment mapping:
>        Segment Sections...
>         00     .hash .dynsym .dynstr .text .MIPS.stubs .rel.dyn
>         01     .data .dynamic .got .bss
>         02     .reginfo .hash .dynsym .dynstr .text .MIPS.stubs .data
> .dynamic .debug_aranges .debug_pubnames .debug_info .debug_abbrev
> .debug_line .debug_frame .debug_str .pdr .rel.dyn .compact_rel .shstrtab
> .symtab


You can see the relationship between segments and sections.

Cheers
   Nick






More information about the Binutils mailing list