Trigger function on shared module init

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rayuthar@gmail.com

    Trigger function on shared module init

    Hi,

    I need to trigger a function, whenever my shared module (.so) gets
    loaded and before its been used by application.

    Any suggestions?

    Thanks
    Rayuthar
  • Walter Roberson

    #2
    Re: Trigger function on shared module init

    In article <809e9371-bad4-4e46-9e06-cfc5af3272da@c6 5g2000hsa.googl egroups.com>,
    <rayuthar@gmail .comwrote:
    >I need to trigger a function, whenever my shared module (.so) gets
    >loaded and before its been used by application.
    Please consult a newsgroup appropriate for the operating system
    and toolchain that you are using. The C language itself does not
    know anything about shared modules or dynamic loading.

    [OT]

    In SGI IRIX, this would be handled by the 'ld' option -init
    --
    "The slogans of an inadequate criticism peddle ideas to fashion"
    -- Walter Benjamin

    Comment

    • Antoninus Twink

      #3
      Re: Trigger function on shared module init

      On 17 Apr 2008 at 5:23, Walter Roberson wrote:
      In article <809e9371-bad4-4e46-9e06-cfc5af3272da@c6 5g2000hsa.googl egroups.com>,
      <rayuthar@gmail .comwrote:
      >
      >>I need to trigger a function, whenever my shared module (.so) gets
      >>loaded and before its been used by application.
      >
      In SGI IRIX, this would be handled by the 'ld' option -init
      On GNU at least, you can also just include a function called _init, and
      the linker will use that without needing a special option.

      Comment

      • CBFalconer

        #4
        Re: Trigger function on shared module init

        rayuthar@gmail. com wrote:
        >
        I need to trigger a function, whenever my shared module (.so) gets
        loaded and before its been used by application.
        Ignoring off-topic things such as .so, consider the following:

        void checkinit(void) {
        static int initdone = 0;

        if (initdone) return;
        else {
        initdone = 1;
        /* whatever initialization is needed */
        }
        return;
        }

        --
        [mail]: Chuck F (cbfalconer at maineline dot net)
        [page]: <http://cbfalconer.home .att.net>
        Try the download section.


        ** Posted from http://www.teranews.com **

        Comment

        Working...