1 | $
|
---|
2 | $ TOPPERS ATK2
|
---|
3 | $ Toyohashi Open Platform for Embedded Real-Time Systems
|
---|
4 | $ Automotive Kernel Version 2
|
---|
5 | $
|
---|
6 | $ Copyright (C) 2014-2015 by Center for Embedded Computing Systems
|
---|
7 | $ Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
8 | $
|
---|
9 | $ 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
10 | $ ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
11 | $ 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
12 | $ (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
13 | $ 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
14 | $ スコード中に含まれていること.
|
---|
15 | $ (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
16 | $ 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
17 | $ 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
18 | $ の無保証規定を掲載すること.
|
---|
19 | $ (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
20 | $ 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
21 | $ と.
|
---|
22 | $ (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
23 | $ 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
24 | $ (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
25 | $ 報告すること.
|
---|
26 | $ (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
27 | $ 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
28 | $ また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
29 | $ 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
30 | $ 免責すること.
|
---|
31 | $
|
---|
32 | $ AUTOSAR(AUTomotive Open System ARchitecture)は,AUTOSAR仕様に基づ
|
---|
33 | $ いたソフトウェアを商用目的で利用する者に対して,AUTOSARパートナーに
|
---|
34 | $ なることを求めている.
|
---|
35 | $
|
---|
36 | $ 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
37 | $ よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
38 | $ に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
39 | $ アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
40 | $ の責任を負わない.
|
---|
41 | $
|
---|
42 | $ $Id: ldscript.tf 189 2015-06-26 01:54:57Z t_ishikawa $
|
---|
43 | $
|
---|
44 |
|
---|
45 | $ =====================================================================
|
---|
46 | $ リンカスクリプト(ldscript.py)の生成
|
---|
47 | $ =====================================================================
|
---|
48 |
|
---|
49 | $
|
---|
50 | $ 生成するファイルの指定
|
---|
51 | $
|
---|
52 | $FILE "ldscript.py"$
|
---|
53 | # This file is generated by ccrh/ldscript.tf$NL$
|
---|
54 | $NL$
|
---|
55 | import os.path$NL$
|
---|
56 | import os$NL$
|
---|
57 | import shutil$NL$
|
---|
58 | os.chdir(os.path.dirname(project.Path))$NL$
|
---|
59 | proj_rel_dir = "../"$NL$
|
---|
60 | common.Source("../def.py")$NL$
|
---|
61 | src_abs_path = os.path.abspath(SRCDIR)$NL$
|
---|
62 | # call common file$NL$
|
---|
63 | common.Source("../../../arch/ccrh/common.py")$NL$
|
---|
64 | $NL$
|
---|
65 |
|
---|
66 | $
|
---|
67 | $ 変数の初期化
|
---|
68 | $
|
---|
69 | $reset_lma = 0$
|
---|
70 |
|
---|
71 | $provide_gp = 0$
|
---|
72 | $data_flg = 0$
|
---|
73 |
|
---|
74 | $reg_initdata = REG.REGNAME[STANDARD_ROM]$
|
---|
75 | $ROMtoRAMsection = "ROMtoRAMsection"$
|
---|
76 | $AlignSection = "AlignSection"$
|
---|
77 |
|
---|
78 | # initialize variables$NL$
|
---|
79 | $FOREACH regid REG.ORDER_LIST$
|
---|
80 | $REG.REGNAME[regid]$ = []$NL$
|
---|
81 | $END$
|
---|
82 | $ROMtoRAMsection$ = []$NL$
|
---|
83 | $AlignSection$ = []$NL$
|
---|
84 | $NL$
|
---|
85 |
|
---|
86 | $
|
---|
87 | $ リンク指定の生成
|
---|
88 | $
|
---|
89 | # preprocess for OsMemorySection$NL$
|
---|
90 | $ ターゲット依存のセクション記述の生成
|
---|
91 | $IF ISFUNCTION("GENERATE_SECTION_FIRST")$
|
---|
92 | $GENERATE_SECTION_FIRST()$
|
---|
93 | $END$
|
---|
94 |
|
---|
95 | $FOREACH moid MO_ORDER$
|
---|
96 | $IF MO.LINKER[moid]$
|
---|
97 | $ // セクションの開始記述の生成
|
---|
98 | $IF (MO.SEFLAG[moid] & 0x01) != 0$
|
---|
99 | $ // セクションを配置するリージョンの取得
|
---|
100 | $reg = REG.REGNAME[MO.MEMREG[moid]]$
|
---|
101 | $IF !OMIT_IDATA && !EQ(MO.ILABEL[moid], "")$
|
---|
102 | $AlignSection$.append("$MO.SECTION[moid]$.R")$NL$
|
---|
103 | $END$
|
---|
104 | $AlignSection$.append("$MO.SECTION[moid]$")$NL$
|
---|
105 | $END$
|
---|
106 |
|
---|
107 | $ // リンクするファイル記述の生成
|
---|
108 | $section_dscr = SECTION_DESCRIPTION(MO.SECTION[moid])$
|
---|
109 | $IF MO.TYPE[moid] == TOPPERS_ATTSEC$
|
---|
110 | $IF !OMIT_IDATA && !EQ(MO.ILABEL[moid], "")$
|
---|
111 | $reg$.append("$MO.SECTION[moid]$.R")$NL$
|
---|
112 | $reg_initdata$.append("$MO.SECTION[moid]$")$NL$
|
---|
113 | $ROMtoRAMsection$.append($FORMAT("\'%1%=%1%.R\'", MO.SECTION[moid])$)$NL$
|
---|
114 | $ELSE$
|
---|
115 | $reg$.append("$MO.SECTION[moid]$")$NL$
|
---|
116 | $END$
|
---|
117 | $ELSE$
|
---|
118 | $ // ユーザスタック領域
|
---|
119 | $reg$.append("$MO.SECTION[moid]$")$NL$
|
---|
120 | $END$
|
---|
121 |
|
---|
122 | $ // アライン記述の生成
|
---|
123 | $IF (MO.SEFLAG[moid] & 0x20) != 0$
|
---|
124 | $IF !OMIT_IDATA && !EQ(MO.ILABEL[moid], "")$
|
---|
125 | $AlignSection$.append("$MO.SECTION[moid]$.R")$NL$
|
---|
126 | $END$
|
---|
127 | $AlignSection$.append("$MO.SECTION[moid]$")$NL$
|
---|
128 | $END$
|
---|
129 |
|
---|
130 | $ // メモリリージョン末でアラインさせるためのダミーセクションの生成
|
---|
131 | $IF (MO.SEFLAG[moid] & 0x80) != 0$
|
---|
132 | $IF !OMIT_IDATA && !EQ(MO.ILABEL[moid], "")$
|
---|
133 | $AlignSection$.append("$MO.SECTION[moid]$.R")$NL$
|
---|
134 | $END$
|
---|
135 | $AlignSection$.append("$MO.SECTION[moid]$")$NL$
|
---|
136 | $END$
|
---|
137 |
|
---|
138 | $preid = moid$
|
---|
139 | $END$
|
---|
140 | $END$
|
---|
141 | $NL$
|
---|
142 |
|
---|
143 | # preprocess for OsLinkSection$NL$
|
---|
144 | $FOREACH lsid RANGE(1, numls)$
|
---|
145 | $REG.REGNAME[LNKSEC.MEMREG[lsid]]$.append("$LNKSEC.SECTION[lsid]$")$NL$
|
---|
146 | $END$
|
---|
147 | $NL$
|
---|
148 |
|
---|
149 | sections = ""$NL$
|
---|
150 | $FOREACH regid REG.ORDER_LIST$
|
---|
151 | if sections != "":$NL$
|
---|
152 | $TAB$sections += ","$NL$
|
---|
153 | sections += ",".join($REG.REGNAME[regid]$)$NL$
|
---|
154 | sections += $FORMAT("\"/%x\"", +REG.BASE[regid])$$NL$
|
---|
155 | $END$
|
---|
156 |
|
---|
157 | $NL$
|
---|
158 | wd_abs_path = os.path.abspath('..')$NL$
|
---|
159 | project.Change(wd_abs_path + r'\atk2-sc3.mtpj')$NL$
|
---|
160 | project.Close(True)$NL$
|
---|
161 | inputstr = ReadFile('../atk2-sc3.mtpj')$NL$
|
---|
162 | print sections$NL$
|
---|
163 | # build.Link.SectionStartAddress = sections$NL$
|
---|
164 | inputstr = NewSetItemXml(inputstr, 'LinkOptionStart-0', sections)$NL$
|
---|
165 | inputstr = ChangeItemXml(inputstr, 'LinkOptionStart-0', sections)$NL$
|
---|
166 | print $ROMtoRAMsection$$NL$
|
---|
167 | # build.Link.SectionROMtoRAM = $ROMtoRAMsection$$NL$
|
---|
168 | inputstr = NewSetItemXml(inputstr, 'LinkOptionRom-0', "\n".join($ROMtoRAMsection$))$NL$
|
---|
169 | inputstr = ChangeItemXml(inputstr, 'LinkOptionRom-0', "\n".join($ROMtoRAMsection$))$NL$
|
---|
170 | print sorted(set($AlignSection$), key=$AlignSection$.index)$NL$
|
---|
171 | # build.Link.SectionAlignment = sorted(set($AlignSection$), key=$AlignSection$.index)$NL$
|
---|
172 | inputstr = NewSetItemXml(inputstr, 'LinkOptionAlignedSection-0',
|
---|
173 | "\n".join(sorted(set($AlignSection$), key=$AlignSection$.index)))$NL$
|
---|
174 | inputstr = ChangeItemXml(inputstr, 'LinkOptionAlignedSection-0',
|
---|
175 | "\n".join(sorted(set($AlignSection$), key=$AlignSection$.index)))$NL$
|
---|
176 | WriteFile('../atk2-sc3.mtpj', inputstr)$NL$
|
---|
177 | $NL$
|
---|
178 | inputstr = ReadFile('../cfg_pass4/cfg_pass4.mtsp')$NL$
|
---|
179 | print sections$NL$
|
---|
180 | # build.Link.SectionStartAddress = sections$NL$
|
---|
181 | inputstr = NewSetItemXml(inputstr, 'LinkOptionStart-0', sections)$NL$
|
---|
182 | inputstr = ChangeItemXml(inputstr, 'LinkOptionStart-0', sections)$NL$
|
---|
183 | print $ROMtoRAMsection$$NL$
|
---|
184 | # build.Link.SectionROMtoRAM = $ROMtoRAMsection$$NL$
|
---|
185 | inputstr = NewSetItemXml(inputstr, 'LinkOptionRom-0', "\n".join($ROMtoRAMsection$))$NL$
|
---|
186 | inputstr = ChangeItemXml(inputstr, 'LinkOptionRom-0', "\n".join($ROMtoRAMsection$))$NL$
|
---|
187 | print sorted(set($AlignSection$), key=$AlignSection$.index)$NL$
|
---|
188 | # build.Link.SectionAlignment = sorted(set($AlignSection$), key=$AlignSection$.index)$NL$
|
---|
189 | inputstr = NewSetItemXml(inputstr, 'LinkOptionAlignedSection-0',
|
---|
190 | "\n".join(sorted(set($AlignSection$), key=$AlignSection$.index)))$NL$
|
---|
191 | inputstr = ChangeItemXml(inputstr, 'LinkOptionAlignedSection-0',
|
---|
192 | "\n".join(sorted(set($AlignSection$), key=$AlignSection$.index)))$NL$
|
---|
193 | WriteFile('../cfg_pass4/cfg_pass4.mtsp', inputstr)$NL$
|
---|
194 | $NL$
|
---|
195 | wd_abs_path = os.path.abspath('..')$NL$
|
---|
196 | project.Open(wd_abs_path + r'\atk2-sc3.mtpj')$NL$
|
---|
197 | project.Change(wd_abs_path + r'\cfg\cfg.mtsp')$NL$
|
---|
198 | $NL$
|
---|
199 |
|
---|