* elf.c (assign_file_positions_for_load_sections): Use elf
authorAlan Modra <amodra@gmail.com>
Fri, 29 Jun 2007 01:21:08 +0000 (01:21 +0000)
committerAlan Modra <amodra@gmail.com>
Fri, 29 Jun 2007 01:21:08 +0000 (01:21 +0000)
section header sh_size rather than bfd section size, simplifying
.tbss handling.

bfd/ChangeLog
bfd/elf.c

index 37782207b474b3de22a79649933da6325a77a76a..a4e166d9d34f645696ca2a6360e2d532d1aa8765 100644 (file)
@@ -1,3 +1,9 @@
+2007-06-29  Alan Modra  <amodra@bigpond.net.au>
+
+       * elf.c (assign_file_positions_for_load_sections): Use elf
+       section header sh_size rather than bfd section size, simplifying
+       .tbss handling.
+
 2007-06-29  Alan Modra  <amodra@bigpond.net.au>
 
        * elf.c (assign_file_positions_for_load_sections): Ensure bss
index a269f329ff0533c7a5dee6ddf0acccdb74e4cf54..baa9512469e56f56dd23ad288483a12f2fec94a5 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4578,8 +4578,8 @@ assign_file_positions_for_load_sections (bfd *abfd,
              if (i == 0)
                {
                  this_hdr->sh_offset = sec->filepos = off;
-                 off += sec->size;
-                 p->p_filesz = sec->size;
+                 off += this_hdr->sh_size;
+                 p->p_filesz = this_hdr->sh_size;
                  p->p_memsz = 0;
                  p->p_align = 1;
                }
@@ -4598,33 +4598,27 @@ assign_file_positions_for_load_sections (bfd *abfd,
                {
                  this_hdr->sh_offset = sec->filepos = off;
                  if (this_hdr->sh_type != SHT_NOBITS)
-                   off += sec->size;
+                   off += this_hdr->sh_size;
                }
 
              if (this_hdr->sh_type != SHT_NOBITS)
                {
-                 p->p_filesz += sec->size;
+                 p->p_filesz += this_hdr->sh_size;
                  /* A load section without SHF_ALLOC is something like
                     a note section in a PT_NOTE segment.  These take
                     file space but are not loaded into memory.  */
                  if ((this_hdr->sh_flags & SHF_ALLOC) != 0)
-                   p->p_memsz += sec->size;
+                   p->p_memsz += this_hdr->sh_size;
                }
-
-             /* .tbss is special.  It doesn't contribute to p_memsz of
-                normal segments.  */
-             else if ((this_hdr->sh_flags & SHF_ALLOC) != 0
-                      && ((this_hdr->sh_flags & SHF_TLS) == 0
-                          || p->p_type == PT_TLS))
-               p->p_memsz += sec->size;
-
-             if (p->p_type == PT_TLS
-                 && sec->size == 0
-                 && (sec->flags & SEC_HAS_CONTENTS) == 0)
+             else if ((this_hdr->sh_flags & SHF_ALLOC) != 0)
                {
-                 struct bfd_link_order *o = sec->map_tail.link_order;
-                 if (o != NULL)
-                   p->p_memsz += o->offset + o->size;
+                 if (p->p_type == PT_TLS)
+                   p->p_memsz += this_hdr->sh_size;
+
+                 /* .tbss is special.  It doesn't contribute to p_memsz of
+                    normal segments.  */
+                 else if ((this_hdr->sh_flags & SHF_TLS) == 0)
+                   p->p_memsz += this_hdr->sh_size;
                }
 
              if (p->p_type == PT_GNU_RELRO)
This page took 0.029015 seconds and 4 git commands to generate.