Created attachment 12803 [details] Patch implementing described fix bfd_generic_define_common_symbol does not calculate the correct alignment for targets with more than 1 octet per byte if alignment power is less than 1. 3103: linker.c alignment = bfd_octets_per_byte (output_bfd, section) << power_of_two; e.g. A target has 16-bit bytes and an alignment of 1 byte (2 octets). A common variable may be defined as .comm variable,1,1 bfd_log2(1) will calculate alignment_power == 0 Mathematically 2 ** 0 == 1 which would be correct but the above statement will evaluate to 2. Instead the statement should check for a power_of_two == 0 condition i.e. alignment = power_of_two ? bfd_octets_per_byte (output_bfd, section) << power_of_two : 1;
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1e597a89971e781f5c33d75009b2cbf26323d2a5 commit 1e597a89971e781f5c33d75009b2cbf26323d2a5 Author: Tuckker <tuckkern+sourceware@gmail.com> Date: Fri Aug 28 13:27:16 2020 +0100 Prevent the linker from overestimating the alignment requirement of common symbols on targets with octets that are larger than one byte. PR 26543 * linker.c (bfd_generic_define_common_symbol): Force the alignment to 1 if the section has now alignment requirement.
Hi Tucker, Thanks for pointing out this problem. I have checked in a patch to make the fix that you have suggested. Cheers Nick
Nick, No problem. Thanks for the quick response! -Tucker