blob: 5ce2d195fefa931a27e38cc638e0d599426d5f12 [file] [log] [blame]
Adithya Baglodyff631012018-11-26 21:52:42 +05301#!/usr/bin/env python3
2#
3# Copyright (c) 2018 Intel Corporation.
4#
5# SPDX-License-Identifier: Apache-2.0
6#
7
David B. Kinder17299f02019-05-31 15:39:39 -07008"""
9This script will relocate .text, .rodata, .data and .bss sections from required files
10and places it in the required memory region. This memory region and file
11are given to this python script in the form of a string.
12
13Example of such a string would be::
14
15 SRAM2:/home/xyz/zephyr/samples/hello_world/src/main.c,\
16 SRAM1:/home/xyz/zephyr/samples/hello_world/src/main2.c
17
18To invoke this script::
19
20 python3 gen_relocate_app.py -i input_string -o generated_linker -c generated_code
21
22Configuration that needs to be sent to the python script.
23
24- If the memory is like SRAM1/SRAM2/CCD/AON then place full object in
25 the sections
26- If the memory type is appended with _DATA / _TEXT/ _RODATA/ _BSS only the
27 selected memory is placed in the required memory region. Others are
28 ignored.
29
30Multiple regions can be appended together like SRAM2_DATA_BSS
31this will place data and bss inside SRAM2.
32"""
33
Adithya Baglodyff631012018-11-26 21:52:42 +053034
35import sys
36import argparse
37import os
38import glob
39import warnings
40from elftools.elf.elffile import ELFFile
41
42# This script will create linker comands for text,rodata data, bss section relocation
43
44PRINT_TEMPLATE = """
45 KEEP(*({0}))
46"""
47
48SECTION_LOAD_MEMORY_SEQ = """
49 __{0}_{1}_rom_start = LOADADDR(_{2}_{3}_SECTION_NAME);
50"""
51
Wentong Wuc8f43b92019-05-14 01:04:06 +080052LOAD_ADDRESS_LOCATION_FLASH = """
53#ifdef CONFIG_XIP
54GROUP_DATA_LINK_IN({0}, FLASH)
55#else
56GROUP_DATA_LINK_IN({0}, {0})
57#endif
58"""
Adithya Baglodyff631012018-11-26 21:52:42 +053059LOAD_ADDRESS_LOCATION_BSS = "GROUP_LINK_IN({0})"
60
Wentong Wu743a1842019-05-14 00:30:52 +080061MPU_RO_REGION_START = """
62
Jordan Yatesc6cc9272021-04-16 20:38:44 +100063 _{0}_mpu_ro_region_start = ORIGIN({1});
Wentong Wu743a1842019-05-14 00:30:52 +080064
65"""
66
67MPU_RO_REGION_END = """
68
Wentong Wu743a1842019-05-14 00:30:52 +080069 _{0}_mpu_ro_region_end = .;
70
71"""
72
Adithya Baglodyff631012018-11-26 21:52:42 +053073# generic section creation format
74LINKER_SECTION_SEQ = """
75
76/* Linker section for memory region {2} for {3} section */
77
Kumar Gala4da0f8b2019-03-14 18:39:36 -050078 SECTION_PROLOGUE(_{2}_{3}_SECTION_NAME,,)
Adithya Baglodyff631012018-11-26 21:52:42 +053079 {{
80 . = ALIGN(4);
81 {4}
82 . = ALIGN(4);
83 }} {5}
84 __{0}_{1}_end = .;
85 __{0}_{1}_start = ADDR(_{2}_{3}_SECTION_NAME);
86 __{0}_{1}_size = SIZEOF(_{2}_{3}_SECTION_NAME);
87"""
88
Wentong Wufa7ce3f2019-07-02 01:18:40 +080089LINKER_SECTION_SEQ_MPU = """
90
91/* Linker section for memory region {2} for {3} section */
92
93 SECTION_PROLOGUE(_{2}_{3}_SECTION_NAME,,)
94 {{
95 __{0}_{1}_start = .;
96 {4}
Wentong Wu09af98a2019-09-19 21:40:29 +080097#if {6}
98 . = ALIGN({6});
99#else
Wentong Wufa7ce3f2019-07-02 01:18:40 +0800100 MPU_ALIGN(__{0}_{1}_size);
Wentong Wu09af98a2019-09-19 21:40:29 +0800101#endif
Wentong Wufa7ce3f2019-07-02 01:18:40 +0800102 __{0}_{1}_end = .;
103 }} {5}
104 __{0}_{1}_size = __{0}_{1}_end - __{0}_{1}_start;
105"""
106
Adithya Baglodyff631012018-11-26 21:52:42 +0530107SOURCE_CODE_INCLUDES = """
108/* Auto generated code. Do not modify.*/
109#include <zephyr.h>
110#include <linker/linker-defs.h>
111#include <kernel_structs.h>
Stephanos Ioannidis2d746042019-10-25 00:08:21 +0900112#include <string.h>
Adithya Baglodyff631012018-11-26 21:52:42 +0530113"""
114
115EXTERN_LINKER_VAR_DECLARATION = """
116extern char __{0}_{1}_start[];
117extern char __{0}_{1}_rom_start[];
Adithya Baglody65f79cd2018-12-17 14:21:34 +0530118extern char __{0}_{1}_size[];
Adithya Baglodyff631012018-11-26 21:52:42 +0530119"""
120
121
122DATA_COPY_FUNCTION = """
123void data_copy_xip_relocation(void)
124{{
125{0}
126}}
127"""
128
129BSS_ZEROING_FUNCTION = """
130void bss_zeroing_relocation(void)
131{{
132{0}
133}}
134"""
135
136MEMCPY_TEMPLATE = """
137 (void)memcpy(&__{0}_{1}_start, &__{0}_{1}_rom_start,
Kumar Galaa1b77fd2020-05-27 11:26:57 -0500138 (uint32_t) &__{0}_{1}_size);
Adithya Baglody65f79cd2018-12-17 14:21:34 +0530139
Adithya Baglodyff631012018-11-26 21:52:42 +0530140"""
141
142MEMSET_TEMPLATE = """
143 (void)memset(&__{0}_bss_start, 0,
Kumar Galaa1b77fd2020-05-27 11:26:57 -0500144 (uint32_t) &__{0}_bss_size);
Adithya Baglodyff631012018-11-26 21:52:42 +0530145"""
146
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000147
Adithya Baglodyff631012018-11-26 21:52:42 +0530148def find_sections(filename, full_list_of_sections):
149 with open(filename, 'rb') as obj_file_desc:
150 full_lib = ELFFile(obj_file_desc)
151 if not full_lib:
Ulf Magnusson50b9b122019-09-07 14:41:01 +0200152 sys.exit("Error parsing file: " + filename)
Adithya Baglodyff631012018-11-26 21:52:42 +0530153
154 sections = [x for x in full_lib.iter_sections()]
155
Adithya Baglodyff631012018-11-26 21:52:42 +0530156 for section in sections:
157
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000158 if ".text." in section.name:
Adithya Baglodyff631012018-11-26 21:52:42 +0530159 full_list_of_sections["text"].append(section.name)
160
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000161 if ".rodata." in section.name:
Adithya Baglodyff631012018-11-26 21:52:42 +0530162 full_list_of_sections["rodata"].append(section.name)
163
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000164 if ".data." in section.name:
Adithya Baglodyff631012018-11-26 21:52:42 +0530165 full_list_of_sections["data"].append(section.name)
166
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000167 if ".bss." in section.name:
Adithya Baglodyff631012018-11-26 21:52:42 +0530168 full_list_of_sections["bss"].append(section.name)
169
170 # Common variables will be placed in the .bss section
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000171 # only after linking in the final executable. This "if" finds
Adithya Baglodyff631012018-11-26 21:52:42 +0530172 # common symbols and warns the user of the problem.
173 # The solution to which is simply assigning a 0 to
174 # bss variable and it will go to the required place.
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000175 if ".symtab" in section.name:
Adithya Baglodyff631012018-11-26 21:52:42 +0530176 symbols = [x for x in section.iter_symbols()]
177 for symbol in symbols:
178 if symbol.entry["st_shndx"] == 'SHN_COMMON':
179 warnings.warn("Common variable found. Move "+
180 symbol.name + " to bss by assigning it to 0/NULL")
181
182 return full_list_of_sections
183
184
185def assign_to_correct_mem_region(memory_type,
186 full_list_of_sections, complete_list_of_sections):
187 all_regions = False
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000188 iteration_sections = {"text": False, "rodata": False, "data": False, "bss": False}
Adithya Baglodyff631012018-11-26 21:52:42 +0530189 if "_TEXT" in memory_type:
190 iteration_sections["text"] = True
191 memory_type = memory_type.replace("_TEXT", "")
192 if "_RODATA" in memory_type:
193 iteration_sections["rodata"] = True
194 memory_type = memory_type.replace("_RODATA", "")
195 if "_DATA" in memory_type:
196 iteration_sections["data"] = True
197 memory_type = memory_type.replace("_DATA", "")
198 if "_BSS" in memory_type:
199 iteration_sections["bss"] = True
200 memory_type = memory_type.replace("_BSS", "")
201 if not (iteration_sections["data"] or iteration_sections["bss"] or
202 iteration_sections["text"] or iteration_sections["rodata"]):
203 all_regions = True
204
Wentong Wu09af98a2019-09-19 21:40:29 +0800205 pos = memory_type.find('_')
206 if pos in range(len(memory_type)):
207 align_size = int(memory_type[pos+1:])
208 memory_type = memory_type[:pos]
209 mpu_align[memory_type] = align_size
210
Adithya Baglodyff631012018-11-26 21:52:42 +0530211 if memory_type in complete_list_of_sections:
212 for iter_sec in ["text", "rodata", "data", "bss"]:
213 if ((iteration_sections[iter_sec] or all_regions) and
214 full_list_of_sections[iter_sec] != []):
215 complete_list_of_sections[memory_type][iter_sec] += (
216 full_list_of_sections[iter_sec])
217 else:
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000218 # new memory type was found. in which case just assign the
Adithya Baglodyff631012018-11-26 21:52:42 +0530219 # full_list_of_sections to the memorytype dict
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000220 tmp_list = {"text": [], "rodata": [], "data": [], "bss": []}
Adithya Baglodyff631012018-11-26 21:52:42 +0530221 for iter_sec in ["text", "rodata", "data", "bss"]:
222 if ((iteration_sections[iter_sec] or all_regions) and
223 full_list_of_sections[iter_sec] != []):
224 tmp_list[iter_sec] = full_list_of_sections[iter_sec]
225
226 complete_list_of_sections[memory_type] = tmp_list
227
228 return complete_list_of_sections
229
230
231def print_linker_sections(list_sections):
232 print_string = ''
Marc Herbert6ccd0262019-06-24 12:20:18 -0700233 for section in sorted(list_sections):
Adithya Baglodyff631012018-11-26 21:52:42 +0530234 print_string += PRINT_TEMPLATE.format(section)
235 return print_string
236
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000237
Adithya Baglodyff631012018-11-26 21:52:42 +0530238def string_create_helper(region, memory_type,
239 full_list_of_sections, load_address_in_flash):
240 linker_string = ''
241 if load_address_in_flash:
242 load_address_string = LOAD_ADDRESS_LOCATION_FLASH.format(memory_type)
243 else:
244 load_address_string = LOAD_ADDRESS_LOCATION_BSS.format(memory_type)
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000245 if full_list_of_sections[region]:
Adithya Baglodyff631012018-11-26 21:52:42 +0530246 # Create a complete list of funcs/ variables that goes in for this
247 # memory type
248 tmp = print_linker_sections(full_list_of_sections[region])
Ulf Magnusson11d98ae2019-09-03 14:29:31 +0200249 if memory_type == 'SRAM' and region in {'data', 'bss'}:
Wentong Wu743a1842019-05-14 00:30:52 +0800250 linker_string += tmp
251 else:
Wentong Wufa7ce3f2019-07-02 01:18:40 +0800252 if memory_type != 'SRAM' and region == 'rodata':
Wentong Wu09af98a2019-09-19 21:40:29 +0800253 align_size = 0
Bartosz Bilas50ec0462021-10-29 20:09:54 +0200254 if memory_type in mpu_align:
Wentong Wu09af98a2019-09-19 21:40:29 +0800255 align_size = mpu_align[memory_type]
256
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000257 linker_string += LINKER_SECTION_SEQ_MPU.format(memory_type.lower(), region, memory_type.upper(),
Wentong Wu09af98a2019-09-19 21:40:29 +0800258 region.upper(), tmp, load_address_string, align_size)
Wentong Wufa7ce3f2019-07-02 01:18:40 +0800259 else:
Mahesh Mahadevan3035b3a2021-04-06 14:27:25 -0500260 if memory_type == 'SRAM' and region == 'text':
261 align_size = 0
262 linker_string += LINKER_SECTION_SEQ_MPU.format(memory_type.lower(), region, memory_type.upper(),
263 region.upper(), tmp, load_address_string, align_size)
264 else:
265 linker_string += LINKER_SECTION_SEQ.format(memory_type.lower(), region, memory_type.upper(),
266 region.upper(), tmp, load_address_string)
Wentong Wu743a1842019-05-14 00:30:52 +0800267 if load_address_in_flash:
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000268 linker_string += SECTION_LOAD_MEMORY_SEQ.format(memory_type.lower(), region, memory_type.upper(),
269 region.upper())
Adithya Baglodyff631012018-11-26 21:52:42 +0530270 return linker_string
271
272
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000273def generate_linker_script(linker_file, sram_data_linker_file, sram_bss_linker_file, complete_list_of_sections):
Adithya Baglodyff631012018-11-26 21:52:42 +0530274 gen_string = ''
Wentong Wu743a1842019-05-14 00:30:52 +0800275 gen_string_sram_data = ''
276 gen_string_sram_bss = ''
Marc Herbert6ccd0262019-06-24 12:20:18 -0700277
278 for memory_type, full_list_of_sections in \
279 sorted(complete_list_of_sections.items()):
Wentong Wu743a1842019-05-14 00:30:52 +0800280
281 if memory_type != "SRAM":
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000282 gen_string += MPU_RO_REGION_START.format(memory_type.lower(), memory_type.upper())
283 gen_string += string_create_helper("text", memory_type, full_list_of_sections, 1)
284 gen_string += string_create_helper("rodata", memory_type, full_list_of_sections, 1)
Wentong Wu743a1842019-05-14 00:30:52 +0800285 if memory_type != "SRAM":
286 gen_string += MPU_RO_REGION_END.format(memory_type.lower())
287
288 if memory_type == 'SRAM':
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000289 gen_string_sram_data += string_create_helper("data", memory_type, full_list_of_sections, 1)
290 gen_string_sram_bss += string_create_helper("bss", memory_type, full_list_of_sections, 0)
Wentong Wu743a1842019-05-14 00:30:52 +0800291 else:
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000292 gen_string += string_create_helper("data", memory_type, full_list_of_sections, 1)
293 gen_string += string_create_helper("bss", memory_type, full_list_of_sections, 0)
Adithya Baglodyff631012018-11-26 21:52:42 +0530294
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000295 # finally writing to the linker file
Adithya Baglodyff631012018-11-26 21:52:42 +0530296 with open(linker_file, "a+") as file_desc:
297 file_desc.write(gen_string)
298
Wentong Wu743a1842019-05-14 00:30:52 +0800299 with open(sram_data_linker_file, "a+") as file_desc:
300 file_desc.write(gen_string_sram_data)
301
302 with open(sram_bss_linker_file, "a+") as file_desc:
303 file_desc.write(gen_string_sram_bss)
304
Adithya Baglodyff631012018-11-26 21:52:42 +0530305
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000306def generate_memcpy_code(memory_type, full_list_of_sections, code_generation):
Adithya Baglodyff631012018-11-26 21:52:42 +0530307 all_sections = True
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000308 generate_section = {"text": False, "rodata": False, "data": False, "bss": False}
Adithya Baglodyff631012018-11-26 21:52:42 +0530309 for section_name in ["_TEXT", "_RODATA", "_DATA", "_BSS"]:
310 if section_name in memory_type:
311 generate_section[section_name.lower()[1:]] = True
312 memory_type = memory_type.replace(section_name, "")
313 all_sections = False
314
315 if all_sections:
316 generate_section["text"] = True
317 generate_section["rodata"] = True
318 generate_section["data"] = True
319 generate_section["bss"] = True
320
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000321 # add all the regions that needs to be copied on boot up
Adithya Baglodyff631012018-11-26 21:52:42 +0530322 for mtype in ["text", "rodata", "data"]:
Wentong Wu743a1842019-05-14 00:30:52 +0800323 if memory_type == "SRAM" and mtype == "data":
324 continue
325
Adithya Baglodyff631012018-11-26 21:52:42 +0530326 if full_list_of_sections[mtype] and generate_section[mtype]:
327 code_generation["copy_code"] += MEMCPY_TEMPLATE.format(memory_type.lower(), mtype)
328 code_generation["extern"] += EXTERN_LINKER_VAR_DECLARATION.format(
329 memory_type.lower(), mtype)
330
331 # add for all the bss data that needs to be zeored on boot up
Wentong Wu743a1842019-05-14 00:30:52 +0800332 if full_list_of_sections["bss"] and generate_section["bss"] and memory_type != "SRAM":
Adithya Baglodyff631012018-11-26 21:52:42 +0530333 code_generation["zero_code"] += MEMSET_TEMPLATE.format(memory_type.lower())
334 code_generation["extern"] += EXTERN_LINKER_VAR_DECLARATION.format(
335 memory_type.lower(), "bss")
336
337 return code_generation
338
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000339
Adithya Baglodyff631012018-11-26 21:52:42 +0530340def dump_header_file(header_file, code_generation):
341 code_string = ''
342 # create a dummy void function if there is no code to generate for
343 # bss/data/text regions
344
345 code_string += code_generation["extern"]
346
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000347 if code_generation["copy_code"]:
Adithya Baglodyff631012018-11-26 21:52:42 +0530348 code_string += DATA_COPY_FUNCTION.format(code_generation["copy_code"])
349 else:
350 code_string += DATA_COPY_FUNCTION.format("void;")
351 if code_generation["zero_code"]:
352 code_string += BSS_ZEROING_FUNCTION.format(code_generation["zero_code"])
353 else:
354 code_string += BSS_ZEROING_FUNCTION.format("return;")
355
Adithya Baglodyff631012018-11-26 21:52:42 +0530356 with open(header_file, "w") as header_file_desc:
357 header_file_desc.write(SOURCE_CODE_INCLUDES)
358 header_file_desc.write(code_string)
359
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000360
Adithya Baglodyff631012018-11-26 21:52:42 +0530361def parse_args():
362 global args
363 parser = argparse.ArgumentParser(
364 description=__doc__,
365 formatter_class=argparse.RawDescriptionHelpFormatter)
366 parser.add_argument("-d", "--directory", required=True,
367 help="obj file's directory")
368 parser.add_argument("-i", "--input_rel_dict", required=True,
369 help="input src:memory type(sram2 or ccm or aon etc) string")
370 parser.add_argument("-o", "--output", required=False, help="Output ld file")
Wentong Wu743a1842019-05-14 00:30:52 +0800371 parser.add_argument("-s", "--output_sram_data", required=False,
372 help="Output sram data ld file")
373 parser.add_argument("-b", "--output_sram_bss", required=False,
374 help="Output sram bss ld file")
Adithya Baglodyff631012018-11-26 21:52:42 +0530375 parser.add_argument("-c", "--output_code", required=False,
376 help="Output relocation code header file")
377 parser.add_argument("-v", "--verbose", action="count", default=0,
378 help="Verbose Output")
379 args = parser.parse_args()
380
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000381
382# return the absolute path for the object file.
Adithya Baglodyff631012018-11-26 21:52:42 +0530383def get_obj_filename(searchpath, filename):
384 # get the object file name which is almost always pended with .obj
385 obj_filename = filename.split("/")[-1] + ".obj"
386
Ulf Magnusson12ba9df2019-03-19 19:28:24 +0100387 for dirpath, _, files in os.walk(searchpath):
Adithya Baglodyff631012018-11-26 21:52:42 +0530388 for filename1 in files:
389 if filename1 == obj_filename:
390 if filename.split("/")[-2] in dirpath.split("/")[-1]:
391 fullname = os.path.join(dirpath, filename1)
392 return fullname
393
394
395# Create a dict with key as memory type and files as a list of values.
396def create_dict_wrt_mem():
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000397 # need to support wild card *
Adithya Baglodyff631012018-11-26 21:52:42 +0530398 rel_dict = dict()
399 if args.input_rel_dict == '':
Ulf Magnusson50b9b122019-09-07 14:41:01 +0200400 sys.exit("Disable CONFIG_CODE_DATA_RELOCATION if no file needs relocation")
Adithya Baglodyff631012018-11-26 21:52:42 +0530401 for line in args.input_rel_dict.split(';'):
Bartosz Bilasd85465f2021-10-29 14:04:42 +0200402 if ':' not in line:
403 continue
404
Torsten Rasmussen1bd0b292020-12-08 14:52:10 +0100405 mem_region, file_name = line.split(':', 1)
Adithya Baglodyff631012018-11-26 21:52:42 +0530406
407 file_name_list = glob.glob(file_name)
408 if not file_name_list:
409 warnings.warn("File: "+file_name+" Not found")
410 continue
411 if mem_region == '':
412 continue
413 if args.verbose:
414 print("Memory region ", mem_region, " Selected for file:", file_name_list)
415 if mem_region in rel_dict:
416 rel_dict[mem_region].extend(file_name_list)
417 else:
418 rel_dict[mem_region] = file_name_list
419
420 return rel_dict
421
422
423def main():
Wentong Wu09af98a2019-09-19 21:40:29 +0800424 global mpu_align
425 mpu_align = {}
Adithya Baglodyff631012018-11-26 21:52:42 +0530426 parse_args()
427 searchpath = args.directory
428 linker_file = args.output
Wentong Wu743a1842019-05-14 00:30:52 +0800429 sram_data_linker_file = args.output_sram_data
430 sram_bss_linker_file = args.output_sram_bss
Adithya Baglodyff631012018-11-26 21:52:42 +0530431 rel_dict = create_dict_wrt_mem()
432 complete_list_of_sections = {}
433
434 # Create/or trucate file contents if it already exists
435 # raw = open(linker_file, "w")
436
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000437 # for each memory_type, create text/rodata/data/bss sections for all obj files
438 for memory_type, files in rel_dict.items():
439 full_list_of_sections = {"text": [], "rodata": [], "data": [], "bss": []}
Adithya Baglodyff631012018-11-26 21:52:42 +0530440
441 for filename in files:
442 obj_filename = get_obj_filename(searchpath, filename)
443 # the obj file wasn't found. Probably not compiled.
444 if not obj_filename:
445 continue
446
447 full_list_of_sections = find_sections(obj_filename, full_list_of_sections)
448
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000449 # cleanup and attach the sections to the memory type after cleanup.
Adithya Baglodyff631012018-11-26 21:52:42 +0530450 complete_list_of_sections = assign_to_correct_mem_region(memory_type,
451 full_list_of_sections,
452 complete_list_of_sections)
453
Wentong Wu743a1842019-05-14 00:30:52 +0800454 generate_linker_script(linker_file, sram_data_linker_file,
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000455 sram_bss_linker_file, complete_list_of_sections)
Marc Herbert6ccd0262019-06-24 12:20:18 -0700456
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000457 code_generation = {"copy_code": '', "zero_code": '', "extern": ''}
458 for mem_type, list_of_sections in sorted(complete_list_of_sections.items()):
Adithya Baglodyff631012018-11-26 21:52:42 +0530459 code_generation = generate_memcpy_code(mem_type,
460 list_of_sections, code_generation)
461
462 dump_header_file(args.output_code, code_generation)
463
Håkon Øye Amundsen4e135012019-08-15 08:36:15 +0000464
Adithya Baglodyff631012018-11-26 21:52:42 +0530465if __name__ == '__main__':
466 main()