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

LowFat: Non-Const Global Variables are Placed in Read-Only Memory #1

Open
JungT opened this issue Aug 31, 2022 · 1 comment
Open

LowFat: Non-Const Global Variables are Placed in Read-Only Memory #1

JungT opened this issue Aug 31, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@JungT
Copy link
Member

JungT commented Aug 31, 2022

Problem

Low-Fat Pointers protect global variables by using a custom linker script which ensures that their addresses fulfill alignment and size conditions. For custom linker sections, the linker seems to have a mechanism to determine which attributes the memory this section is assigned to has to have. In case some variables are constant, the linker might determine that the memory is only allocatable, but not writable.
The MemInstrument Low-Fat implementation distinguishes between constant and non-constant global variables (based on attributes), and assigns different sections to them. However, in some cases, the constantness is only determined after the MemInstrument pass by other analyses. This leads to constant and non-constant global variables having the same section assigned. Now the linker seems to decide that this mixed section should be assigned to not-writable memory, and the execution of the code terminates with a segmentation fault.

Behavior

Custom linker sections which contain mixed constant and non-constant global variables might end up being read-only.

Expected Behavior

Custom linker sections which contain mixed constant and non-constant global variables should be writable.

Additional Resources

We wrote a stack overflow question with MWE on how we can influence the behavior of the linker, without having to fully write a custom linker script.

@JungT JungT added the bug Something isn't working label Aug 31, 2022
@JungT JungT self-assigned this Aug 31, 2022
@JungT
Copy link
Member Author

JungT commented Jan 4, 2023

It turned out that this is a bug in the compiler, not our project. LLVM 14 fixes it.

Thank you Alex Shpilkin for providing the answer!

@JungT JungT closed this as completed Jan 4, 2023
@JungT JungT reopened this Jan 4, 2023
@JungT JungT mentioned this issue Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant