【发布时间】:2015-07-26 13:41:28
【问题描述】:
#include <stdio.h>
// xyz will be emitted with -flto (or if it is static) even when
// the function is unused
__attribute__((__used__))
void xyz() {
printf("Hello World!\n");
}
int main() {
return 0;
}
我需要这个做什么?
除了直接调用函数之外,我还能以某种方式访问xyz,就像魔术一样的dlsym()?
【问题讨论】:
-
dlsym不是您要找的答案吗?在问题中提及这样的答案令人困惑。 -
我想你可以调用
xyz隐藏在编译器不知道的内联汇编中。 -
@Potatoswatter:不,不是。
dlsym()不适用于可执行文件,这就是我写“like some”的原因。 -
@Thomas 我很确定可执行文件本身可以
dlopen。 -
@melpomene:我试过了,但找不到符号。