linking executables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Evert Carton

    #1

    linking executables

    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

  • Christopher Benson-Manica

    #2
    Re: linking executables

    Evert Carton <me@you.he> spoke thus:
    [color=blue]
    > I bet this question has been asked a thousand times.
    > Is it in any way possible to link to an executable.[/color]
    [color=blue]
    > 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.[/color]
    [color=blue]
    > I bet this must sound like blasphemy ;-)[/color]

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





    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cybers pace.org | don't, I need to know. Flames welcome.

    Comment

    • E. Robert Tisdale

      #3
      Re: linking executables

      Evert Carton wrote:
      [color=blue]
      > I bet this question has been asked a thousand times.
      > Is it in any way possible to link to an executable.
      >
      > Platform: Linux[/color]

      I'll assume that means that you are using the GNU C compiler.
      [color=blue]
      > 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.[/color]

      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.
      [color=blue]
      > I bet this must sound like blasphemy ;-)[/color]

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

      Comment

      Working...