gen_relocate_app.py: make generated/linker_relocate.ld deterministic
Dictionaries are not ordered in Python 3.5 and before, so building twice ${ZEPHYR_BASE}/samples/application_development/code_relocation/ in a row could lead to a different sections order, different build/zephyr/include/generated/linker_relocate.d and code_relocation.c and different binaries. Fix with a minor change to three "for" loops in the output functions: make them iterate on sorted(list of sections) instead of the raw and randomly ordered dictionaries of sections. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is contained in:
parent
2a63e342f4
commit
6ccd026f7c
1 changed files with 8 additions and 4 deletions
|
@ -197,7 +197,7 @@ def assign_to_correct_mem_region(memory_type,
|
|||
|
||||
def print_linker_sections(list_sections):
|
||||
print_string = ''
|
||||
for section in list_sections:
|
||||
for section in sorted(list_sections):
|
||||
print_string += PRINT_TEMPLATE.format(section)
|
||||
return print_string
|
||||
|
||||
|
@ -233,7 +233,9 @@ def generate_linker_script(linker_file, sram_data_linker_file,
|
|||
gen_string = ''
|
||||
gen_string_sram_data = ''
|
||||
gen_string_sram_bss = ''
|
||||
for memory_type, full_list_of_sections in complete_list_of_sections.items():
|
||||
|
||||
for memory_type, full_list_of_sections in \
|
||||
sorted(complete_list_of_sections.items()):
|
||||
|
||||
if memory_type != "SRAM":
|
||||
gen_string += MPU_RO_REGION_START.format(memory_type.lower(),
|
||||
|
@ -393,7 +395,6 @@ def main():
|
|||
# Create/or trucate file contents if it already exists
|
||||
# raw = open(linker_file, "w")
|
||||
|
||||
code_generation = {"copy_code": '', "zero_code":'', "extern":''}
|
||||
#for each memory_type, create text/rodata/data/bss sections for all obj files
|
||||
for memory_type, files in rel_dict.items():
|
||||
full_list_of_sections = {"text":[], "rodata":[], "data":[], "bss":[]}
|
||||
|
@ -413,7 +414,10 @@ def main():
|
|||
|
||||
generate_linker_script(linker_file, sram_data_linker_file,
|
||||
sram_bss_linker_file, complete_list_of_sections)
|
||||
for mem_type, list_of_sections in complete_list_of_sections.items():
|
||||
|
||||
code_generation = {"copy_code": '', "zero_code":'', "extern":''}
|
||||
for mem_type, list_of_sections in \
|
||||
sorted(complete_list_of_sections.items()):
|
||||
code_generation = generate_memcpy_code(mem_type,
|
||||
list_of_sections, code_generation)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue