[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Ch.10.2 Libraries - shared lib compilation - -fPIC



On Thu, 2019-05-23 at 10:50 +0000, Dudziak Krzysztof wrote:
> I have troubles on comprehending following statement
> "If the package is architecture: any, then the shared library compilation and linking flags must have -fPIC.."
> Cit. Debian Policy, chapter 10.2, https://www.debian.org/doc/debian-policy/ch-files.html#s-libraries
> 
> I have little to zero shared libraries expertise. All I was lucky to learn about shared libraries
> was with GNU libtool, GNU autotools, pkgconf in background.
> 
> Isn't it that way for shared libraries IN GENERAL to need be compiled as position-independent code
> then linked as such ?

No, one could also register the virtual addresses for all shared
libraries in a central database and make sure they don't conflict. 
That was the case for the ancient a.out binary format:

+---
| Linux's transition to ELF was more or less forced due to the complex
| nature of building a.out shared libraries on that platform, which
| included the need to register the virtual address space at which the
| library was located with a central authority, as the a.out ld.so in
| Linux was unable to relocate shared libraries.
+---[ https://en.wikipedia.org/wiki/A.out ]

I wouldn't be surprised if this reference to `-fPIC` comes from the
time of switching from a.out to ELF in the last millenium; it could
probably be removed.

Ansgar


Reply to: