I would like to create file-12.o
by linking/loading two files, file-1.o
and file-2.o
so that function references in file-1.o
that can be resolved by symbols in file-2.o
are resolved, but leaving other symbols to be resolved in a subsequent load.
Is this possible? I'm using the gnu toolchain on linux (ubuntu 18.04).
I have tried using ld -r -o file-12.o file-1.o file-2.o
but the function calls (as seen by objdump -S) are not resolved, i.e., the callq instruction still shows e8 00 00 00 00
.
This What is Partial Linking in GNU Linker? seems to indicate that it's not possible, or at least this author didn't know how to ("This also taught me that GCC does not resolve function calls before the final link either TODO rationale, possible to force it to resolve?")
As a little background, I'm trying to link to hdr_histogram in a node 11/12 environment. As part of the Performance Hooks they started using hdr_histogram and my node addon is linking to the node version as opposed to the library I wish to link. So if you know a way for node-gyp to prioritize my library in front of the node library in linking priority that solution would work for me too.