On SUSE 15 "-no-pie" option doesn't work with GCC

Hi There,

We are trying to create a non-pie enabled binary. By default GCC version 7 on SUSE machine produces a PIE enabled binary. Hence to disable that we use flag “-no-pie” as mentioned in GCC man page but its failing. The only option works is if we use “-fno-pie”. Can anyone explain this difference? which option is right to be used?

We get the following highlighted red font error when “-no-pie” option is used while linking the binary.

fnpauto@linux-wwft:~/samrin/x64_lsb> gcc -fno-pie -c sample.c
fnpauto@linux-wwft:~/samrin/x64_lsb> gcc -no-pie -o final sample.o
[COLOR=#ff0000]/usr/lib64/gcc/x86_64-suse-linux/7/…/…/…/…/x86_64-suse-linux/bin/ld: sample.o: relocation R_X86_64_32 against `.rodata’ can not be used when making a PIE object; recompile with -fPIC
/usr/lib64/gcc/x86_64-suse-linux/7/…/…/…/…/x86_64-suse-linux/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status

[/COLOR]If we use “-fno-pie” then no error is seen and the binary is build successfully as mentioned below
fnpauto@linux-wwft:~/samrin/x64_lsb> gcc [COLOR=#008000]-fno-pie[/COLOR] -c sample.c
fnpauto@linux-wwft:~/samrin/x64_lsb> gcc [COLOR=#008000]-fno-pie[/COLOR] -o final sample.o
fnpauto@linux-wwft:~/samrin/x64_lsb> file final
final: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=d3a8a098def6362354b308cfbeb570168f90f57a, with debug_info, not stripped

Any help would be really appreciated.

Thanks