程序编译中的PIC级别是多少?

NoI*_*Guy 5 c++ llvm clang llvm-ir

我正在查看LLVM库,我发现Clang发出了添加此元数据的LLVM IR模块:

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"PIC Level", i32 2}
!1 = !{!"Apple LLVM version 7.3.0 (clang-703.0.31)"}
Run Code Online (Sandbox Code Playgroud)

然后我发现setPICLevel()在模块上调用方法会得到类似的结果:

!0 = !{i32 1, !"PIC Level", i32 0}
Run Code Online (Sandbox Code Playgroud)

所以整个元数据!0都是关于PIC级别的.

我一直在互联网上搜索它,但我一无所获.什么是PIC级别,它表示什么?

bod*_*gly 5

它是仅适用于PowerPC的标志,否则将被忽略.它将与位置无关的代码模型设置为小型或大型模型.其他体系结构当然可以有PIC,但是如果模型不适用于其他地方,则该标志表示大小.

您可以看到它首次添加到LLVM的提交:http://comments.gmane.org/gmane.comp.compilers.llvm.cvs/205216

更多信息:

https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/dynamic_code.html

https://en.m.wikipedia.org/wiki/Position-independent_code