gprolog icon indicating copy to clipboard operation
gprolog copied to clipboard

Ma2Asm for linux x64 with gcc is not generating PIC code (v1.5.0+)

Open gusbro opened this issue 1 year ago • 0 comments

In this commit 6d96e05d92c150232ca25d341e2cc01b911f10fd in src/Ma2Asm/x86_64_any.c circa lines 238-241 the assignment pic_code = TRUE; was changed to pic_code = FALSE; where it explicitly comments that /* gcc >= 6 needs PIC for linux */ Therefore when using linux x64, ma2asm is not generating PIC code anymore.

Afterwards when linking a shared library using gprolog libs the linker complains that the code is not PIC: /usr/bin/ld: /usr/local/gprolog-1.6.0/lib/libbips_pl.a(foreign.o): relocation R_X86_64_PC32 against symbol 'X1_24666F7263655F666F726569676E5F6C696E6B__a0' can not be used when making a shared object; recompile with -fPIC

This assignment is executed after processing arguments so it cannot be overriden by --pic command line argument.

Tested with v1.6.0rc but the commit also appears in v1.5.0

gusbro avatar Jan 12 '24 18:01 gusbro