-
Notifications
You must be signed in to change notification settings - Fork 7k
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
scripts: code_relocate: support section filter #74402
Conversation
@tejlmand can you take a look please? |
scripts/build/gen_relocate_app.py
Outdated
# 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.
scripts/build/gen_relocate_app.py
Outdated
@@ -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 |
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
@schouleu it's been a while, would you mind if we take over the PR? |
@schouleu would you mind if we take over your PR as per the process described here: |
Sure, go ahead |
7f75913
to
0545d26
Compare
31cfd0d
to
b8e5f54
Compare
PR rebased and updated in following areas:
|
b8e5f54
to
78e7519
Compare
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.
78e7519
to
ebc6ae5
Compare
Extended the This is now fixed, together with the new, non-relocated, function. |
With code relocation directives passed to the gen_relocate_app.py script using generated file, then each directive can be place on individual line in the file and thus free up the `|` character as separator. Furthermore, a multi-line file with each directive on separate line is also more user-readable, making debugging easier. Signed-off-by: Torsten Rasmussen <[email protected]>
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. The test_function_in_sram2 test case in `tests/application_development/code_relocation` has been updated to verify that only one function `function_in_sram()` is relocated to ram and that the function `function_not_relocated()` is not being relocated when using relocation filter. Signed-off-by: Sylvain Chouleur <[email protected]> Signed-off-by: Torsten Rasmussen <[email protected]>
ebc6ae5
to
416e531
Compare
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.