Reputation: 433
We carried out an exercise to stop using --start-group and --end-group for static linking unless it is absolutely necessary. We had this used unconditionally, whether or not the static libs in question have circular dependencies or not. I understand the linker is less stressed after we took out the unconditional --start-group and --end-group but place it only where it is really necessary.
I want to know the significance of these options for the dynamic linked libraries.
How does the ld.so runtime loader resolve the circular dependencies, if there are any, with the dynamic libraries?
That raises another question, should we really be worried about the --start-group and --end-group usage with Dynamic Libraries at all?
To be honest, I haven't read enough about this yet, but I thought it is okay to ask here.
Upvotes: 3
Views: 5358
Reputation: 16441
Dynamic libraries, unlike static libraries, are loaded even if they provide no useful symbols. This makes the order much less relevant.
With static libraries, the wrong order can lead to required libraries, or objects within a .a
file, not to be taken, even if they're later needed. This is what --start-group
and --end-group
solve.
With dynamic libraries, both orders work. Suppose liba.so
exports a
and libb.so
requires it. If liba.so
is loaded first, then when libb.so
is loaded, it will use it. If libb.so
is loaded first, then a
will be unresolved for a while, until liba.so
is loaded. Either way, it works.
Upvotes: 6