Unable to write strings with curly braces inside inline assembler code

Solution Unverified - Updated -

Issue

  • Writing inline assembler code as below:
void f()
{
  asm ( ".pushsection \".foo\"; .asciz \"div { width : 50%% | height = 10px } \"; .long %c0; .popsection" : : "i"(42) );
}

results in invalid output after compilation with gcc:

    .file   "asm-curly.c"
    .text
    .globl  f
    .type   f, @function
f:
.LFB0:
    .cfi_startproc
    pushq   %rbp
    .cfi_def_cfa_offset 16
    .cfi_offset 6, -16
    movq    %rsp, %rbp
    .cfi_def_cfa_register 6
#APP
# 3 "asm-curly.c" 1
    .pushsection ".data";foo1:; .asciz "div  width : 50%  "; .long 42; .popsection
# 0 "" 2
#NO_APP
    popq    %rbp
    .cfi_def_cfa 7, 8
    ret
    .cfi_endproc
.LFE0:
    .size   f, .-f
    .ident  "GCC: (GNU) 4.6.3 20120306 (Red Hat 4.6.3-2)"
    .section    .note.GNU-stack,"",@progbits

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content