LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-22-2010, 06:53 PM   #1
rookie.mp
LQ Newbie
 
Registered: Oct 2010
Distribution: Ubuntu, FreeBSD
Posts: 3

Rep: Reputation: 0
Problem with dynamically loading libraries in GNU/Linux.


This post isn't really asking for a tutorial, but rather asking for some ideas. I've come up with a few ideas, but they seem cumbersome and unnecessary, so I was wondering if someone with more experience than me could help me out.

Also, my explanations suck, but I'll try to do my best.

So say I have an executable called X. At some point during its execution, X loads and uses (using dlopen and dlsym) a library called Y. In Y, there a bunch of functions that call the function called, for example, void *special_malloc (size_t). These functions come from another linked library (linked during compilation) called Z. Problem is, special_malloc contains some static variables within its scope, and when those variables are reset midway through a program, an invalid free occurs (special_malloc uses garbage collection). Now, what I want to happen is that whenever lib Z calls special_malloc, it instead calls the special_malloc defined in the executable X, so that these static variables are retained. Keep in mind that I have control of the Z library, meaning I can edit the source to fit my needs. Any idea?
 
Old 10-22-2010, 07:28 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Linux .so's are NOT Windows .dll's.

A Linux shared library doesn't hold "state".

A Linux executable loads a shared library ... and the EXECUTABLE holds the state.

If that's what you're getting at
 
Old 10-22-2010, 07:36 PM   #3
rookie.mp
LQ Newbie
 
Registered: Oct 2010
Distribution: Ubuntu, FreeBSD
Posts: 3

Original Poster
Rep: Reputation: 0
I'm not sure I understand what you're getting at. Sorry, I'm not very good at programming, so if you could explain what you're saying it would be helpful.

Also I've never really used windows, so I'm not sure how DLLs work.

Last edited by rookie.mp; 10-22-2010 at 07:39 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Gnu/Linux C++ Visual Libraries cheifmoon Programming 5 11-23-2009 12:07 PM
Linux Dynamically Loaded Libraries and Global Variables Millenniumman Programming 3 06-13-2007 11:37 AM
How to see (dynamically) imported libraries? G00fy Programming 2 04-30-2007 05:27 AM
Dynamically linked libraries.. vishalbutte Programming 6 04-17-2006 08:54 PM
problem in dynamically loading the shared object sumit Programming 1 01-10-2002 03:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration