+2005-07-14 Bob Rossi <bob@brasko.net>
[deliverable/binutils-gdb.git] / bfd / elf32-arm.c
index f5feeaf7e115f74ebec4231cf0099e6eb7d5b543..8adbf104a8c1006e64941d903ac6fb75b6589cef 100644 (file)
 #define ARM_ELF_ABI_VERSION            0
 #define ARM_ELF_OS_ABI_VERSION         ELFOSABI_ARM
 
-static reloc_howto_type * elf32_arm_reloc_type_lookup
-  PARAMS ((bfd * abfd, bfd_reloc_code_real_type code));
-static bfd_boolean elf32_arm_nabi_grok_prstatus
-  PARAMS ((bfd *abfd, Elf_Internal_Note *note));
-static bfd_boolean elf32_arm_nabi_grok_psinfo
-  PARAMS ((bfd *abfd, Elf_Internal_Note *note));
-
 /* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g.
    R_ARM_PC24 as an index into this, and find the R_ARM_PC24 HOWTO
    in that slot.  */
@@ -1344,9 +1337,8 @@ static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] =
   };
 
 static reloc_howto_type *
-elf32_arm_reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+elf32_arm_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                            bfd_reloc_code_real_type code)
 {
   unsigned int i;
   for (i = 0; i < NUM_ELEM (elf32_arm_reloc_map); i ++)
@@ -1358,9 +1350,7 @@ elf32_arm_reloc_type_lookup (abfd, code)
 
 /* Support for core dump NOTE sections */
 static bfd_boolean
-elf32_arm_nabi_grok_prstatus (abfd, note)
-     bfd *abfd;
-     Elf_Internal_Note *note;
+elf32_arm_nabi_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
 {
   int offset;
   size_t size;
@@ -1390,9 +1380,7 @@ elf32_arm_nabi_grok_prstatus (abfd, note)
 }
 
 static bfd_boolean
-elf32_arm_nabi_grok_psinfo (abfd, note)
-     bfd *abfd;
-     Elf_Internal_Note *note;
+elf32_arm_nabi_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 {
   switch (note->descsz)
     {
@@ -2355,10 +2343,8 @@ bfd_elf32_arm_process_before_allocation (bfd *abfd,
          /* These are the only relocation types we care about.  */
          if (   r_type != R_ARM_PC24
              && r_type != R_ARM_PLT32
-#ifndef OLD_ARM_ABI
              && r_type != R_ARM_CALL
              && r_type != R_ARM_JUMP24
-#endif
              && r_type != R_ARM_THM_CALL)
            continue;
 
@@ -2402,10 +2388,8 @@ bfd_elf32_arm_process_before_allocation (bfd *abfd,
            {
            case R_ARM_PC24:
            case R_ARM_PLT32:
-#ifndef OLD_ARM_ABI
            case R_ARM_CALL:
            case R_ARM_JUMP24:
-#endif
              /* This one is a call from arm code.  We need to look up
                 the target of the call.  If it is a thumb target, we
                 insert glue.  */
@@ -2452,7 +2436,6 @@ error_return:
 #endif
 
 
-#ifndef OLD_ARM_ABI
 /* Set target relocation values needed during linking.  */
 
 void
@@ -2481,7 +2464,6 @@ bfd_elf32_arm_set_target_relocs (struct bfd_link_info *link_info,
   globals->fix_v4bx = fix_v4bx;
   globals->use_blx |= use_blx;
 }
-#endif
 
 /* The thumb form of a long branch is a bit finicky, because the offset
    encoding is split over two fields, each in it's own instruction. They
@@ -2752,8 +2734,6 @@ elf32_arm_to_thumb_stub (struct bfd_link_info * info,
   return TRUE;
 }
 
-
-#ifndef OLD_ARM_ABI
 /* Some relocations map to different relocations depending on the
    target.  Return the real relocation.  */
 static int
@@ -2775,8 +2755,6 @@ arm_real_reloc_type (struct elf32_arm_link_hash_table * globals,
       return r_type;
     }
 }
-#endif /* OLD_ARM_ABI */
-
 
 /* Return the base VMA address which should be subtracted from real addresses
    when resolving @dtpoff relocation.
@@ -2840,13 +2818,11 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
 
   globals = elf32_arm_hash_table (info);
 
-#ifndef OLD_ARM_ABI
   /* Some relocation type map to different relocations depending on the
      target.  We pick the right one here.  */
   r_type = arm_real_reloc_type (globals, r_type);
   if (r_type != howto->type)
     howto = elf32_arm_howto_from_type (r_type);
-#endif /* OLD_ARM_ABI */
 
   /* If the start address has been set, then set the EF_ARM_HASENTRY
      flag.  Setting this more than once is redundant, but the cost is
@@ -2898,12 +2874,10 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
     case R_ARM_PC24:
     case R_ARM_ABS32:
     case R_ARM_REL32:
-#ifndef OLD_ARM_ABI
     case R_ARM_CALL:
     case R_ARM_JUMP24:
     case R_ARM_XPC25:
     case R_ARM_PREL31:
-#endif
     case R_ARM_PLT32:
       /* r_symndx will be zero only for relocs against symbols
         from removed linkonce sections, or sections discarded by
@@ -2945,11 +2919,9 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
              || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
              || h->root.type != bfd_link_hash_undefweak)
          && r_type != R_ARM_PC24
-#ifndef OLD_ARM_ABI
          && r_type != R_ARM_CALL
          && r_type != R_ARM_JUMP24
          && r_type != R_ARM_PREL31
-#endif
          && r_type != R_ARM_PLT32)
        {
          Elf_Internal_Rela outrel;
@@ -3047,14 +3019,11 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
        }
       else switch (r_type)
        {
-#ifndef OLD_ARM_ABI
        case R_ARM_XPC25:         /* Arm BLX instruction.  */
        case R_ARM_CALL:
        case R_ARM_JUMP24:
-#endif
        case R_ARM_PC24:          /* Arm B/BL instruction */
        case R_ARM_PLT32:
-#ifndef OLD_ARM_ABI
          if (r_type == R_ARM_XPC25)
            {
              /* Check for Arm calling Arm function.  */
@@ -3067,7 +3036,6 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
                   h ? h->root.root.string : "(local)");
            }
          else
-#endif
            {
              /* Check for Arm calling Thumb function.  */
              if (sym_flags == STT_ARM_TFUNC)
@@ -3123,14 +3091,12 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
                return bfd_reloc_overflow;
            }
 
-#ifndef OLD_ARM_ABI
          /* If necessary set the H bit in the BLX instruction.  */
          if (r_type == R_ARM_XPC25 && ((value & 2) == 2))
            value = (signed_addend & howto->dst_mask)
              | (bfd_get_32 (input_bfd, hit_data) & (~ howto->dst_mask))
              | (1 << 24);
          else
-#endif
            value = (signed_addend & howto->dst_mask)
              | (bfd_get_32 (input_bfd, hit_data) & (~ howto->dst_mask));
          break;
@@ -3147,7 +3113,6 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
          value += addend;
          break;
 
-#ifndef OLD_ARM_ABI
        case R_ARM_PREL31:
          value -= (input_section->output_section->vma
                    + input_section->output_offset + rel->r_offset);
@@ -3163,7 +3128,6 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
          if (sym_flags == STT_ARM_TFUNC)
            value |= 1;
          break;
-#endif
        }
 
       bfd_put_32 (input_bfd, value, hit_data);
@@ -3218,9 +3182,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
       bfd_put_16 (input_bfd, value, hit_data);
       return bfd_reloc_ok;
 
-#ifndef OLD_ARM_ABI
     case R_ARM_THM_XPC22:
-#endif
     case R_ARM_THM_CALL:
       /* Thumb BL (branch long instruction).  */
       {
@@ -3244,7 +3206,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
            addend = (upper << 12) | (lower << 1);
            signed_addend = addend;
          }
-#ifndef OLD_ARM_ABI
+
        if (r_type == R_ARM_THM_XPC22)
          {
            /* Check for Thumb to Thumb call.  */
@@ -3257,7 +3219,6 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
                 h ? h->root.root.string : "(local)");
          }
        else
-#endif
          {
            /* If it is not a call to Thumb, assume call to Arm.
               If it is a call relative to a section name, then it is not a
@@ -3317,7 +3278,6 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
        if (signed_check > reloc_signed_max || signed_check < reloc_signed_min)
          overflow = TRUE;
 
-#ifndef OLD_ARM_ABI
        if ((r_type == R_ARM_THM_XPC22
             && ((lower_insn & 0x1800) == 0x0800))
            || thumb_plt_call)
@@ -3326,7 +3286,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
             which specifies that bit 1 of the target address will come from bit
             1 of the base address.  */
          relocation = (relocation + 2) & ~ 3;
-#endif
+
        /* Put RELOCATION back into the insn.  */
        upper_insn = (upper_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 12) & 0x7ff);
        lower_insn = (lower_insn & ~(bfd_vma) 0x7ff) | ((relocation >> 1) & 0x7ff);
@@ -3538,7 +3498,6 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
        return bfd_reloc_ok;
       }
 
-#ifndef OLD_ARM_ABI
     case R_ARM_ALU_PCREL7_0:
     case R_ARM_ALU_PCREL15_8:
     case R_ARM_ALU_PCREL23_15:
@@ -3564,7 +3523,6 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
        bfd_put_32 (input_bfd, value, hit_data);
       }
       return bfd_reloc_ok;
-#endif
 
     case R_ARM_GNU_VTINHERIT:
     case R_ARM_GNU_VTENTRY:
@@ -3608,9 +3566,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *           howto,
                                       (bfd_vma) 0);
 
     case R_ARM_GOT32:
-#ifndef OLD_ARM_ABI
     case R_ARM_GOT_PREL:
-#endif
       /* Relocation is to the entry for this symbol in the
          global offset table.  */
       if (sgot == NULL)
@@ -4007,10 +3963,8 @@ arm_add_to_rel (bfd *              abfd,
 
        case R_ARM_PC24:
        case R_ARM_PLT32:
-#ifndef OLD_ARM_ABI
        case R_ARM_CALL:
        case R_ARM_JUMP24:
-#endif
          addend <<= howto->size;
          addend += increment;
 
@@ -4820,15 +4774,11 @@ elf32_arm_gc_sweep_hook (bfd *                     abfd,
        }
 
       r_type = ELF32_R_TYPE (rel->r_info);
-#ifndef OLD_ARM_ABI
       r_type = arm_real_reloc_type (globals, r_type);
-#endif
       switch (r_type)
        {
        case R_ARM_GOT32:
-#ifndef OLD_ARM_ABI
        case R_ARM_GOT_PREL:
-#endif
        case R_ARM_TLS_GD32:
        case R_ARM_TLS_IE32:
          if (h != NULL)
@@ -4851,11 +4801,9 @@ elf32_arm_gc_sweep_hook (bfd *                     abfd,
        case R_ARM_REL32:
        case R_ARM_PC24:
        case R_ARM_PLT32:
-#ifndef OLD_ARM_ABI
        case R_ARM_CALL:
        case R_ARM_JUMP24:
        case R_ARM_PREL31:
-#endif
        case R_ARM_THM_CALL:
          /* Should the interworking branches be here also?  */
 
@@ -4952,9 +4900,7 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
       r_symndx = ELF32_R_SYM (rel->r_info);
       r_type = ELF32_R_TYPE (rel->r_info);
-#ifndef OLD_ARM_ABI
       r_type = arm_real_reloc_type (htab, r_type);
-#endif
 
       if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr))
        {
@@ -4966,16 +4912,19 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info,
       if (r_symndx < symtab_hdr->sh_info)
         h = NULL;
       else
-        h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+       {
+         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 elf32_arm_link_hash_entry *) h;
 
       switch (r_type)
         {
          case R_ARM_GOT32:
-#ifndef OLD_ARM_ABI
          case R_ARM_GOT_PREL:
-#endif
          case R_ARM_TLS_GD32:
          case R_ARM_TLS_IE32:
            /* This symbol requires a global offset table entry.  */
@@ -5055,11 +5004,9 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info,
          case R_ARM_REL32:
          case R_ARM_PC24:
          case R_ARM_PLT32:
-#ifndef OLD_ARM_ABI
          case R_ARM_CALL:
          case R_ARM_JUMP24:
          case R_ARM_PREL31:
-#endif
          case R_ARM_THM_CALL:
            /* Should the interworking branches be listed here?  */
            if (h != NULL)
@@ -5078,11 +5025,9 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info,
                   sure yet, because something later might force the
                   symbol local.  */
                if (r_type == R_ARM_PC24
-#ifndef OLD_ARM_ABI
                    || r_type == R_ARM_CALL
                    || r_type == R_ARM_JUMP24
                    || r_type == R_ARM_PREL31
-#endif
                    || r_type == R_ARM_PLT32
                    || r_type == R_ARM_THM_CALL)
                  h->needs_plt = 1;
@@ -5337,6 +5282,19 @@ elf32_arm_find_nearest_line (bfd *          abfd,
   return TRUE;
 }
 
+static bfd_boolean
+elf32_arm_find_inliner_info (bfd *          abfd,
+                            const char **  filename_ptr,
+                            const char **  functionname_ptr,
+                            unsigned int * line_ptr)
+{
+  bfd_boolean found;
+  found = _bfd_dwarf2_find_inliner_info (abfd, filename_ptr,
+                                        functionname_ptr, line_ptr,
+                                        & elf_tdata (abfd)->dwarf2_find_line_info);
+  return found;
+}
+
 /* Adjust a symbol defined by a dynamic object and referenced by a
    regular object.  The current definition is in some section of the
    dynamic object, but we're not including those sections.  We have to
@@ -5894,7 +5852,6 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
   for (s = dynobj->sections; s != NULL; s = s->next)
     {
       const char * name;
-      bfd_boolean strip;
 
       if ((s->flags & SEC_LINKER_CREATED) == 0)
        continue;
@@ -5903,38 +5860,14 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
         of the dynobj section names depend upon the input files.  */
       name = bfd_get_section_name (dynobj, s);
 
-      strip = FALSE;
-
       if (strcmp (name, ".plt") == 0)
        {
-         if (s->size == 0)
-           {
-             /* Strip this section if we don't need it; see the
-                 comment below.  */
-             strip = TRUE;
-           }
-         else
-           {
-             /* Remember whether there is a PLT.  */
-             plt = TRUE;
-           }
+         /* Remember whether there is a PLT.  */
+         plt = s->size != 0;
        }
       else if (strncmp (name, ".rel", 4) == 0)
        {
-         if (s->size == 0)
-           {
-             /* If we don't need this section, strip it from the
-                output file.  This is mostly to handle .rel.bss and
-                .rel.plt.  We must create both sections in
-                create_dynamic_sections, because they must be created
-                before the linker maps input sections to output
-                sections.  The linker does that before
-                adjust_dynamic_symbol is called, and it is that
-                function which decides whether anything needs to go
-                into these sections.  */
-             strip = TRUE;
-           }
-         else
+         if (s->size != 0)
            {
              /* Remember whether there are any reloc sections other
                  than .rel.plt.  */
@@ -5946,21 +5879,34 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
              s->reloc_count = 0;
            }
        }
-      else if (strncmp (name, ".got", 4) != 0)
+      else if (strncmp (name, ".got", 4) != 0
+              && strcmp (name, ".dynbss") != 0)
        {
          /* It's not one of our sections, so don't allocate space.  */
          continue;
        }
 
-      if (strip)
+      if (s->size == 0)
        {
+         /* If we don't need this section, strip it from the
+            output file.  This is mostly to handle .rel.bss and
+            .rel.plt.  We must create both sections in
+            create_dynamic_sections, because they must be created
+            before the linker maps input sections to output
+            sections.  The linker does that before
+            adjust_dynamic_symbol is called, and it is that
+            function which decides whether anything needs to go
+            into these sections.  */
          s->flags |= SEC_EXCLUDE;
          continue;
        }
 
+      if ((s->flags & SEC_HAS_CONTENTS) == 0)
+       continue;
+
       /* Allocate memory for the section contents.  */
       s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
-      if (s->contents == NULL && s->size != 0)
+      if (s->contents == NULL)
        return FALSE;
     }
 
@@ -5974,7 +5920,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
 #define add_dynamic_entry(TAG, VAL) \
   _bfd_elf_add_dynamic_entry (info, TAG, VAL)
 
-      if (!info->shared)
+     if (info->executable)
        {
          if (!add_dynamic_entry (DT_DEBUG, 0))
            return FALSE;
@@ -6007,10 +5953,9 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED,
        {
          if (!add_dynamic_entry (DT_TEXTREL, 0))
            return FALSE;
-         info->flags |= DF_TEXTREL;
        }
     }
-#undef add_synamic_entry
+#undef add_dynamic_entry
 
   return TRUE;
 }
@@ -6858,6 +6803,7 @@ const struct elf_size_info elf32_arm_size_info = {
 #define bfd_elf32_bfd_link_hash_table_create    elf32_arm_link_hash_table_create
 #define bfd_elf32_bfd_reloc_type_lookup                elf32_arm_reloc_type_lookup
 #define bfd_elf32_find_nearest_line            elf32_arm_find_nearest_line
+#define bfd_elf32_find_inliner_info            elf32_arm_find_inliner_info
 #define bfd_elf32_new_section_hook             elf32_arm_new_section_hook
 #define bfd_elf32_bfd_is_target_special_symbol elf32_arm_is_target_special_symbol
 
@@ -6983,8 +6929,8 @@ elf32_arm_symbian_link_hash_table_create (bfd *abfd)
   return ret;
 }     
 
-static struct bfd_elf_special_section const
-  symbian_special_sections_d[]=
+static const struct bfd_elf_special_section
+elf32_arm_symbian_special_sections[] =
 {
   /* In a BPABI executable, the dynamic linking sections do not go in
      the loadable read-only segment.  The post-linker may wish to
@@ -6993,93 +6939,17 @@ static struct bfd_elf_special_section const
   { ".dynamic",        8,  0, SHT_DYNAMIC,  0 },
   { ".dynstr",         7,  0, SHT_STRTAB,   0 },
   { ".dynsym",         7,  0, SHT_DYNSYM,   0 },
-  { NULL,              0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  symbian_special_sections_g[]=
-{
-  /* In a BPABI executable, the dynamic linking sections do not go in
-     the loadable read-only segment.  The post-linker may wish to
-     refer to these sections, but they are not part of the final
-     program image.  */
   { ".got",            4,  0, SHT_PROGBITS, 0 },
-  { NULL,              0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  symbian_special_sections_h[]=
-{
-  /* In a BPABI executable, the dynamic linking sections do not go in
-     the loadable read-only segment.  The post-linker may wish to
-     refer to these sections, but they are not part of the final
-     program image.  */
   { ".hash",           5,  0, SHT_HASH,     0 },
-  { NULL,              0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  symbian_special_sections_i[]=
-{
   /* These sections do not need to be writable as the SymbianOS
      postlinker will arrange things so that no dynamic relocation is
      required.  */
   { ".init_array",    11,  0, SHT_INIT_ARRAY, SHF_ALLOC },
-  { NULL,              0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  symbian_special_sections_f[]=
-{
-  /* These sections do not need to be writable as the SymbianOS
-     postlinker will arrange things so that no dynamic relocation is
-     required.  */
   { ".fini_array",    11,  0, SHT_FINI_ARRAY, SHF_ALLOC },
-  { NULL,              0,  0, 0,            0 }
-};
-
-static struct bfd_elf_special_section const
-  symbian_special_sections_p[]=
-{
-  /* These sections do not need to be writable as the SymbianOS
-     postlinker will arrange things so that no dynamic relocation is
-     required.  */
   { ".preinit_array", 14,  0, SHT_PREINIT_ARRAY, SHF_ALLOC },
   { NULL,              0,  0, 0,            0 }
 };
 
-static struct bfd_elf_special_section const *
-  elf32_arm_symbian_special_sections[27]=
-{
-  NULL,                                /* 'a' */
-  NULL,                                /* 'b' */
-  NULL,                                /* 'c' */
-  symbian_special_sections_d,  /* 'd' */
-  NULL,                                /* 'e' */
-  symbian_special_sections_f,  /* 'f' */
-  symbian_special_sections_g,  /* 'g' */
-  symbian_special_sections_h,  /* 'h' */
-  symbian_special_sections_i,  /* 'i' */
-  NULL,                                /* 'j' */
-  NULL,                                /* 'k' */
-  NULL,                                /* 'l' */
-  NULL,                                /* 'm' */
-  NULL,                                /* 'n' */
-  NULL,                                /* 'o' */
-  symbian_special_sections_p,  /* 'p' */
-  NULL,                                /* 'q' */
-  NULL,                                /* 'r' */
-  NULL,                                /* 's' */
-  NULL,                                /* 't' */
-  NULL,                                /* 'u' */
-  NULL,                                /* 'v' */
-  NULL,                                /* 'w' */
-  NULL,                                /* 'x' */
-  NULL,                                /* 'y' */
-  NULL,                                /* 'z' */
-  NULL                         /* other */
-};
-
 static void
 elf32_arm_symbian_begin_write_processing (bfd *abfd, 
                                          struct bfd_link_info *link_info
This page took 0.033165 seconds and 4 git commands to generate.