How might a multitude of independent programs be consolidated (similarly to busybox) into a library such that symbols don't collide and the original programs can be "called" without the OS overhead of a new process invocation?
-
Given a variety of programs where the source code is available, how might these programs be consolidated into a single library (or executable) such that the original programs can be invoked from within a C function without the overhead of a fork or new program execution? Since most of the programs would include their own main () function for instance then it would be important to individualise that function and make it different for each program (at a minimum). And maybe there can be some standard interface to "invoke" each program (a calling convention that maps the provided command line arguments into the argc and argv that the original main function would expect). Similarly, those original set of programs may have colliding function names and methods and so there would be a need to keep those separate. Keeping the overall program size down is less of a priority compared to avoiding the overhead of process execution or forking, but there is definitely room for further tweaking. And the simple case would be one where the programs are individual C files, but potentially this question can be applied to more complicated executables which rely upon local libraries and dependencies. Could even this be automated? It seems challenging enough for example to provide a standard way to build statically or resolve dependencies, but maybe the technologies that already attempt to do this could be of use in solving the problem. I'm wondering: would the source code need to be modified? Are there standard ways to translate the function names to be distinct for a certain isolated program? Certainly in some cases (for example, shared libraries), the symbol names would need to be unique or there would be some logic to getting at the right function given the name. The environment in consideration is Linux but another UNIX-based OS could work too. Would the fact that a fair amount of the programs come with a configure script or where the build environment can be specified through an autogen process be of any use? Are there flags in the linker that could be of help here? And could a library (or even an existing executable) be dropped in here to be callable as part of a group? Busybox implements a kind of multiplicity and it examines the executable name to decide where to despatch processing, so maybe the techniques or ideas used by Busybox can be of use here. Any ideas on this matter would be very helpful.
-
Answer:
Copy what busybox does? Get all your programs rename all main functions into regular functions. Create a new main function that intelligently calls the appropriate program function depending on the invocation name (like busybox). Statically build everything (common libraries first, build each individual object for each program, remove unused objects, combine to a single archive). No dynamic magic.
William Emmanuel Yu at Quora Visit the source
Related Q & A:
- How can you erase a link on the tab that I don't want to have anymore?Best solution by Yahoo! Answers
- How long can you stay in jail if you don't do 8 hours of community service?Best solution by Yahoo! Answers
- Does anyone know where I can download yu-gi-oh online games that don't need real money to play?Best solution by Yahoo! Answers
- How do I find a certain tv channel if I don't know what number it is?Best solution by timewarnercable.com
- What is it called when you don't have a knuckle?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.