473,763 Members | 3,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Questions about shared libraries (.so)

Hi.

I am writing a shared library to override some libc
functions.

I have the following questions:

Ex.
int XXX=0;
void f() {++XXX; ...; --XXX;}

1.
Are global data (extern) shared among processes
or threads? If a process or a thread accesses f while
another one is also executing f it sees XXX as 0 or 1?

2.
Is there any problem not freeing malloc allocated areas in f
relying on the automatic free at the end of the job?
I am asking this because I want to share some information
between sucessive calls to f in a process but I don't know what
is the last call. So, I don't know when to free the malloc'ed
areas.

Any links to literature about these is welcome.

Thanks for any help.
Nov 14 '05 #1
2 1385
Paulo da Silva wrote:
Hi.

I am writing a shared library to override some libc
functions.

I have the following questions: [snip]
Any links to literature about these is welcome.

Thanks for any help.


Wrong newsgroup. This newsgroup, news:comp.lang. c,
discusses the _standard_ C language which has no
facilities for shared libraries. These are outside
the scope of the language.

Not all platforms support shared libraries. Please
consult a newsgroup dedicated to your platform.
Many newsgroups are listed in the FAQs below.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Nov 14 '05 #2
On Mon, 07 Feb 2005 16:41:55 +0000, Paulo da Silva wrote:
Hi.

I am writing a shared library to override some libc
functions.

I have the following questions:

Ex.
int XXX=0;
void f() {++XXX; ...; --XXX;}

1.
Are global data (extern) shared among processes
or threads?
That would depend on the implementation and how it implements processes
and thread which are not C concepts. Typically however threads share the
same address space whereas processes for normal operations don't.

Given your reference ot .so lubraries comp.unix.prorg ammer might be a
better place to discuss this.
If a process or a thread accesses f while
another one is also executing f it sees XXX as 0 or 1?
That would depend on when XXX is accessed. Also consider makin XXX
volatile.
2.
Is there any problem not freeing malloc allocated areas in f relying on
the automatic free at the end of the job?
That depends on what you mean by a "job". You should free memory when you
no longer need it or else you might have a memory leak. On reasonable
systems the memory allocated by a program is reclaimed when the program
terminates.
I am asking this because I
want to share some information between sucessive calls to f in a process
but I don't know what is the last call. So, I don't know when to free
the malloc'ed areas.


If it is a single allocation that's not too large that may not be a
problem, you might think of it like a static variable.

Lawrence
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2270
by: Phil | last post by:
I realize this is the php group, but I have a question that recurses back to my php install. My objective is a pure 64 bit shared object installation of php 5.0 on UltraSparc Solaris 9 compiled with the Sun Compiler version 8. My problem is that EVERYTHING builds great EXCEPT that the 6b distribution of JPEG will NOT build a shared object, thus gd cannot include support for JPEG, thus php loses that functionality.
0
1121
by: Frieder Loercher | last post by:
Hello, I am developping a (lammpi) parallel Application where any of the processes uses the Python script language. It works fine on Compaq Alpha and SUN Solaris5.9 On AIX5.1, it doesn't work. In fact, there is a problem in using shared libraries on AIX in combination with the parallelisation (lammpi).
3
2608
by: Rickard Lind | last post by:
Is there any way to build the python executable statically and still be able to load modules built as shared libraries? I'm trying to run python scripts on a stripped down FreeBSD (4.9) machine which has no shared system libraries so I want to link it statically against libc et al, but it would be nice to still be able to load modules which were built as shared libraries. In particular I have a library for which I've generated a wrapper...
1
2793
by: rinku24 | last post by:
We have two C++ libraries (Unix Shared objects) with the same class name and no namespace. Is there any way to load both the libraries and selectivly create the instance of the class from different library? e.g. We have class Process in libABC.so and libXYZ.so. Can I instantiate object of class Process from libABC.so or libXYZ.so by specifying symbol name or some other way?? I know can do that for global function using dlsym...
1
2157
by: RHNewBie | last post by:
Hello, I have an executable which uses two shared libraries(A and Z). I do not have the source code for the executable. However I can tell the executable to load the shared libraries and invoke API in the shared libraries. One of the shared libraries(A) broadcasts a lwp_kill which kills all the lwp's in shared library(A) and also in the executable. Is there a way to ignore/trap signals from within library B? Thanks.
7
5212
by: Steve | last post by:
Hi, We have an application framework library that gets statically linked to any applications we produce. (Windows apps, but I don't think that matters here). The framework is based heavily on the STL and the API uses many STL constructs. Because of the static linking, and the fact that both app and framework are built by the same compiler, we don't have any problems.
2
1539
by: Tobias Bergmann | last post by:
Hi, I work on a big project that consists of many small linux C++ CGI binaries. This actually works fine but our problem is that we use many ..so libraries and we need to compile it separately for many different linux distributions and versions and even architectures. I actually want one compiled version that works everywhere. One idea is to store all used .so libraries of the compiling system in a seperate directory, install that...
3
3274
by: Bala | last post by:
Hello, I am trying to create a shared library on solaris. The inputs to this library is a source file and then 2 static libraries. I need to call code within the shared library in another application which in turn will use the static libraries for further processing. This is the command i am using to build the shared library
4
2343
by: stuntgoat | last post by:
Hi, I want to start using Python 2.6 and 3000. I have several questions. What, in your experiences, is a functionally elegant solution to installing 2.6 and 3 from source without breaking package dependencies on your favorite Linux/Unix flavor? Is compiling Python 2.6 and 3.0 on a *nix development machine and having it work seamlessly as simple as choosing a particular flavor or are there always going to be package...
0
10148
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10002
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9938
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.