* elf.c (elf_fake_sections): Fix up .tbss sh_size and sh_type.
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 Jul 2002 14:28:55 +0000 (14:28 +0000)
committerJakub Jelinek <jakub@redhat.com>
Tue, 30 Jul 2002 14:28:55 +0000 (14:28 +0000)
* ldlang.c (lang_add_section): Don't turn .tbss into normal sections
for relocatable link.
(lang_size_sections_1): Don't make .tbss zero size for relocatable
link.

bfd/ChangeLog
bfd/elf.c
ld/ChangeLog
ld/ldlang.c

index 63a7b83d6fa62355f0c7f843f0d0b1c3b4765570..764b36172dbfe10aac49ac27c70b4bc966dfb69e 100644 (file)
@@ -1,3 +1,7 @@
+2002-07-30  Jakub Jelinek  <jakub@redhat.com>
+
+       * elf.c (elf_fake_sections): Fix up .tbss sh_size and sh_type.
+
 2002-07-30  Alan Modra  <amodra@bigpond.net.au>
 
        * aoutx.h (some_aout_object_p): Clean up tdata properly on error.
index 79190e60f2bf3b40ce716bff90a08458b9b871ff..1582496a1dbd700ee35822e3a7e704a2f719da51 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2443,7 +2443,20 @@ elf_fake_sections (abfd, asect, failedptrarg)
   if ((asect->flags & SEC_GROUP) == 0 && elf_group_name (asect) != NULL)
     this_hdr->sh_flags |= SHF_GROUP;
   if ((asect->flags & SEC_THREAD_LOCAL) != 0)
-    this_hdr->sh_flags |= SHF_TLS;
+    {
+      this_hdr->sh_flags |= SHF_TLS;
+      if (asect->_raw_size == 0 && (asect->flags & SEC_HAS_CONTENTS) == 0)
+       {
+         struct bfd_link_order *o;
+                                          
+         this_hdr->sh_size = 0;
+         for (o = asect->link_order_head; o != NULL; o = o->next)
+           if (this_hdr->sh_size < o->offset + o->size)
+             this_hdr->sh_size = o->offset + o->size;
+         if (this_hdr->sh_size)
+           this_hdr->sh_type = SHT_NOBITS;
+       }
+    }
 
   /* Check for processor-specific section types.  */
   if (bed->elf_backend_fake_sections
index 6b9b887dee29560d39faa5b268c670e1a7e7b649..5b530ad74cc3df2acbd346d3376851bbe7e0a91e 100644 (file)
@@ -1,3 +1,10 @@
+2002-07-30  Jakub Jelinek  <jakub@redhat.com>
+
+       * ldlang.c (lang_add_section): Don't turn .tbss into normal sections
+       for relocatable link.
+       (lang_size_sections_1): Don't make .tbss zero size for relocatable
+       link.
+
 2002-07-26  Bernd Schmidt  <bernds@redhat.com>
 
        * emulparams/elf32frv.sh (OTHER_RELOCATING_SECTIONS): Delete.
index ba14c63a1f98f57f3ed8f4b28cb3c2b08fa025c0..c26082910026e2eb115aa71efcf3a63a6646a6e9 100644 (file)
@@ -1218,7 +1218,7 @@ lang_add_section (ptr, section, output, file)
        }
 
       /* For now make .tbss normal section.  */
-      if (flags & SEC_THREAD_LOCAL)
+      if ((flags & SEC_THREAD_LOCAL) && ! link_info.relocateable)
        flags |= SEC_LOAD;
 
       section->output_section->flags |= flags;
@@ -3055,7 +3055,8 @@ lang_size_sections_1 (s, output_section_statement, prev, fill, dot, relax)
            if (bfd_is_abs_section (os->bfd_section))
              ASSERT (after == os->bfd_section->vma);
            else if ((os->bfd_section->flags & SEC_HAS_CONTENTS) == 0
-                    && (os->bfd_section->flags & SEC_THREAD_LOCAL))
+                    && (os->bfd_section->flags & SEC_THREAD_LOCAL)
+                    && ! link_info.relocateable)
              os->bfd_section->_raw_size = 0;
            else
              os->bfd_section->_raw_size =