mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ldgen: surround always pre and post
This commit is contained in:
parent
dbdc17cced
commit
7af3d65868
@ -276,42 +276,28 @@ class Mapping(Fragment):
|
||||
|
||||
class Surround(Flag):
|
||||
|
||||
def __init__(self, symbol, pre=True, post=True):
|
||||
def __init__(self, symbol):
|
||||
self.symbol = symbol
|
||||
self.pre = pre
|
||||
self.post = post
|
||||
self.pre = True
|
||||
self.post = True
|
||||
|
||||
@staticmethod
|
||||
def get_grammar():
|
||||
# surround(symbol [, pre, post])
|
||||
# surround(symbol)
|
||||
#
|
||||
# __symbol_start, __symbol_end is generated before and after
|
||||
# the corresponding input section description, respectively.
|
||||
grammar = (Keyword('surround').suppress() +
|
||||
Suppress('(') +
|
||||
Fragment.IDENTIFIER.setResultsName('symbol') +
|
||||
Mapping.Flag.PRE_POST +
|
||||
Suppress(')'))
|
||||
|
||||
def on_parse(tok):
|
||||
if tok.pre == '' and tok.post == '':
|
||||
res = Mapping.Surround(tok.symbol)
|
||||
elif tok.pre != '' and tok.post == '':
|
||||
res = Mapping.Surround(tok.symbol, tok.pre, False)
|
||||
elif tok.pre == '' and tok.post != '':
|
||||
res = Mapping.Surround(tok.symbol, False, tok.post)
|
||||
else:
|
||||
res = Mapping.Surround(tok.symbol, tok.pre, tok.post)
|
||||
return res
|
||||
|
||||
grammar.setParseAction(on_parse)
|
||||
grammar.setParseAction(lambda tok: Mapping.Surround(tok.symbol))
|
||||
return grammar
|
||||
|
||||
def __eq__(self, other):
|
||||
return (isinstance(other, Mapping.Surround) and
|
||||
self.symbol == other.symbol and
|
||||
self.pre == other.pre and
|
||||
self.post == other.post)
|
||||
self.symbol == other.symbol)
|
||||
|
||||
class Align(Flag):
|
||||
|
||||
|
@ -906,28 +906,20 @@ entries:
|
||||
text->iram0_text sort(name) sort(alignment)
|
||||
""")
|
||||
|
||||
def test_emit_flag(self):
|
||||
def test_surround_flag(self):
|
||||
# Test parsing combinations and orders of flags
|
||||
test_fragment = self.create_fragment_file(u"""
|
||||
[mapping:map]
|
||||
archive: libmain.a
|
||||
entries:
|
||||
obj1 (default);
|
||||
text->flash_text surround(sym1),
|
||||
rodata->flash_rodata surround(sym2, pre),
|
||||
data->dram0_data surround(sym3, post),
|
||||
bss->dram0_bss surround(sym4, pre, post),
|
||||
common->dram0_bss surround(sym5, pre, post) surround(sym6)
|
||||
text->flash_text surround(sym1)
|
||||
""")
|
||||
|
||||
fragment_file = FragmentFile(test_fragment, self.sdkconfig)
|
||||
fragment = fragment_file.fragments[0]
|
||||
|
||||
expected = [('text', 'flash_text', [Mapping.Surround('sym1', True, True)]),
|
||||
('rodata', 'flash_rodata', [Mapping.Surround('sym2', True, False)]),
|
||||
('data', 'dram0_data', [Mapping.Surround('sym3', False, True)]),
|
||||
('bss', 'dram0_bss', [Mapping.Surround('sym4', True, True)]),
|
||||
('common', 'dram0_bss', [Mapping.Surround('sym5', True, True), Mapping.Surround('sym6', True, True)])]
|
||||
expected = [('text', 'flash_text', [Mapping.Surround('sym1')])]
|
||||
actual = fragment.flags[('obj1', None, 'default')]
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@ -946,13 +938,13 @@ entries:
|
||||
|
||||
expected = [('text', 'flash_text', [Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Align(8, True, False),
|
||||
Mapping.Sort('name')]),
|
||||
('rodata', 'flash_rodata', [Mapping.Keep(),
|
||||
Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Align(8, True, False),
|
||||
Mapping.Align(4, True, False),
|
||||
Mapping.Sort('name')])]
|
||||
@ -976,11 +968,11 @@ entries:
|
||||
|
||||
expected = [('text', 'flash_text', [Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Sort('name')]),
|
||||
('text', 'flash_text', [Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Sort('name')])]
|
||||
actual = fragment.flags[('obj1', None, 'default')]
|
||||
self.assertEqual(expected, actual)
|
||||
@ -1004,11 +996,11 @@ entries:
|
||||
|
||||
expected = [('text', 'flash_text', [Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Sort('name')]),
|
||||
('text', 'flash_text', [Mapping.Align(4, True, False),
|
||||
Mapping.Keep(),
|
||||
Mapping.Surround('sym1', True, True),
|
||||
Mapping.Surround('sym1'),
|
||||
Mapping.Sort('name')])]
|
||||
actual = fragment.flags[('obj1', None, 'default')]
|
||||
self.assertEqual(expected, actual)
|
||||
|
@ -1410,29 +1410,29 @@ class FlagTest(GenerationTest):
|
||||
#
|
||||
# flash_rodata
|
||||
# *((EXCLUDE_FILE(libfreertos:timers) .rodata ...) C
|
||||
# _sym2_start D.1
|
||||
# _sym2_start D.1
|
||||
# . = ALIGN(4) E.1
|
||||
# KEEP(* (EXCLUDE_FILE(libfreertos:timers) .rodata ...) F
|
||||
# _sym2_end D.2
|
||||
# _sym2_end D.2
|
||||
# . = ALIGN(4) E.2
|
||||
#
|
||||
# iram0_text
|
||||
# *(.iram .iram.*)
|
||||
# . = ALIGN(4) G.1
|
||||
# _sym1_start H.1
|
||||
# _sym1_start H.1
|
||||
# libfreertos.a:croutine(.text .literal ...) I
|
||||
# . = ALIGN(4) G.2
|
||||
# _sym1_end H.2
|
||||
# _sym1_end H.2
|
||||
mapping = u"""
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
croutine (noflash_text);
|
||||
text->iram0_text align(4, pre, post) surround(sym1, pre, post) #1
|
||||
text->iram0_text align(4, pre, post) surround(sym1) #1
|
||||
timers (default);
|
||||
text->flash_text keep sort(name) #2
|
||||
timers (default);
|
||||
rodata->flash_rodata surround(sym2, pre, post) align(4, pre, post) #3
|
||||
rodata->flash_rodata surround(sym2) align(4, pre, post) #3
|
||||
"""
|
||||
|
||||
self.add_fragments(mapping)
|
||||
@ -1475,10 +1475,10 @@ entries:
|
||||
# are included in the flags.
|
||||
#
|
||||
# flash_text
|
||||
# _sym1_start A.1
|
||||
# _sym1_start A.1
|
||||
# KEEP(* (EXCLUDE_FILE(libfreertos:croutine).text ...) B
|
||||
# KEEP(libfreertos.a:croutine(...))) C
|
||||
# _sym1_end A.2
|
||||
# _sym1_end A.2
|
||||
#
|
||||
# iram0_text
|
||||
# *(.iram .iram.*)
|
||||
@ -1494,7 +1494,7 @@ entries:
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
croutine:prvCheckPendingReadyList (noflash_text) #3
|
||||
croutine:prvCheckPendingReadyList (noflash_text) #3
|
||||
"""
|
||||
|
||||
self.generation.mappings = {}
|
||||
@ -1537,10 +1537,10 @@ entries:
|
||||
#
|
||||
# flash_text
|
||||
# *(EXCLUDE_FILE(libfreertos.a).text ...)
|
||||
# _sym1_start A.1
|
||||
# _sym1_start A.1
|
||||
# KEEP(libfreertos.a(EXCLUDE_FILE(libfreertos:croutine).text.* ...)) B
|
||||
# KEEP(libfreertos.a:croutine(...))) C
|
||||
# _sym1_end A.2
|
||||
# _sym1_end A.2
|
||||
#
|
||||
# iram0_text
|
||||
# *(.iram .iram.*)
|
||||
@ -1552,7 +1552,7 @@ entries:
|
||||
# 1
|
||||
* (default);
|
||||
text->flash_text surround(sym1) keep #2
|
||||
croutine:prvCheckPendingReadyList (noflash_text) #3
|
||||
croutine:prvCheckPendingReadyList (noflash_text) #3
|
||||
"""
|
||||
|
||||
self.add_fragments(mapping)
|
||||
@ -1594,9 +1594,9 @@ entries:
|
||||
#
|
||||
# flash_text
|
||||
# *(EXCLUDE_FILE(libfreertos.a).text ...)
|
||||
# _sym1_start A.1
|
||||
# _sym1_start A.1
|
||||
# KEEP(libfreertos.a:croutine(...))) B
|
||||
# _sym1_end A.2
|
||||
# _sym1_end A.2
|
||||
#
|
||||
# iram0_text
|
||||
# *(.iram .iram.*)
|
||||
@ -1608,7 +1608,7 @@ entries:
|
||||
# 1
|
||||
croutine (default);
|
||||
text->flash_text surround(sym1) keep #2
|
||||
croutine:prvCheckPendingReadyList (noflash_text) #3
|
||||
croutine:prvCheckPendingReadyList (noflash_text) #3
|
||||
"""
|
||||
|
||||
self.add_fragments(mapping)
|
||||
@ -1644,9 +1644,9 @@ entries:
|
||||
# Explicit commands are separated from the parent's flags.
|
||||
#
|
||||
# flash_text
|
||||
# _sym1_start A.1
|
||||
# _sym1_start A.1
|
||||
# KEEP(* (EXCLUDE_FILE(libfreertos:croutine).text ...) B
|
||||
# _sym1_end A.2
|
||||
# _sym1_end A.2
|
||||
# KEEP(libfreertos.a:croutine(...))) C
|
||||
#
|
||||
# iram0_text
|
||||
@ -1663,8 +1663,8 @@ entries:
|
||||
[mapping:test]
|
||||
archive: libfreertos.a
|
||||
entries:
|
||||
croutine (default) #3
|
||||
croutine:prvCheckPendingReadyList (noflash_text) #4
|
||||
croutine (default) #3
|
||||
croutine:prvCheckPendingReadyList (noflash_text) #4
|
||||
"""
|
||||
|
||||
self.generation.mappings = {}
|
||||
@ -1706,9 +1706,9 @@ entries:
|
||||
#
|
||||
# flash_text
|
||||
# *(EXCLUDE_FILE(libfreertos.a).text ...)
|
||||
# _sym1_start A.1
|
||||
# _sym1_start A.1
|
||||
# KEEP(libfreertos.a(EXCLUDE_FILE(libfreertos:croutine).text.* ...)) B
|
||||
# _sym1_end A.2
|
||||
# _sym1_end A.2
|
||||
# KEEP(libfreertos.a:croutine(...))) C
|
||||
#
|
||||
# iram0_text
|
||||
|
Loading…
Reference in New Issue
Block a user