Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* A query on shared library in Digital UNIX 4.0 ....
@ 1997-04-18  4:00 Kamal Kishore Mantri
  1997-04-21  4:00 ` Dave Butenhof
  1997-05-07  4:00 ` Craig Neth USG
  0 siblings, 2 replies; 3+ messages in thread
From: Kamal Kishore Mantri @ 1997-04-18  4:00 UTC (permalink / raw)



Hi,
	I want to intialize some global data & acquire few
system resources(mutexes, shared memory .. etc) when shared
library is loaded. Similiarly these resouces need to released
when shared library is unloaded. Can anybody suggest me a way
of doing this in Digital UNIX 4.0. In HP-UX , it could have
been done with +I_INITIALIZER flag in ld.

	Thanks in advance,

Regards,
Kamal
kamal@wipsys.stph.net



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A query on shared library in Digital UNIX 4.0 ....
  1997-04-18  4:00 A query on shared library in Digital UNIX 4.0 Kamal Kishore Mantri
@ 1997-04-21  4:00 ` Dave Butenhof
  1997-05-07  4:00 ` Craig Neth USG
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Butenhof @ 1997-04-21  4:00 UTC (permalink / raw)



Kamal Kishore Mantri wrote:
> 
>         I want to intialize some global data & acquire few
> system resources(mutexes, shared memory .. etc) when shared
> library is loaded. Similiarly these resouces need to released
> when shared library is unloaded. Can anybody suggest me a way
> of doing this in Digital UNIX 4.0. In HP-UX , it could have
> been done with +I_INITIALIZER flag in ld.

Two ways:

1) Create a routine with the name __init_[anything], for example,
   __init_mylib. The loader will call all routines with this format
   when the library is loaded. Similarly, __fini_[anything] routines
   are called before the library is unloaded.
2) Use the ld options -init <name> and -fini <name> to cause specific
   functions to be called at load and unload time.

/---[ Dave Butenhof ]-----------------------[ butenhof@zko.dec.com ]---\
| Digital Equipment Corporation           110 Spit Brook Rd ZKO2-3/Q18 |
| 603.881.2218, FAX 603.881.0120                  Nashua NH 03062-2698 |
\-----------------[ Better Living Through Concurrency ]----------------/



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: A query on shared library in Digital UNIX 4.0 ....
  1997-04-18  4:00 A query on shared library in Digital UNIX 4.0 Kamal Kishore Mantri
  1997-04-21  4:00 ` Dave Butenhof
@ 1997-05-07  4:00 ` Craig Neth USG
  1 sibling, 0 replies; 3+ messages in thread
From: Craig Neth USG @ 1997-05-07  4:00 UTC (permalink / raw)
  To: kamal


Kamal Kishore Mantri wrote:
> 
> Hi,
>         I want to intialize some global data & acquire few
> system resources(mutexes, shared memory .. etc) when shared
> library is loaded. Similiarly these resouces need to released
> when shared library is unloaded. Can anybody suggest me a way
> of doing this in Digital UNIX 4.0. In HP-UX , it could have
> been done with +I_INITIALIZER flag in ld.
> 

Kamal,

Please take a look at the ld(1) man page, specifically, this section:

"Symbol names that start with __init_ and __fini_ have special meaning to
the linker.  All routines that start with __init_ are treated, by default,
as initialization routines.  These are routines that are called without an
argument when the file that contains them is loaded or when the program
that contains them is started.  All routines that start with __fini_ are
treated by default as termination routines, which are routines that are
called without an argument when the file that contains them is unloaded or
when the program that contains them exits."

This sounds exactly like what you want, yes?   If you cannot rename
the routines, you may also want to look at the -init and -fini
linker options, which let you name symbols that you wish to be
treated as init or fini routines.

Hope this helps...

Craig

\b
-------------------------------------------------------------------------
Craig Neth                         ! neth@zk3.dec.com
DIGITAL Equipment Corporation      ! 
110 Spit Brook Road ZKO3-3/W17     !
Nashua, NH 03062                   ! Opinions expressed herein are my own.
==========================================================================



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-05-07  4:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-04-18  4:00 A query on shared library in Digital UNIX 4.0 Kamal Kishore Mantri
1997-04-21  4:00 ` Dave Butenhof
1997-05-07  4:00 ` Craig Neth USG

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox