$ $ TOPPERS ATK2 $ Toyohashi Open Platform for Embedded Real-Time Systems $ Automotive Kernel Version 2 $ $ Copyright (C) 2014-2015 by Center for Embedded Computing Systems $ Graduate School of Information Science, Nagoya Univ., JAPAN $ $ 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ $ ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 $ 変・再配布(以下,利用と呼ぶ)することを無償で許諾する. $ (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作 $ 権表示,この利用条件および下記の無保証規定が,そのままの形でソー $ スコード中に含まれていること. $ (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使 $ 用できる形で再配布する場合には,再配布に伴うドキュメント(利用 $ 者マニュアルなど)に,上記の著作権表示,この利用条件および下記 $ の無保証規定を掲載すること. $ (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使 $ 用できない形で再配布する場合には,次のいずれかの条件を満たすこ $ と. $ (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著 $ 作権表示,この利用条件および下記の無保証規定を掲載すること. $ (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに $ 報告すること. $ (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損 $ 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること. $ また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理 $ 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを $ 免責すること. $ $ AUTOSAR(AUTomotive Open System ARchitecture)は,AUTOSAR仕様に基づ $ いたソフトウェアを商用目的で利用する者に対して,AUTOSARパートナーに $ なることを求めている. $ $ 本ソフトウェアは,無保証で提供されているものである.上記著作権者お $ よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 $ に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ $ アの利用により直接的または間接的に生じたいかなる損害に関しても,そ $ の責任を負わない. $ $ $Id: ldscript.tf 189 2015-06-26 01:54:57Z t_ishikawa $ $ $ ===================================================================== $ リンカスクリプト(ldscript.py)の生成 $ ===================================================================== $ $ 生成するファイルの指定 $ $FILE "ldscript.py"$ # This file is generated by ccrh/ldscript.tf$NL$ $NL$ import os.path$NL$ import os$NL$ import shutil$NL$ os.chdir(os.path.dirname(project.Path))$NL$ proj_rel_dir = "../"$NL$ common.Source("../def.py")$NL$ src_abs_path = os.path.abspath(SRCDIR)$NL$ # call common file$NL$ common.Source("../../../arch/ccrh/common.py")$NL$ $NL$ $ $ 変数の初期化 $ $reset_lma = 0$ $provide_gp = 0$ $data_flg = 0$ $reg_initdata = REG.REGNAME[STANDARD_ROM]$ $ROMtoRAMsection = "ROMtoRAMsection"$ $AlignSection = "AlignSection"$ # initialize variables$NL$ $FOREACH regid REG.ORDER_LIST$ $REG.REGNAME[regid]$ = []$NL$ $END$ $ROMtoRAMsection$ = []$NL$ $AlignSection$ = []$NL$ $NL$ $ $ リンク指定の生成 $ # preprocess for OsMemorySection$NL$ $ ターゲット依存のセクション記述の生成 $IF ISFUNCTION("GENERATE_SECTION_FIRST")$ $GENERATE_SECTION_FIRST()$ $END$ $FOREACH moid MO_ORDER$ $IF MO.LINKER[moid]$ $ // セクションの開始記述の生成 $IF (MO.SEFLAG[moid] & 0x01) != 0$ $ // セクションを配置するリージョンの取得 $reg = REG.REGNAME[MO.MEMREG[moid]]$ $IF !OMIT_IDATA && !EQ(MO.ILABEL[moid], "")$ $AlignSection$.append("$MO.SECTION[moid]$.R")$NL$ $END$ $AlignSection$.append("$MO.SECTION[moid]$")$NL$ $END$ $ // リンクするファイル記述の生成 $section_dscr = SECTION_DESCRIPTION(MO.SECTION[moid])$ $IF MO.TYPE[moid] == TOPPERS_ATTSEC$ $IF !OMIT_IDATA && !EQ(MO.ILABEL[moid], "")$ $reg$.append("$MO.SECTION[moid]$.R")$NL$ $reg_initdata$.append("$MO.SECTION[moid]$")$NL$ $ROMtoRAMsection$.append($FORMAT("\'%1%=%1%.R\'", MO.SECTION[moid])$)$NL$ $ELSE$ $reg$.append("$MO.SECTION[moid]$")$NL$ $END$ $ELSE$ $ // ユーザスタック領域 $reg$.append("$MO.SECTION[moid]$")$NL$ $END$ $ // アライン記述の生成 $IF (MO.SEFLAG[moid] & 0x20) != 0$ $IF !OMIT_IDATA && !EQ(MO.ILABEL[moid], "")$ $AlignSection$.append("$MO.SECTION[moid]$.R")$NL$ $END$ $AlignSection$.append("$MO.SECTION[moid]$")$NL$ $END$ $ // メモリリージョン末でアラインさせるためのダミーセクションの生成 $IF (MO.SEFLAG[moid] & 0x80) != 0$ $IF !OMIT_IDATA && !EQ(MO.ILABEL[moid], "")$ $AlignSection$.append("$MO.SECTION[moid]$.R")$NL$ $END$ $AlignSection$.append("$MO.SECTION[moid]$")$NL$ $END$ $preid = moid$ $END$ $END$ $NL$ # preprocess for OsLinkSection$NL$ $FOREACH lsid RANGE(1, numls)$ $REG.REGNAME[LNKSEC.MEMREG[lsid]]$.append("$LNKSEC.SECTION[lsid]$")$NL$ $END$ $NL$ sections = ""$NL$ $FOREACH regid REG.ORDER_LIST$ if sections != "":$NL$ $TAB$sections += ","$NL$ sections += ",".join($REG.REGNAME[regid]$)$NL$ sections += $FORMAT("\"/%x\"", +REG.BASE[regid])$$NL$ $END$ $NL$ wd_abs_path = os.path.abspath('..')$NL$ project.Change(wd_abs_path + r'\atk2-sc3.mtpj')$NL$ project.Close(True)$NL$ inputstr = ReadFile('../atk2-sc3.mtpj')$NL$ print sections$NL$ # build.Link.SectionStartAddress = sections$NL$ inputstr = NewSetItemXml(inputstr, 'LinkOptionStart-0', sections)$NL$ inputstr = ChangeItemXml(inputstr, 'LinkOptionStart-0', sections)$NL$ print $ROMtoRAMsection$$NL$ # build.Link.SectionROMtoRAM = $ROMtoRAMsection$$NL$ inputstr = NewSetItemXml(inputstr, 'LinkOptionRom-0', "\n".join($ROMtoRAMsection$))$NL$ inputstr = ChangeItemXml(inputstr, 'LinkOptionRom-0', "\n".join($ROMtoRAMsection$))$NL$ print sorted(set($AlignSection$), key=$AlignSection$.index)$NL$ # build.Link.SectionAlignment = sorted(set($AlignSection$), key=$AlignSection$.index)$NL$ inputstr = NewSetItemXml(inputstr, 'LinkOptionAlignedSection-0', "\n".join(sorted(set($AlignSection$), key=$AlignSection$.index)))$NL$ inputstr = ChangeItemXml(inputstr, 'LinkOptionAlignedSection-0', "\n".join(sorted(set($AlignSection$), key=$AlignSection$.index)))$NL$ WriteFile('../atk2-sc3.mtpj', inputstr)$NL$ $NL$ inputstr = ReadFile('../cfg_pass4/cfg_pass4.mtsp')$NL$ print sections$NL$ # build.Link.SectionStartAddress = sections$NL$ inputstr = NewSetItemXml(inputstr, 'LinkOptionStart-0', sections)$NL$ inputstr = ChangeItemXml(inputstr, 'LinkOptionStart-0', sections)$NL$ print $ROMtoRAMsection$$NL$ # build.Link.SectionROMtoRAM = $ROMtoRAMsection$$NL$ inputstr = NewSetItemXml(inputstr, 'LinkOptionRom-0', "\n".join($ROMtoRAMsection$))$NL$ inputstr = ChangeItemXml(inputstr, 'LinkOptionRom-0', "\n".join($ROMtoRAMsection$))$NL$ print sorted(set($AlignSection$), key=$AlignSection$.index)$NL$ # build.Link.SectionAlignment = sorted(set($AlignSection$), key=$AlignSection$.index)$NL$ inputstr = NewSetItemXml(inputstr, 'LinkOptionAlignedSection-0', "\n".join(sorted(set($AlignSection$), key=$AlignSection$.index)))$NL$ inputstr = ChangeItemXml(inputstr, 'LinkOptionAlignedSection-0', "\n".join(sorted(set($AlignSection$), key=$AlignSection$.index)))$NL$ WriteFile('../cfg_pass4/cfg_pass4.mtsp', inputstr)$NL$ $NL$ wd_abs_path = os.path.abspath('..')$NL$ project.Open(wd_abs_path + r'\atk2-sc3.mtpj')$NL$ project.Change(wd_abs_path + r'\cfg\cfg.mtsp')$NL$ $NL$