-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scripts: code_relocate: support section filter #74402
base: main
Are you sure you want to change the base?
Conversation
One might want to select the symbols to be relocated inside a file or a library. To do this, one can use the FILTER argument of zephyr_code_relocate which must contain a regular expression of the section names to be selected for relocation. Signed-off-by: Sylvain Chouleur <sylvain.chouleur@gmail.com>
@tejlmand can you take a look please? |
# Replace pipes used in symbol filter regular expression | ||
input_rel_dict = input_rel_dict.replace("\\|", "##PIPE##") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the |
is used widely in regex'es, so it's natural to support them directly, but going through this substitution seems less than optimal to me.
This PR #60999 changed the input relocation argument from being a string to be a file.
Being a file actually means that there is no reason for a single string because a file can be multi-line.
I suggest to make a #60999 follow-up commit which remove the use of |
as separator and instead create a multi-line input file.
Doing so will free the use of |
and thereby remove the need for special handling in the regex.
@@ -514,12 +520,13 @@ def parse_input_string(line): | |||
phdr, rest = rest.split(':', 1) | |||
|
|||
# Split lists by semicolons, in part to support generator expressions | |||
flag_list, file_list = (lst.split(';') for lst in rest.split(':', 1)) | |||
flag_list, file_list, symbol_filter = (lst.split(';') for lst in rest.split(':', 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails on windows, most likely because drive letters contains :
.
c:/users/torsten/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(test_file1.c.obj): in function `code_relocation_test_function_in_sram2':
C:/projects/github/ncs/zephyr/tests/application_development/code_relocation/src/test_file1.c:80: undefined reference to `__sram2_data_reloc_start'
c:/users/torsten/zephyr-sdk-0.16.8/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: C:/projects/github/ncs/zephyr/tests/application_development/code_relocation/src/test_file1.c:80: undefined reference to `__sram2_data_reloc_end'
....
Also note the existing warning in this script:
zephyr/scripts/build/gen_relocate_app.py
Line 508 in 878640f
# Be careful when splitting by : to avoid breaking absolute paths on Windows |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tejlmand do you have a way to test on windows without windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately not.
Hi @carlescufi |
One might want to select the symbols to be relocated inside a file or a library.
To do this, one can use the FILTER argument of zephyr_code_relocate which
must contain a regular expression of the section names to be selected for relocation.
This pull-request covers the issue #64148
About the dependency on -ffunction-sections and -fdata-sections flags, those are enabled by default in arch/common//home/schouleur/GML/zephyr_upstream/zephyr/arch/common/CMakeLists.txt:37
In case the flags are not enabled, this feature can also be used to select some specific sections.