scripts: gen_relocate_app.py: add custom align size for relocation
add custom align size for code relocation to reduce alignment memory wasting. Fixes: #17337. Signed-off-by: Wentong Wu <wentong.wu@intel.com>
This commit is contained in:
parent
da31c81737
commit
09af98aba9
1 changed files with 17 additions and 1 deletions
|
@ -84,7 +84,11 @@ LINKER_SECTION_SEQ_MPU = """
|
|||
{{
|
||||
__{0}_{1}_start = .;
|
||||
{4}
|
||||
#if {6}
|
||||
. = ALIGN({6});
|
||||
#else
|
||||
MPU_ALIGN(__{0}_{1}_size);
|
||||
#endif
|
||||
__{0}_{1}_end = .;
|
||||
}} {5}
|
||||
__{0}_{1}_size = __{0}_{1}_end - __{0}_{1}_start;
|
||||
|
@ -187,6 +191,12 @@ def assign_to_correct_mem_region(memory_type,
|
|||
iteration_sections["text"] or iteration_sections["rodata"]):
|
||||
all_regions = True
|
||||
|
||||
pos = memory_type.find('_')
|
||||
if pos in range(len(memory_type)):
|
||||
align_size = int(memory_type[pos+1:])
|
||||
memory_type = memory_type[:pos]
|
||||
mpu_align[memory_type] = align_size
|
||||
|
||||
if memory_type in complete_list_of_sections:
|
||||
for iter_sec in ["text", "rodata", "data", "bss"]:
|
||||
if ((iteration_sections[iter_sec] or all_regions) and
|
||||
|
@ -229,8 +239,12 @@ def string_create_helper(region, memory_type,
|
|||
linker_string += tmp
|
||||
else:
|
||||
if memory_type != 'SRAM' and region == 'rodata':
|
||||
align_size = 0
|
||||
if memory_type in mpu_align.keys():
|
||||
align_size = mpu_align[memory_type]
|
||||
|
||||
linker_string += LINKER_SECTION_SEQ_MPU.format(memory_type.lower(), region, memory_type.upper(),
|
||||
region.upper(), tmp, load_address_string)
|
||||
region.upper(), tmp, load_address_string, align_size)
|
||||
else:
|
||||
linker_string += LINKER_SECTION_SEQ.format(memory_type.lower(), region, memory_type.upper(),
|
||||
region.upper(), tmp, load_address_string)
|
||||
|
@ -389,6 +403,8 @@ def create_dict_wrt_mem():
|
|||
|
||||
|
||||
def main():
|
||||
global mpu_align
|
||||
mpu_align = {}
|
||||
parse_args()
|
||||
searchpath = args.directory
|
||||
linker_file = args.output
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue