On Thu, Jul 9, 2020 at 1:51 AM Peter Lamby via Gcc-help <gcc-help@xxxxxxxxxxx> wrote: > export CFLAGS=-pipe -march=native -fstack-protector-strong -fno-plt \ > -pie -fpie You can't use -pie when linking a shared library. So this isn't going to work. Also the -fno-plt is suspicious. Can you compile a shared library without plts? The -fpie is clearly wrong too. You need to do this a different way. Note that gcc has a configure option --enable-default-pie which will produce pie output by default, but won't pass -pie to the linker with -static, -shared, or -r. And won't add -fpie if -fpic was specified. rohan:2242$ gcc -shared -fpic -o tmp.so tmp.c rohan:2243$ gcc -shared -fpic -o tmp.so tmp.c -pie /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status rohan:2244$ Jim