What does the CodeModel in Clang / LLVM refer to?

喜夏-厌秋 提交于 2020-07-03 03:16:08

问题


I have been looking through the Clang / LLVM source-code and I came across the CodeModel property of CodeGenOptions.

Based on this method, the valid values appear to be: "small", "kernel", "medium" and "large".

What do this property control?

How do I go about choosing the correct value for my application?


回答1:


Code model is a term from AMD64 ABI (see 3.5.1 from https://software.intel.com/sites/default/files/article/402129/mpx-linux64-abi.pdf for more information).

In short - the majority of the offsets inside x64-64 instructions are PC-relative, however the immediate field inside instructions is only 32-bit long. Therefore if the data is located "far" from the code (more than 32-bit apart), then one could not use immediate field inside the instructions to efficiently encode the offset and should calculate the address explicitly. The code model provides various restrictions on the relative location of code and data.

If you're compiling everything statically, then 'small' is safe (and default). If you're JIT'ing, then everything is possible especially if ASLR is enabled and you'd need to use medium / large code model.



来源:https://stackoverflow.com/questions/40493448/what-does-the-codemodel-in-clang-llvm-refer-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!