2005-02-06 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / bfd / elf32-ppc.c
index 38f8d09bf536197ae4077102d4c1a14b02072d97..6a1c4e591263b6539ba0aae9c27351ff26ad0a54 100644 (file)
@@ -1,6 +1,6 @@
 /* PowerPC-specific support for 32-bit ELF
    Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004 Free Software Foundation, Inc.
+   2004, 2005 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -1533,35 +1533,6 @@ static reloc_howto_type ppc_elf_howto_raw[] = {
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
-  /* Phony relocs to handle branch stubs.  */
-  HOWTO (R_PPC_RELAX32,                /* type */
-        0,                     /* rightshift */
-        0,                     /* size */
-        0,                     /* bitsize */
-        FALSE,                 /* pc_relative */
-        0,                     /* bitpos */
-        complain_overflow_dont, /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
-        "R_PPC_RELAX32",       /* name */
-        FALSE,                 /* partial_inplace */
-        0,                     /* src_mask */
-        0,                     /* dst_mask */
-        FALSE),                /* pcrel_offset */
-
-  HOWTO (R_PPC_RELAX32PC,      /* type */
-        0,                     /* rightshift */
-        0,                     /* size */
-        0,                     /* bitsize */
-        FALSE,                 /* pc_relative */
-        0,                     /* bitpos */
-        complain_overflow_dont, /* complain_on_overflow */
-        bfd_elf_generic_reloc, /* special_function */
-        "R_PPC_RELAX32PC",     /* name */
-        FALSE,                 /* partial_inplace */
-        0,                     /* src_mask */
-        0,                     /* dst_mask */
-        FALSE),                /* pcrel_offset */
-
   /* GNU extension to record C++ vtable hierarchy.  */
   HOWTO (R_PPC_GNU_VTINHERIT,  /* type */
         0,                     /* rightshift */
@@ -1867,6 +1838,12 @@ ppc_elf_relax_section (bfd *abfd,
              stub_rtype = R_PPC_RELAX32;
            }
 
+         if (R_PPC_RELAX32_PLT - R_PPC_RELAX32
+             != R_PPC_RELAX32PC_PLT - R_PPC_RELAX32PC)
+           abort ();
+         if (tsec == ppc_info->plt)
+           stub_rtype += R_PPC_RELAX32_PLT - R_PPC_RELAX32;
+
          /* Hijack the old relocation.  Since we need two
             relocations for this use a "composite" reloc.  */
          irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
@@ -2820,7 +2797,7 @@ ppc_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   htab->dynbss = bfd_get_section_by_name (abfd, ".dynbss");
   htab->dynsbss = s = bfd_make_section (abfd, ".dynsbss");
   if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
+      || ! bfd_set_section_flags (abfd, s, SEC_ALLOC | SEC_LINKER_CREATED))
     return FALSE;
 
   if (! info->shared)
@@ -4075,6 +4052,9 @@ ppc_elf_gc_sweep_hook (bfd *abfd,
          struct ppc_elf_link_hash_entry *eh;
 
          h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+         while (h->root.type == bfd_link_hash_indirect
+                || h->root.type == bfd_link_hash_warning)
+           h = (struct elf_link_hash_entry *) h->root.u.i.link;
          eh = (struct ppc_elf_link_hash_entry *) h;
 
          for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
@@ -5419,12 +5399,27 @@ ppc_elf_relocate_section (bfd *output_bfd,
            }
          break;
 
+       case R_PPC_RELAX32PC_PLT:
+       case R_PPC_RELAX32_PLT:
+         BFD_ASSERT (h != NULL
+                     && h->plt.offset != (bfd_vma) -1
+                     && htab->plt != NULL);
+
+         relocation = (htab->plt->output_section->vma
+                       + htab->plt->output_offset
+                       + h->plt.offset);
+         if (r_type == R_PPC_RELAX32_PLT)
+           goto relax32;
+         /* Fall thru */
+
        case R_PPC_RELAX32PC:
          relocation -= (input_section->output_section->vma
                         + input_section->output_offset
                         + rel->r_offset - 4);
          /* Fall thru */
+
        case R_PPC_RELAX32:
+       relax32:
          {
            unsigned long t0;
            unsigned long t1;
@@ -6176,6 +6171,7 @@ static struct bfd_elf_special_section const ppc_elf_special_sections[]=
 #else
 #define ELF_MAXPAGESIZE                0x10000
 #endif
+#define ELF_MINPAGESIZE                0x1000
 #define elf_info_to_howto      ppc_elf_info_to_howto
 
 #ifdef  EM_CYGNUS_POWERPC
This page took 0.025099 seconds and 4 git commands to generate.