0

Micro Focus recommends the use of cobgetfuncaddr() to load shared objects.

I would prefer to use dlopen(), but I don't want to risk missing out on side effects of cobgetfuncaddr() that are not provided by dlopen().

I prefer dlopen() because it can load a shared object with many entry points.

Also, the error reporting on cobgetfuncaddr() is weird: You can call it in two modes: 1) When an error occurs you get a function pointer to a function that prints an error message. 2) When an error occurs it returns a NULL with no indication of the exact problem.

With dlopen()/dlsym() I can get detailed information on the problem.

Is there anything I need to do to safely use dlopen() rather than coberrfuncaddr()?

BTW: Testing indicates it works fine, but I don't code against tests, I code against doc. If the doc and tests disagree, then I report a bug.

Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125
  • So take it up with Micro Focus support. – Bill Woodger Aug 06 '15 at 06:08
  • The advantages of using cobgetfuncaddr() are that will work with .int, .gnt and shared object... the runtime will then be able to remove the shared object/.int/.gnt when it needs too... if you use dlopen/dlsym then the runtime will have no way of removing it when it needs too. – Stephen Gennard Aug 06 '15 at 12:49
  • Under what conditions does the the runtime need to remove it? – Be Kind To New Users Aug 06 '15 at 15:44
  • 1
    Unless you explicitly set RTLD_NODELETE during `dlopen()`, then `dlcose()` will unload any shared objects when the reference count goes to zero. No worries with temporarily loading huge libraries, as they will be unloaded once closed (by all sharing parties) With proper care, even conflicting namespaces can be managed this way. For POSIX systems, physical CANCEL can be coded this way. – Brian Tiffin Aug 07 '15 at 01:48
  • @BrianTiffin , can you elaborate a bit about how what you wrote applies to Micro Focus COBOL? I use dlopen() on GNU COBOL without any issue, that is one of the reasons I would like to make my code consistent by using dlopen on Micro Focus. – Be Kind To New Users Aug 07 '15 at 07:38
  • The Micro Focus runtime can remove a shared object when a CANCEL occurs, at the end of sub rununit, end of link level or during stop run processing. The Micro Focus runtime has the notion of logical cancel's (shared objects are left in memory but the programs's data is reset) and physical cancel's which will do a dlclose(). Note: some platforms might not use dlopen/dlsym/dlclose but use the native versions (such as some AIX platforms). – Stephen Gennard Aug 07 '15 at 12:08
  • @MichaelPotter, sorry, I was responding to spgennard about having no way to remove objects when using dlopen. Excuse the noise. – Brian Tiffin Aug 10 '15 at 22:16

0 Answers0