This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] elf section building


Elias Athanasopoulos <eathan@otenet.gr> writes:

> In bfd_section_from_shdr() (elf.c) the sections of an elf are parsed. There
> is code like:
> 
>  case SHT_SYMTAB:            /* A symbol table */
>    if (elf_onesymtab (abfd) == shindex)
>      return true;
> 
> What's the purpose of this check? Wouldn't be better to return a call to
> _bfd_elf_make_section_from_shdr()? This way objdump will not miss some
> sections when it is invoked with the -h switch.
> 	       
> I have a scenario where objdump misses .shstrtab, .symtab and .strtab,
> whilst readelf prints all sections. I have a patch that replaces some
> plain 'true' returns with calls to _bfd_elf_make_section_from_shdr(), but
> I want to verify that this is the right direction to procceed.

That probably won't work--it might work for objdump, but it will
probably break other tools.  BFD is designed to interpret object files
in a generic fashion.  In BFD's generic view, the symbol table is not
itself a section--that is an ELF-specific notion.  So when objdump
prints sections, it doesn't print the symbol table.  Similarly for
.shstrtab.

readelf is ELF specific, so it handles all sections according to the
ELF definition.

In general, I believe that objdump -h should not print the ELF
.shstrtab, .symtab, and .strtab sections.  If you want ELF specific
information, that is what readelf is for.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]