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.
In computing, position-independent code (PIC) or position-independent executable (PIE) is a body of machine code that, being placed somewhere in the primary memory, executes properly regardless of its absolute address.
Position Independent Executables (PIE) are an output of the hardened package build process. A PIE binary and all of its dependencies are loaded into random locations within virtual memory each time the application is executed. This makes Return Oriented Programming (ROP) attacks much more difficult to execute reliably.
(Primary Interchange Carrier) The code assigned to interstate and intrastate telephone carriers. When you change your service, the local telephone company has to be notified of the new PIC code in order to switch calls to the appropriate network.
Position-independent code is not tied to a specific address. This independence allows the code to execute efficiently at a different address in each process that uses the code. Position-independent code is recommended for the creation of shared objects.
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....
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With