Linking to a static library and replacing modules
Doug Hardie
bc979 at lafn.org
Fri Nov 22 08:23:01 UTC 2019
I have a collections of modules linked into a static library. These are called from other modules compiled separately from the library. There are 3 stub modules in the library. The point was that they are called by other modules in the library. Often an application need to replace one or more of the stubs with a module that does some real work. In the past the loader just linked the new modules in place of the old one. However, now it seems to be a bit more random. I have one program where it links the way I want. Others the loader returns a duplicate symbol error and dies. I can't find any differences between those two situations. For the time being, I removed the 3 stubs from the library and force the users to include them. It works, but it is not elegant.
How do you build a library such that lld will replace modules in the library if there is a replacement in the user's code? I found a few things that appear to be more Linux based and tried them. None of them worked. I am using FreeBSD 12.1.
-- Doug
More information about the freebsd-questions
mailing list