bfd/nds32: remove unused got_size variable

Message ID 20261030150041.1145882-1-simon.marchi@efficios.com
State New
Headers
Series bfd/nds32: remove unused got_size variable |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Simon Marchi Oct. 30, 2026, 3 p.m. UTC
  Building bfd with a recent clang fails with:

    /home/smarchi/src/binutils-gdb/bfd/elf32-nds32.c:154:13: error: variable 'got_size' set but not used [-Werror,-Wunused-but-set-global]

The variable has been unused since it was introduced by commit
35c081572f32 ("Add support for Andes NDS32:", 2013-12-13).  Remove it,
along with the comment that describes it.  The branches handling the
.got and .got.plt sections in nds32_elf_late_size_sections become
empty, merge them with the one handling .plt.

Cc: Kuan-Lin Chen <kuanlinchentw@gmail.com>
Cc: Wei-Cheng Wang <cole945@gmail.com>
---
 bfd/elf32-nds32.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)


base-commit: 5ffe4ba215c0bc186b91c85739350a67a8f61a0f
  

Comments

Alan Modra Nov. 10, 2026, 4:51 a.m. UTC | #1
On Fri, Oct 30, 2026 at 11:00:32AM -0400, Simon Marchi wrote:
> Building bfd with a recent clang fails with:
> 
>     /home/smarchi/src/binutils-gdb/bfd/elf32-nds32.c:154:13: error: variable 'got_size' set but not used [-Werror,-Wunused-but-set-global]
> 
> The variable has been unused since it was introduced by commit
> 35c081572f32 ("Add support for Andes NDS32:", 2013-12-13).  Remove it,
> along with the comment that describes it.  The branches handling the
> .got and .got.plt sections in nds32_elf_late_size_sections become
> empty, merge them with the one handling .plt.

OK.
  
Simon Marchi Nov. 10, 2026, 7:47 p.m. UTC | #2
On 11/9/26 11:51 PM, Alan Modra wrote:
> On Fri, Oct 30, 2026 at 11:00:32AM -0400, Simon Marchi wrote:
>> Building bfd with a recent clang fails with:
>>
>>     /home/smarchi/src/binutils-gdb/bfd/elf32-nds32.c:154:13: error: variable 'got_size' set but not used [-Werror,-Wunused-but-set-global]
>>
>> The variable has been unused since it was introduced by commit
>> 35c081572f32 ("Add support for Andes NDS32:", 2013-12-13).  Remove it,
>> along with the comment that describes it.  The branches handling the
>> .got and .got.plt sections in nds32_elf_late_size_sections become
>> empty, merge them with the one handling .plt.
> 
> OK.
> 
> -- 
> Alan Modra

Thanks, pushed.

Simon
  

Patch

diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c
index 1c1cb4ca030a..3792701cf12c 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -150,8 +150,6 @@  enum
 #define CONSERVATIVE_19BIT	(0x40000 - 0x1000)
 #define CONSERVATIVE_20BIT	(0x80000 - 0x1000)
 
-/* Size of small data/bss sections, used to calculate SDA_BASE.  */
-static long got_size = 0;
 static int is_SDA_BASE_set = 0;
 
 /* Convert ELF-VER in eflags to string for debugging purpose.  */
@@ -4531,20 +4529,14 @@  nds32_elf_late_size_sections (struct bfd_link_info *info)
       if ((s->flags & SEC_LINKER_CREATED) == 0)
 	continue;
 
-      if (s == htab->root.splt)
+      if (s == htab->root.splt
+	  || s == elf_hash_table (info)->sgot
+	  || s == elf_hash_table (info)->sgotplt)
 	{
 	  /* Strip this section if we don't need it; see the
 	     comment below.  */
 	  ;
 	}
-      else if (s == elf_hash_table (info)->sgot)
-	{
-	  got_size += s->size;
-	}
-      else if (s == elf_hash_table (info)->sgotplt)
-	{
-	  got_size += s->size;
-	}
       else if (startswith (bfd_section_name (s), ".rela"))
 	{
 	  if (s->size != 0 && s != elf_hash_table (info)->srelplt)