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 01-18-2006, 04:50 PM   #1
milewis1
LQ Newbie
 
Registered: May 2005
Distribution: SuSE, TurboLinux
Posts: 4

Rep: Reputation: 0
dladdr returning incorrect address in dli_fbase?


I have a shared library in which there are functions that I want to load using dlsym. However, the names of the functions are passed into the library, via an entry call. Naturally I want to use dlsym to a pointer to the function whose name is passed in. To do this I need to know the base address of the library, so I use dladdr. Here's the code (i've left out the error checking and such to make it easier to read):

Code:
void FindWithdladdr(void) { return; }
void LibEntry(char *funcname)
{
  Dl_info info;

  ...

  dladdr(&FindWithdladdr,&info);
  funcptr = dlsym(info.dli_fbase,funcname);

  ...
}
This code actually crashes and the reason is that info.dli_fbase is not the correct address. I know this because using gdb I got the address of the library when I opened it with dlopen (it happened to be 0x87840c0). However, in info.dli_fbase I got a different address (0x4024d000). If I use gdb to put 0x87840c0 into info.dli_fbase then the code works perfectly.

Does anyone have any idea what might be going wrong?
 
  


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
fan status/control incorrect and out of sync after returning from hibernate jlinkels Linux - Laptop and Netbook 2 04-08-2005 04:11 PM
Weird card problem - DHCP returning IPv6 address lacitpo Linux - Wireless Networking 2 03-16-2005 11:28 PM
gethostbyname() is not returning my IP address hal2000 Programming 5 10-11-2004 05:54 PM
kmalloc returning overlapped address dipakn Linux - General 4 10-29-2003 11:29 PM
Program returning ip-address? smellofsunshine Linux - Software 4 08-11-2003 05:59 AM

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

All times are GMT -5. The time now is 08:35 AM.

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