Skip to content
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

linker: move scripts generated code at the beginning of .text #17185

Merged
merged 3 commits into from
Jul 18, 2019

Conversation

wentongwu
Copy link
Contributor

1) When code relocation enabled, there will be serval regions holding
text. And then there will be function call between these .text
regions, when distance between caller and callee is too far, linker
will automatically generate and insert veneer functions. And these
veneer functions will be located right after the last instruction
in the .text region by the linker. So these code will be put in the
memory reserved for priv_stacks text and kobject text if they don't
consume all the reserved memory. Or the veneer functions will be put
before the reserved memory if there isn't code in the reserved
memory. And then in the user mode building process, there will be
different memory layout and it will cause usr mode not working.
And moving the memory reserved for priv_stacks text and kobject text
at the beginning of .text will avoid above problem. The detailed
analysis for this issue can be found on Github issue #17038.

2) make mpu align inside sections instead of outside to avoid
overlap for code relocation feature.
3) fix spell typo in target_relocation.cmake

Fixes: #17038.

wentongwu added 3 commits July 2, 2019 00:42
When code relocation enabled, there will be serval regions holding
text. And then there will be function call between these .text
regions, when distance between caller and callee is too far, linker
will automatically generate and insert veneer functions. And these
veneer functions will be located right after the last instruction
in the .text region by the linker. So these code will be put in the
memory reserved for priv_stacks text and kobject text if they don't
consume all the reserved memory. Or the veneer functions will be put
before the reserved memory if there isn't code in the reserved
memory. And then in the user mode building process, there will be
different memory layout and it will cause usr mode not working.
And moving the memory reserved for priv_stacks text and kobject text
at the beginning of .text will avoid above problem. The detailed
analysis for this issue can be found on Github issue zephyrproject-rtos#17038.

Fixes: zephyrproject-rtos#17038.

Signed-off-by: Wentong Wu <[email protected]>
make mpu align inside sections instead of outside to avoid
overlap for code relocation feature.

Signed-off-by: Wentong Wu <[email protected]>
fix spell typo in target_relocation.cmake.

Signed-off-by: Wentong Wu <[email protected]>
@wentongwu wentongwu requested review from marc-hb, andyross and a user July 2, 2019 21:22
@wentongwu
Copy link
Contributor Author

@andrewboie @ioannisg could you please take a look this patch? thanks

@nashif nashif merged commit be2c937 into zephyrproject-rtos:master Jul 18, 2019
@backporting
Copy link

backporting bot commented Jul 23, 2019

The backport to v1.14-branch failed:

Commits ["4fd2136072c2b9efb3c57da2b39918dc875846d8","5b7711dc463a2b0f43a6d46192684dd2fe74463e","8386e3e8a7fe4a15459edd226ca5aad4c6050389"] could not be cherry-picked on top of v1.14-branch

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub.
git fetch
# Create new working tree.
git worktree add .worktrees/backport v1.14-branch
# Navigate to the new directory.
cd .worktrees/backport
# Cherry-pick all the commits of this pull request and resolve the likely conflicts.
git cherry-pick 4fd2136072c2b9efb3c57da2b39918dc875846d8 5b7711dc463a2b0f43a6d46192684dd2fe74463e 8386e3e8a7fe4a15459edd226ca5aad4c6050389
# Create a new branch with these backported commits.
git checkout -b backport-17185-to-v1.14-branch
# Push it to GitHub.
git push --set-upstream origin backport-17185-to-v1.14-branch
# Go back to the original working tree.
cd ../..
# Delete the working tree.
git worktree remove .worktrees/backport

Then, create a pull request where the base branch is v1.14-branch and the compare/head branch is backport-17185-to-v1.14-branch.

@nashif
Copy link
Member

nashif commented Aug 16, 2019

@wentongwu This needs to be backported manually.

@wentongwu
Copy link
Contributor Author

wentongwu commented Aug 16, 2019

@wentongwu This needs to be backported manually.

@nashif I have backported it, see #17906

@wentongwu wentongwu deleted the no-flash branch September 20, 2019 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

code relocation generating different memory layout cause user mode not working
6 participants