OSDN Git Service

bfd/
authorAlan Modra <amodra@bigpond.net.au>
Wed, 16 Mar 2005 02:41:25 +0000 (02:41 +0000)
committerAlan Modra <amodra@bigpond.net.au>
Wed, 16 Mar 2005 02:41:25 +0000 (02:41 +0000)
* elf32-ppc.c (ppc_elf_create_linker_section): Set SEC_LINKER_CREATED
on section.  Correct comment, and add FIXME.
(ppc_elf_additional_program_headers): Don't bump header count for
interp.  Test SEC_ALLOC, not SEC_LOAD, and don't test size.
(ppc_elf_size_dynamic_sections): Don't strip sdata and sdata2, but
do allocate memory if they need it.
ld/
* emulparams/elf32ppclinux.sh (OTHER_READWRITE_SECTION): Delete.
(OTHER_RELRO_SECTIONS): Set this instead.
ld/testsuite/
* ld-powerpc/tlsexe32.d: Update.
* ld-powerpc/tlsexe32.g: Update.
* ld-powerpc/tlsexe32.r: Update.
* ld-powerpc/tlsexe32.t: Update.
* ld-powerpc/tlsso32.d: Update.
* ld-powerpc/tlsso32.g: Update.
* ld-powerpc/tlsso32.r: Update.
* ld-powerpc/tlsso32.t: Update.

bfd/ChangeLog
bfd/elf32-ppc.c

index c69b076..51592c9 100644 (file)
@@ -1,3 +1,12 @@
+2005-03-16  Alan Modra  <amodra@bigpond.net.au>
+
+       * elf32-ppc.c (ppc_elf_create_linker_section): Set SEC_LINKER_CREATED
+       on section.  Correct comment, and add FIXME.
+       (ppc_elf_additional_program_headers): Don't bump header count for
+       interp.  Test SEC_ALLOC, not SEC_LOAD, and don't test size.
+       (ppc_elf_size_dynamic_sections): Don't strip sdata and sdata2, but
+       do allocate memory if they need it.
+
 2005-03-15  Mikkel Krautz  <krautz@gmail.com>
 
        * config.bfd (x86_64-elf): Add target.
index b38a48a..0866e46 100644 (file)
@@ -2606,15 +2606,16 @@ ppc_elf_create_linker_section (bfd *abfd,
   const char *sym_name;
   bfd_vma sym_offset;
 
-  /* Both of these sections are (technically) created by the user
-     putting data in them, so they shouldn't be marked
-     SEC_LINKER_CREATED.
-
-     The linker creates them so it has somewhere to attach their
-     respective symbols. In fact, if they were empty it would
-     be OK to leave the symbol set to 0 (or any random number), because
-     the appropriate register should never be used.  */
-  flags = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY;
+  /* The linker creates these sections so it has somewhere to attach
+     their respective symbols.  Startup code (crt1.o) uses these symbols
+     to initialize a register pointing to the section.  If the output
+     sections corresponding to these input sections were empty it would
+     be OK to set the symbol to 0 (or any random number), because the
+     associated register should never be used.
+     FIXME: Setting a symbol this way is silly.  The symbols ought to 
+     be set the same way other backends set gp.  */
+  flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+          | SEC_LINKER_CREATED);
   sym_offset = 32768;
 
   switch (which)
@@ -2711,27 +2712,21 @@ ppc_elf_create_linker_section (bfd *abfd,
   return lsect;
 }
 \f
-/* If we have a non-zero sized .sbss2 or .PPC.EMB.sbss0 sections, we
+/* If we have .sbss2 or .PPC.EMB.sbss0 output sections, we
    need to bump up the number of section headers.  */
 
 static int
 ppc_elf_additional_program_headers (bfd *abfd)
 {
   asection *s;
-  int ret;
-
-  ret = 0;
-
-  s = bfd_get_section_by_name (abfd, ".interp");
-  if (s != NULL)
-    ++ret;
+  int ret = 0;
 
   s = bfd_get_section_by_name (abfd, ".sbss2");
-  if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->size > 0)
+  if (s != NULL && (s->flags & SEC_ALLOC) != 0)
     ++ret;
 
   s = bfd_get_section_by_name (abfd, ".PPC.EMB.sbss0");
-  if (s != NULL && (s->flags & SEC_LOAD) != 0 && s->size > 0)
+  if (s != NULL && (s->flags & SEC_ALLOC) != 0)
     ++ret;
 
   return ret;
@@ -3394,13 +3389,20 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        continue;
 
       if (s == htab->plt
-         || s == htab->got
-         || (htab->sdata != NULL && s == htab->sdata->section)
-         || (htab->sdata2 != NULL && s == htab->sdata2->section))
+         || s == htab->got)
        {
          /* Strip this section if we don't need it; see the
             comment below.  */
        }
+      else if ((htab->sdata != NULL && s == htab->sdata->section)
+              || (htab->sdata2 != NULL && s == htab->sdata2->section))
+       {
+         if (s->size == 0)
+           /* Don't strip these sections.  We need them because they
+              define _SDA_BASE_ and _SDA2_BASE_.  crt1.o makes a
+              reference to _SDA_BASE_ to set up r13.  */
+           continue;
+       }
       else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
        {
          if (s->size == 0)