[Vm-dev] IMPORTANT: GCC 6 generates position independent executables by default on Linux
btc at openinworld.com
Tue Feb 21 13:06:31 UTC 2017
On Tue, Feb 21, 2017 at 1:23 PM, Ronie Salgado <roniesalg at gmail.com> wrote:
> Correction: this is not because of GCC, but because of Ubuntu 16.10. The same happens with GCC 5
> 2017-02-21 0:35 GMT-03:00 Ronie Salgado <roniesalg at gmail.com>:
>> I was debugging a strange crash when calling sqrt via a Lowcode instruction in the interpreter, which I tracked to currentBytecode stored in register(EBX), having a very large value. When debugging the generated assembly code with GDB, I noticed that GCC was generating position independent code and using EBX for doing a call without spilling/unspilling its value.
>> By googling, it seems that position independent executable generation was turned on GCC 6 by default ( https://www.open-mesh.org/issues/304 ). To disable PIE, we have to compile the sources with -fno-pie and link with the -no-pie options.
Would that only be applicable to 32-bit?
To familiarise myself with these concepts I found this a good
explanation of Position Independent Code...
which says it "... will explain only how PIC works on x86, picking
this older architecture specifically because (unlike x64) it wasn't
designed with PIC in mind, so implementing PIC on it is a bit trickier
... Some non-Intel architectures like SPARC64 force PIC-only code for
shared libraries, and many others (for example, ARM) include
IP-relative addressing modes to make PIC more efficient. Both are true
for the successor of x86, the x64 architecture."
and the sister article on Load Time Relocation...
says "... some modern systems (such as x86-64) no longer support
and at the bottom here describes why -nopic on 64-bit requires -mcmodel=large.
More information about the Vm-dev