From: Jan Beulich Date: Fri, 8 Aug 2025 09:44:12 +0000 (+0200) Subject: bfd/ELF: make three local arrays static X-Git-Tag: gdb-17-branchpoint~361 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e118fe363d5538651ea6a0af6d5e05c105f01dc;p=thirdparty%2Fbinutils-gdb.git 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 --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