[comp.unix.wizards] unlinking / linking functions in a compiled program

andy@cats.com (Andy Davidson) (06/20/91)

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 have been able to do this sucessfully using gnu dld (dynamic link
and load) libraries. But this is not really what I want for the
following reasons

	1) the dynamic link and loading happens every time the product
starts. My users should only have to do this one time. They should
only have to doctor the program once

	2) I do not want to have to link in the dynamic link load lib. My
program is already quite large


It would be nice but not required if this solution also worked in DOS

thanks in advance
Andy
-- 

-----------------------------------------------------------------
                 "bede-bede-bede Thats all Folks"
                            Porky Pig

darcy@druid.uucp (D'Arcy J.M. Cain) (06/21/91)

[Note cross-post and followup - this really isn't a wizard question]

In article <1991Jun19.214339.7255@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@druid)     |
D'Arcy Cain Consulting             |   There's no government
Toronto, Ontario, Canada           |   like no government!
+1 416 424 2871                    |