I am trying to build curl as shared object executable in pie(position independent executable) mode. So I have added -pie -fPIC to the CFLAGS of MakeFile which was generated by ./configure. But after make and make install, the generated curl executable under /usr/local/bin is still a ELF 64-bit LSB executable. So could someone give an idea on how to generate curl executable in position independent shared object mode? Thanks in advance.
Asked
Active
Viewed 257 times
0
-
It is not really clear what the problem or question is. You should add `-fPIC` to `CFLAGS`; you should not add `-fPIE`. What is the output of `readelf -l /usr/local/bin/curl | grep -i "file type"`? Is it `DYN`? If so, then it is position independent. Maybe you are asking about the libraries in `usr/local/lib`? Also see [Position Independent Executables and Android](https://stackoverflow.com/q/30498776/608639) It answers some basic questions about PIC. – jww May 28 '19 at 08:16
-
@jww Yes I have added -fPIC flag to CFLAGS not -fPIE; And the output of the command is EXEC, not DYN. Is there something else which is causing it to be normal EXEC? Thanks. – Sat_sen May 28 '19 at 08:35
-
What are the commands you are using to pass `CFLAGS` exactly? Also, try `make V=1` to see compiler (and linker) invocations and check whether the options you are trying to pass are present. Do a clean make (in a new directory and/or from a fresh checkout/tarball of cURL). – Vladislav Ivanishin May 29 '19 at 10:40