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

Consider rewriting Sancus LLVM pass as a GCC plugin #8

Open
jovanbulck opened this issue Jun 28, 2017 · 3 comments
Open

Consider rewriting Sancus LLVM pass as a GCC plugin #8

jovanbulck opened this issue Jun 28, 2017 · 3 comments

Comments

@jovanbulck
Copy link
Member

jovanbulck commented Jun 28, 2017

Currently, sancus-cc is implemented as an LLVM pass that prepares SMs for sancus-ld by:

  1. Placing SM_ENTRY/SM_FUNC code and SM_DATA data in respectively .text.sm.name.text and .sm.name.data ELF sections

  2. Replacing inter-protection domain function calls with custom asm stubs that call to the corresponding sm_entry/exit/verify stubs.

  3. Creating an entry function table with (adrs, args_len, ret_len) for use by sm_entry.

Since the MSP430 LLVM back-end generates inferior code, we should investigate the feasibility of doing the above in a GCC plugin. We then could benefit from the clean, stable, and fast code generated by MSP430GCC.

Note that sancus-cc is our only dependency on LLVM/Clang, for sancus-ld already uses MSP430GCC.

@jovanbulck
Copy link
Member Author

@pmaene also had an idea of implementing the entire Sancus pass inside the sancus-ld Python script by:

  1. Annotating C source code with the GCC section attrribute
  2. Patching ELF relocation target addresses to instrument inter-SM calls

A bit hacky of course, but to be considered if we ever need it..

@jovanbulck
Copy link
Member Author

Another quick note: we might also want to consider using the ROSE source-to-source compiler infrastructure to implement a dedicated precompiler that can take care of some of the stuff above.

@jovanbulck
Copy link
Member Author

We could possibly also develop a GCC plugin in MELT or GCC-Python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant