call function in unrelated executable linux

前端 未结 2 1190
没有蜡笔的小新
没有蜡笔的小新 2021-01-16 00:40

If I have a pointer to a function and I give that to another (Unrelated/Child) Executable, how can I call that function without making a segfault?

At the moment I ca

2条回答
  •  無奈伤痛
    2021-01-16 01:12

    If you have control over the other executable (the one you want to call a function from), then build it as a PIE (position-independent executable), and load it into the first executable's address space.

    In C, you would build with -fPIC -pie, then use dlopen(3) and dlsym(3).

    In BASIC, I have no clue ;-(

提交回复
热议问题