What is the PIC level in program compilation?

I am looking at LLVM libraries, and I realized that Clang emits LLVM IR modules, adding this metadata:

!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)"} 

Then I found out that calling the setPICLevel() method in a module gets a similar result:

 !0 = !{i32 1, !"PIC Level", i32 0} 

Thus, all !0 metadata refers to the PIC level.

I searched it on the Internet, but found nothing. What is this PIC level and what does it indicate?

+5
source share
1 answer

This is a flag that applies only to PowerPC and is otherwise ignored. He sets up a model for position-independent code for both small and large models. Of course, in other architectures there may be a PIC, but this flag represents the size if the model is not used elsewhere.

You could see the commit where it was first added to LLVM: http://comments.gmane.org/gmane.comp.compilers.llvm.cvs/205216

Additional Information:

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

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

+5
source

All Articles