Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6858201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:07:40+00:00 2026-05-27T02:07:40+00:00

I have to call functions in the main executable from a shared library loaded

  • 0

I have to call functions in the main executable from a shared library loaded with LD_PRELOAD.

The executable exports all symbols and contains debug information. Unfortunately I don’t have access to it’s source code.

Currently I’m getting undefined symbol errors when trying to load that shared library.
Is there a way to do this?

PS:
Target platform is FreeBSD/x86.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:07:41+00:00Added an answer on May 27, 2026 at 2:07 am

    Can you create a function pointer by doing a typedef and use ‘dlsym()’ to get the address
    of the symbol. You can then invoke the function through the function pointer like a normal
    function call. Note: You do not need dlopen() since the main executable with symbols exported
    is loaded into process address space.

    Prototype:

    void *dlsym(void *handle, const char *symbol);
    

    Assume the exported function is:

    int foo(char *arg);
    

    Your function pointer:

    typedef (int)(*fooPtr)(char *);
    

    In you code:

    /* You can send NULL for first argument */
    fooPtr fp = dlsym(NULL, "foo");
    assert(0 != fp);
    int ret = fp("hello world");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with static library symbols missed in linked executable. Here is
I have two WIN32 DLL projects in the solution, main.dll should call a function
in clojure i have vector [myfn1 myfn2 myfn3] how can i call functions named
I have an iphone app where I call these three functions in appDidFinishLaunching: glMatrixMode(GL_PROJECTION);
I have a certain service where specific functions will take longer to call than
I have a wrapper around a C++ function call which I call from C#
I have a main application which dynamically loads a dylib , from inside that
Im trying to call python functions from C code, and i followed a sample
I have the following situation main() { hnd = CreateTHread( func1 ); // Call
I have 2 projects UI Functionality UI references Functionality to call specific functions. Functionality

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.