Hacker News new | past | comments | ask | show | jobs | submit login

So happy to see progress in linkers!

Can this one statically link shared libraries? That would be a great feature.

EDIT: I realize that such a feature would necessarily involve a fair amount of black magic. But it does not seem an impossible endeavor.




Are you asking if mold can link an executable file and its depending .so files into a single binary? If so, neither mold nor other major linkers can't do that.


Exactly. That would be a pretty big deal and definitely a killer feature. Equivalently, a tool for converting .a to .so


> Equivalently, a tool for converting .a to .so

Well, an .a file is just an archive of object files. Turning several object files into a single binary is pretty much what a linker does. However, you can't really automate this because object files might have external dependencies and the linker needs to know what these dependencies are.


> you can't really automate this because object files might have external dependencies and the linker needs to know what these dependencies are

If it can be done at runtime of the program, I guess it can be done at runtime of the linker, doesn't it?


Technically, Linux and macOS allow to build a shared library with undefined symbols and let the loader figure it out, but I wouldn't recommend it (it's easy to miss linker errors). On Windows, however, this is not possible.

EDIT: also, building with unresolved symbols requires the host application to know about and link all the required external libraries, which is usually not what you want...


Yeah I have the same question. lld can list the dependencies right?


Yes, because someone put them there ;-)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: