* elf.c (elf_fake_sections): When calculating tbss size, just use
authorAlan Modra <amodra@gmail.com>
Thu, 3 Nov 2005 02:53:38 +0000 (02:53 +0000)
committerAlan Modra <amodra@gmail.com>
Thu, 3 Nov 2005 02:53:38 +0000 (02:53 +0000)
the last link_order.
(assign_file_positions_for_segments): Likewise.
* elflink.c (bfd_elf_final_link): Likewise.
(elf_reloc_link_order): Correct comment.

bfd/ChangeLog
bfd/elf.c
bfd/elflink.c

index f4549c30455bbf8863c3a730a4d4492dfe4e4ba0..53a2538e8bc8170a01be0ac05b15a357fcc0fb4d 100644 (file)
@@ -1,3 +1,11 @@
+2005-11-03  Alan Modra  <amodra@bigpond.net.au>
+
+       * elf.c (elf_fake_sections): When calculating tbss size, just use
+       the last link_order.
+       (assign_file_positions_for_segments): Likewise.
+       * elflink.c (bfd_elf_final_link): Likewise.
+       (elf_reloc_link_order): Correct comment.
+
 2005-11-02  Alan Modra  <amodra@bigpond.net.au>
 
        PR ld/1775
index 0e72d4ef93f3bac01468cdae88590fb0161c5cd2..ea86c3ef859a93befa18132e66fd843c399f2d25 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2764,16 +2764,18 @@ elf_fake_sections (bfd *abfd, asection *asect, void *failedptrarg)
   if ((asect->flags & SEC_THREAD_LOCAL) != 0)
     {
       this_hdr->sh_flags |= SHF_TLS;
-      if (asect->size == 0 && (asect->flags & SEC_HAS_CONTENTS) == 0)
+      if (asect->size == 0
+         && (asect->flags & SEC_HAS_CONTENTS) == 0)
        {
-         struct bfd_link_order *o;
+         struct bfd_link_order *o = asect->map_tail.link_order;
 
          this_hdr->sh_size = 0;
-         for (o = asect->map_head.link_order; o != NULL; o = o->next)
-           if (this_hdr->sh_size < o->offset + o->size)
+         if (o != NULL)
+           {
              this_hdr->sh_size = o->offset + o->size;
-         if (this_hdr->sh_size)
-           this_hdr->sh_type = SHT_NOBITS;
+             if (this_hdr->sh_size != 0)
+               this_hdr->sh_type = SHT_NOBITS;
+           }
        }
     }
 
@@ -4396,14 +4398,9 @@ assign_file_positions_for_segments (bfd *abfd, struct bfd_link_info *link_info)
                  && sec->size == 0
                  && (sec->flags & SEC_HAS_CONTENTS) == 0)
                {
-                 struct bfd_link_order *o;
-                 bfd_vma tbss_size = 0;
-
-                 for (o = sec->map_head.link_order; o != NULL; o = o->next)
-                   if (tbss_size < o->offset + o->size)
-                     tbss_size = o->offset + o->size;
-
-                 p->p_memsz += tbss_size;
+                 struct bfd_link_order *o = sec->map_tail.link_order;
+                 if (o != NULL)
+                   p->p_memsz += o->offset + o->size;
                }
 
              if (align > p->p_align
index 899c48db8e92e6f5fd4be85168c3915b6734da1e..1fcfce352d8989abc781b6dd48cd0dd40880cdfe 100644 (file)
@@ -7394,7 +7394,7 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
 }
 
 /* Generate a reloc when linking an ELF file.  This is a reloc
-   requested by the linker, and does come from any input file.  This
+   requested by the linker, and does not come from any input file.  This
    is used to build constructor and destructor tables when linking
    with -Ur.  */
 
@@ -8129,15 +8129,14 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
           sec && (sec->flags & SEC_THREAD_LOCAL);
           sec = sec->next)
        {
-         bfd_vma size = sec->size;
+         bfd_size_type size = sec->size;
 
-         if (size == 0 && (sec->flags & SEC_HAS_CONTENTS) == 0)
+         if (size == 0
+             && (sec->flags & SEC_HAS_CONTENTS) == 0)
            {
-             struct bfd_link_order *o;
-
-             for (o = sec->map_head.link_order; o != NULL; o = o->next)
-               if (size < o->offset + o->size)
-                 size = o->offset + o->size;
+             struct bfd_link_order *o = sec->map_tail.link_order;
+             if (o != NULL)
+               size = o->offset + o->size;
            }
          end = sec->vma + size;
        }