diff --git a/components/bt/linker.lf b/components/bt/linker.lf index 1617106076..eeab598215 100644 --- a/components/bt/linker.lf +++ b/components/bt/linker.lf @@ -9,7 +9,7 @@ entries: data -> dram0_data # For the following fragments, order matters for -# 'align(4, post) surround(sym)', which generates: +# 'ALIGN(4, post) SURROUND(sym)', which generates: # # _sym_start # ... @@ -20,8 +20,8 @@ entries: archive: libbt.a entries: * (bt_start_end); - bss_common -> dram0_bss align(4, post) surround(bt_bss), - data -> dram0_data align(4, post) surround(bt_data) + bss_common -> dram0_bss ALIGN(4, post) SURROUND(bt_bss), + data -> dram0_data ALIGN(4, post) SURROUND(bt_data) if ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y: * (extram_bss) @@ -29,12 +29,12 @@ entries: archive: libbtdm_app.a entries: * (bt_start_end); - bss_common -> dram0_bss align(4, post) surround(btdm_bss), - data -> dram0_data align(4, post) surround(btdm_data) + bss_common -> dram0_bss ALIGN(4, post) SURROUND(btdm_bss), + data -> dram0_data ALIGN(4, post) SURROUND(btdm_data) [mapping:nimble] archive: libnimble.a entries: * (bt_start_end); - bss_common -> dram0_bss align(4, post) surround(nimble_bss), - data -> dram0_data align(4, post) surround(nimble_data) + bss_common -> dram0_bss ALIGN(4, post) SURROUND(nimble_bss), + data -> dram0_data ALIGN(4, post) SURROUND(nimble_data) diff --git a/components/espcoredump/linker.lf b/components/espcoredump/linker.lf index 62880f285c..f4af6d7c64 100644 --- a/components/espcoredump/linker.lf +++ b/components/espcoredump/linker.lf @@ -27,12 +27,12 @@ entries: archive: * entries: * (coredump_default); - rtc_fast_coredump -> rtc_force_fast surround(coredump_rtc_fast), - rtc_coredump -> rtc_data surround(coredump_rtc), - dram_coredump -> dram0_data surround(coredump_dram) + rtc_fast_coredump -> rtc_force_fast SURROUND(coredump_rtc_fast), + rtc_coredump -> rtc_data SURROUND(coredump_rtc), + dram_coredump -> dram0_data SURROUND(coredump_dram) if IDF_TARGET_ESP32S2 = n: * (coredump_default); - iram_coredump -> iram0_data surround(coredump_iram) + iram_coredump -> iram0_data SURROUND(coredump_iram) [mapping:espcoredump] archive: libespcoredump.a diff --git a/tools/ldgen/fragments.py b/tools/ldgen/fragments.py index 0305c07c18..d3e2a2e761 100644 --- a/tools/ldgen/fragments.py +++ b/tools/ldgen/fragments.py @@ -283,11 +283,11 @@ class Mapping(Fragment): @staticmethod def get_grammar(): - # surround(symbol) + # SURROUND(symbol) # # __symbol_start, __symbol_end is generated before and after # the corresponding input section description, respectively. - grammar = (Keyword('surround').suppress() + + grammar = (Keyword('SURROUND').suppress() + Suppress('(') + Fragment.IDENTIFIER.setResultsName('symbol') + Suppress(')')) @@ -308,8 +308,8 @@ class Mapping(Fragment): @staticmethod def get_grammar(): - # align(alignment, [, pre, post]) - grammar = (Keyword('align').suppress() + + # ALIGN(alignment, [, pre, post]) + grammar = (Keyword('ALIGN').suppress() + Suppress('(') + Word(nums).setResultsName('alignment') + Mapping.Flag.PRE_POST + @@ -343,7 +343,7 @@ class Mapping(Fragment): @staticmethod def get_grammar(): - grammar = Keyword('keep').setParseAction(Mapping.Keep) + grammar = Keyword('KEEP').setParseAction(Mapping.Keep) return grammar def __eq__(self, other): @@ -361,9 +361,9 @@ class Mapping(Fragment): @staticmethod def get_grammar(): - # sort(sort_by_first [, sort_by_second]) + # SORT(sort_by_first [, sort_by_second]) keywords = Keyword('name') | Keyword('alignment') | Keyword('init_priority') - grammar = (Keyword('sort').suppress() + Suppress('(') + + grammar = (Keyword('SORT').suppress() + Suppress('(') + keywords.setResultsName('first') + Optional(Suppress(',') + keywords.setResultsName('second')) + Suppress(')')) @@ -428,7 +428,7 @@ class Mapping(Fragment): # obj (scheme) # * (scheme) # Flags can be specified for section->target in the scheme specified, ex: - # obj (scheme); section->target surround(symbol), section2->target2 align(4) + # obj (scheme); section->target SURROUND(symbol), section2->target2 ALIGN(4) obj = Fragment.ENTITY.setResultsName('object') symbol = Suppress(':') + Fragment.IDENTIFIER.setResultsName('symbol') scheme = Suppress('(') + Fragment.IDENTIFIER.setResultsName('scheme') + Suppress(')') diff --git a/tools/ldgen/generation.py b/tools/ldgen/generation.py index 0d0bf46afd..71fbf48339 100644 --- a/tools/ldgen/generation.py +++ b/tools/ldgen/generation.py @@ -155,14 +155,14 @@ class EntityNode(): keep = True elif isinstance(flag, Mapping.Sort): sort = (flag.first, flag.second) - else: # surround or align + else: # SURROUND or ALIGN surround_type.append(flag) for flag in surround_type: if flag.pre: if isinstance(flag, Mapping.Surround): commands[placement.target].append(SymbolAtAddress('_%s_start' % flag.symbol)) - else: # align + else: # ALIGN commands[placement.target].append(AlignAtAddress(flag.alignment)) # This is for expanded object node and symbol node placements without checking for @@ -185,7 +185,7 @@ class EntityNode(): if flag.post: if isinstance(flag, Mapping.Surround): commands[placement.target].append(SymbolAtAddress('_%s_end' % flag.symbol)) - else: # align + else: # ALIGN commands[placement.target].append(AlignAtAddress(flag.alignment)) return commands diff --git a/tools/ldgen/test/test_fragments.py b/tools/ldgen/test/test_fragments.py index bdd685e2d0..d844ae5fb4 100755 --- a/tools/ldgen/test/test_fragments.py +++ b/tools/ldgen/test/test_fragments.py @@ -818,8 +818,8 @@ entries: archive: libmain.a entries: obj1 (default); - text->flash_text keep, - rodata->flash_rodata keep keep + text->flash_text KEEP, + rodata->flash_rodata KEEP KEEP """) fragment_file = FragmentFile(test_fragment, self.sdkconfig) @@ -838,11 +838,11 @@ entries: archive: libmain.a entries: obj1 (default); - text->flash_text align(8), - rodata->flash_rodata align(8, pre), - data->dram0_data align(8, pre, post), - bss->dram0_bss align(8, post), - common->dram0_bss align(8, pre, post) align(8) + text->flash_text ALIGN(8), + rodata->flash_rodata ALIGN(8, pre), + data->dram0_data ALIGN(8, pre, post), + bss->dram0_bss ALIGN(8, post), + common->dram0_bss ALIGN(8, pre, post) ALIGN(8) """) fragment_file = FragmentFile(test_fragment, self.sdkconfig) @@ -863,7 +863,7 @@ entries: archive: libmain.a entries: obj1 (noflash) - text->iram0_text align(8, post, pre) + text->iram0_text ALIGN(8, post, pre) """) with self.assertRaises(ParseFatalException): @@ -876,13 +876,13 @@ entries: archive: libmain.a entries: obj1 (default); - text->flash_text sort(name), - rodata->flash_rodata sort(alignment), - data->dram0_data sort(init_priority), - bss->dram0_bss sort(name, alignment), - common->dram0_bss sort(alignment, name), - iram->iram0_text sort(name, name), - dram->dram0_data sort(alignment, alignment) + text->flash_text SORT(name), + rodata->flash_rodata SORT(alignment), + data->dram0_data SORT(init_priority), + bss->dram0_bss SORT(name, alignment), + common->dram0_bss SORT(alignment, name), + iram->iram0_text SORT(name, name), + dram->dram0_data SORT(alignment, alignment) """) fragment_file = FragmentFile(test_fragment, self.sdkconfig) @@ -903,7 +903,7 @@ entries: archive: libmain.a entries: obj1 (default) - text->iram0_text sort(name) sort(alignment) + text->iram0_text SORT(name) SORT(alignment) """) def test_surround_flag(self): @@ -913,7 +913,7 @@ entries: archive: libmain.a entries: obj1 (default); - text->flash_text surround(sym1) + text->flash_text SURROUND(sym1) """) fragment_file = FragmentFile(test_fragment, self.sdkconfig) @@ -930,8 +930,8 @@ entries: archive: libmain.a entries: obj1 (default); - text->flash_text align(4) keep surround(sym1) align(8) sort(name), - rodata->flash_rodata keep align(4) keep surround(sym1) align(8) align(4) sort(name) + text->flash_text ALIGN(4) KEEP SURROUND(sym1) ALIGN(8) SORT(name), + rodata->flash_rodata KEEP ALIGN(4) KEEP SURROUND(sym1) ALIGN(8) ALIGN(4) SORT(name) """) fragment_file = FragmentFile(test_fragment, self.sdkconfig) fragment = fragment_file.fragments[0] @@ -960,8 +960,8 @@ entries: archive: libmain.a entries: obj1 (default); - text->flash_text align(4) keep surround(sym1) sort(name), - text->flash_text align(4) keep surround(sym1) sort(name) + text->flash_text ALIGN(4) KEEP SURROUND(sym1) SORT(name), + text->flash_text ALIGN(4) KEEP SURROUND(sym1) SORT(name) """) fragment_file = FragmentFile(test_fragment, self.sdkconfig) fragment = fragment_file.fragments[0] @@ -987,9 +987,9 @@ entries: archive: libmain.a entries: obj1 (default); - text->flash_text align(4) keep surround(sym1) sort(name) + text->flash_text ALIGN(4) KEEP SURROUND(sym1) SORT(name) obj1 (default); - text->flash_text align(4) keep surround(sym1) sort(name) + text->flash_text ALIGN(4) KEEP SURROUND(sym1) SORT(name) """) fragment_file = FragmentFile(test_fragment, self.sdkconfig) fragment = fragment_file.fragments[0] diff --git a/tools/ldgen/test/test_generation.py b/tools/ldgen/test/test_generation.py index a05c1b3a95..5a2fd2e920 100755 --- a/tools/ldgen/test/test_generation.py +++ b/tools/ldgen/test/test_generation.py @@ -1397,8 +1397,8 @@ class FlagTest(GenerationTest): # with flags. def test_flags_basics(self): - # Test that input section commands additions are done (keep, sort). - # Test that order dependent commands are properly generated (align, surround) + # Test that input section commands additions are done (KEEP, SORT). + # Test that order dependent commands are properly generated (ALIGN, SURROUND) # Normally, if an entry has the same mapping as parent, commands. # are not emitted for them. However, if there are flags, they should be - # only for the scheme entries that have flags, though. @@ -1428,11 +1428,11 @@ class FlagTest(GenerationTest): archive: libfreertos.a entries: croutine (noflash_text); - text->iram0_text align(4, pre, post) surround(sym1) #1 + text->iram0_text ALIGN(4, pre, post) SURROUND(sym1) #1 timers (default); - text->flash_text keep sort(name) #2 + text->flash_text KEEP SORT(name) #2 timers (default); - rodata->flash_rodata surround(sym2) align(4, pre, post) #3 + rodata->flash_rodata SURROUND(sym2) ALIGN(4, pre, post) #3 """ self.add_fragments(mapping) @@ -1489,7 +1489,7 @@ archive: * entries: # 1 * (default); - text->flash_text surround(sym1) keep #2 + text->flash_text SURROUND(sym1) KEEP #2 [mapping:test] archive: libfreertos.a @@ -1509,7 +1509,7 @@ entries: # Command for #2, pre A.1 flash_text.insert(0, SymbolAtAddress('_sym1_start')) - # Command for #1 with keep B + # Command for #1 with KEEP B # and exclusion for #3 flash_text[1].keep = True flash_text[1].exclusions.add(CROUTINE) @@ -1551,7 +1551,7 @@ archive: libfreertos.a entries: # 1 * (default); - text->flash_text surround(sym1) keep #2 + text->flash_text SURROUND(sym1) KEEP #2 croutine:prvCheckPendingReadyList (noflash_text) #3 """ @@ -1567,7 +1567,7 @@ entries: flash_text.append(SymbolAtAddress('_sym1_start')) flash_text[0].exclusions.add(FREERTOS) - # Command for #1 with keep B + # Command for #1 with KEEP B # and exclusion for #3 flash_text.append(InputSectionDesc(FREERTOS, flash_text[0].sections, [CROUTINE], keep=True)) @@ -1607,7 +1607,7 @@ archive: libfreertos.a entries: # 1 croutine (default); - text->flash_text surround(sym1) keep #2 + text->flash_text SURROUND(sym1) KEEP #2 croutine:prvCheckPendingReadyList (noflash_text) #3 """ @@ -1658,7 +1658,7 @@ archive: * entries: # 1 * (default); - text->flash_text surround(sym1) keep #2 + text->flash_text SURROUND(sym1) KEEP #2 [mapping:test] archive: libfreertos.a @@ -1679,7 +1679,7 @@ entries: # Command for #2, pre A.1 flash_text.insert(0, SymbolAtAddress('_sym1_start')) - # Command for #1 with keep B + # Command for #1 with KEEP B # and exclusion for #3 flash_text[1].keep = True flash_text[1].exclusions.add(CROUTINE) @@ -1720,7 +1720,7 @@ archive: libfreertos.a entries: # 1 * (default); - text->flash_text surround(sym1) keep + text->flash_text SURROUND(sym1) KEEP croutine (default) #2 croutine:prvCheckPendingReadyList (noflash_text) #3 """ @@ -1737,7 +1737,7 @@ entries: flash_text.append(SymbolAtAddress('_sym1_start')) flash_text[0].exclusions.add(FREERTOS) - # Command for #1 with keep B + # Command for #1 with KEEP B # and exclusion for #3 flash_text.append(InputSectionDesc(FREERTOS, flash_text[0].sections, [CROUTINE], keep=True)) @@ -1766,7 +1766,7 @@ entries: archive: * entries: * (default); - text->flash_text keep + text->flash_text KEEP """ self.add_fragments(mapping) @@ -1787,13 +1787,13 @@ entries: archive: * entries: * (default); - text->flash_text keep + text->flash_text KEEP [mapping:default_add_flag_2] archive: * entries: * (default); - text->flash_text keep + text->flash_text KEEP """ self.add_fragments(mapping) @@ -1814,13 +1814,13 @@ entries: archive: * entries: * (default); - text->flash_text align(2) + text->flash_text ALIGN(2) [mapping:default_add_flag_2] archive: * entries: * (default); - text->flash_text surround(sym1) + text->flash_text SURROUND(sym1) """ self.add_fragments(mapping) diff --git a/tools/ldgen/test/test_output_commands.py b/tools/ldgen/test/test_output_commands.py index 2bc8ec8071..96effe52ec 100755 --- a/tools/ldgen/test/test_output_commands.py +++ b/tools/ldgen/test/test_output_commands.py @@ -137,7 +137,7 @@ class InputSectionDescTest(unittest.TestCase): self.assertEqual(expected, str(desc)) def test_keep(self): - # Test keep + # Test KEEP expected = 'KEEP(*libfreertos.a:croutine.*( ))' desc = InputSectionDesc(Entity('libfreertos.a', 'croutine'), [], keep=True) diff --git a/tools/test_apps/build_system/ldgen_test/main/linker.lf b/tools/test_apps/build_system/ldgen_test/main/linker.lf index 45d1886da7..6b9d0e32c2 100644 --- a/tools/test_apps/build_system/ldgen_test/main/linker.lf +++ b/tools/test_apps/build_system/ldgen_test/main/linker.lf @@ -4,5 +4,5 @@ entries: * (noflash) src1 (default) src1:func1 (noflash); - text->iram0_text keep align(9) align(12, post) surround(sym1) + text->iram0_text KEEP ALIGN(9) ALIGN(12, post) SURROUND(sym1) src1:func2 (rtc)