1

I am using a processor that uses sparc v8 architecture. I would like to compile my executable such that each function call is absolute address. Using -fPIC option generate position independent code, is there any reverse of this flag ?

zephyr0110
  • 223
  • 1
  • 11

1 Answers1

2

Most of GCC options have both -fxxx and -fno-xxx variants.

You can easily test if this is the case for fPIC. Just compile some simple test:

int main () { printf ("Hello, world!\n"); }

with command line like:

gcc -fPIC test.c -S

and look for PLT-relative call in assembler

    call    puts@PLT

Now try to cancel this option with its reverse:

gcc -fPIC test.c -S -fno-PIC

You will see, that PLT-relative call has gone, so everything works.

Konstantin Vladimirov
  • 6,791
  • 1
  • 27
  • 36
  • Oh I see. The sparc v8 Instruction set has two instructions for jumping. "call" for relative jump and "jmpl" for absolute jump. So it must be possible to generate code with absolute jumps. I tried just now with the sparc gcc with -fno-pic. Even though code compiles it still generates pic code. Do I need to pass this flag to linker also ? – zephyr0110 Apr 27 '17 at 08:31
  • No, just compiler option. There is difference between fno-PIC and fno-pic (large and small mode). Check compiler line: canceling option shall go last and be in the same case. – Konstantin Vladimirov Apr 27 '17 at 09:15