Difference between pic Vs pie

Vineet1982 picture Vineet1982 · Apr 15, 2013 · Viewed 26.5k times · Source

I am looking the options for Binary Encryption Code generation and found two options available that are PIC and PIE. I have tried for find the differences between both but didn't find suitable articles. If anybody can explain the difference with example with pros and corn or provide the link to the good article would be great to learn.

My basic motive is to protect the compiled code as ELF/PE format can be attacked by virus or it can be hacked or with the help of reverse techniques can re-produce code. Kindly also provide any other means for protection of compiled code from attacks and d-compling.

I am using GCC Compiler through Cygwin for building cross platform application.

Answer

Carl Norum picture Carl Norum · Apr 15, 2013

From the gcc documentation:

-fpic
Generate position-independent code (PIC) suitable for use in a shared library...

-fpie
These options are similar to -fpic and -fPIC, but generated position independent code can be only linked into executables....