[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

LINKER symbol substitition?

» close window

The Question is:

 
We have our own application written in C that uses an API
provided by a 3rd party as a library
(lets call it l3p.olb). We have other 3rd party
applications that also use the API in l3p.olb
 
We want to add to the functionality of one routine in
l3p.olb (lets call it api_1) so that it does some logging
and then carries on as before. We want this enhanced
functionality to be apparent in all applications using
l3p.olb
 
The proposal is to have our own function of the same name
(api_1) in a library that all applications link to that
does the extra work and then calls the original api_1 in
l3p.olb
 
1) Is this proposal workable i.e. how could it be done
without the new api_1 function re-calling itself ?
 
2) How would you overcome possible linker symbol
resolution conflicts.
 
Many Thanks,
 
Credit Suisse First Boston,
Hr. Andrew Bartle,
FTIS 1 / Front Office IT
Postfach 900
8070 Z|rich
 
Tel. +41 (0)1 332 3355
e-mail andrew.bartle@csfb.com
 
 
 


The Answer is :

 
  Use CC/PREFIX or a preprocessor define in a common header file when
  you compile your applications, specifying a prefix or alternate name
  for the particular target routine.  The routine that calls the "real"
  version of the routine is compiled without the prefix or define,
  obviously.
 
  As an alternative, you could extract the object module from the library,
  patch the symbol name, and replace it.  With the inclusion of a module
  you created, you could then redirect the access to the "new" name for
  the "real" routine.
 
  This whole interception process is far easier when the library is built
  as a shareable image -- please see the available cookbook for details
  on creating a shareable image.  Through the use of a "stub" shareable
  image, any and all routines can be intercepted or otherwise tailored
  as required.
 

answer written or last revised on ( 8-JUL-1999 )

» close window