This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
phdrs and excluded sections
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sources dot redhat dot com
- Date: Mon, 4 Jul 2005 19:57:50 +0930
- Subject: phdrs and excluded sections
When using PHDRS in a linker script, the assignment of sections to
segments happens before output sections are stripped. This can result
in linker errors that aren't really warranted.
PR 1042
* elf.c (assign_file_positions_for_segments): Remove excluded
sections from the segment map.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.304
diff -u -p -r1.304 elf.c
--- bfd/elf.c 4 Jul 2005 01:53:38 -0000 1.304
+++ bfd/elf.c 4 Jul 2005 09:57:12 -0000
@@ -4044,7 +4044,8 @@ assign_file_positions_for_segments (bfd
{
/* The placement algorithm assumes that non allocated sections are
not in PT_LOAD segments. We ensure this here by removing such
- sections from the segment map. */
+ sections from the segment map. We also remove excluded
+ sections. */
for (m = elf_tdata (abfd)->segment_map;
m != NULL;
m = m->next)
@@ -4052,13 +4053,12 @@ assign_file_positions_for_segments (bfd
unsigned int new_count;
unsigned int i;
- if (m->p_type != PT_LOAD)
- continue;
-
new_count = 0;
for (i = 0; i < m->count; i ++)
{
- if ((m->sections[i]->flags & SEC_ALLOC) != 0)
+ if ((m->sections[i]->flags & SEC_EXCLUDE) == 0
+ && ((m->sections[i]->flags & SEC_ALLOC) != 0
+ || m->p_type != PT_LOAD))
{
if (i != new_count)
m->sections[new_count] = m->sections[i];
--
Alan Modra
IBM OzLabs - Linux Technology Centre