public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2][MSP430][LD] Fix alignment of __*_array_start symbols in default linker script
@ 2020-01-16 11:48 Jozef Lawrynowicz
  2020-01-16 11:50 ` [PATCH 1/2][LD] Add new %pU vfinfo format for printing linker script name Jozef Lawrynowicz
  2020-01-16 11:53 ` [PATCH 2/2][LD][MSP430] Fix alignment of __*_array_start symbols in default linker script Jozef Lawrynowicz
  0 siblings, 2 replies; 4+ messages in thread
From: Jozef Lawrynowicz @ 2020-01-16 11:48 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH 0/2] MSP430: ld: Warn about mis-aligned symbols
@ 2020-08-07 12:12 Jozef Lawrynowicz
  2020-08-07 12:13 ` [PATCH 1/2] LD: Add new %pU vfinfo format for printing linker script name Jozef Lawrynowicz
  0 siblings, 1 reply; 4+ messages in thread
From: Jozef Lawrynowicz @ 2020-08-07 12:12 UTC (permalink / raw)
  To: binutils

The goal of this patch series is to warn the user at link time if their
are mis-aligned __*_array_start symbols in their program.

The first patch is a generic change to add a new vfinfo format, required
by the second, MSP430-specific patch.

Successfully regtested the GCC/G++/LD testsuites for msp430-elf.

Ok to apply?

Jozef Lawrynowicz (2):
  LD: Add new %pU vfinfo format for printing linker script name
  MSP430: ld: Emit warning when __*_array_start symbols are mis-aligned

 ld/emultempl/msp430.em                        | 81 ++++++++++++++++++-
 ld/ldmisc.c                                   | 10 ++-
 ld/scripttempl/elf32msp430.sc                 |  4 +
 ld/testsuite/ld-msp430-elf/finiarray-warn.ld  | 46 +++++++++++
 ld/testsuite/ld-msp430-elf/finiarray-warn.r   |  1 +
 .../ld-msp430-elf/initarray-nowarn.ld         | 45 +++++++++++
 ld/testsuite/ld-msp430-elf/initarray-nowarn.r |  0
 ld/testsuite/ld-msp430-elf/initarray-warn.ld  | 46 +++++++++++
 ld/testsuite/ld-msp430-elf/initarray-warn.r   |  1 +
 ld/testsuite/ld-msp430-elf/initarray.s        | 21 +++++
 ld/testsuite/ld-msp430-elf/msp430-elf.exp     | 13 +++
 .../ld-msp430-elf/preinitarray-warn.ld        | 46 +++++++++++
 .../ld-msp430-elf/preinitarray-warn.r         |  1 +
 13 files changed, 311 insertions(+), 4 deletions(-)
 create mode 100644 ld/testsuite/ld-msp430-elf/finiarray-warn.ld
 create mode 100644 ld/testsuite/ld-msp430-elf/finiarray-warn.r
 create mode 100644 ld/testsuite/ld-msp430-elf/initarray-nowarn.ld
 create mode 100644 ld/testsuite/ld-msp430-elf/initarray-nowarn.r
 create mode 100644 ld/testsuite/ld-msp430-elf/initarray-warn.ld
 create mode 100644 ld/testsuite/ld-msp430-elf/initarray-warn.r
 create mode 100644 ld/testsuite/ld-msp430-elf/initarray.s
 create mode 100644 ld/testsuite/ld-msp430-elf/preinitarray-warn.ld
 create mode 100644 ld/testsuite/ld-msp430-elf/preinitarray-warn.r

-- 
2.27.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-07 12:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 11:48 [PATCH 0/2][MSP430][LD] Fix alignment of __*_array_start symbols in default linker script Jozef Lawrynowicz
2020-01-16 11:50 ` [PATCH 1/2][LD] Add new %pU vfinfo format for printing linker script name Jozef Lawrynowicz
2020-01-16 11:53 ` [PATCH 2/2][LD][MSP430] Fix alignment of __*_array_start symbols in default linker script Jozef Lawrynowicz
2020-08-07 12:12 [PATCH 0/2] MSP430: ld: Warn about mis-aligned symbols Jozef Lawrynowicz
2020-08-07 12:13 ` [PATCH 1/2] LD: Add new %pU vfinfo format for printing linker script name Jozef Lawrynowicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).