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: [PATCH] Explicitly get .dynamic section for "readelf -d"


Hi Jie,

Here is it. But I'm afraid it is not good enough yet.

Thanks this is much better.



The -d option of readelf is for displaying the contents of the file's dynamic section as stated in the document. However, almost all relevant code say dynamic *segment* rather than dynamic *section*. For most targets dynamic segment contains only .dynamic section and they are equivalent, but for SGI's MIPS this is not true. Is it worth changing all "dynamic segment" to "dynamic section", e.g. process_dynamic_segment to process_dynamic_section and dynamic_segment to dynamic_section?

Yes it is. It is better to be accurate and consistent. Especially with segments and sections because it is so easy to confuse the two. I have added this to the patch and checked it in with this ChangeLog entry:


binutils/ChangeLog
2004-06-18  Jie Zhang  <zhangjie@magima.com.cn>

	* readelf.c (process_program_headers): When locating the dynamic
	section use the section table if it is present.
	(dynamic_segment): Renamed to dynamic_section.
	Replace references to dynamic segment with references to dynamic
	section, except where appropriate.
	(dynamic_segment_mips_val): Rename to dynamic_section_mips_val.
	(dynamic_segment_parisc_val): Rename to dynamic_section_parisc_val.
	(dynamic_segment_ia64_val): Rename to dynamic_section_ia64_val.
	(get_32bit_dynamic_segment): Rename to get_32bit_dynamic_section.
	Remove tag counting code as it is no longer needed.
	(get_64bit_dynamic_segment): Rename to get_64bit_dynamic_section.
	Remove tag counting code as it is no longer needed.
	(process_dynamic_segment): Rename to process_dynamic_section.
	

The .dynamic section, I think now, should be the first section in the dynamic segment. Since section header table is optional in executable file, we cannot always rely on it to relocate .dynamic section. If a script does not make it come first in the segment, it's the script's fault not others. So I think that it would better to make ld warn (or error) if the .dynamic section is not the first section in the dynamic segment. Is this reasonable?

Yes I think so.


Is there any target other than MIPS that has more than one section in dynamic segment? If it is the only target, I'm going to add check in _bfd_mips_elf_modify_segment_map (). Otherwise, I'm going to add check in map_sections_to_segments (). Are they the right places?

As far as I know it is only the MIPS port that does this at the moment, but there is no guarantee that other ports will not do so in the future. Thus I would suggest adding the check to map_sections_to_segments().


Cheers
  Nick


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