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

  • SEARCH
  • Home
  • 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 7052759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:25:21+00:00 2026-05-28T03:25:21+00:00

I just have an interesting idea. I was using objdump to dump a simple

  • 0

I just have an interesting idea. I was using objdump to dump a simple binary and I see many functions in the binary. Is it possible to create another C program that link with these functions? Assuming I know the parameters for input and output.

Some more information:
file1:test.c

#include <stdio.h>

int add(int x,int y)
{
    return x+y;
}

int main(int argc, const char *argv[])
{
    printf("%d\n",add(3,4));
    return 0;
}

file2: test1.c

#include <stdio.h>

int main(int argc, const char *argv[]) 
{
    printf("%d\n",add(8,8));
    return 0; 
}

gcc test.c -o test.exe
gcc test1.c test.exe -o test1.exe

Output:

ld: in test.exe, can't link with a main executable
collect2: ld returned 1 exit status
  • 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-28T03:25:21+00:00Added an answer on May 28, 2026 at 3:25 am

    From a practical standpoint, there is little difference between an object (.o) file and an executable. The object file can contain unbound symbols, where the executable cannot. The executable must contain an entry point, where the object file has no such restriction. The executable has a more complete header. The executable also has all its jump offsets resolved, as it has been through the linking resolution phase. Some functions may have been permanently inlined away.

    So yes, in theory you can create an executable which calls the functions from another executable, but not just with a normal link line. Your primary issue is that the second executable can’t have an entry point – a main function – and still be linked with the original (since the names would collide).

    If your goal is just to call the original functions, I suggest using a different method from the direct linking you seem to be suggesting. If you craft a shared library and put it in the LD_PRELOAD environment variable, and then invoke the original executable, you may use your library to effectively hook the program entry (possibly via the _main symbol) and then call an alternate program routine. Because this library is loaded along with the original binary, you may call all the original functions…

    But the easiest way by far to call the functions from the binary is just to link with the object files instead of the executable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just came across an interesting situation in JavaScript. I have a class with
I just have an XP machine, and i want to play around using CC.NET.
Just something interesting come in my mind. Assume that we have a table (in
I have run into an interesting issue using PHP's date() function. Haven't had any
I just have started to learn Haskell and combine reading books and tutorials with
I just have a quick question about how to get the length of a
Currently I just have a file like this that I manually parse into a
So I have site list on certain pages that basically just have links to
I've recently decided that I just have to finally learn C/C++, and there is
I recall I have read about a parser which you just have to feed

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.