https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98778
Bug ID: 98778 Summary: asm() accepts certain "i" (symbol) constructs despite -fpie for x86-64 Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: inline-asm Assignee: unassigned at gcc dot gnu.org Reporter: jbeulich at suse dot com Target Milestone: --- While in the example below all 3 variants get refused ("impossible constraint") with -fpic or with "-m32 -fpie", the ones in cases 0 and 2 get accepted with just -fpie, producing non-position-independent code (or more precisely unsuitable relocations). void efn(void); void(*efp)(void); void*test(int i) { void*res; switch(i) { case 0: asm("mov %1,%0" : "=r" (res) : "i" (test)); break; #ifndef __PIE__ case 1: asm("mov %1,%0" : "=r" (res) : "i" (efn)); break; #endif case 2: asm("mov %1,%0" : "=r" (res) : "i" (&efp)); break; default: res = (void*)0; break; } return res; }