[PATCH 0/2][MSP430][LD] Fix alignment of __*_array_start symbols in default linker script

Jozef Lawrynowicz jozef.l@mittosystems.com
Thu Jan 16 11:48:00 GMT 2020


Some MSP430 linker scripts do not include ALIGN directives before the
definition of __{preinit,init,fini}_array_start symbols, to ensure these are
word aligned. 

If the preceding section has an odd size and the symbols are misaligned, then
when the .*_array section itself gets automatically word-aligned, there will be
a NULL byte between the symbol definition and the first address.
This then results in a branch to an invalid address when the crt0 code tries
to run through the functions in the array.

The attached patch adds align directives to the default linker script, and also
adds a warning to the MSP430 linker which alerts the user if the __*array_start
symbols are misaligned.

To support warning when the __*array_start symbols are misaligned, without
knowing the location of the symbols within the linker script, a new format
specifier "%pU" has been added to vfinfo. This prints the name of the linker
script, without trying to print the line number (the "%pS" specifier will print
both).

Successfully regtested the binutils and GCC testsuites for msp430-elf.

Ok to apply?

Thanks,
Jozef



More information about the Binutils mailing list