linking executables

E

Evert Carton

Hi all,

I bet this question has been asked a thousand times.
Is it in any way possible to link to an executable.

Platform: Linux

What would like to do:

I have a binary, say mybin, I don't have the sources.

I would like to dlopen it and execute the main() function.
Is this, or a workaround possible.
I don't want to "exec()"-it in a forked process.

I bet this must sound like blasphemy ;-)

Regards,
Evert
 
C

Christopher Benson-Manica

Evert Carton said:
I bet this question has been asked a thousand times.
Is it in any way possible to link to an executable.
I would like to dlopen it and execute the main() function.
Is this, or a workaround possible.
I don't want to "exec()"-it in a forked process.
I bet this must sound like blasphemy ;-)

Actually, it sounds like you should have posted this question
elsewhere.

http://www.ungerhu.com/jxh/clc.welcome.txt
http://www.eskimo.com/~scs/C-faq/top.html
http://benpfaff.org/writings/clc/off-topic.html
 
E

E. Robert Tisdale

Evert said:
I bet this question has been asked a thousand times.
Is it in any way possible to link to an executable.

Platform: Linux

I'll assume that means that you are using the GNU C compiler.
What would like to do:

I have a binary, say mybin, I don't have the sources.

I would like to dlopen it and execute the main() function.
Is this, or a workaround possible.
I don't want to "exec()"-it in a forked process.

man system
SYSTEM(3) Linux Programmer’s Manual
SYSTEM(3)

NAME
system - execute a shell command

SYNOPSIS
#include <stdlib.h>

int system(const char *string);

DESCRIPTION
system() executes a command specified in string
by calling /bin/sh -c string, and returns
after the command has been completed.
During execution of the command, SIGCHLD will be blocked,
and SIGINT and SIGQUIT will be ignored.
I bet this must sound like blasphemy ;-)

You might try asking this question in the gnu.gcc.help newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top