sancus-tee / sancus-compiler

Secure compilation of annotated C code to Sancus enclaves
GNU General Public License v3.0
6 stars 7 forks source link

Inline intra-SM multiplications #6

Closed jovanbulck closed 7 years ago

jovanbulck commented 7 years ago

The MSP430 does not feature native instructions for multiplication/division/modulo operations. These are translated to library function calls by the architecture-specific MSP430 back-end.

Problem. The sancus-cc pass proceeds on the architecture-agnostic LLVM intermediate representation and can therefore not intercept the library function calls, which are later inserted by the back-end.

Solution. Intercept the arithmetic function calls at link time in the sancus-ld script. The target relocation address of these function calls can be redirected to an intra-SM stub by directly patching the binary ELF file.

jovanbulck commented 7 years ago

Feature has been implemented in the above commit. For future reference:

http://wiki.osdev.org/ELF_Tutorial#Relocation_Sections