[binutils-gdb] bfd/ELF: make three local arrays static

Jan Beulich jbeulich@sourceware.org
Fri Aug 8 09:46:07 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1e118fe363d5538651ea6a0af6d5e05c105f01dc

commit 1e118fe363d5538651ea6a0af6d5e05c105f01dc
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Aug 8 11:44:12 2025 +0200

    bfd/ELF: make three local arrays static
    
    ... and const. There's no reason to have the compiler copy anonymous
    objects onto the stack. And there's also no reason to allow the arrays
    to be modifiable.

Diff:
---
 bfd/elf-bfd.h | 2 +-
 bfd/elf.c     | 4 ++--
 bfd/elflink.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index b7916239737..f24342cb029 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2632,7 +2632,7 @@ extern bool _bfd_elf_link_output_relocs
    struct elf_link_hash_entry **);
 
 extern void _bfd_elf_link_add_glibc_version_dependency
-  (struct elf_find_verdep_info *, const char *[]);
+  (struct elf_find_verdep_info *, const char *const []);
 
 extern void _bfd_elf_link_add_dt_relr_dependency
   (struct elf_find_verdep_info *);
diff --git a/bfd/elf.c b/bfd/elf.c
index dfa04c9268d..1b2e331eaa8 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -10948,7 +10948,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note)
 
   type = bfd_get_32 (abfd, note->descdata);
 
-  struct
+  static const struct
   {
     const char *type_name;
     unsigned long min_size;
@@ -13345,7 +13345,7 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset,
 	case bfd_core:
 	  {
 #define GROKER_ELEMENT(S,F) {S, sizeof (S) - 1, F}
-	    struct
+	    static const struct
 	    {
 	      const char * string;
 	      size_t len;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index cdd58b25fc8..7b0375406ac 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -2380,7 +2380,7 @@ elf_link_add_glibc_verneed (struct elf_find_verdep_info *rinfo,
 void
 _bfd_elf_link_add_glibc_version_dependency
   (struct elf_find_verdep_info *rinfo,
-   const char *version_dep[])
+   const char *const version_dep[])
 {
   Elf_Internal_Verneed *t = NULL;
   int glibc_minor_base = INT_MAX;
@@ -2405,7 +2405,7 @@ _bfd_elf_link_add_dt_relr_dependency (struct elf_find_verdep_info *rinfo)
 {
   if (rinfo->info->enable_dt_relr)
     {
-      const char *version[] =
+      static const char *const version[] =
 	{
 	  "GLIBC_ABI_DT_RELR",
 	  NULL


More information about the Binutils-cvs mailing list