mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 11:03:11 +00:00
fix(ldgen): correct formatting issues reported by ruff
Resolve ruff's UP031 errors related to the use of percent formatting for strings and lines longer than 120 characters. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import collections
|
||||
@@ -83,11 +83,13 @@ class Placement:
|
||||
#
|
||||
# Placement can also be a basis if it has flags
|
||||
# (self.flags) or its basis has flags (self.basis.flags)
|
||||
significant = (not self.basis or
|
||||
self.target != self.basis.target or
|
||||
(self.flags and not self.basis.flags) or
|
||||
(not self.flags and self.basis.flags) or
|
||||
self.force)
|
||||
significant = (
|
||||
not self.basis
|
||||
or self.target != self.basis.target
|
||||
or (self.flags and not self.basis.flags)
|
||||
or (not self.flags and self.basis.flags)
|
||||
or self.force
|
||||
)
|
||||
|
||||
if significant and not self.explicit and not self.sections:
|
||||
# The placement is significant, but it is an intermediate placement
|
||||
@@ -155,7 +157,7 @@ class EntityNode:
|
||||
assert name and name != Entity.ALL
|
||||
|
||||
child = [c for c in self.children if c.name == name]
|
||||
assert (len(child) <= 1)
|
||||
assert len(child) <= 1
|
||||
|
||||
if not child:
|
||||
child = self.child_t(self, name)
|
||||
@@ -169,7 +171,7 @@ class EntityNode:
|
||||
commands = collections.defaultdict(list)
|
||||
|
||||
def process_commands(cmds):
|
||||
for (target, commands_list) in cmds.items():
|
||||
for target, commands_list in cmds.items():
|
||||
commands[target].extend(commands_list)
|
||||
|
||||
# Process the commands generated from this node
|
||||
@@ -221,16 +223,28 @@ class EntityNode:
|
||||
placement_sections = frozenset(placement.sections)
|
||||
command_sections = sections if sections == placement_sections else placement_sections
|
||||
|
||||
command = InputSectionDesc(placement.node.entity, command_sections,
|
||||
[e.node.entity for e in placement.exclusions], keep, sort, tied)
|
||||
command = InputSectionDesc(
|
||||
placement.node.entity,
|
||||
command_sections,
|
||||
[e.node.entity for e in placement.exclusions],
|
||||
keep,
|
||||
sort,
|
||||
tied,
|
||||
)
|
||||
commands[placement.target].append(command)
|
||||
|
||||
# Generate commands for intermediate, non-explicit exclusion placements here,
|
||||
# so that they can be enclosed by flags that affect the parent placement.
|
||||
for subplacement in placement.subplacements:
|
||||
if not subplacement.flags and not subplacement.explicit:
|
||||
command = InputSectionDesc(subplacement.node.entity, subplacement.sections,
|
||||
[e.node.entity for e in subplacement.exclusions], keep, sort, tied)
|
||||
command = InputSectionDesc(
|
||||
subplacement.node.entity,
|
||||
subplacement.sections,
|
||||
[e.node.entity for e in subplacement.exclusions],
|
||||
keep,
|
||||
sort,
|
||||
tied,
|
||||
)
|
||||
commands[placement.target].append(command)
|
||||
|
||||
for flag in surround_type:
|
||||
@@ -319,7 +333,7 @@ class ObjectNode(EntityNode):
|
||||
|
||||
if obj_sections:
|
||||
symbol = entity.symbol
|
||||
remove_sections = [s.replace('.*', '.%s' % symbol) for s in sections if '.*' in s]
|
||||
remove_sections = [s.replace('.*', f'.{symbol}') for s in sections if '.*' in s]
|
||||
# As part of IPA optimization, the compiler may perform
|
||||
# constant propagation and generate specialized versions of a
|
||||
# function. For example, for the function spiflash_start_core,
|
||||
@@ -417,7 +431,7 @@ class Generation:
|
||||
for scheme in self.schemes.values():
|
||||
sections_bucket = collections.defaultdict(list)
|
||||
|
||||
for (sections_name, target_name) in scheme.entries:
|
||||
for sections_name, target_name in scheme.entries:
|
||||
# Get the sections under the bucket 'target_name'. If this bucket does not exist
|
||||
# is created automatically
|
||||
sections_in_bucket = sections_bucket[target_name]
|
||||
@@ -433,7 +447,7 @@ class Generation:
|
||||
scheme_dictionary[scheme.name] = sections_bucket
|
||||
|
||||
# Search for and raise exception on first instance of sections mapped to multiple targets
|
||||
for (scheme_name, sections_bucket) in scheme_dictionary.items():
|
||||
for scheme_name, sections_bucket in scheme_dictionary.items():
|
||||
for sections_a, sections_b in itertools.combinations(sections_bucket.values(), 2):
|
||||
set_a = set()
|
||||
set_b = set()
|
||||
@@ -466,15 +480,17 @@ class Generation:
|
||||
for mapping in self.mappings.values():
|
||||
archive = mapping.archive
|
||||
|
||||
for (obj, symbol, scheme_name) in mapping.entries:
|
||||
for obj, symbol, scheme_name in mapping.entries:
|
||||
entity = Entity(archive, obj, symbol)
|
||||
|
||||
# Check the entity exists
|
||||
if (self.check_mappings
|
||||
and entity.specificity.value > Entity.Specificity.ARCHIVE.value
|
||||
and mapping.name not in self.check_mapping_exceptions):
|
||||
if (
|
||||
self.check_mappings
|
||||
and entity.specificity.value > Entity.Specificity.ARCHIVE.value
|
||||
and mapping.name not in self.check_mapping_exceptions
|
||||
):
|
||||
if not entities.check_exists(entity):
|
||||
message = "'%s' not found" % str(entity)
|
||||
message = f"'{entity}' not found"
|
||||
raise GenerationException(message, mapping)
|
||||
|
||||
if (obj, symbol, scheme_name) in mapping.flags.keys():
|
||||
@@ -482,16 +498,16 @@ class Generation:
|
||||
# Check if all section->target defined in the current
|
||||
# scheme.
|
||||
for flag in flags:
|
||||
if (flag.target not in scheme_dictionary[scheme_name].keys()
|
||||
or flag.section not in
|
||||
[_s.name for _s in scheme_dictionary[scheme_name][flag.target]]):
|
||||
message = "%s->%s not defined in scheme '%s'" % (flag.section, flag.target, scheme_name)
|
||||
if flag.target not in scheme_dictionary[scheme_name].keys() or flag.section not in [
|
||||
_s.name for _s in scheme_dictionary[scheme_name][flag.target]
|
||||
]:
|
||||
message = f"{flag.section}->{flag.target} not defined in scheme '{scheme_name}'"
|
||||
raise GenerationException(message, mapping)
|
||||
else:
|
||||
flags = None
|
||||
|
||||
# Create placement for each 'section -> target' in the scheme.
|
||||
for (target, sections) in scheme_dictionary[scheme_name].items():
|
||||
for target, sections in scheme_dictionary[scheme_name].items():
|
||||
for section in sections:
|
||||
# Find the applicable flags
|
||||
_flags = []
|
||||
@@ -522,9 +538,9 @@ class Generation:
|
||||
if _flags or existing.flags:
|
||||
if (_flags and not existing.flags) or (not _flags and existing.flags):
|
||||
_flags.extend(existing.flags)
|
||||
entity_mappings[key] = Generation.EntityMapping(entity,
|
||||
sections_str,
|
||||
target, _flags)
|
||||
entity_mappings[key] = Generation.EntityMapping(
|
||||
entity, sections_str, target, _flags
|
||||
)
|
||||
elif _flags == existing.flags:
|
||||
pass
|
||||
else:
|
||||
@@ -565,8 +581,7 @@ class Generation:
|
||||
if fragment.name in dict_to_append_to:
|
||||
stored = dict_to_append_to[fragment.name].path
|
||||
new = fragment.path
|
||||
message = "Duplicate definition of fragment '%s' found in %s and %s." % (
|
||||
fragment.name, stored, new)
|
||||
message = f"Duplicate definition of fragment '{fragment.name}' found in {stored} and {new}."
|
||||
raise GenerationException(message)
|
||||
|
||||
dict_to_append_to[fragment.name] = fragment
|
||||
@@ -586,6 +601,6 @@ class GenerationException(LdGenFailure):
|
||||
|
||||
def __str__(self):
|
||||
if self.fragment:
|
||||
return "%s\nIn fragment '%s' defined in '%s'." % (self.message, self.fragment.name, self.fragment.path)
|
||||
return f"{self.message}\nIn fragment '{self.fragment.name}' defined in '{self.fragment.path}'."
|
||||
else:
|
||||
return self.message
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
import collections
|
||||
@@ -12,19 +12,27 @@ import unittest
|
||||
from io import StringIO
|
||||
|
||||
try:
|
||||
from ldgen.entity import Entity, EntityDB
|
||||
from ldgen.entity import Entity
|
||||
from ldgen.entity import EntityDB
|
||||
from ldgen.fragments import parse_fragment_file
|
||||
from ldgen.generation import Generation, GenerationException
|
||||
from ldgen.generation import Generation
|
||||
from ldgen.generation import GenerationException
|
||||
from ldgen.linker_script import LinkerScript
|
||||
from ldgen.output_commands import AlignAtAddress, InputSectionDesc, SymbolAtAddress
|
||||
from ldgen.output_commands import AlignAtAddress
|
||||
from ldgen.output_commands import InputSectionDesc
|
||||
from ldgen.output_commands import SymbolAtAddress
|
||||
from ldgen.sdkconfig import SDKConfig
|
||||
except ImportError:
|
||||
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
|
||||
from ldgen.entity import Entity, EntityDB
|
||||
from ldgen.entity import Entity
|
||||
from ldgen.entity import EntityDB
|
||||
from ldgen.fragments import parse_fragment_file
|
||||
from ldgen.generation import Generation, GenerationException
|
||||
from ldgen.generation import Generation
|
||||
from ldgen.generation import GenerationException
|
||||
from ldgen.linker_script import LinkerScript
|
||||
from ldgen.output_commands import AlignAtAddress, InputSectionDesc, SymbolAtAddress
|
||||
from ldgen.output_commands import AlignAtAddress
|
||||
from ldgen.output_commands import InputSectionDesc
|
||||
from ldgen.output_commands import SymbolAtAddress
|
||||
from ldgen.sdkconfig import SDKConfig
|
||||
|
||||
ROOT = Entity('*')
|
||||
@@ -39,7 +47,6 @@ FREERTOS2 = Entity('libfreertos2.a')
|
||||
|
||||
|
||||
class GenerationTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.generation = Generation()
|
||||
self.entities = None
|
||||
@@ -125,7 +132,6 @@ class GenerationTest(unittest.TestCase):
|
||||
|
||||
|
||||
class DefaultMappingTest(GenerationTest):
|
||||
|
||||
def test_rule_generation_default(self):
|
||||
# Checks that default rules are generated from
|
||||
# the default scheme properly and even if no mappings
|
||||
@@ -138,7 +144,7 @@ class DefaultMappingTest(GenerationTest):
|
||||
def test_default_mapping_lib(self):
|
||||
# Mapping a library with default mapping. This should not emit additional rules,
|
||||
# other than the default ones.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -150,7 +156,7 @@ entries:
|
||||
def test_default_mapping_obj(self):
|
||||
# Mapping an object with default mapping. This should not emit additional rules,
|
||||
# other than the default ones.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -162,7 +168,7 @@ entries:
|
||||
def test_default_mapping_symbol(self):
|
||||
# Mapping a symbol with default mapping. This should not emit additional rules,
|
||||
# other than the default ones.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -174,7 +180,7 @@ entries:
|
||||
def test_default_mapping_all(self):
|
||||
# Mapping a library, object, and symbol with default mapping. This should not emit additional rules,
|
||||
# other than the default ones.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -191,7 +197,7 @@ entries:
|
||||
#
|
||||
# This is a check needed to make sure generation does not generate
|
||||
# intermediate commands due to presence of symbol mapping.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -207,7 +213,7 @@ entries:
|
||||
#
|
||||
# This is a check needed to make sure generation does not generate
|
||||
# intermediate commands due to presence of symbol mapping.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -234,7 +240,7 @@ class BasicTest(GenerationTest):
|
||||
# iram0_text
|
||||
# *(.iram ...)
|
||||
# *libfreertos.a(.literal ...) B
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -264,14 +270,14 @@ entries:
|
||||
# There should be exclusions in the default commands for flash_text and flash_rodata:
|
||||
#
|
||||
# flash_text
|
||||
# *((EXCLUDE_FILE(libfreertos.a:croutine)) .literal ...) A
|
||||
# *((EXCLUDE_FILE(libfreertos.a:croutine)) .literal ...) A
|
||||
#
|
||||
# Commands placing the entire library in iram, dram should be generated:
|
||||
#
|
||||
# iram0_text
|
||||
# *(.iram ...)
|
||||
# *libfreertos.a:croutine(.literal ...) B
|
||||
mapping = u"""
|
||||
# *libfreertos.a:croutine(.literal ...) B
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -299,19 +305,20 @@ entries:
|
||||
|
||||
def test_nondefault_mapping_symbol(self):
|
||||
# Test mapping entry different from default for symbol.
|
||||
# There should be exclusions in the default commands for flash_text, as well as the implicit intermediate object command
|
||||
# There should be exclusions in the default commands for flash_text, as
|
||||
# well as the implicit intermediate object command
|
||||
# with an exclusion from default:
|
||||
#
|
||||
# flash_text
|
||||
# *((EXCLUDE_FILE(libfreertos.a:croutine)) .literal ...) A
|
||||
# *libfreertos.a:croutine(.literal .literal.prvCheckDelayedList ...) B
|
||||
# *((EXCLUDE_FILE(libfreertos.a:croutine)) .literal ...) A
|
||||
# *libfreertos.a:croutine(.literal .literal.prvCheckDelayedList ...) B
|
||||
#
|
||||
# Commands placing the entire library in iram should be generated:
|
||||
#
|
||||
# iram0_text
|
||||
# *(.iram ...)
|
||||
# *libfreertos.a:croutine(.text.prvCheckPendingReadyList .literal.prvCheckPendingReadyList) C
|
||||
mapping = u"""
|
||||
# *libfreertos.a:croutine(.text.prvCheckPendingReadyList .literal.prvCheckPendingReadyList) C
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -340,7 +347,9 @@ entries:
|
||||
flash_text.append(InputSectionDesc(CROUTINE, set(filtered_sections), []))
|
||||
|
||||
# Input section commands in iram_text for #1 C
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
@@ -422,14 +431,14 @@ entries:
|
||||
# object file, including .debug, .comment and other input section.
|
||||
#
|
||||
# flash.rodata
|
||||
# *((EXCLUDE_FILE(*libsoc.a:temperature_sensor_periph.*)) .rodata.* ...) A
|
||||
# # *libsoc.a:temperature_sensor_periph.* X
|
||||
# *((EXCLUDE_FILE(*libsoc.a:temperature_sensor_periph.*)) .rodata.* ...) A
|
||||
# # *libsoc.a:temperature_sensor_periph.* X
|
||||
#
|
||||
# Commands placing the entire library in iram should be generated:
|
||||
#
|
||||
# dram0_data
|
||||
# *libsoc.a:temperature_sensor_periph.*(.rodata.temperature_sensor_attribute) B
|
||||
mapping = u"""
|
||||
# *libsoc.a:temperature_sensor_periph.*(.rodata.temperature_sensor_attribute) B
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libsoc.a
|
||||
entries:
|
||||
@@ -447,14 +456,15 @@ entries:
|
||||
flash_rodata[0].exclusions.add(TEMPERATURE_SENSOR_PERIPH)
|
||||
|
||||
# Input section commands in dram0_data for #1 B
|
||||
dram0_data.append(InputSectionDesc(TEMPERATURE_SENSOR_PERIPH,
|
||||
set(['.rodata.temperature_sensor_attributes']),
|
||||
[]))
|
||||
dram0_data.append(
|
||||
InputSectionDesc(TEMPERATURE_SENSOR_PERIPH, set(['.rodata.temperature_sensor_attributes']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
def test_default_symbol_nondefault_lib(self):
|
||||
# Test default symbol mapping with different lib mapping. This should create an implicit intermediate object command.
|
||||
# Test default symbol mapping with different lib mapping. This should
|
||||
# create an implicit intermediate object command.
|
||||
# The significant targets are flash_text, flash_rodata, iram0_text, dram0_data.
|
||||
#
|
||||
# flash_text
|
||||
@@ -474,7 +484,7 @@ entries:
|
||||
# libfreertos.a ( .rodata ...) C.2
|
||||
#
|
||||
# Only default commands are in the other targets.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -511,7 +521,9 @@ entries:
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(filtered_sections), []))
|
||||
|
||||
# Command for #2 B
|
||||
flash_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
flash_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
@@ -536,7 +548,7 @@ entries:
|
||||
# *libfreertos.a:croutine(.rodata ....) C.2
|
||||
#
|
||||
# Only default commands are in the other targets
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -570,7 +582,9 @@ entries:
|
||||
dram0_data.append(InputSectionDesc(CROUTINE, flash_rodata[0].sections, []))
|
||||
|
||||
# Command for #2 B
|
||||
flash_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
flash_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
@@ -603,7 +617,7 @@ entries:
|
||||
# libfreertos.a (EXCLUDE_FILE(libfreertos:croutine) .rodata ...) C
|
||||
#
|
||||
# For the other targets only the default commands should be present.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -646,14 +660,16 @@ entries:
|
||||
flash_text.append(InputSectionDesc(CROUTINE, set(filtered_sections), []))
|
||||
|
||||
# Command for #3 D
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
def test_nondefault_but_same_lib_and_obj(self):
|
||||
# Extension of DefaultMappingTest. Commands should not be generated for #2, since it does similar mapping
|
||||
# to #1. Output is similar to test_different_mapping_lib.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -665,7 +681,7 @@ entries:
|
||||
def test_nondefault_but_same_lib_and_sym(self):
|
||||
# Extension of DefaultMappingTest. Commands should not be generated for #2, since it does similar mapping
|
||||
# to #1. Output is similar to test_different_mapping_lib.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -677,7 +693,7 @@ entries:
|
||||
def test_nondefault_but_same_obj_and_sym(self):
|
||||
# Commands should not be generated for #2, since it does similar mapping
|
||||
# to #1. Output is similar to test_different_mapping_obj.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -698,7 +714,7 @@ entries:
|
||||
# iram0_text
|
||||
#
|
||||
#
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -730,8 +746,12 @@ entries:
|
||||
flash_text.append(InputSectionDesc(CROUTINE, set(filtered_sections), []))
|
||||
|
||||
# Commands for #1 & 2
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckDelayedList', '.literal.prvCheckDelayedList']), []))
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckDelayedList', '.literal.prvCheckDelayedList']), [])
|
||||
)
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
@@ -742,7 +762,7 @@ entries:
|
||||
# iram0_text
|
||||
# * (.custom_section) A
|
||||
# * (.iram .iram.*)
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[sections:custom_section]
|
||||
entries:
|
||||
.custom_section
|
||||
@@ -771,7 +791,6 @@ entries:
|
||||
|
||||
|
||||
class AdvancedTest(GenerationTest):
|
||||
|
||||
# Test valid but quirky cases, corner cases, failure cases, and
|
||||
# cases involving interaction between schemes, other mapping
|
||||
# fragments.
|
||||
@@ -798,7 +817,7 @@ class AdvancedTest(GenerationTest):
|
||||
# *(.data ..)
|
||||
# *(.dram ...)
|
||||
# *libfreertos.a:croutine(.rodata .rodata.*) D
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -852,7 +871,7 @@ entries:
|
||||
# *(.data ..)
|
||||
# *(.dram ...)
|
||||
# *libfreertos.a:croutine(.rodata .rodata.*) D
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -889,7 +908,7 @@ entries:
|
||||
# noflash = text -> iram0_text, rodata -> dram0_data
|
||||
#
|
||||
# This operation should fail.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -908,7 +927,7 @@ entries:
|
||||
# noflash = .text -> iram0_text, .rodata -> dram0_data
|
||||
#
|
||||
# This operation should fail.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[sections:custom_text]
|
||||
entries:
|
||||
.text+
|
||||
@@ -932,42 +951,42 @@ entries:
|
||||
# using another. Another object and symbol is mapped the other way around.
|
||||
#
|
||||
# flash_text
|
||||
# *(EXCLUDE_FILE(libfreertos.a:croutine libfreertos.a:timers) .text ...) A, B
|
||||
# *(EXCLUDE_FILE(libfreertos.a:croutine libfreertos.a:timers) .text ...) A, B
|
||||
#
|
||||
# flash_rodata
|
||||
# *(EXCLUDE_FILE(libfreertos.a:croutine libfreertos.a:timers) .rodata ...) A, B
|
||||
# *(EXCLUDE_FILE(libfreertos.a:croutine libfreertos.a:timers) .rodata ...) A, B
|
||||
#
|
||||
# dram0_data
|
||||
# *(EXCLUDE_FILES(libfreertos.a:timers) .data ..) B
|
||||
# *(EXCLUDE_FILES(libfreertos.a:timers) .data ..) B
|
||||
# *(.dram ...)
|
||||
# *libfreertos.a:croutine(.rodata .rodata.*) C
|
||||
# *libfreertos.a:timers(.rodata.prvProcessReceivedCommands ...) E
|
||||
# *libfreertos.a:croutine(.rodata .rodata.*) C
|
||||
# *libfreertos.a:timers(.rodata.prvProcessReceivedCommands ...) E
|
||||
#
|
||||
# dram0_bss
|
||||
# *(EXCLUDE_FILE(libfreertos.a:timers) .bss .bss.* ...) B
|
||||
# *(EXCLUDE_FILE(libfreertos.a:timers) COMMON) B
|
||||
# *(EXCLUDE_FILE(libfreertos.a:timers) .bss .bss.* ...) B
|
||||
# *(EXCLUDE_FILE(libfreertos.a:timers) COMMON) B
|
||||
#
|
||||
# iram0_text
|
||||
# *(.iram ...)
|
||||
# *libfreertos.a:croutine(.literal .literal.prvCheckDelayedList ...) C
|
||||
# *libfreertos.a:timers(.literal .literal.prvProcessReceivedCommands ...) E
|
||||
# *libfreertos.a:croutine(.literal .literal.prvCheckDelayedList ...) C
|
||||
# *libfreertos.a:timers(.literal .literal.prvProcessReceivedCommands ...) E
|
||||
#
|
||||
# rtc_text
|
||||
# *(rtc.text .rtc.literal)
|
||||
# libfreertos.a:croutine (.text.prvCheckPendingReadyList .literal.prvCheckPendingReadyList) F
|
||||
# libfreertos.a:timers (.text .text.prvCheckForValidListAndQueue ...) D.2
|
||||
# libfreertos.a:croutine (.text.prvCheckPendingReadyList .literal.prvCheckPendingReadyList) F
|
||||
# libfreertos.a:timers (.text .text.prvCheckForValidListAndQueue ...) D.2
|
||||
#
|
||||
# rtc_data
|
||||
# *(rtc.data)
|
||||
# *(rtc.rodata)
|
||||
# libfreertos.a:timers (.data .data.*) D
|
||||
# libfreertos.a:timers (.rodata ...) D.2
|
||||
# libfreertos.a:timers (.data .data.*) D
|
||||
# libfreertos.a:timers (.rodata ...) D.2
|
||||
#
|
||||
# rtc_bss
|
||||
# *(rtc.bss .rtc.bss)
|
||||
# libfreertos.a:timers (.bss .bss.*) D
|
||||
# libfreertos.a:timers (COMMON) D
|
||||
mapping = u"""
|
||||
# libfreertos.a:timers (.bss .bss.*) D
|
||||
# libfreertos.a:timers (COMMON) D
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -1015,7 +1034,9 @@ entries:
|
||||
|
||||
# Commands for #4 F
|
||||
# Processed first due to alphabetical ordering
|
||||
rtc_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
rtc_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
# Commands for #2 D
|
||||
# List all relevant sections excluding #3 for text -> rtc_text and D.2
|
||||
@@ -1037,7 +1058,11 @@ entries:
|
||||
rtc_bss.append(InputSectionDesc(TIMERS, dram0_bss[1].sections, []))
|
||||
|
||||
# Commands for #3 E
|
||||
iram0_text.append(InputSectionDesc(TIMERS, set(['.text.prvProcessReceivedCommands', '.literal.prvProcessReceivedCommands']), []))
|
||||
iram0_text.append(
|
||||
InputSectionDesc(
|
||||
TIMERS, set(['.text.prvProcessReceivedCommands', '.literal.prvProcessReceivedCommands']), []
|
||||
)
|
||||
)
|
||||
dram0_data.append(InputSectionDesc(TIMERS, set(['.rodata.prvProcessReceivedCommands']), []))
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
@@ -1054,7 +1079,7 @@ entries:
|
||||
# * (EXCLUDE_FILE(libfreertos.a libfreertos.a:croutine) .text ...)
|
||||
#
|
||||
# iram0_text
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test_1]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -1099,7 +1124,7 @@ entries:
|
||||
#
|
||||
# Uses the same entries as C_05 but spreads them across
|
||||
# two fragments. The output should still be the same.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test_1]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -1117,7 +1142,7 @@ entries:
|
||||
def test_mapping_same_lib_in_multiple_fragments_conflict(self):
|
||||
# Test mapping fragments operating on the same archive
|
||||
# with conflicting mappings.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test_1]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -1149,7 +1174,7 @@ entries:
|
||||
# libfreertos:croutine(.text.prvCheckPendingReadyList .literal.prvCheckPendingReadyList) G
|
||||
# libfreertos2:croutine(.text .literal ...) D
|
||||
# libfreertos2:croutine2(.text .literal ...) E
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:freertos2]
|
||||
archive: libfreertos2.a
|
||||
entries:
|
||||
@@ -1187,8 +1212,12 @@ entries:
|
||||
flash_text.append(InputSectionDesc(CROUTINE, set(filtered_sections), []))
|
||||
|
||||
# Command for
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckDelayedList', '.literal.prvCheckDelayedList']), []))
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckDelayedList', '.literal.prvCheckDelayedList']), [])
|
||||
)
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
iram0_text.append(InputSectionDesc(Entity(FREERTOS2.archive, 'croutine'), flash_text[0].sections, []))
|
||||
iram0_text.append(InputSectionDesc(Entity(FREERTOS2.archive, 'croutine2'), flash_text[0].sections, []))
|
||||
@@ -1197,7 +1226,7 @@ entries:
|
||||
|
||||
def test_ambigious_obj(self):
|
||||
# Command generation for ambiguous entry should fail.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -1214,7 +1243,7 @@ entries:
|
||||
#
|
||||
# 'custom_scheme' entries conflict the 'default' scheme
|
||||
# entries.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[scheme:custom_scheme]
|
||||
entries:
|
||||
flash_text -> iram0_text
|
||||
@@ -1234,7 +1263,7 @@ entries:
|
||||
#
|
||||
# custom_scheme has the 'iram -> iram0_text' in common with
|
||||
# default scheme
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[sections:custom_section]
|
||||
entries:
|
||||
.custom_section
|
||||
@@ -1269,7 +1298,7 @@ class ConfigTest(GenerationTest):
|
||||
def _test_conditional_on_scheme(self, perf, alt=None):
|
||||
# Test that proper commands are generated if using
|
||||
# schemes with conditional entries.
|
||||
scheme = u"""
|
||||
scheme = """
|
||||
[sections:cond_text_data]
|
||||
entries:
|
||||
if PERFORMANCE_LEVEL >= 1:
|
||||
@@ -1286,7 +1315,7 @@ entries:
|
||||
cond_text_data -> dram0_data
|
||||
"""
|
||||
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: lib.a
|
||||
entries:
|
||||
@@ -1321,7 +1350,7 @@ entries:
|
||||
def test_conditional_mapping(self, alt=None):
|
||||
# Test that proper commands are generated
|
||||
# in conditional mapping entries.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:default]
|
||||
archive: *
|
||||
entries:
|
||||
@@ -1370,7 +1399,7 @@ entries:
|
||||
def test_multiple_fragment_same_lib_conditional(self):
|
||||
# Test conditional entries on new mapping fragment grammar.
|
||||
# across multiple fragments.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:default]
|
||||
archive: *
|
||||
entries:
|
||||
@@ -1402,7 +1431,6 @@ entries:
|
||||
|
||||
|
||||
class FlagTest(GenerationTest):
|
||||
|
||||
# Test correct generation of mapping fragment entries
|
||||
# with flags.
|
||||
|
||||
@@ -1433,7 +1461,7 @@ class FlagTest(GenerationTest):
|
||||
# libfreertos.a:croutine(.text .literal ...) I
|
||||
# . = ALIGN(4) G.2
|
||||
# _sym1_end H.2
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -1493,7 +1521,7 @@ entries:
|
||||
# iram0_text
|
||||
# *(.iram .iram.*)
|
||||
# libfreertos.a:croutine(.text.prvCheckPendingReadyList ...) D
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:default]
|
||||
archive: *
|
||||
entries:
|
||||
@@ -1537,7 +1565,9 @@ entries:
|
||||
flash_text.append(SymbolAtAddress('_sym1_end'))
|
||||
|
||||
# Command for #3 D
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
@@ -1555,7 +1585,7 @@ entries:
|
||||
# iram0_text
|
||||
# *(.iram .iram.*)
|
||||
# libfreertos.a:croutine(.text.prvCheckPendingReadyList ...) D
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -1594,7 +1624,9 @@ entries:
|
||||
flash_text.append(SymbolAtAddress('_sym1_end'))
|
||||
|
||||
# Command for #3 C
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
@@ -1611,7 +1643,7 @@ entries:
|
||||
# iram0_text
|
||||
# *(.iram .iram.*)
|
||||
# libfreertos.a:croutine(.text.prvCheckPendingReadyList ...) C
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -1646,7 +1678,9 @@ entries:
|
||||
flash_text.append(SymbolAtAddress('_sym1_end'))
|
||||
|
||||
# Command for #3 C
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
@@ -1662,7 +1696,7 @@ entries:
|
||||
# iram0_text
|
||||
# *(.iram .iram.*)
|
||||
# libfreertos.a:croutine(.text.prvCheckPendingReadyList ...) D
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:default]
|
||||
archive: *
|
||||
entries:
|
||||
@@ -1707,7 +1741,9 @@ entries:
|
||||
flash_text.append(InputSectionDesc(CROUTINE, set(filtered_sections), []))
|
||||
|
||||
# Command for #4 D
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
@@ -1724,7 +1760,7 @@ entries:
|
||||
# iram0_text
|
||||
# *(.iram .iram.*)
|
||||
# libfreertos.a:croutine(.text.prvCheckPendingReadyList ...) D
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
@@ -1764,14 +1800,16 @@ entries:
|
||||
flash_text.append(InputSectionDesc(CROUTINE, set(filtered_sections), []))
|
||||
|
||||
# Command for #3 C
|
||||
iram0_text.append(InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), []))
|
||||
iram0_text.append(
|
||||
InputSectionDesc(CROUTINE, set(['.text.prvCheckPendingReadyList', '.literal.prvCheckPendingReadyList']), [])
|
||||
)
|
||||
|
||||
self.compare_rules(expected, actual)
|
||||
|
||||
def test_flag_additions(self):
|
||||
# Test ability to add flags as long as no other mapping fragments
|
||||
# does the same thing.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:default_add_flag]
|
||||
archive: *
|
||||
entries:
|
||||
@@ -1792,7 +1830,7 @@ entries:
|
||||
def test_flags_flag_additions_duplicate(self):
|
||||
# Test same flags added to same entity - these
|
||||
# are ignored.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:default_add_flag_1]
|
||||
archive: *
|
||||
entries:
|
||||
@@ -1819,7 +1857,7 @@ entries:
|
||||
def test_flags_flag_additions_conflict(self):
|
||||
# Test condition where multiple fragments specifies flags
|
||||
# to same entity - should generate exception.
|
||||
mapping = u"""
|
||||
mapping = """
|
||||
[mapping:default_add_flag_1]
|
||||
archive: *
|
||||
entries:
|
||||
|
||||
Reference in New Issue
Block a user