Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / elf32-nds32.c
index 6215f2880093858b58c9c5e5a141f97e1b6705ad..2d26e2ad85d5f1e9a316f62d8588d1e3cbb471bd 100644 (file)
@@ -1,5 +1,5 @@
 /* NDS32-specific support for 32-bit ELF.
 /* NDS32-specific support for 32-bit ELF.
-   Copyright (C) 2012-2018 Free Software Foundation, Inc.
+   Copyright (C) 2012-2020 Free Software Foundation, Inc.
    Contributed by Andes Technology Corporation.
 
    This file is part of BFD, the Binary File Descriptor library.
    Contributed by Andes Technology Corporation.
 
    This file is part of BFD, the Binary File Descriptor library.
 
 #include "sysdep.h"
 #include "bfd.h"
 
 #include "sysdep.h"
 #include "bfd.h"
-#include "bfd_stdint.h"
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "libiberty.h"
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "libiberty.h"
-#include "bfd_stdint.h"
 #include "elf/nds32.h"
 #include "opcode/nds32.h"
 #include "elf32-nds32.h"
 #include "opcode/cgen.h"
 #include "../opcodes/nds32-opc.h"
 
 #include "elf/nds32.h"
 #include "opcode/nds32.h"
 #include "elf32-nds32.h"
 #include "opcode/cgen.h"
 #include "../opcodes/nds32-opc.h"
 
+/* All users of this file have bfd_octets_per_byte (abfd, sec) == 1.  */
+#define OCTETS_PER_BYTE(ABFD, SEC) 1
+
 /* Relocation HOWTO functions.  */
 static bfd_reloc_status_type nds32_elf_ignore_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
 /* Relocation HOWTO functions.  */
 static bfd_reloc_status_type nds32_elf_ignore_reloc
   (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
@@ -2528,7 +2529,9 @@ nds32_insertion_sort (void *base, size_t nmemb, size_t size,
 {
   char *ptr = (char *) base;
   int i, j;
 {
   char *ptr = (char *) base;
   int i, j;
-  char *tmp = xmalloc (size);
+  char tmp[sizeof (Elf_Internal_Rela)];
+
+  BFD_ASSERT (size <= sizeof (tmp));
 
   /* If i is less than j, i is inserted before j.
 
 
   /* If i is less than j, i is inserted before j.
 
@@ -2552,7 +2555,6 @@ nds32_insertion_sort (void *base, size_t nmemb, size_t size,
       memmove (ptr + (j + 1) * size, ptr + j * size, (i - j) * size);
       memcpy (ptr + j * size, tmp, size);
     }
       memmove (ptr + (j + 1) * size, ptr + j * size, (i - j) * size);
       memcpy (ptr + j * size, tmp, size);
     }
-  free (tmp);
 }
 
 /* Sort relocation by r_offset.
 }
 
 /* Sort relocation by r_offset.
@@ -3165,19 +3167,6 @@ static const struct nds32_reloc_map_entry nds32_reloc_map[] =
 
 /* Patch tag.  */
 
 
 /* Patch tag.  */
 
-/* Reserve space for COUNT dynamic relocations in relocation selection
-   SRELOC.  */
-
-static inline void
-elf32_nds32_allocate_dynrelocs (struct bfd_link_info *info, asection *sreloc,
-                               bfd_size_type count)
-{
-  BFD_ASSERT (elf_hash_table (info)->dynamic_sections_created);
-  if (sreloc == NULL)
-    abort ();
-  sreloc->size += sizeof (Elf32_External_Rela) * count;
-}
-
 static reloc_howto_type *
 bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
                                 const char *r_name)
 static reloc_howto_type *
 bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
                                 const char *r_name)
@@ -3695,7 +3684,7 @@ nds32_elf_link_hash_table_create (bfd *abfd)
 {
   struct elf_nds32_link_hash_table *ret;
 
 {
   struct elf_nds32_link_hash_table *ret;
 
-  bfd_size_type amt = sizeof (struct elf_nds32_link_hash_table);
+  size_t amt = sizeof (struct elf_nds32_link_hash_table);
 
   ret = (struct elf_nds32_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
 
   ret = (struct elf_nds32_link_hash_table *) bfd_zmalloc (amt);
   if (ret == NULL)
@@ -3738,11 +3727,11 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info)
   /* _bfd_elf_create_got_section will create it for us.  */
   ehtab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
   if (ehtab->srelgot == NULL
   /* _bfd_elf_create_got_section will create it for us.  */
   ehtab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
   if (ehtab->srelgot == NULL
-      || !bfd_set_section_flags (dynobj, ehtab->srelgot,
+      || !bfd_set_section_flags (ehtab->srelgot,
                                 (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
                                  | SEC_IN_MEMORY | SEC_LINKER_CREATED
                                  | SEC_READONLY))
                                 (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
                                  | SEC_IN_MEMORY | SEC_LINKER_CREATED
                                  | SEC_READONLY))
-      || !bfd_set_section_alignment (dynobj, ehtab->srelgot, 2))
+      || !bfd_set_section_alignment (ehtab->srelgot, 2))
     return FALSE;
 
   return TRUE;
     return FALSE;
 
   return TRUE;
@@ -3784,8 +3773,8 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   s = bfd_make_section (abfd, ".plt");
   ehtab->splt = s;
   if (s == NULL
   s = bfd_make_section (abfd, ".plt");
   ehtab->splt = s;
   if (s == NULL
-      || !bfd_set_section_flags (abfd, s, pltflags)
-      || !bfd_set_section_alignment (abfd, s, bed->plt_alignment))
+      || !bfd_set_section_flags (s, pltflags)
+      || !bfd_set_section_alignment (s, bed->plt_alignment))
     return FALSE;
 
   if (bed->want_plt_sym)
     return FALSE;
 
   if (bed->want_plt_sym)
@@ -3813,8 +3802,8 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
                        bed->default_use_rela_p ? ".rela.plt" : ".rel.plt");
   ehtab->srelplt = s;
   if (s == NULL
                        bed->default_use_rela_p ? ".rela.plt" : ".rel.plt");
   ehtab->srelplt = s;
   if (s == NULL
-      || !bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
-      || !bfd_set_section_alignment (abfd, s, ptralign))
+      || !bfd_set_section_flags (s, flags | SEC_READONLY)
+      || !bfd_set_section_alignment (s, ptralign))
     return FALSE;
 
   if (ehtab->sgot == NULL && !create_got_section (abfd, info))
     return FALSE;
 
   if (ehtab->sgot == NULL && !create_got_section (abfd, info))
@@ -3822,11 +3811,11 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
 
   for (sec = abfd->sections; sec; sec = sec->next)
     {
 
   for (sec = abfd->sections; sec; sec = sec->next)
     {
-      secflags = bfd_get_section_flags (abfd, sec);
+      secflags = bfd_section_flags (sec);
       if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
          || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
        continue;
       if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
          || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
        continue;
-      secname = bfd_get_section_name (abfd, sec);
+      secname = bfd_section_name (sec);
       relname = (char *) bfd_malloc ((bfd_size_type) strlen (secname) + 6);
       strcpy (relname, ".rela");
       strcat (relname, secname);
       relname = (char *) bfd_malloc ((bfd_size_type) strlen (secname) + 6);
       strcpy (relname, ".rela");
       strcat (relname, secname);
@@ -3834,8 +3823,8 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
        continue;
       s = bfd_make_section (abfd, relname);
       if (s == NULL
        continue;
       s = bfd_make_section (abfd, relname);
       if (s == NULL
-         || !bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
-         || !bfd_set_section_alignment (abfd, s, ptralign))
+         || !bfd_set_section_flags (s, flags | SEC_READONLY)
+         || !bfd_set_section_alignment (s, ptralign))
        return FALSE;
     }
 
        return FALSE;
     }
 
@@ -3850,7 +3839,7 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
       s = bfd_make_section (abfd, ".dynbss");
       htab->sdynbss = s;
       if (s == NULL
       s = bfd_make_section (abfd, ".dynbss");
       htab->sdynbss = s;
       if (s == NULL
-         || !bfd_set_section_flags (abfd, s, SEC_ALLOC | SEC_LINKER_CREATED))
+         || !bfd_set_section_flags (s, SEC_ALLOC | SEC_LINKER_CREATED))
        return FALSE;
       /* The .rel[a].bss section holds copy relocs.  This section is not
         normally needed.  We need to create it here, though, so that the
        return FALSE;
       /* The .rel[a].bss section holds copy relocs.  This section is not
         normally needed.  We need to create it here, though, so that the
@@ -3869,8 +3858,8 @@ nds32_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
                                       ? ".rela.bss" : ".rel.bss"));
          htab->srelbss = s;
          if (s == NULL
                                       ? ".rela.bss" : ".rel.bss"));
          htab->srelbss = s;
          if (s == NULL
-             || !bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
-             || !bfd_set_section_alignment (abfd, s, ptralign))
+             || !bfd_set_section_flags (s, flags | SEC_READONLY)
+             || !bfd_set_section_alignment (s, ptralign))
            return FALSE;
        }
     }
            return FALSE;
        }
     }
@@ -4080,9 +4069,9 @@ nds32_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
 
   /* Apply the required alignment.  */
   s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two));
 
   /* Apply the required alignment.  */
   s->size = BFD_ALIGN (s->size, (bfd_size_type) (1 << power_of_two));
-  if (power_of_two > bfd_get_section_alignment (dynobj, s))
+  if (power_of_two > bfd_section_alignment (s))
     {
     {
-      if (!bfd_set_section_alignment (dynobj, s, power_of_two))
+      if (!bfd_set_section_alignment (s, power_of_two))
        return FALSE;
     }
 
        return FALSE;
     }
 
@@ -4292,7 +4281,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 
       eh->dyn_relocs = NULL;
 
 
       eh->dyn_relocs = NULL;
 
-keep:;
+    keep:;
     }
 
   /* Finally, allocate space.  */
     }
 
   /* Finally, allocate space.  */
@@ -4540,7 +4529,7 @@ nds32_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
        {
          got_size += s->size;
        }
        {
          got_size += s->size;
        }
-      else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
+      else if (strncmp (bfd_section_name (s), ".rela", 5) == 0)
        {
          if (s->size != 0 && s != elf_hash_table (info)->srelplt)
            relocs = TRUE;
        {
          if (s->size != 0 && s != elf_hash_table (info)->srelplt)
            relocs = TRUE;
@@ -4873,7 +4862,7 @@ nds32_elf_output_symbol_hook (struct bfd_link_info *info,
       if (bfd_is_const_section (input_sec))
        source = input_sec->name;
       else
       if (bfd_is_const_section (input_sec))
        source = input_sec->name;
       else
-       source = input_sec->owner->filename;
+       source = bfd_get_filename (input_sec->owner);
 
       fprintf (sym_ld_script, "\t%s = 0x%08lx;\t /* %s */\n",
               h->root.root.string,
 
       fprintf (sym_ld_script, "\t%s = 0x%08lx;\t /* %s */\n",
               h->root.root.string,
@@ -5058,7 +5047,7 @@ patch_tls_desc_to_ie (bfd_byte *contents, Elf_Internal_Rela *rel, bfd *ibfd)
 
   if (!rz)
     {
 
   if (!rz)
     {
-      printf ("%s: %s @ 0x%08x\n", __func__, ibfd->filename,
+      printf ("%s: %s @ 0x%08x\n", __func__, bfd_get_filename (ibfd),
              (int) rel->r_offset);
       BFD_ASSERT(0); /* Unsupported pattern.  */
     }
              (int) rel->r_offset);
       BFD_ASSERT(0); /* Unsupported pattern.  */
     }
@@ -5083,11 +5072,13 @@ ones32 (register unsigned int x)
   return (x & 0x0000003f);
 }
 
   return (x & 0x0000003f);
 }
 
+#if !HAVE_FLS
 static unsigned int
 fls (register unsigned int x)
 {
   return ffs (x & (-x));
 }
 static unsigned int
 fls (register unsigned int x)
 {
   return ffs (x & (-x));
 }
+#endif /* !HAVE_FLS */
 
 #define nds32_elf_local_tlsdesc_gotent(bfd) \
   (elf_nds32_tdata (bfd)->local_tlsdesc_gotent)
 
 #define nds32_elf_local_tlsdesc_gotent(bfd) \
   (elf_nds32_tdata (bfd)->local_tlsdesc_gotent)
@@ -5584,8 +5575,7 @@ nds32_elf_relocate_section (bfd *            output_bfd ATTRIBUTE_UNUSED,
                    return FALSE;
 
                  BFD_ASSERT (strncmp (name, ".rela", 5) == 0
                    return FALSE;
 
                  BFD_ASSERT (strncmp (name, ".rela", 5) == 0
-                             && strcmp (bfd_get_section_name (input_bfd,
-                                                              input_section),
+                             && strcmp (bfd_section_name (input_section),
                                         name + 5) == 0);
 
                  sreloc = bfd_get_section_by_name (dynobj, name);
                                         name + 5) == 0);
 
                  sreloc = bfd_get_section_by_name (dynobj, name);
@@ -5649,7 +5639,7 @@ nds32_elf_relocate_section (bfd *            output_bfd ATTRIBUTE_UNUSED,
                      if (h->dynindx == -1)
                        {
                          _bfd_error_handler
                      if (h->dynindx == -1)
                        {
                          _bfd_error_handler
-                           (_("%pB: relocation %s against `%s' can not be used when"
+                           (_("%pB: relocation %s against `%s' can not be used when "
                               "making a shared object; recompile with -fPIC"),
                             input_bfd, nds32_elf_howto_table[r_type].name, h->root.root.string);
                          bfd_set_error (bfd_error_bad_value);
                               "making a shared object; recompile with -fPIC"),
                             input_bfd, nds32_elf_howto_table[r_type].name, h->root.root.string);
                          bfd_set_error (bfd_error_bad_value);
@@ -5837,7 +5827,7 @@ nds32_elf_relocate_section (bfd *            output_bfd ATTRIBUTE_UNUSED,
        case R_NDS32_SDA15S0_RELA:
        case R_NDS32_SDA15S0:
          align = 0x0;
        case R_NDS32_SDA15S0_RELA:
        case R_NDS32_SDA15S0:
          align = 0x0;
-handle_sda:
+       handle_sda:
          BFD_ASSERT (sec != NULL);
 
          /* If the symbol is in the abs section, the out_bfd will be null.
          BFD_ASSERT (sec != NULL);
 
          /* If the symbol is in the abs section, the out_bfd will be null.
@@ -6165,7 +6155,7 @@ handle_sda:
          break;
        }
 
          break;
        }
 
-check_reloc:
+    check_reloc:
 
       if (r != bfd_reloc_ok)
        {
 
       if (r != bfd_reloc_ok)
        {
@@ -6179,7 +6169,7 @@ check_reloc:
              name = bfd_elf_string_from_elf_section
                      (input_bfd, symtab_hdr->sh_link, sym->st_name);
              if (name == NULL || *name == '\0')
              name = bfd_elf_string_from_elf_section
                      (input_bfd, symtab_hdr->sh_link, sym->st_name);
              if (name == NULL || *name == '\0')
-               name = bfd_section_name (input_bfd, sec);
+               name = bfd_section_name (sec);
            }
 
          if (errmsg != NULL)
            }
 
          if (errmsg != NULL)
@@ -6214,7 +6204,7 @@ check_reloc:
              errmsg = _("internal error: unknown error");
              /* Fall through.  */
 
              errmsg = _("internal error: unknown error");
              /* Fall through.  */
 
-common_error:
+           common_error:
              (*info->callbacks->warning) (info, errmsg, name, input_bfd,
                                           input_section, offset);
              break;
              (*info->callbacks->warning) (info, errmsg, name, input_bfd,
                                           input_section, offset);
              break;
@@ -6498,7 +6488,7 @@ nds32_elf_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
              goto get_vma;
            case DT_JMPREL:
              s = ehtab->srelplt->output_section;
              goto get_vma;
            case DT_JMPREL:
              s = ehtab->srelplt->output_section;
-get_vma:
+           get_vma:
              BFD_ASSERT (s != NULL);
              dyn.d_un.d_ptr = s->vma;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              BFD_ASSERT (s != NULL);
              dyn.d_un.d_ptr = s->vma;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
@@ -6685,9 +6675,8 @@ nds32_elf_object_p (bfd *abfd)
 
 /* Store the machine number in the flags field.  */
 
 
 /* Store the machine number in the flags field.  */
 
-static void
-nds32_elf_final_write_processing (bfd *abfd,
-                                 bfd_boolean linker ATTRIBUTE_UNUSED)
+static bfd_boolean
+nds32_elf_final_write_processing (bfd *abfd)
 {
   unsigned long val;
   static unsigned int cur_mach = 0;
 {
   unsigned long val;
   static unsigned int cur_mach = 0;
@@ -6724,6 +6713,7 @@ nds32_elf_final_write_processing (bfd *abfd,
 
   elf_elfheader (abfd)->e_flags &= ~EF_NDS_ARCH;
   elf_elfheader (abfd)->e_flags |= val;
 
   elf_elfheader (abfd)->e_flags &= ~EF_NDS_ARCH;
   elf_elfheader (abfd)->e_flags |= val;
+  return _bfd_elf_final_write_processing (abfd);
 }
 
 /* Function to keep NDS32 specific file flags.  */
 }
 
 /* Function to keep NDS32 specific file flags.  */
@@ -6827,6 +6817,10 @@ nds32_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   flagword out_fpu_config;
   flagword in_fpu_config;
 
   flagword out_fpu_config;
   flagword in_fpu_config;
 
+  /* FIXME: What should be checked when linking shared libraries?  */
+  if ((ibfd->flags & DYNAMIC) != 0)
+    return TRUE;
+
   /* TODO: Revise to use object-attributes instead.  */
   if (!nds32_check_vec_size (ibfd))
     return FALSE;
   /* TODO: Revise to use object-attributes instead.  */
   if (!nds32_check_vec_size (ibfd))
     return FALSE;
@@ -7403,7 +7397,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
                    return FALSE;
 
                  BFD_ASSERT (strncmp (name, ".rela", 5) == 0
                    return FALSE;
 
                  BFD_ASSERT (strncmp (name, ".rela", 5) == 0
-                             && strcmp (bfd_get_section_name (abfd, sec),
+                             && strcmp (bfd_section_name (sec),
                                         name + 5) == 0);
 
                  sreloc = bfd_get_section_by_name (dynobj, name);
                                         name + 5) == 0);
 
                  sreloc = bfd_get_section_by_name (dynobj, name);
@@ -7417,8 +7411,8 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
                      if ((sec->flags & SEC_ALLOC) != 0)
                        flags |= SEC_ALLOC | SEC_LOAD;
                      if (sreloc == NULL
                      if ((sec->flags & SEC_ALLOC) != 0)
                        flags |= SEC_ALLOC | SEC_LOAD;
                      if (sreloc == NULL
-                         || !bfd_set_section_flags (dynobj, sreloc, flags)
-                         || !bfd_set_section_alignment (dynobj, sreloc, 2))
+                         || !bfd_set_section_flags (sreloc, flags)
+                         || !bfd_set_section_alignment (sreloc, 2))
                        return FALSE;
 
                      elf_section_type (sreloc) = SHT_RELA;
                        return FALSE;
 
                      elf_section_type (sreloc) = SHT_RELA;
@@ -7452,7 +7446,7 @@ nds32_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
              p = *head;
              if (p == NULL || p->sec != sec)
                {
              p = *head;
              if (p == NULL || p->sec != sec)
                {
-                 bfd_size_type amt = sizeof (*p);
+                 size_t amt = sizeof (*p);
                  p = (struct elf_dyn_relocs *) bfd_alloc (dynobj, amt);
                  if (p == NULL)
                    return FALSE;
                  p = (struct elf_dyn_relocs *) bfd_alloc (dynobj, amt);
                  if (p == NULL)
                    return FALSE;
@@ -8291,7 +8285,7 @@ nds32_convert_32_to_16 (bfd *abfd, uint32_t insn, uint16_t *pinsn16,
       goto done;
     }
 
       goto done;
     }
 
-done:
+ done:
   /* Bit-15 of insn16 should be set for a valid instruction.  */
   if ((insn16 & 0x8000) == 0)
     return 0;
   /* Bit-15 of insn16 should be set for a valid instruction.  */
   if ((insn16 & 0x8000) == 0)
     return 0;
@@ -8613,7 +8607,7 @@ nds32_convert_16_to_32 (bfd *abfd, uint16_t insn16, uint32_t *pinsn)
       goto done;
     }
 
       goto done;
     }
 
-done:
+ done:
   if (insn & 0x80000000)
     return 0;
 
   if (insn & 0x80000000)
     return 0;
 
@@ -9458,7 +9452,7 @@ nds32_elf_relax_delete_blanks (bfd *abfd, asection *sec,
              if (p < endp)
                *p |= 0x80;
            }
              if (p < endp)
                *p |= 0x80;
            }
-done_adjust_diff:
+       done_adjust_diff:
 
          if (sec == sect)
            {
 
          if (sec == sect)
            {
@@ -12577,21 +12571,19 @@ nds32_elf_relax_section (bfd *abfd, asection *sec,
       clean_nds32_elf_blank ();
     }
 
       clean_nds32_elf_blank ();
     }
 
-finish:
-  if (internal_relocs != NULL
-      && elf_section_data (sec)->relocs != internal_relocs)
+ finish:
+  if (elf_section_data (sec)->relocs != internal_relocs)
     free (internal_relocs);
 
     free (internal_relocs);
 
-  if (contents != NULL
-      && elf_section_data (sec)->this_hdr.contents != contents)
+  if (elf_section_data (sec)->this_hdr.contents != contents)
     free (contents);
 
     free (contents);
 
-  if (isymbuf != NULL && symtab_hdr->contents != (bfd_byte *) isymbuf)
+  if (symtab_hdr->contents != (bfd_byte *) isymbuf)
     free (isymbuf);
 
   return result;
 
     free (isymbuf);
 
   return result;
 
-error_return:
+ error_return:
   result = FALSE;
   goto finish;
 }
   result = FALSE;
   goto finish;
 }
@@ -12603,6 +12595,18 @@ static struct bfd_elf_special_section const nds32_elf_special_sections[] =
   {NULL, 0, 0, 0, 0}
 };
 
   {NULL, 0, 0, 0, 0}
 };
 
+static bfd_boolean
+nds32_elf_section_flags (const Elf_Internal_Shdr *hdr)
+{
+  const char *name = hdr->bfd_section->name;
+
+  if (strncmp (name, ".sbss", 5) == 0
+      || strncmp (name, ".sdata", 6) == 0)
+    hdr->bfd_section->flags |= SEC_SMALL_DATA;
+
+  return TRUE;
+}
+
 static bfd_boolean
 nds32_elf_output_arch_syms (bfd *output_bfd ATTRIBUTE_UNUSED,
                            struct bfd_link_info *info,
 static bfd_boolean
 nds32_elf_output_arch_syms (bfd *output_bfd ATTRIBUTE_UNUSED,
                            struct bfd_link_info *info,
@@ -13162,7 +13166,7 @@ nds32_fag_remove_unused_fpbase (bfd *abfd, asection *sec,
        goto error_return;
     }
 
        goto error_return;
     }
 
-finish:
+ finish:
   if (relax_blank_list)
     {
       nds32_elf_relax_delete_blanks (abfd, sec, relax_blank_list);
   if (relax_blank_list)
     {
       nds32_elf_relax_delete_blanks (abfd, sec, relax_blank_list);
@@ -13170,7 +13174,7 @@ finish:
     }
   return result;
 
     }
   return result;
 
-error_return:
+ error_return:
   result = FALSE;
   goto finish;
 }
   result = FALSE;
   goto finish;
 }
@@ -13228,14 +13232,15 @@ nds32_elf_get_relocated_section_contents (bfd *abfd,
          symbol = *(*parent)->sym_ptr_ptr;
          if (symbol->section && discarded_section (symbol->section))
            {
          symbol = *(*parent)->sym_ptr_ptr;
          if (symbol->section && discarded_section (symbol->section))
            {
-             bfd_byte *p;
+             bfd_vma off;
              static reloc_howto_type none_howto
                = HOWTO (0, 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL,
                         "unused", FALSE, 0, 0, FALSE);
 
              static reloc_howto_type none_howto
                = HOWTO (0, 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL,
                         "unused", FALSE, 0, 0, FALSE);
 
-             p = data + (*parent)->address * bfd_octets_per_byte (input_bfd);
-             _bfd_clear_contents ((*parent)->howto, input_bfd, input_section,
-                                  p);
+             off = (*parent)->address * OCTETS_PER_BYTE (input_bfd,
+                                                         input_section);
+             _bfd_clear_contents ((*parent)->howto, input_bfd,
+                                  input_section, data, off);
              (*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
              (*parent)->addend = 0;
              (*parent)->howto = &none_howto;
              (*parent)->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
              (*parent)->addend = 0;
              (*parent)->howto = &none_howto;
@@ -13300,7 +13305,7 @@ nds32_elf_get_relocated_section_contents (bfd *abfd,
   free (reloc_vector);
   return data;
 
   free (reloc_vector);
   return data;
 
-error_return:
+ error_return:
   free (reloc_vector);
   return NULL;
 }
   free (reloc_vector);
   return NULL;
 }
@@ -13466,7 +13471,7 @@ elf32_nds32_check_relax_group (bfd *abfd, asection *asec)
     }
   while (FALSE);
 
     }
   while (FALSE);
 
-  if ((relocs != NULL) && (elf_section_data (asec)->relocs != relocs))
+  if (elf_section_data (asec)->relocs != relocs)
     free (relocs);
 
   if ((min_id != relax_group_ptr->min_id)
     free (relocs);
 
   if ((min_id != relax_group_ptr->min_id)
@@ -13605,7 +13610,7 @@ elf32_nds32_unify_relax_group (bfd *abfd, asection *asec)
     }
   while (FALSE);
 
     }
   while (FALSE);
 
-  if (relocs != NULL && elf_section_data (asec)->relocs != relocs)
+  if (elf_section_data (asec)->relocs != relocs)
     free (relocs);
 
   return result;
     free (relocs);
 
   return result;
@@ -14027,19 +14032,17 @@ nds32_elf_unify_tls_model (bfd *inbfd, asection *insec, bfd_byte *incontents,
 #endif
     }
 
 #endif
     }
 
-finish:
+ finish:
   if (incontents)
     contents = NULL;
 
   if (incontents)
     contents = NULL;
 
-  if (internal_relocs != NULL
-      && elf_section_data (insec)->relocs != internal_relocs)
+  if (elf_section_data (insec)->relocs != internal_relocs)
     free (internal_relocs);
 
     free (internal_relocs);
 
-  if (contents != NULL
-      && elf_section_data (insec)->this_hdr.contents != contents)
+  if (elf_section_data (insec)->this_hdr.contents != contents)
     free (contents);
 
     free (contents);
 
-  if (local_syms != NULL && symtab_hdr->contents != (bfd_byte *) local_syms)
+  if (symtab_hdr->contents != (bfd_byte *) local_syms)
     free (local_syms);
 
   if (chain.next)
     free (local_syms);
 
   if (chain.next)
@@ -14056,7 +14059,7 @@ finish:
 
   return result;
 
 
   return result;
 
-error_return:
+ error_return:
   result = FALSE;
   goto finish;
 }
   result = FALSE;
   goto finish;
 }
@@ -14102,6 +14105,7 @@ error_return:
 #define elf_backend_object_p                   nds32_elf_object_p
 #define elf_backend_final_write_processing     nds32_elf_final_write_processing
 #define elf_backend_special_sections           nds32_elf_special_sections
 #define elf_backend_object_p                   nds32_elf_object_p
 #define elf_backend_final_write_processing     nds32_elf_final_write_processing
 #define elf_backend_special_sections           nds32_elf_special_sections
+#define elf_backend_section_flags              nds32_elf_section_flags
 #define bfd_elf32_bfd_get_relocated_section_contents \
                                nds32_elf_get_relocated_section_contents
 #define bfd_elf32_bfd_is_target_special_symbol nds32_elf_is_target_special_symbol
 #define bfd_elf32_bfd_get_relocated_section_contents \
                                nds32_elf_get_relocated_section_contents
 #define bfd_elf32_bfd_is_target_special_symbol nds32_elf_is_target_special_symbol
This page took 0.035977 seconds and 4 git commands to generate.