3

If I don't use -fPIC flag while compiling a shared library, will it really matter? Will it affect the way loader loads it into process's address space?

Jack
  • 741
  • 1
  • 8
  • 25
  • 1
    http://stackoverflow.com/questions/5311515/gcc-fpic-option – Oleg Olivson Sep 20 '13 at 09:52
  • @oleg Thanks. From the link it looks like, it will create a problem only when i have multiple shared libraries which is the case most of the times. – Jack Sep 20 '13 at 10:07
  • 2
    If you compile without -fPIC flag, you'll probably have a lot of broken adresses (pointing out of library memory space) in library. So all adresses have to be relative (with -fPIC flag). – Oleg Olivson Sep 20 '13 at 10:12
  • 1
    http://www.agner.org/optimize/optimizing_cpp.pdf, p.151. -- 14.12 Position-independent code. It contains a discussion about PIC, PLT, GOT – Konstantin Burlachenko Sep 06 '17 at 17:00

0 Answers0