This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
tweak elf-generic.em
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sourceware dot org
- Date: Wed, 26 Jul 2006 21:56:46 +0930
- Subject: tweak elf-generic.em
It is more efficient to lay out sections before trying to map to
segments, because there's some hope that the estimate for number
of segments is correct. Also, it doesn't make sense to do a
segment map for relocatable linking.
* emultempl/elf-generic.em (map_segments): Reorganise loop so that
layout happens before segment map. Don't do segment map on
relocatable link.
Index: ld/emultempl/elf-generic.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf-generic.em,v
retrieving revision 1.2
diff -u -p -r1.2 elf-generic.em
--- ld/emultempl/elf-generic.em 20 Jun 2006 16:37:29 -0000 1.2
+++ ld/emultempl/elf-generic.em 26 Jul 2006 01:08:23 -0000
@@ -28,9 +28,26 @@ gld${EMULATION_NAME}_map_segments (bfd_b
{
int tries = 10;
- while (tries)
+ do
{
- if (output_bfd->xvec->flavour == bfd_target_elf_flavour)
+ if (need_layout)
+ {
+ lang_reset_memory_regions ();
+
+ /* Resize the sections. */
+ lang_size_sections (NULL, TRUE);
+
+ /* Redo special stuff. */
+ ldemul_after_allocation ();
+
+ /* Do the assignments again. */
+ lang_do_assignments ();
+
+ need_layout = FALSE;
+ }
+
+ if (output_bfd->xvec->flavour == bfd_target_elf_flavour
+ && !link_info.relocatable)
{
bfd_size_type phdr_size;
@@ -45,24 +62,8 @@ gld${EMULATION_NAME}_map_segments (bfd_b
if (phdr_size != elf_tdata (output_bfd)->program_header_size)
need_layout = TRUE;
}
-
- if (!need_layout)
- break;
-
- lang_reset_memory_regions ();
-
- /* Resize the sections. */
- lang_size_sections (NULL, TRUE);
-
- /* Redo special stuff. */
- ldemul_after_allocation ();
-
- /* Do the assignments again. */
- lang_do_assignments ();
-
- need_layout = FALSE;
- --tries;
}
+ while (need_layout && --tries);
if (tries == 0)
einfo (_("%P%F: looping in map_segments"));
--
Alan Modra
IBM OzLabs - Linux Technology Centre