This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Make sure the .dynamic section is the first section in thePTDYNAMIC segment (was Re: [PATCH] Explicitly get .dynamic section for "readelf-d")
Hi Nick,
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:
Thanks!
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().
Later, I find the best place to add this check is
assign_file_positions_for_segments (). Here is the small patch. However,
I'm not sure that we should give a warn or error if the check fails.
This patch just gives an error.
Regards
--
Jie
2004-06-25 Jie Zhang <zhangjie@magima.com.cn>
* bfd/elf.c (assign_file_positions_for_segments): Make sure the
.dynamic section is the first section in the PT_DYNAMIC segment.
--- elf.c.old 2004-06-25 11:13:45.000000000 +0800
+++ elf.c 2004-06-25 11:15:54.000000000 +0800
@@ -3826,6 +3826,18 @@ assign_file_positions_for_segments (bfd
1 << align);
}
}
+ /* Make sure the .dynamic section is the first section in the
+ PT_DYNAMIC segment. */
+ else if (p->p_type == PT_DYNAMIC
+ && m->count > 1
+ && strcmp (m->sections[0]->name, ".dynamic") != 0)
+ {
+ (*_bfd_error_handler)
+ (_("%s: The first section in the PT_DYNAMIC segment is not
the .dynamic section"),
+ bfd_get_filename (abfd));
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
if (m->count == 0)
p->p_vaddr = 0;