What does %P stand for in gcc inline assembly
 In Linux kernel linux/arch/x86/boot/main.c , I found a piece of inline asm code:  
asm("leal %P1(%%esp),%0"
        : "=r" (stack_end) : "i" (-STACK_SIZE));
 This code snippet is pretty simple, but %P1 confused me.  I checked some assembly language tutorials, but found nothing about this.  
So, can anyone give me some pieces of clue about this?
 The P output modifier is unofficially documented in a comment in gcc/config/i386/i386.md:  
;; The special asm out single letter directives following a '%' are:
...
;; P -- if PIC, print an @PLT suffix.
;; p -- print raw symbol name.
 The upper-case P modifier probably isn't what is wanted here, but when not compiling PIC (Position Independent Code), then it acts like the lower-case p modifier.  The intent to prevent the compiler from emitting the operand using the format normally used for immediate values, which wouldn't work here.  As David Wohlferd said it would be a better idea to use the c modifier, which is documented and is meant specifically to handle immediate values.  Mind you this code was probably written before the c modifier was documented, as for a long time none of the modifiers were documented.  
Given that the inline assembly statement is only executed once at boot time, performance doesn't matter, so I wouldn't have bothered trying to be smart by using LEA. You can avoid the operand modifiers completely with something simple like:
 char *stack_pointer;
 asm ("mov %%esp, %0" : "=r" (stack_pointer));
 stack_end = stack_pointer - STACK_SIZE;
上一篇: JavaScript location.href调用是异步的吗?
下一篇: %P在gcc内联汇编中代表什么?
