This is an automated email from the ASF dual-hosted git repository. m-gorecki pushed a commit to branch m-gorecki/link_alignment in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit edf186cd0cca583bd11f120cd5819e23e55372bb Author: Michal Gorecki <[email protected]> AuthorDate: Tue Sep 1 22:33:59 2026 +0200 newt/pkg: Add link tables alignment setting for bsp pkgs This adds link_tables_alignment for BSP pkgs. Now it's possible to configure link tables data alignment for each BSP. --- newt/builder/extcmd.go | 9 +++++++-- newt/pkg/bsp_package.go | 29 ++++++++++++++++------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/newt/builder/extcmd.go b/newt/builder/extcmd.go index 7fb50a84..ecc22aa6 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" @@ -184,7 +185,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 +194,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 } @@ -221,7 +226,7 @@ func (t *TargetBuilder) generateLinkTables() { } for _, linkTable := range s { - linkHeader.WriteString(getLinkTableEntry(linkTable)) + linkHeader.WriteString(getLinkTableEntry(linkTable, t.bspPkg.LinkTablesAlignment)) } } diff --git a/newt/pkg/bsp_package.go b/newt/pkg/bsp_package.go index 6807d2b1..b8d9ad30 100644 --- a/newt/pkg/bsp_package.go +++ b/newt/pkg/bsp_package.go @@ -41,19 +41,20 @@ type BspYCfgOverride struct { type BspPackage struct { *LocalPackage - yov *BspYCfgOverride - CompilerName string - CompilerNamePkg *LocalPackage /* package which defines compiler name */ - Arch string - LinkerScripts []string - Part2LinkerScripts []string /* scripts to link app to second partition */ - DownloadScript string - DebugScript string - OptChkScript string - ImageOffset int - ImagePad int - FlashMap flashmap.FlashMap - BspV ycfg.YCfg + yov *BspYCfgOverride + CompilerName string + CompilerNamePkg *LocalPackage /* package which defines compiler name */ + Arch string + LinkerScripts []string + Part2LinkerScripts []string /* scripts to link app to second partition */ + DownloadScript string + DebugScript string + OptChkScript string + ImageOffset int + ImagePad int + LinkTablesAlignment int + FlashMap flashmap.FlashMap + BspV ycfg.YCfg } func (bsp *BspPackage) BspYamlPath() string { @@ -227,6 +228,8 @@ func (bsp *BspPackage) Reload(settings *cfgv.Settings) error { bsp.OptChkScript, err = bsp.resolvePathSetting( settings, "bsp.optionalcheckscript") + bsp.LinkTablesAlignment, _ = ycfg.GetValInt("bsp.link_tables_alignment", settings) + if bsp.CompilerName == "" { return util.NewNewtError("BSP does not specify a compiler " + "(bsp.compiler)")
