【发布时间】:2014-05-14 11:59:10
【问题描述】:
我写了下一个程序:
#include <iostream>
#include <dlfcn.h>
int main(int argc, char** argv)
{
typedef void* (*fptr)();
fptr func;
void *handle = dlopen(0, RTLD_NOW);
std::cout << dlerror() << std::endl;
*(void **)(&func) = dlsym(handle, "__libc_start_main");
std::cout << dlerror() << std::endl;
std::cout << handle << " " << func << "\n";
dlclose(handle);
return 0;
}
并尝试用下一种方式编译:
g++ -rdynamic main.cpp -ldl -o test
当我运行这个程序时,我没有看到任何消息。为什么?
感谢您的关注。
【问题讨论】: