【发布时间】:2021-06-21 22:22:39
【问题描述】:
我有以下 C 代码:
void test_func()
{
__asm__ ("mov $0x2,%rax");
__asm__ ("mov $0x6000dd,%rdi");
__asm__ ("mov $0x0,%rsi");
__asm__ ("syscall");
}
int main(int argc, char *argv[]) {
test_func();
return 0;
}
当我像这样gcc mine.cxx -S -no-pie 编译它时,我在汇编文件中得到以下内容:
.globl _Z9test_funcv
为什么我的函数名称会改变以及如何防止/预测它的新名称?
【问题讨论】:
-
你是怎么编译的?
-
Don't split up instructions into splitting separate
__asm__statements like that。编译器可能会在它们之间插入指令,甚至“将它们相对于彼此重新排序,因为它们是没有依赖关系的基本汇编程序” -
@phuclv 怎么样?
-
@ariel 你读过上面的链接吗?还有this。只需将说明与
\n或;分开
标签: c symbols elf name-mangling