2013-06-25 22 views
1

我想知道在下面的代码%P3的含义:含义在Linux内核内联组件的

#define get_user(x, ptr)      \ 
({         \ 
    int __ret_gu;       \ 
    register __inttype(*(ptr)) __val_gu asm("%edx");  \ 
    __chk_user_ptr(ptr);      \ 
    might_fault();       \ 
    asm volatile("call __get_user_%P3"    \ 
      : "=a" (__ret_gu), "=r" (__val_gu)   \ 
      : "0" (ptr), "i" (sizeof(*(ptr))));  \ 
    (x) = (__typeof__(*(ptr))) __val_gu;    \ 
    __ret_gu;       \ 
}) 

而且在LLVM IR代码被映射到:

call { i32*, i64 } asm sideeffect "call __get_user_${3:P}", "={ax},={edx},0,i,~{dirflag},~{fpsr},~{flags}"(i32* %tmp73, i64 4) 

我的理解是,这实际上调用了arch/x86/lib/getuser.S中的特定函数__get_user_X,但是不清楚哪一个特别(__get_user_4?)。

最后,我想了解%P和%P之间的差异。

回答

1

我认为%P3表示在__get_user_X的X是依赖于 “I”(的sizeof((PTR))。如的sizeof((PTR))可以是1,2,4,8。

3意味着,ASM挥发性里面的第三个参数(“...”)语句,而且%p是字符串连接。

大约%p和%p区别,我想这是对字符串规范,但我我不知道,我复制了GCC用户手册中的以下句子:

%p Substitutes the standard macro predefinitions for the current target machine. 
    Use this when running cpp. 
%P Like ‘%p’, but puts ‘__’ before and after the name of each predefined macro, 
    except for macros that start with ‘__’ or with ‘_L’, where L is an uppercase 
    letter. This is for ISO C. 
+0

[文档似乎用于“spec文件”](https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html),它似乎与GAS没有关系 – delcypher