objcopy section alignment
authorAlan Modra <amodra@gmail.com>
Sat, 6 Aug 2022 05:27:27 +0000 (14:57 +0930)
committerAlan Modra <amodra@gmail.com>
Sat, 6 Aug 2022 09:13:24 +0000 (18:43 +0930)
commit578a7392c33c7c7cde5559278e519c75047318c9
treea2c254b92055bfbfd070f2d60cb9d14ab6d6d35b
parent77b38f6db98e046232ecaac11b61c453965fb75a
objcopy section alignment

bfd_set_section_alignment currently always returns true.  This patch
changes it to return false on silly alignment values, avoiding yet
another way to trigger ubsan errors like coffcode.h:3192:12: runtime
error: shift exponent 299 is too large for 32-bit type 'int'.  We'll
catch that one in objcopy.c:setup_sections.  However, setup_sections
gives up on other setup operations that are necessary even after an
error of some sort.  Change that to keep going, which might change the
error message but that shouldn't matter in the least.

bfd/
* section.c (bfd_set_section_alignment): Return false and
don't set alignment_power for stupidly large alignments.
* bfd-in2.h: Regenerate.
* coffcode.h (coff_compute_section_file_positions): Don't use
an int constant when calculating alignment.
binutils/
* objcopy.c (setup_section): Keep on going after hitting
non-fatal errors.
bfd/bfd-in2.h
bfd/coffcode.h
bfd/section.c
binutils/objcopy.c