3 ms·
There was a comment more than ten years back on gcc-help by Ian Lance Taylor, author of gold and the gnu linkers: Passing commands directly to the linker req
by CalChris 9y ago
There was a comment more than ten years back on gcc-help by Ian Lance Taylor, author of gold and the gnu linkers:
Passing commands directly to the linker requires
that you know what you are doing.
I added this to my makefiles. It doesn't make the linker work any better. But it does make me think a little harder about what the linker is doing with my incantations.
Linker scripts [1] are a particular pain to get write and if you want to do something complicated on Linux or BSD, you'll be using linker scripts. These are a gnu linker thing. The OSX linker doesn't have the same. Indeed, linkers are different or duplicated on each platform.
gnu ld
osx ld
gold ld (Google)
lld (llvm)
whatever Windows uses because I don't know
...
I'm not embarrassed to admit this: I get my linker command lines and scripts working and that's about it. But linkers should be easier to understand and use. There is even a security bug that relies on our not understanding them [2].
I can't sugar coat this: linkers are a pain. Taylor is right when he says Passing commands directly to the linker requires that you know what you are doing.
[1] https://sourceware.org/binutils/docs/ld/Scripts.html https://sourceware.org/binutils/docs/ld/Scripts.html
[2] http://www.cse.psu.edu/~trj1/papers/ndss17.pdf http://www.cse.psu.edu/~trj1/papers/ndss17.pdf