https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105576
Bug ID: 105576 Summary: x86: Support a machine constraint to get raw symbol name Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: i at maskray dot me Target Milestone: --- An raw symbolic operand is useful in inline asm (e.g. in C++ to get the mangled name, or in C to let the compiler do some asm checking). In aarch64 and riscv, there is a documented (supported) approach. documented on https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints extern int var; void *addr(void) { return &var; } void addr_via_asm(void) { asm (".pushsection .xxx,\"aw\"; .dc.a %0; .popsection" :: "S"(addr)); // supported on aarch64 and riscv asm (".pushsection .xxx,\"aw\"; .dc.a %0; .popsection" :: "S"(&var)); // supported on aarch64 } On x86, it is unclear which should be preferred. It seems that the operand modifier 'p' can be used for a function, but not a variable. asm (".pushsection .xxx,\"aw\"; .dc.a %p0; .popsection" :: "m"(addr));