From c4e6b6be66500cb31f7d123377a90fed17dd992a Mon Sep 17 00:00:00 2001
From: Xin Wang <wangxin03@loongson.cn>
Date: Wed, 30 Oct 2024 19:48:09 +0800
Subject: [PATCH 123/123] replace space with tab

---
 bfd/elfnn-loongarch.c | 322 +++++++++++++++++++++---------------------
 1 file changed, 161 insertions(+), 161 deletions(-)

diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c
index 8b9628f7..13216ef9 100644
--- a/bfd/elfnn-loongarch.c
+++ b/bfd/elfnn-loongarch.c
@@ -159,7 +159,7 @@ loongarch_elf_new_section_hook (bfd *abfd, asection *sec)
 
       sdata = bfd_zalloc (abfd, amt);
       if (!sdata)
-       return false;
+	return false;
       sec->used_by_bfd = sdata;
     }
 
@@ -993,17 +993,17 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 	r_type = loongarch_tls_transition (abfd, info, h, r_symndx, r_type);
 
       /* I don't want to spend time supporting DT_RELR with old object
-        files doing stack-based relocs.  */
+	 files doing stack-based relocs.  */
       if (info->enable_dt_relr
-         && r_type >= R_LARCH_SOP_PUSH_PCREL
-         && r_type <= R_LARCH_SOP_POP_32_U)
-       {
-         /* xgettext:c-format */
-         _bfd_error_handler (_("%pB: stack based reloc type (%u) is not "
-                               "supported with -z pack-relative-relocs"),
-                             abfd, r_type);
-         return false;
-       }
+	  && r_type >= R_LARCH_SOP_PUSH_PCREL
+	  && r_type <= R_LARCH_SOP_POP_32_U)
+	{
+	  /* xgettext:c-format */
+	  _bfd_error_handler (_("%pB: stack based reloc type (%u) is not "
+				"supported with -z pack-relative-relocs"),
+			      abfd, r_type);
+	  return false;
+	}
 
       switch (r_type)
 	{
@@ -1218,19 +1218,19 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 	    return false;
 	  break;
 
-       case R_LARCH_ALIGN:
-         /* Check against irrational R_LARCH_ALIGN relocs which may cause
-            removing an odd number of bytes and disrupt DT_RELR.  */
-         if (rel->r_offset % 4 != 0)
-           {
-             /* xgettext:c-format */
-             _bfd_error_handler (
-               _("%pB: R_LARCH_ALIGN with offset %" PRId64 " not aligned "
-                 "to instruction boundary"),
-               abfd, (uint64_t) rel->r_offset);
-             return false;
-           }
-         break;
+	case R_LARCH_ALIGN:
+	  /* Check against irrational R_LARCH_ALIGN relocs which may cause
+	     removing an odd number of bytes and disrupt DT_RELR.  */
+	  if (rel->r_offset % 4 != 0)
+	    {
+	      /* xgettext:c-format */
+	      _bfd_error_handler (
+		_("%pB: R_LARCH_ALIGN with offset %" PRId64 " not aligned "
+		  "to instruction boundary"),
+		abfd, (uint64_t) rel->r_offset);
+	      return false;
+	    }
+	  break;
 
 	default:
 	  break;
@@ -1948,7 +1948,7 @@ maybe_set_textrel (struct elf_link_hash_entry *h, void *info_p)
 
 static bool
 record_relr (struct loongarch_elf_link_hash_table *htab, asection *sec,
-            bfd_vma off, asection *sreloc)
+	     bfd_vma off, asection *sreloc)
 {
   struct relr_entry **sec_relr = &loongarch_elf_section_data (sec)->relr;
 
@@ -1960,14 +1960,14 @@ record_relr (struct loongarch_elf_link_hash_table *htab, asection *sec,
   if (htab->relr_count >= htab->relr_alloc)
     {
       if (htab->relr_alloc == 0)
-       htab->relr_alloc = 4096;
+	htab->relr_alloc = 4096;
       else
-       htab->relr_alloc *= 2;
+	htab->relr_alloc *= 2;
 
       htab->relr = bfd_realloc (htab->relr,
-                               htab->relr_alloc * sizeof (*htab->relr));
+				htab->relr_alloc * sizeof (*htab->relr));
       if (!htab->relr)
-       return false;
+	return false;
     }
   htab->relr[htab->relr_count].sec = sec;
   htab->relr[htab->relr_count].off = off;
@@ -1994,11 +1994,11 @@ record_relr_local_got_relocs (bfd *input_bfd, struct bfd_link_info *info)
       bfd_vma off = local_got_offsets[i];
 
       /* FIXME: If the local symbol is in SHN_ABS then emitting
-        a relative relocation is not correct, but it seems to be wrong
-        in loongarch_elf_relocate_section too.  */
+	 a relative relocation is not correct, but it seems to be wrong
+	 in loongarch_elf_relocate_section too.  */
       if (local_tls_type[i] == GOT_NORMAL
-         && !record_relr (htab, htab->elf.sgot, off, htab->elf.srelgot))
-       return false;
+	  && !record_relr (htab, htab->elf.sgot, off, htab->elf.srelgot))
+	return false;
     }
 
   return true;
@@ -2036,7 +2036,7 @@ record_relr_dyn_got_relocs (struct elf_link_hash_entry *h, void *inf)
     return true;
 
   if (!record_relr (htab, htab->elf.sgot, h->got.offset,
-                   htab->elf.srelgot))
+		    htab->elf.srelgot))
     return false;
 
   return true;
@@ -2044,7 +2044,7 @@ record_relr_dyn_got_relocs (struct elf_link_hash_entry *h, void *inf)
 
 static bool
 record_relr_non_got_relocs (bfd *input_bfd, struct bfd_link_info *info,
-                           asection *sec)
+			    asection *sec)
 {
   asection *sreloc;
   struct loongarch_elf_link_hash_table *htab;
@@ -2072,7 +2072,7 @@ record_relr_non_got_relocs (bfd *input_bfd, struct bfd_link_info *info,
   symtab_hdr = &elf_symtab_hdr (input_bfd);
   sym_hashes = elf_sym_hashes (input_bfd);
   relocs = _bfd_elf_link_info_read_relocs (input_bfd, info, sec, NULL,
-                                          NULL, info->keep_memory);
+					   NULL, info->keep_memory);
   BFD_ASSERT (relocs != NULL);
   rel_end = relocs + sec->reloc_count;
   for (rel = relocs; rel < rel_end; rel++)
@@ -2083,59 +2083,59 @@ record_relr_non_got_relocs (bfd *input_bfd, struct bfd_link_info *info,
       asection *def_sec = NULL;
 
       if ((r_type != R_LARCH_64 && r_type != R_LARCH_32)
-         || rel->r_offset % 2 != 0)
-       continue;
+	  || rel->r_offset % 2 != 0)
+	continue;
 
       /* The logical below must match loongarch_elf_relocate_section.  */
       if (r_symndx < symtab_hdr->sh_info)
-       {
-         /* A local symbol.  */
-         Elf_Internal_Sym *isym;
-         isym = bfd_sym_from_r_symndx (&htab->elf.sym_cache, input_bfd,
-                                       r_symndx);
-         BFD_ASSERT(isym != NULL);
-
-         /* Local STT_GNU_IFUNC symbol uses R_LARCH_IRELATIVE for
-            R_LARCH_NN, not R_LARCH_RELATIVE.  */
-         if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
-           continue;
-         def_sec = bfd_section_from_elf_index (input_bfd, isym->st_shndx);
-       }
+	{
+	  /* A local symbol.  */
+	  Elf_Internal_Sym *isym;
+	  isym = bfd_sym_from_r_symndx (&htab->elf.sym_cache, input_bfd,
+					r_symndx);
+	  BFD_ASSERT(isym != NULL);
+
+	  /* Local STT_GNU_IFUNC symbol uses R_LARCH_IRELATIVE for
+	     R_LARCH_NN, not R_LARCH_RELATIVE.  */
+	  if (ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
+	    continue;
+	  def_sec = bfd_section_from_elf_index (input_bfd, isym->st_shndx);
+	}
       else
-       {
-         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;
-
-         /* Filter out symbols that cannot have a relative reloc.  */
-         if (h->dyn_relocs == NULL)
-           continue;
-         if (bfd_is_abs_symbol (&h->root))
-           continue;
-         if (h->type == STT_GNU_IFUNC)
-           continue;
-
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           def_sec = h->root.u.def.section;
-
-         /* On LoongArch an R_LARCH_NN against undefined weak symbol
-            is never converted to R_LARCH_RELATIVE: we don't have
-            -z dynamic-undefined-weak, thus the reloc is either removed
-            (if the symbol is LARCH_REF_LOCAL) or kept (otherwise).  */
-         if (h->root.type == bfd_link_hash_undefweak)
-           continue;
-
-         if (!LARCH_REF_LOCAL (info, h))
-           continue;
-       }
+	{
+	  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;
+
+	  /* Filter out symbols that cannot have a relative reloc.  */
+	  if (h->dyn_relocs == NULL)
+	    continue;
+	  if (bfd_is_abs_symbol (&h->root))
+	    continue;
+	  if (h->type == STT_GNU_IFUNC)
+	    continue;
+
+	  if (h->root.type == bfd_link_hash_defined
+	      || h->root.type == bfd_link_hash_defweak)
+	    def_sec = h->root.u.def.section;
+
+	  /* On LoongArch an R_LARCH_NN against undefined weak symbol
+	     is never converted to R_LARCH_RELATIVE: we don't have
+	     -z dynamic-undefined-weak, thus the reloc is either removed
+	     (if the symbol is LARCH_REF_LOCAL) or kept (otherwise).  */
+	  if (h->root.type == bfd_link_hash_undefweak)
+	    continue;
+
+	  if (!LARCH_REF_LOCAL (info, h))
+	    continue;
+	}
 
       if (!def_sec || discarded_section (def_sec))
-       continue;
+	continue;
 
       if (!record_relr (htab, sec, rel->r_offset, sreloc))
-       return false;
+	return false;
     }
 
   return true;
@@ -2150,7 +2150,7 @@ cmp_relr_addr (const void *p, const void *q)
 
 static bool
 sort_relr (struct bfd_link_info *info,
-          struct loongarch_elf_link_hash_table *htab)
+	   struct loongarch_elf_link_hash_table *htab)
 {
   if (htab->relr_count == 0)
     return true;
@@ -2160,17 +2160,17 @@ sort_relr (struct bfd_link_info *info,
     {
       addr = bfd_malloc (htab->relr_count * sizeof (*addr));
       if (!addr)
-       return false;
+	return false;
       htab->relr_sorted = addr;
     }
 
   for (bfd_size_type i = 0; i < htab->relr_count; i++)
     {
       bfd_vma off = _bfd_elf_section_offset (info->output_bfd, info,
-                                            htab->relr[i].sec,
-                                            htab->relr[i].off);
+					     htab->relr[i].sec,
+					     htab->relr[i].off);
       addr[i] = htab->relr[i].sec->output_section->vma
-               + htab->relr[i].sec->output_offset + off;
+		+ htab->relr[i].sec->output_offset + off;
     }
   qsort(addr, htab->relr_count, sizeof (*addr), cmp_relr_addr);
   return true;
@@ -2178,7 +2178,7 @@ sort_relr (struct bfd_link_info *info,
 
 static bool
 loongarch_elf_size_relative_relocs (struct bfd_link_info *info,
-                                   bool *need_layout)
+				    bool *need_layout)
 {
   struct loongarch_elf_link_hash_table *htab =
     loongarch_elf_hash_table (info);
@@ -2200,29 +2200,29 @@ loongarch_elf_size_relative_relocs (struct bfd_link_info *info,
       srelrdyn->size += NN / 8;
       base += NN / 8;
       while (1)
-       {
-         bfd_size_type start_i = i;
-         while (i < htab->relr_count
-                && addr[i] - base < (NN - 1) * (NN / 8)
-                && (addr[i] - base) % (NN / 8) == 0)
-           i++;
-         if (i == start_i)
-           break;
-         srelrdyn->size += NN / 8;
-         base += (NN - 1) * (NN / 8);
-       }
+	{
+	  bfd_size_type start_i = i;
+	  while (i < htab->relr_count
+		 && addr[i] - base < (NN - 1) * (NN / 8)
+		 && (addr[i] - base) % (NN / 8) == 0)
+	    i++;
+	  if (i == start_i)
+	    break;
+	  srelrdyn->size += NN / 8;
+	  base += (NN - 1) * (NN / 8);
+	}
     }
   if (srelrdyn->size != oldsize)
     {
       *need_layout = true;
       /* Stop after a few iterations in case the layout does not converge,
-        but we can only stop when the size would shrink (and pad the
-        spare space with 1.  */
+	 but we can only stop when the size would shrink (and pad the
+	 spare space with 1.  */
       if (htab->relr_layout_iter++ > 5 && srelrdyn->size < oldsize)
-       {
-         srelrdyn->size = oldsize;
-         *need_layout = false;
-       }
+	{
+	  srelrdyn->size = oldsize;
+	  *need_layout = false;
+	}
     }
 
   htab->layout_mutating_for_relr = *need_layout;
@@ -2254,22 +2254,22 @@ loongarch_elf_finish_relative_relocs (struct bfd_link_info *info)
       loc += NN / 8;
       base += NN / 8;
       while (1)
-       {
-         uintNN_t bits = 0;
-         while (i < htab->relr_count)
-           {
-             bfd_vma delta = addr[i] - base;
-             if (delta >= (NN - 1) * (NN / 8) || delta % (NN / 8) != 0)
-               break;
-             bits |= (uintNN_t) 1 << (delta / (NN / 8));
-             i++;
-           }
-         if (bits == 0)
-           break;
-         bfd_put_NN (dynobj, (bits << 1) | 1, loc);
-         loc += NN / 8;
-         base += (NN - 1) * (NN / 8);
-       }
+	{
+	  uintNN_t bits = 0;
+	  while (i < htab->relr_count)
+	    {
+	      bfd_vma delta = addr[i] - base;
+	      if (delta >= (NN - 1) * (NN / 8) || delta % (NN / 8) != 0)
+		break;
+	      bits |= (uintNN_t) 1 << (delta / (NN / 8));
+	      i++;
+	    }
+	  if (bits == 0)
+	    break;
+	  bfd_put_NN (dynobj, (bits << 1) | 1, loc);
+	  loc += NN / 8;
+	  base += (NN - 1) * (NN / 8);
+	}
     }
 
   free (addr);
@@ -2469,17 +2469,17 @@ loongarch_elf_size_dynamic_sections (bfd *output_bfd,
       elf_link_hash_traverse (&htab->elf, record_relr_dyn_got_relocs, info);
 
       for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link.next)
-       {
-         if (!is_loongarch_elf (ibfd))
-           continue;
+	{
+	  if (!is_loongarch_elf (ibfd))
+	    continue;
 
-         for (s = ibfd->sections; s != NULL; s = s->next)
-           if (!record_relr_non_got_relocs (ibfd, info, s))
-             return false;
+	  for (s = ibfd->sections; s != NULL; s = s->next)
+	    if (!record_relr_non_got_relocs (ibfd, info, s))
+	      return false;
 
-         if (!record_relr_local_got_relocs (ibfd, info))
-           return false;
-       }
+	  if (!record_relr_local_got_relocs (ibfd, info))
+	    return false;
+	}
     }
 
   /* The check_relocs and adjust_dynamic_symbol entry points have
@@ -2507,13 +2507,13 @@ loongarch_elf_size_dynamic_sections (bfd *output_bfd,
 	    }
 	}
       else if (s == htab->elf.srelrdyn && htab->relr_count == 0)
-       {
-         /* Remove .relr.dyn based on relr_count, not size, since
-            it is not sized yet.  */
-         s->flags |= SEC_EXCLUDE;
-         /* Allocate contents later.  */
-         continue;
-       }
+	{
+	  /* Remove .relr.dyn based on relr_count, not size, since
+	     it is not sized yet.  */
+	  s->flags |= SEC_EXCLUDE;
+	  /* Allocate contents later.  */
+	  continue;
+	}
       else
 	{
 	  /* It's not one of our sections.  */
@@ -3430,21 +3430,21 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
 	      if (unresolved_reloc
 		  && (ARCH_SIZE == 32 || r_type != R_LARCH_32)
 		  && !(h && (h->is_weakalias || !h->dyn_relocs)))
-               {
-                 if (info->enable_dt_relr
-                     && (ELFNN_R_TYPE (outrel.r_info) == R_LARCH_RELATIVE)
-                     && input_section->alignment_power != 0
-                     && rel->r_offset % 2 == 0)
-                   /* Don't emit a relative relocation that is packed,
-                      only apply the addend (as if we are applying the
-                      original R_LARCH_NN reloc in a PDE).  */
-                   r = perform_relocation (rel, input_section, howto,
-                                           relocation, input_bfd,
-                                           contents);
-                 else
-                   loongarch_elf_append_rela (output_bfd, sreloc,
-                                              &outrel);
-               }
+		{
+		  if (info->enable_dt_relr
+		      && (ELFNN_R_TYPE (outrel.r_info) == R_LARCH_RELATIVE)
+		      && input_section->alignment_power != 0
+		      && rel->r_offset % 2 == 0)
+		    /* Don't emit a relative relocation that is packed,
+		       only apply the addend (as if we are applying the
+		       original R_LARCH_NN reloc in a PDE).  */
+		    r = perform_relocation (rel, input_section, howto,
+					    relocation, input_bfd,
+					    contents);
+		  else
+		    loongarch_elf_append_rela (output_bfd, sreloc,
+					       &outrel);
+		}
 	    }
 
 	  relocation += rel->r_addend;
@@ -5725,16 +5725,16 @@ loongarch_elf_finish_dynamic_symbol (bfd *output_bfd,
       else if (bfd_link_pic (info) && LARCH_REF_LOCAL (info, h))
 	{
 	  asection *sec = h->root.u.def.section;
-          bfd_vma linkaddr = h->root.u.def.value + sec->output_section->vma
-                             + sec->output_offset;
- 
-          /* Don't emit relative relocs if they are packed, but we need
-             to write the addend (link-time addr) into the GOT then.  */
-          if (info->enable_dt_relr)
-            {
-              bfd_put_NN (output_bfd, linkaddr, sgot->contents + off);
-              goto skip_got_reloc;
-            }
+	  bfd_vma linkaddr = h->root.u.def.value + sec->output_section->vma
+			     + sec->output_offset;
+
+	  /* Don't emit relative relocs if they are packed, but we need
+	     to write the addend (link-time addr) into the GOT then.  */
+	  if (info->enable_dt_relr)
+	    {
+	      bfd_put_NN (output_bfd, linkaddr, sgot->contents + off);
+	      goto skip_got_reloc;
+	    }
 	  rela.r_info = ELFNN_R_INFO (0, R_LARCH_RELATIVE);
 	  rela.r_addend = linkaddr;
 	}
-- 
2.33.0