mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
fix(ldgen): enable default name SORT in linker fragment
Currently, the `SORT` flag mandates the inclusion of at least the `sort_by_first` argument in the grammar, despite the documentation[1] indicating that `SORT` can be utilized without any arguments, defaulting to sorting input sections by name. Fix this by modifying the grammar to allow a default `SORT` and update a test accordingly. [1] https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/ linker-script-generation.html Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
parent
050730e8c0
commit
b56d53dfb8
@ -1,13 +1,34 @@
|
|||||||
#
|
#
|
||||||
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
from typing import Any
|
||||||
|
from typing import Dict
|
||||||
|
from typing import List
|
||||||
|
from typing import Optional
|
||||||
|
from typing import Set
|
||||||
|
from typing import Tuple
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
from typing import Any, Dict, List, Optional, Set, Tuple, Union
|
from pyparsing import alphanums
|
||||||
|
from pyparsing import alphas
|
||||||
from pyparsing import (Combine, Forward, Group, IndentedBlock, Keyword, LineEnd, Literal, OneOrMore, Opt,
|
from pyparsing import Combine
|
||||||
ParseFatalException, SkipTo, Suppress, Word, ZeroOrMore, alphanums, alphas, delimited_list,
|
from pyparsing import delimited_list
|
||||||
nums, rest_of_line)
|
from pyparsing import Forward
|
||||||
|
from pyparsing import Group
|
||||||
|
from pyparsing import IndentedBlock
|
||||||
|
from pyparsing import Keyword
|
||||||
|
from pyparsing import LineEnd
|
||||||
|
from pyparsing import Literal
|
||||||
|
from pyparsing import nums
|
||||||
|
from pyparsing import OneOrMore
|
||||||
|
from pyparsing import Opt
|
||||||
|
from pyparsing import ParseFatalException
|
||||||
|
from pyparsing import rest_of_line
|
||||||
|
from pyparsing import SkipTo
|
||||||
|
from pyparsing import Suppress
|
||||||
|
from pyparsing import Word
|
||||||
|
from pyparsing import ZeroOrMore
|
||||||
|
|
||||||
|
|
||||||
class Empty:
|
class Empty:
|
||||||
@ -227,11 +248,11 @@ class Sort(EntryFlag):
|
|||||||
_keywords = Keyword('name') | Keyword('alignment') | Keyword('init_priority')
|
_keywords = Keyword('name') | Keyword('alignment') | Keyword('init_priority')
|
||||||
SORT = (Keyword('SORT').suppress()
|
SORT = (Keyword('SORT').suppress()
|
||||||
+ Suppress('(')
|
+ Suppress('(')
|
||||||
+ _keywords.set_results_name('first')
|
+ Opt(_keywords.set_results_name('first')
|
||||||
+ Opt(Suppress(',') + _keywords.set_results_name('second'))
|
+ Opt(Suppress(',') + _keywords.set_results_name('second')))
|
||||||
+ Suppress(')'))
|
+ Suppress(')'))
|
||||||
|
|
||||||
def __init__(self, first: str, second: Optional[str] = None):
|
def __init__(self, first: Optional[str] = None, second: Optional[str] = None):
|
||||||
self.first = first
|
self.first = first
|
||||||
self.second = second
|
self.second = second
|
||||||
|
|
||||||
@ -244,7 +265,7 @@ class Sort(EntryFlag):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse(toks):
|
def parse(toks):
|
||||||
return Sort(toks.first, toks.second or None)
|
return Sort(toks.first or None, toks.second or None)
|
||||||
|
|
||||||
|
|
||||||
class Flag:
|
class Flag:
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -706,6 +705,7 @@ entries:
|
|||||||
archive: libmain.a
|
archive: libmain.a
|
||||||
entries:
|
entries:
|
||||||
obj1 (default);
|
obj1 (default);
|
||||||
|
text->flash_text SORT(),
|
||||||
text->flash_text SORT(name),
|
text->flash_text SORT(name),
|
||||||
rodata->flash_rodata SORT(alignment),
|
rodata->flash_rodata SORT(alignment),
|
||||||
data->dram0_data SORT(init_priority),
|
data->dram0_data SORT(init_priority),
|
||||||
@ -718,7 +718,8 @@ entries:
|
|||||||
fragment_file = parse_fragment_file(test_fragment, self.sdkconfig)
|
fragment_file = parse_fragment_file(test_fragment, self.sdkconfig)
|
||||||
fragment = fragment_file.fragments[0]
|
fragment = fragment_file.fragments[0]
|
||||||
|
|
||||||
expected = [Flag('text', 'flash_text', [Sort('name')]),
|
expected = [Flag('text', 'flash_text', [Sort()]),
|
||||||
|
Flag('text', 'flash_text', [Sort('name')]),
|
||||||
Flag('rodata', 'flash_rodata', [Sort('alignment')]),
|
Flag('rodata', 'flash_rodata', [Sort('alignment')]),
|
||||||
Flag('data', 'dram0_data', [Sort('init_priority')]),
|
Flag('data', 'dram0_data', [Sort('init_priority')]),
|
||||||
Flag('bss', 'dram0_bss', [Sort('name', 'alignment')]),
|
Flag('bss', 'dram0_bss', [Sort('name', 'alignment')]),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user