[binutils-gdb] bfd/PE: make local array in _bfd_XXi_swap_scnhdr_out() static

Jan Beulich jbeulich@sourceware.org
Fri Oct 10 14:05:49 GMT 2025


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

commit 1ff5a447620050135b6431c761a5f2d8b01519fe
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri Oct 10 16:03:15 2025 +0200

    bfd/PE: make local array in _bfd_XXi_swap_scnhdr_out() static
    
    ... and const. There's no reason to have the compiler copy an anonymous
    .rodata object onto the stack. And there's also no reason to allow the
    array to be modifiable.

Diff:
---
 bfd/peXXigen.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index ac818ee383c..e6686dc3259 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -1003,7 +1003,7 @@ _bfd_XXi_swap_scnhdr_out (bfd * abfd, void * in, void * out,
     }
     pe_required_section_flags;
 
-    pe_required_section_flags known_sections [] =
+    static const pe_required_section_flags known_sections [] =
       {
 	{ ".CRT",   IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA },
 	{ ".arch",  IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_DISCARDABLE | IMAGE_SCN_ALIGN_8BYTES },
@@ -1021,7 +1021,7 @@ _bfd_XXi_swap_scnhdr_out (bfd * abfd, void * in, void * out,
 	{ ".xdata", IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA },
       };
 
-    pe_required_section_flags * p;
+    const pe_required_section_flags * p;
 
     /* We have defaulted to adding the IMAGE_SCN_MEM_WRITE flag, but now
        we know exactly what this specific section wants so we remove it


More information about the Binutils-cvs mailing list