* include/elf/arm.h: Correct names of R_ARM_LDC_G{0,1,2}
[deliverable/binutils-gdb.git] / bfd / elf32-bfin.c
index a08161cd44d74f680b1ac2c8467f47ddad02e97c..661d4bdd24ee48d25f93cb6c1701ac4d461529c7 100644 (file)
@@ -1284,8 +1284,8 @@ bfinfdpic_relocs_info_hash (const void *entry_)
   const struct bfinfdpic_relocs_info *entry = entry_;
 
   return (entry->symndx == -1
-         ? entry->d.h->root.root.hash
-         : entry->symndx + entry->d.abfd->id * 257) + entry->addend;
+         ? (long) entry->d.h->root.root.hash
+         : entry->symndx + (long) entry->d.abfd->id * 257) + entry->addend;
 }
 
 /* Test whether the key fields of two bfinfdpic_relocs_info entries are
@@ -1961,7 +1961,7 @@ bfin_check_relocs (bfd * abfd,
 
        case R_got:
          if (h != NULL
-             && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+             && strcmp (h->root.root.string, "__GLOBAL_OFFSET_TABLE_") == 0)
            break;
          /* Fall through.  */
 
@@ -1984,15 +1984,12 @@ bfin_check_relocs (bfd * abfd,
              srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
              if (srelgot == NULL)
                {
-                 srelgot = bfd_make_section (dynobj, ".rela.got");
+                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
+                                   | SEC_READONLY);
+                 srelgot = bfd_make_section_with_flags (dynobj, ".rela.got",
+                                                        flags);
                  if (srelgot == NULL
-                     || !bfd_set_section_flags (dynobj, srelgot,
-                                                (SEC_ALLOC
-                                                 | SEC_LOAD
-                                                 | SEC_HAS_CONTENTS
-                                                 | SEC_IN_MEMORY
-                                                 | SEC_LINKER_CREATED
-                                                 | SEC_READONLY))
                      || !bfd_set_section_alignment (dynobj, srelgot, 2))
                    return FALSE;
                }
@@ -2435,6 +2432,8 @@ bfinfdpic_relocate_section (bfd * output_bfd,
                                                 input_section->output_section)
                          & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
                  {
+                   bfd_vma offset;
+
                    if (_bfinfdpic_osec_readonly_p (output_bfd,
                                                   input_section
                                                   ->output_section))
@@ -2445,15 +2444,23 @@ bfinfdpic_relocate_section (bfd * output_bfd,
                           name, input_bfd, input_section, rel->r_offset);
                        return FALSE;
                      }
-                   _bfinfdpic_add_dyn_reloc (output_bfd,
-                                             bfinfdpic_gotrel_section (info),
-                                             _bfd_elf_section_offset
-                                             (output_bfd, info,
-                                              input_section, rel->r_offset)
-                                             + input_section
-                                             ->output_section->vma
-                                             + input_section->output_offset,
-                                             r_type, dynindx, addend, picrel);
+                   offset = _bfd_elf_section_offset (output_bfd, info,
+                                                     input_section, rel->r_offset);
+                   /* Only output a reloc for a not deleted entry.  */
+                   if (offset >= (bfd_vma) -2)
+                     _bfinfdpic_add_dyn_reloc (output_bfd,
+                                               bfinfdpic_gotrel_section (info),
+                                               0,
+                                               R_unused0,
+                                               dynindx, addend, picrel);
+                   else
+                     _bfinfdpic_add_dyn_reloc (output_bfd,
+                                               bfinfdpic_gotrel_section (info),
+                                               offset + input_section
+                                               ->output_section->vma
+                                               + input_section->output_offset,
+                                               r_type,
+                                               dynindx, addend, picrel);
                  }
                else
                  addend += bfinfdpic_got_section (info)->output_section->vma;
@@ -2903,7 +2910,7 @@ bfin_relocate_section (bfd * output_bfd,
          /* Relocation is to the address of the entry for this symbol
             in the global offset table.  */
          if (h != NULL
-             && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
+             && strcmp (h->root.root.string, "__GLOBAL_OFFSET_TABLE_") == 0)
            goto do_default;
          /* Fall through.  */
          /* Relocation is the offset of the entry for this symbol in
@@ -3253,7 +3260,6 @@ _bfin_create_got_section (bfd *abfd, struct bfd_link_info *info)
   flagword flags, pltflags;
   asection *s;
   struct elf_link_hash_entry *h;
-  struct bfd_link_hash_entry *bh;
   const struct elf_backend_data *bed = get_elf_backend_data (abfd);
   int ptralign;
   int offset;
@@ -3292,7 +3298,7 @@ _bfin_create_got_section (bfd *abfd, struct bfd_link_info *info)
         (or .got.plt) section.  We don't do this in the linker script
         because we don't want to define the symbol if we are not creating
         a global offset table.  */
-      h = _bfd_elf_define_linkage_sym (abfd, info, s, "_GLOBAL_OFFSET_TABLE_");
+      h = _bfd_elf_define_linkage_sym (abfd, info, s, "__GLOBAL_OFFSET_TABLE_");
       elf_hash_table (info)->hgot = h;
       if (h == NULL)
        return FALSE;
@@ -3371,9 +3377,8 @@ elf32_bfinfdpic_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   if (bed->plt_readonly)
     pltflags |= SEC_READONLY;
 
-  s = bfd_make_section (abfd, ".plt");
+  s = bfd_make_section_with_flags (abfd, ".plt", pltflags);
   if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, pltflags)
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
     return FALSE;
   /* Blackfin-specific: remember it.  */
@@ -3387,7 +3392,7 @@ elf32_bfinfdpic_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
       struct bfd_link_hash_entry *bh = NULL;
 
       if (! (_bfd_generic_link_add_one_symbol
-            (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, 0, NULL,
+            (info, abfd, "__PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, 0, NULL,
              FALSE, get_elf_backend_data (abfd)->collect, &bh)))
        return FALSE;
       h = (struct elf_link_hash_entry *) bh;
@@ -3400,9 +3405,8 @@ elf32_bfinfdpic_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
     }
 
   /* Blackfin-specific: we want rel relocations for the plt.  */
-  s = bfd_make_section (abfd, ".rel.plt");
+  s = bfd_make_section_with_flags (abfd, ".rel.plt", flags | SEC_READONLY);
   if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
       || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
     return FALSE;
   /* Blackfin-specific: remember it.  */
@@ -3426,9 +3430,9 @@ elf32_bfinfdpic_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
         image and use a R_*_COPY reloc to tell the dynamic linker to
         initialize them at run time.  The linker script puts the .dynbss
         section into the .bss section of the final image.  */
-      s = bfd_make_section (abfd, ".dynbss");
-      if (s == NULL
-         || ! bfd_set_section_flags (abfd, s, SEC_ALLOC | SEC_LINKER_CREATED))
+      s = bfd_make_section_with_flags (abfd, ".dynbss",
+                                      SEC_ALLOC | SEC_LINKER_CREATED);
+      if (s == NULL)
        return FALSE;
 
       /* The .rel[a].bss section holds copy relocs.  This section is not
@@ -3444,11 +3448,11 @@ elf32_bfinfdpic_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
      copy relocs.  */
       if (! info->shared)
        {
-         s = bfd_make_section (abfd,
-                               (bed->default_use_rela_p
-                                ? ".rela.bss" : ".rel.bss"));
+         s = bfd_make_section_with_flags (abfd,
+                                          (bed->default_use_rela_p
+                                           ? ".rela.bss" : ".rel.bss"),
+                                          flags | SEC_READONLY);
          if (s == NULL
-             || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
              || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align))
            return FALSE;
        }
@@ -5036,7 +5040,7 @@ bfin_finish_dynamic_symbol (bfd * output_bfd,
          && (info->symbolic
              || h->dynindx == -1 || h->forced_local) && h->def_regular)
        {
-fprintf(stderr, "*** check this relocation %s\n", __FUNCTION__);
+         fprintf(stderr, "*** check this relocation %s\n", __FUNCTION__);
          rela.r_info = ELF32_R_INFO (0, R_pcrel24);
          rela.r_addend = bfd_get_signed_32 (output_bfd,
                                             (sgot->contents
@@ -5062,7 +5066,7 @@ fprintf(stderr, "*** check this relocation %s\n", __FUNCTION__);
       BFD_ASSERT (0);
     }
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
+  if (strcmp (h->root.root.string, "__DYNAMIC") == 0
       || h == elf_hash_table (info)->hgot)
     sym->st_shndx = SHN_ABS;
 
This page took 0.027307 seconds and 4 git commands to generate.