This is an automated email from the ASF dual-hosted git repository.

m-gorecki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git


The following commit(s) were added to refs/heads/master by this push:
     new 16837896 newt/builder: Add link tables alignment setting
16837896 is described below

commit 16837896bcf6ed8a6bd977493405a5cc18d5cf99
Author: Michal Gorecki <[email protected]>
AuthorDate: Wed Sep 16 15:32:40 2026 +0200

    newt/builder: Add link tables alignment setting
    
    This adds link_tables_alignment syscfg for MCU. Now it's possible
    to configure link tables data alignment for each MCU.
---
 newt/builder/extcmd.go | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/newt/builder/extcmd.go b/newt/builder/extcmd.go
index 7fb50a84..d14144cd 100644
--- a/newt/builder/extcmd.go
+++ b/newt/builder/extcmd.go
@@ -23,6 +23,7 @@ import (
        "io/ioutil"
        "os"
        "os/exec"
+       "strconv"
 
        "github.com/kballard/go-shellquote"
        log "github.com/sirupsen/logrus"
@@ -30,6 +31,8 @@ import (
        "mynewt.apache.org/newt/util"
 )
 
+const LinkTablesAlignmentDflt = 4
+
 // replaceArtifactsIfChanged compares the artifacts just produced (temp
 // directory) to those from the previous build (user bin directory).  If they
 // are different, it replaces the old with the new so that they get relinked
@@ -184,7 +187,7 @@ func (t *TargetBuilder) execExtCmds(sf stage.StageFunc, 
userSrcDir string,
        return nil
 }
 
-func getLinkTableEntry(name string) string {
+func getLinkTableEntry(name string, alignment int) string {
        indent := "        "
 
        entry := indent + "__" + name + "_start__ = .;\n" +
@@ -193,6 +196,10 @@ func getLinkTableEntry(name string) string {
                indent + "KEEP(*(SORT(." + name + ".*)))\n" +
                indent + "__" + name + "_end__ = .;\n\n"
 
+       if alignment > 0 {
+               entry = indent + ". = ALIGN(" + strconv.Itoa(alignment) + 
");\n" + entry
+       }
+
        return entry
 }
 
@@ -220,8 +227,14 @@ func (t *TargetBuilder) generateLinkTables() {
                return
        }
 
+       settings := t.res.Cfg.SettingValues()
+       linkTablesAlignment, err := 
strconv.Atoi(settings.Get("MCU_LINK_TABLES_ALIGNMENT"))
+       if err != nil {
+               linkTablesAlignment = LinkTablesAlignmentDflt
+       }
+
        for _, linkTable := range s {
-               linkHeader.WriteString(getLinkTableEntry(linkTable))
+               linkHeader.WriteString(getLinkTableEntry(linkTable, 
linkTablesAlignment))
        }
 
 }

Reply via email to