unlinking / linking functions in a compiled program
D'Arcy J.M. Cain
darcy at druid.uucp
Fri Jun 21 03:41:33 AEST 1991
[Note cross-post and followup - this really isn't a wizard question]
In article <1991Jun19.214339.7255 at cats.com> Andy Davidson writes:
>I need some help with the link editor. What I want to do is find a way
>to ship to my customers my product in binary formated but provide a
>way for them to unlink some of my functions and replace them with
>functions of there own design.
I think you're doing it the hard way. Why not use libraries? Write
the program with main renamed to my_main or something, create a library
with all the modules that make up the program then have a short main
which you ship in source form as follows:
int my_main(int argc, char **argv);
int main(int argc, char **argv)
{ return(my_main(argc, argv)); }
Now by compiling the above with your supplied library you get your program.
If someone wants to modify it then they simply link in new modules. The
system will pick them up before the library routines. They can even add
the new code into the main program if they want to keep it all together.
If you do this you should be careful about global variables. Be sure to
declare everything static outside of functions if possible.
>It would be nice but not required if this solution also worked in DOS
Different tools but the same idea.
Note, I am assuming that the user has a development system since they are
designing their own replacement functions however third party libraries
may be a problem from a copyright standpoint.
--
D'Arcy J.M. Cain (darcy at druid) |
D'Arcy Cain Consulting | There's no government
Toronto, Ontario, Canada | like no government!
+1 416 424 2871 |
More information about the Comp.unix.wizards
mailing list