public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] MSP430: Word align __*_array_start symbols in sim linker scripts
Date: Fri,  7 Aug 2020 13:16:54 +0000 (GMT)	[thread overview]
Message-ID: <20200807131654.9417C385ED4D@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=748970c8337eb286d816ac623c8ee097d4085c29

commit 748970c8337eb286d816ac623c8ee097d4085c29
Author: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date:   Fri Aug 7 11:48:27 2020 +0100

    MSP430: Word align __*_array_start symbols in sim linker scripts
    
    __{preinit,init,fini}_array_start symbols must be word aligned in
    linker scripts. If the section preceding the __*_array_start symbol
    has an odd size, then a NULL byte will be present between the start
    symbol and the .*_array section itself, when the section gets
    automatically word-aligned.
    
    This results in a branch to an invalid address when the CRT startup
    code tries to run through the functions listed in the array sections.
    
    >From de115144d05ecbaa82c9c737cc261715ca4b7d67 Mon Sep 17 00:00:00 2001
    From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
    Date: Mon, 3 Aug 2020 19:09:46 +0100
    Subject: [PATCH 1/2] MSP430: Word align __*_array_start symbols in sim linker
     scripts
    
    __{preinit,init,fini}_array_start symbols must be word aligned in
    linker scripts. If the section preceding the __*_array_start symbol
    has an odd size, then a NULL byte will be present between the start
    symbol and the .*_array section itself, when the section gets
    automatically word-aligned.
    
    This results in a branch to an invalid address when the CRT startup
    code tries to run through the functions listed in the array sections.

Diff:
---
 libgloss/msp430/msp430-sim.ld   | 4 ++++
 libgloss/msp430/msp430xl-sim.ld | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/libgloss/msp430/msp430-sim.ld b/libgloss/msp430/msp430-sim.ld
index fadd137e8..5c0e3b7a7 100644
--- a/libgloss/msp430/msp430-sim.ld
+++ b/libgloss/msp430/msp430-sim.ld
@@ -42,14 +42,18 @@ SECTIONS
     . = ALIGN(2);
     *(.rodata1)
 
+    . = ALIGN(2);
     KEEP (*(.gcc_except_table)) *(.gcc_except_table.*)
+    . = ALIGN(2);
     PROVIDE (__preinit_array_start = .);
     KEEP (*(.preinit_array))
     PROVIDE (__preinit_array_end = .);
+    . = ALIGN(2);
     PROVIDE (__init_array_start = .);
     KEEP (*(SORT(.init_array.*)))
     KEEP (*(.init_array))
     PROVIDE (__init_array_end = .);
+    . = ALIGN(2);
     PROVIDE (__fini_array_start = .);
     KEEP (*(.fini_array))
     KEEP (*(SORT(.fini_array.*)))
diff --git a/libgloss/msp430/msp430xl-sim.ld b/libgloss/msp430/msp430xl-sim.ld
index 125b7d897..5126e398a 100644
--- a/libgloss/msp430/msp430xl-sim.ld
+++ b/libgloss/msp430/msp430xl-sim.ld
@@ -68,13 +68,16 @@ SECTIONS
 
     . = ALIGN(2);
     KEEP (*(.gcc_except_table)) *(.gcc_except_table.*)
+    . = ALIGN(2);
     PROVIDE (__preinit_array_start = .);
     KEEP (*(.preinit_array))
     PROVIDE (__preinit_array_end = .);
+    . = ALIGN(2);
     PROVIDE (__init_array_start = .);
     KEEP (*(SORT(.init_array.*)))
     KEEP (*(.init_array))
     PROVIDE (__init_array_end = .);
+    . = ALIGN(2);
     PROVIDE (__fini_array_start = .);
     KEEP (*(.fini_array))
     KEEP (*(SORT(.fini_array.*)))


                 reply	other threads:[~2020-08-07 13:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200807131654.9417C385ED4D@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=newlib-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).