Make 64k .sdata and .sdata2 sections work; fix typos
authorMichael Meissner <gnu@the-meissners.org>
Mon, 22 Jan 1996 23:55:25 +0000 (23:55 +0000)
committerMichael Meissner <gnu@the-meissners.org>
Mon, 22 Jan 1996 23:55:25 +0000 (23:55 +0000)
bfd/ChangeLog
bfd/elf32-ppc.c
bfd/elflink.h

index 0719dc4..1d72b5a 100644 (file)
@@ -1,3 +1,20 @@
+Mon Jan 22 18:45:51 1996  Michael Meissner  <meissner@tiktok.cygnus.com>
+
+       * elflink.h (elf_finish_pointer_linker_section): Don't allocate
+       memory here for contents.
+
+       * elf32-ppc.c (ppc_elf_relocate_section): Bump up _SDA_BASE_ and
+       _SDA2_BASE_ by 32768.
+       (ppc_elf_size_dynamic_sections): #if out PLT code which we haven't
+       started using.  Allocate contents for .sdata and .sdata2 sections
+       also.
+       (ppc_elf_check_relocs): Use bfd_get_section_name in debug message,
+       rather than _name.
+       (ppc_elf_finish_dynamic_symbol): Remove code that attempted to
+       size _SDA{,2}_BASE_.
+       (ppc_elf_relocate_section): Change how sdata{,2} relocations are
+       done.
+
 Mon Jan 22 08:52:04 1996  Doug Evans  <dje@charmed.cygnus.com>
 
        * elflink.h (elf_finish_pointer_linker_section): Fix typo.
index 6554cf9..a7be7a1 100644 (file)
@@ -1270,6 +1270,7 @@ ppc_elf_create_linker_section (abfd, info, which)
          defaults.rel_name       = ".rela.sdata";
          defaults.bss_name       = ".sbss";
          defaults.sym_name       = "_SDA_BASE_";
+         defaults.sym_offset     = 32768;
          break;
 
        case LINKER_SECTION_SDATA2:     /* .sdata2/.sbss2 section */
@@ -1277,6 +1278,7 @@ ppc_elf_create_linker_section (abfd, info, which)
          defaults.rel_name       = ".rela.sdata2";
          defaults.bss_name       = ".sbss2";
          defaults.sym_name       = "_SDA2_BASE_";
+         defaults.sym_offset     = 32768;
          break;
        }
 
@@ -1399,6 +1401,7 @@ ppc_elf_size_dynamic_sections (output_bfd, info)
 
       strip = false;
 
+#if 0
       if (strncmp (name, ".rela", 5) == 0)
        {
          if (s->_raw_size == 0)
@@ -1433,8 +1436,12 @@ ppc_elf_size_dynamic_sections (output_bfd, info)
              s->reloc_count = 0;
            }
        }
-      else if (strcmp (name, ".plt") != 0
-              && strcmp (name, ".got") != 0)
+      else
+#endif
+       if (strcmp (name, ".plt") != 0
+           && strcmp (name, ".got") != 0
+           && strcmp (name, ".sdata") != 0
+           && strcmp (name, ".sdata2") != 0)
        {
          /* It's not one of our sections, so don't allocate space.  */
          continue;
@@ -1549,7 +1556,8 @@ ppc_elf_check_relocs (abfd, info, sec, relocs)
     return true;
 
 #ifdef DEBUG
-  fprintf (stderr, "ppc_elf_check_relocs called for section %s\n", sec->name);
+  fprintf (stderr, "ppc_elf_check_relocs called for section %s\n",
+          bfd_get_section_name (abfd, sec));
 #endif
 
   /* Create the linker generated sections all the time so that the special
@@ -1755,8 +1763,6 @@ ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
      Elf_Internal_Sym *sym;
 {
   bfd *dynobj;
-  elf_linker_section_t *sdata;
-  elf_linker_section_t *sdata2;
 
 #ifdef DEBUG
   fprintf (stderr, "ppc_elf_finish_dynamic_symbol called for %s\n", h->root.root.string);
@@ -1764,8 +1770,6 @@ ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
 
   dynobj = elf_hash_table (info)->dynobj;
   BFD_ASSERT (dynobj != NULL);
-  sdata = elf_linker_section (dynobj, LINKER_SECTION_SDATA);
-  sdata2 = elf_linker_section (dynobj, LINKER_SECTION_SDATA2);
 
   if (h->plt_offset != (bfd_vma) -1)
     {
@@ -1843,45 +1847,6 @@ ppc_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
       || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
     sym->st_shndx = SHN_ABS;
 
-  /* If .sdata is larger than 32767, bump up _SDA_BASE_ by 32768 so that
-     we put off getting relocation overflows until it is > 65k.  Do the
-     same for .sdata2 and _SDA2_BASE_.  */
-  if (sdata && sdata->sym_hash == h
-      && (h->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) == 0)
-    {
-      bfd_vma size = 0;
-      asection *s = bfd_get_section_by_name (output_bfd, ".sdata");
-      if (s)
-       size = s->_raw_size;
-
-      s = bfd_get_section_by_name (output_bfd, ".sbss");
-      if (s)
-       size += s->_raw_size;
-
-      if (size > 32767)
-       h->root.u.def.value += 32768;
-
-      h->elf_link_hash_flags |= ELF_LINK_HASH_DYNAMIC_ADJUSTED;
-    }
-
-  if (sdata2 && sdata2->sym_hash == h
-      && (h->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) == 0)
-    {
-      bfd_vma size = 0;
-      asection *s = bfd_get_section_by_name (output_bfd, ".sdata2");
-      if (s)
-       size = s->_raw_size;
-
-      s = bfd_get_section_by_name (output_bfd, ".sbss2");
-      if (s)
-       size += s->_raw_size;
-
-      if (size > 32767)
-       h->root.u.def.value += 32768;
-
-      h->elf_link_hash_flags |= ELF_LINK_HASH_DYNAMIC_ADJUSTED;
-    }
-
   return true;
 }
 
@@ -2274,11 +2239,11 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              ret = false;
              continue;
            }
-         relocation = (sdata->sym_hash->root.u.def.value
-                       + sdata->sym_hash->root.u.def.section->output_section->vma
-                       - relocation);
+         addend -= sdata->sym_hash->root.u.def.value;
+         relocation = sdata->sym_hash->root.u.def.section->output_section->vma - relocation;
          break;
 
+
        /* relocate against _SDA2_BASE_ */
        case (int)R_PPC_EMB_SDA2REL:
          BFD_ASSERT (sec != (asection *)0);
@@ -2294,9 +2259,8 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              ret = false;
              continue;
            }
-         relocation = (sdata2->sym_hash->root.u.def.value
-                       + sdata2->sym_hash->root.u.def.section->output_section->vma
-                       - relocation);
+         addend -= sdata2->sym_hash->root.u.def.value;
+         relocation = sdata2->sym_hash->root.u.def.section->output_section->vma - relocation;
          break;
 
 
@@ -2311,17 +2275,15 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
            if (strcmp (name, ".sdata") == 0 || strcmp (name, ".sbss") == 0)
              {
                reg = 13;
-               relocation = (sdata->sym_hash->root.u.def.value
-                             + sdata->sym_hash->root.u.def.section->output_section->vma
-                             - relocation);
+               addend -= sdata->sym_hash->root.u.def.value;
+               relocation = sdata->sym_hash->root.u.def.section->output_section->vma - relocation;
              }
 
            else if (strcmp (name, ".sdata2") == 0 || strcmp (name, ".sbss2") == 0)
              {
                reg = 2;
-               relocation = (sdata2->sym_hash->root.u.def.value
-                             + sdata2->sym_hash->root.u.def.section->output_section->vma
-                             - relocation);
+               addend -= sdata2->sym_hash->root.u.def.value;
+               relocation = sdata2->sym_hash->root.u.def.section->output_section->vma - relocation;
              }
 
            else if (strcmp (name, ".PPC.EMB.sdata0") == 0 || strcmp (name, ".PPC.EMB.sbss0") == 0)
index a1b4b14..283d0c7 100644 (file)
@@ -3208,7 +3208,7 @@ elf_create_pointer_linker_section (abfd, info, lsect, h, rel)
       if (info->shared)
        {
          /* If we are generating a shared object, we need to
-            output a R_PPC_RELATIVE reloc so that the
+            output a R_<xxx>_RELATIVE reloc so that the
             dynamic linker can adjust this GOT entry.  */
          BFD_ASSERT (lsect->rel_section != NULL);
          lsect->rel_section->_raw_size += sizeof (Elf_External_Rela);
@@ -3276,10 +3276,6 @@ elf_finish_pointer_linker_section (output_bfd, input_bfd, info, lsect, h, reloca
 
   BFD_ASSERT (lsect != NULL);
 
-  if (!lsect->section->contents)
-    lsect->section->contents = (unsigned char *) bfd_zalloc (output_bfd,
-                                                            lsect->section->_raw_size);
-
   if (h != NULL)               /* global symbol */
     {
       linker_section_ptr = _bfd_elf_find_pointer_linker_section (h->linker_section_pointer,