aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2002-06-06 10:03:38 +0000
committerNick Clifton <nickc@redhat.com>2002-06-06 10:03:38 +0000
commit1ed89aa92ed7b3fc5a12f8d670392e5ce67c31b4 (patch)
tree6083d580dacb1504fcaa3539065d2495f987b82b /bfd
parentdf3513d4be3a102ad1d7cd73fa15f4bff5434562 (diff)
downloadfsf-binutils-gdb-1ed89aa92ed7b3fc5a12f8d670392e5ce67c31b4.zip
fsf-binutils-gdb-1ed89aa92ed7b3fc5a12f8d670392e5ce67c31b4.tar.gz
fsf-binutils-gdb-1ed89aa92ed7b3fc5a12f8d670392e5ce67c31b4.tar.bz2
Do not include empty sections in loadable segments.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/elf.c36
2 files changed, 41 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 51f9a90..107403d 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2002-06-06 David Heine <dlheine@tensilica.com>
+
+ * elf.c (assign_file_positions_for_segments): Remove unallocated
+ sections from the section to segment mapping for PT_LOAD segments.
+ Update comment about empty loadable segments.
+
2002-06-06 Richard Sandiford <rsandifo@redhat.com>
* stabs.c (_bfd_link_section_stabs): Check that the symbol offset
@@ -44,7 +50,7 @@
* elf64-sh64.c (sh_elf64_get_relocated_section_contents): Likewise.
* elfxx-ia64.c (elfNN_ia64_relax_section): Likewise.
-Wed Jun 5 20:43:27 2002 J"orn Rennecke <joern.rennecke@superh.com>
+2002-06-05 J"orn Rennecke <joern.rennecke@superh.com>
* config.bfd (sh64l*-*-elf*, shl*-*-elf*): New configurations.
diff --git a/bfd/elf.c b/bfd/elf.c
index 36cbb76..fd9aa4b 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3455,6 +3455,37 @@ assign_file_positions_for_segments (abfd)
if (! map_sections_to_segments (abfd))
return false;
}
+ else
+ {
+ /* 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. */
+ for (m = elf_tdata (abfd)->segment_map;
+ m != NULL;
+ m = m->next)
+ {
+ 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 (i != new_count)
+ m->sections[new_count] = m->sections[i];
+
+ new_count ++;
+ }
+ }
+
+ if (new_count != m->count)
+ m->count = new_count;
+ }
+ }
if (bed->elf_backend_modify_segment_map)
{
@@ -4610,10 +4641,11 @@ copy_private_bfd_data (ibfd, obfd)
{
/* Special segments, such as the PT_PHDR segment, may contain
no sections, but ordinary, loadable segments should contain
- something. */
+ something. They are allowed by the ELF spec however, so only
+ a warning is produced. */
if (segment->p_type == PT_LOAD)
(*_bfd_error_handler)
- (_("%s: warning: Empty loadable segment detected\n"),
+ (_("%s: warning: Empty loadable segment detected, is this intentional ?\n"),
bfd_archive_filename (ibfd));
map->count = 0;