shared data section in shared objects on AIX

shared data section in shared objects on AIX

Post by Parag Teredesa » Thu, 21 Sep 2000 04:00:00



I have a dll whose data section ( not the code section ) needs to be shared
across multiple exes.

I have tried the -bM:SRO, -bM:SRE etc (all "ld" options)
I am able to create a shared object but it's data section is not being
shared.

I have these simple programs which I use to test whther I am truly sharing
the dll
Pls let me know if I am not compiling something right or
if my test is not valid.
BTW I know how to get this effect on NT and OS2 which is to declare the DATA
section shared
in the .DEF file (sort of like the exp file in UNIX)
---------------------------------------
FILE share1.c
int shared_I = 0; // global variable which is shared
    // by all exes who dynamically link this
    // shared object
some other functions also to be exported
---------------------------------------
FILE main.c

extern some other functions also to be imported
extern int shared_I;

int main(int argc, char**argv)
{
   printf ( current value of shared_I );
   shared_I++;
   printf ( new value of shared_I );
   sleep(200); // sleep so that I have time to start
               // another   copy of main where I expect
               // that shared_I will be what first run
        // of this main left it at ( if the data area
        // of the shared object share1.o are truly
               // being shared.

Quote:}

---------------------------------------
COMPILE AND LINK using the  -bM:SRO
---------------------------------------
Thanks
Parag
 
 
 

shared data section in shared objects on AIX

Post by Gary R. Hoo » Fri, 22 Sep 2000 04:00:00



> I have a dll whose data section ( not the code section ) needs to be shared
> across multiple exes.

One uses shared memory and programmatically implements support for that.
Shared modules do _not_ share data amongst processes, they share text.

Don't forget to deal with locking issues via semaphores.

Quote:

> I have tried the -bM:SRO, -bM:SRE etc (all "ld" options)
> I am able to create a shared object but it's data section is not being
> shared.

-bM:SRO only works for data that does not require relocation, and
where no text is involved.  Plus, it's read-only, hence the acronym.

--
Gary R. Hook / AIX Kernel Development, IBM / These opinions are _MINE_
________________________________________________________________________
A piece of canvas is only the beginning
It takes on character with every loving stroke
This thing of beauty is the passion of an artist's heart
By God's design, we are a skin kaleidoscope    "Colored people", dc Talk

 
 
 

1. creating new shared object from existing shared objects ??

Hi all.

I have two existing shared objects (and no source code and .o for them)..
Can I create my new .so/.sl using the two already existing shared objects..

Thanks
Sandeep

--
What you do today is getting you closer
to what you want to be tommorow !

http://www.atrenta.com  // Streamlining Electronic Design

2. ignoreeof and su - help

3. error in loading shared libraries: libXmu.so.6: cannot open shared object

4. using linux to enable printing by Windows machines to network printers

5. semaphors & memory share & object share

6. HELP NEEDED on setting up a network

7. Diff between Shared Object & Shared Lib

8. (Q) User CGI scripts with .ns-config

9. SVR3 shared libs and copying of data section

10. Shared Data/Code object creation?

11. Shared data in shared library

12. Data in shared objects

13. Sharing Data in Shared Libraries