Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between pic Vs pie [duplicate]

Tags:

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.

like image 494
Vineet1982 Avatar asked Apr 15 '13 19:04

Vineet1982


People also ask

What is PIC and pie?

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.

What is a pie executable?

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.

What is a PIC code?

(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.

What is position independent code and why is it useful?

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.


1 Answers

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....

like image 133
Carl Norum Avatar answered Oct 07 '22 03:10

Carl Norum