简体   繁体   English

%C在GCC内联汇编代码中的含义是什么?

[英]What does %c mean in GCC inline assembly code?

I am trying to understand this inline assembly code which comes from _hypercall0 here . 我想了解哪些来源于此联汇编代码_hypercall0 这里

asm volatile ("call hypercall_page+%c[offset]" \
        : "=r" (__res) \
        : [offset] "i" (__HYPERVISOR_##name * sizeof(hypercall_page[0])) \
        : "memory", "edi", "esi", "edx", "ecx", "ebx", "eax") 

I am having trouble finding information on what %c in the first line means. 我无法找到第一行中%c的含义的信息。 I did not find any information in the most obvious section of the GCC manual , which explains %[name] , but not %c[name] . 我没有在GCC手册中最明显的部分找到任何信息,这解释了%[name] ,但没有找到%c[name] Is there any other place I should look at? 还有其他我应该看的地方吗?

From the GCC internals documentation : 来自GCC内部文件

`%c digit ' can be used to substitute an operand that is a constant value without the syntax that normally indicates an immediate operand. `%c digit '可用于替换常量值的操作数,而不使用通常表示立即操作数的语法。

Check the assembly output (with gcc -S , or maybe disassemble the object file) and it may be clearer. 检查程序集输出(使用gcc -S ,或者可能反汇编目标文件),它可能更清晰。

My guess is that it stands for constant . 我的猜测是它代表不变 hypercall_page looks like a table of instructions that each do a syscall. hypercall_page看起来像是一个指令表,每个指令执行系统调用。 Maybe this will generate a call hypercall_page + {constant based on the expression given} , essentially having computed the address of this offset at compile time. 也许这会产生一个call hypercall_page + {constant based on the expression given} ,基本上在编译时计算了这个偏移的地址。

As an aside, this __HYPERVISOR##name stuff really reminds me of the __NR_name_of_syscall type convention you see for syscalls in Linux's <asm/unistd.h> and similar places. __HYPERVISOR##name一下,这个__HYPERVISOR##name真的让我想起了你在Linux的<asm / unistd.h>和类似的地方看到的系统调用的__NR_name_of_syscall类型约定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM