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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Jozef Lawrynowicz-2
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
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2][LD] Add new %pU vfinfo format for printing linker script name

Jozef Lawrynowicz-2
On Thu, 16 Jan 2020 11:48:27 +0000
Jozef Lawrynowicz <[hidden email]> wrote:
>
> 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).
>


0001-LD-Add-new-pU-vfinfo-format-for-printing-linker-scri.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Jozef Lawrynowicz-2
In reply to this post by Jozef Lawrynowicz-2
The attached patch adds align directives before __*_array_start symbols in
the default linker script, and also adds a warning to the MSP430 linker which
alerts the user if the __*array_start symbols are misaligned.

0002-MSP430-Fix-alignment-of-__-_array_start-symbols-in-d.patch (13K) Download Attachment