ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The ar command doesn't do anything to the internal content of any files it's putting into or taking out of an archive. So use ar with confidence to create libraries, make single copies of files that existed in libraries, and rename those single copies to your heart's content.
The ar command doesn't do anything to the internal content of any files it's putting into or taking out of an archive. So use ar with confidence to create libraries, make single copies of files that existed in libraries, and rename those single copies to your heart's content.
Good point. Although my original statement is correct, I'm afraid it isn't very helpful; sorry about that.
I've done some googling about your question (and I'm sure you did, too). I don't find anything very helpful.
If I were in your position and I had copious amounts of free time, I would look into the source for the linker, and see whether the building of a shared library removes information which would be necessary to work backwards to the original .a files from a .so file. If no such information is removed, I would write a quick and dirty utility to go in the direction you desire. If it is removed, you're out of luck.
I've never heard about a possibility to do so. I also can't imagine it working since shared objects are some form of executable files, while static libs are collections of objects/functions, so the question would be if they are even able to have the necessary informations to recreate the object files.
Another things that question the plausibility to me is when you think about shared objects that for themselves have dependencies on other shared objects and those too, etc. ... would such a roundtrip make sense ?
I'm genuinely curious too though, so if anyone can give a definitive 'Yes' or 'No', please do so.
I've never heard about a possibility to do so. I also can't imagine it working since shared objects are some form of executable files, while static libs are collections of objects/functions, so the question would be if they are even able to have the necessary informations to recreate the object files.
Another things that question the plausibility to me is when you think about shared objects that for themselves have dependencies on other shared objects and those too, etc. ... would such a roundtrip make sense ?
I'm genuinely curious too though, so if anyone can give a definitive 'Yes' or 'No', please do so.
The item in bold is not quite correct WRT the thread.
For example,
Code:
objdump -d /lib/libz.so.1
happily works on my machine.
And remember, linker ('ld') easily gets satisfaction (== resolves symbols) both in case of .a and .so file, though in the latter case final binding occurs during runtime.
Also, .so files are bigger than the same .a file.
So, I think, .so files contains all the info needed to create a .a file plus more.
...
Maybe 'objcopy' can do the job in a number of passes - haven't tried 'objcopy' at all yet.
Well isn't that more like a special case ? I was talking about straight dynamic libraries (ELF for example), which don't necessarily need to contain all symbol informations.
Well isn't that more like a special case ? I was talking about straight dynamic libraries (ELF for example), which don't necessarily need to contain all symbol informations.
Of course, if a file does not contain all symbol information, it can't be used for linking, but this is not what this thread is about.
If a shared object doesn't have all symbols as info doesn't mean it's not linkable, so that's not correct to say I'm afraid. It would be kinda useless if it wasn't linkable, wouldn't it ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.