return;
}
- OS << "\t.section\t" << getSectionName();
-
+ StringRef name = getSectionName();
+ OS << "\t.section\t\"";
+ for (const char *b = name.begin(), *e = name.end(); b < e; ++b) {
+ if (*b == '"') // Unquoted "
+ OS << "\\\"";
+ else if (*b != '\\') // Neither " or backslash
+ OS << *b;
+ else if (b + 1 == e) // Trailing backslash
+ OS << "\\\\";
+ else {
+ OS << b[0] << b[1]; // Quoted character
+ ++b;
+ }
+ }
+ OS << '"';
+
// Handle the weird solaris syntax if desired.
if (MAI.usesSunStyleELFSectionSwitchSyntax() &&
!(Flags & ELF::SHF_MERGE)) {
; DARWIN: .section __DATA,__mod_init_func,mod_init_funcs
; DARWIN: .section __DATA,__mod_term_func,mod_term_funcs
-; ELF: .section .ctors,"aw",%progbits
-; ELF: .section .dtors,"aw",%progbits
+; ELF: .section ".ctors","aw",%progbits
+; ELF: .section ".dtors","aw",%progbits
-; GNUEABI: .section .init_array,"aw",%init_array
-; GNUEABI: .section .fini_array,"aw",%fini_array
+; GNUEABI: .section ".init_array","aw",%init_array
+; GNUEABI: .section ".fini_array","aw",%fini_array
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @__mf_init } ] ; <[1 x { i32, void ()* }]*> [#uses=0]
@llvm.global_dtors = appending global [1 x { i32, void ()* }] [ { i32, void ()* } { i32 65535, void ()* @__mf_fini } ] ; <[1 x { i32, void ()* }]*> [#uses=0]
; RUN: llc < %s -mtriple=arm-linux | \
; RUN: grep {__DTOR_END__:}
; RUN: llc < %s -mtriple=arm-linux | \
-; RUN: grep {\\.section.\\.dtors,"aw",.progbits}
+; RUN: grep {\\.section."\\.dtors","aw",.progbits}
@__DTOR_END__ = internal global [1 x i32] zeroinitializer, section ".dtors" ; <[1 x i32]*> [#uses=0]
; RUN: llc < %s -march=bfin -verify-machineinstrs | FileCheck %s
-; CHECK: .section .rodata
+; CHECK: .section ".rodata"
; CHECK: JTI0_0:
; CHECK: .long .BB0_1
; RUN: llc < %s -march=cellspu | FileCheck %s
@bssVar = global i32 zeroinitializer
-; CHECK: .section .bss
+; CHECK: .section ".bss"
; CHECK-NEXT: .globl
@localVar= internal global i32 zeroinitializer
; RUN: llc < %s -march=mips -o %t
-; RUN: grep {rodata.str1.4,"aMS",@progbits} %t | count 1
-; RUN: grep {r.data,} %t | count 1
+; RUN: grep {rodata.str1.4","aMS",@progbits} %t | count 1
+; RUN: grep {r.data",} %t | count 1
; RUN: grep {\%hi} %t | count 2
; RUN: grep {\%lo} %t | count 2
; RUN: not grep {gp_rel} %t
; RUN: llc < %s -march=mips -o %t
; RUN: grep {CPI\[01\]_\[01\]:} %t | count 2
-; RUN: grep {rodata.cst4,"aM",@progbits} %t | count 1
+; RUN: grep {".rodata.cst4","aM",@progbits} %t | count 1
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64"
target triple = "mipsallegrexel-unknown-psp-elf"
@A = global i32 0
-; CHECK: .section .bss,"aw",@nobits
+; CHECK: .section ".bss","aw",@nobits
; CHECK: .globl A
declare i32 @foo()
@G0 = global i32 ()* @foo, section ".init_array"
-; LINUX: .section .init_array,"aw"
+; LINUX: .section ".init_array","aw"
; LINUX: .globl G0
@G1 = global i32 ()* @foo, section ".fini_array"
-; LINUX: .section .fini_array,"aw"
+; LINUX: .section ".fini_array","aw"
; LINUX: .globl G1
@G2 = global i32 ()* @foo, section ".preinit_array"
-; LINUX: .section .preinit_array,"aw"
+; LINUX: .section ".preinit_array","aw"
; LINUX: .globl G2
ret void
}
@bm_pte = internal global [512 x %struct.kmem_cache_order_objects] zeroinitializer, section ".bss.page_aligned", align 4096
-; CHECK: .section .bss.page_aligned,"aw",@nobits
+; CHECK: .section ".bss.page_aligned","aw",@nobits
; CHECK-NEXT: .align 4096
; CHECK-NEXT: bm_pte:
; CHECK-NEXT: .zero 4096
; PR4639
@G1 = internal thread_local global i32 0 ; <i32*> [#uses=1]
-; LINUX: .section .tbss,"awT",@nobits
+; LINUX: .section ".tbss","awT",@nobits
; LINUX: G1:
; DARWIN: _G3:
; DARWIN: .long _G1
-; LINUX: .section .rodata,"a",@progbits
+; LINUX: .section ".rodata","a",@progbits
; LINUX: .globl G3
-; LINUX-SECTIONS: .section .rodata.G3,"a",@progbits
+; LINUX-SECTIONS: .section ".rodata.G3","a",@progbits
; LINUX-SECTIONS: .globl G3
@"foo bar" = linkonce global i32 42
; LINUX: .type foo_20_bar,@object
-; LINUX: .section .data.foo_20_bar,"aGw",@progbits,foo_20_bar,comdat
+; LINUX: .section ".data.foo_20_bar","aGw",@progbits,foo_20_bar,comdat
; LINUX: .weak foo_20_bar
; LINUX: foo_20_bar:
@G6 = weak_odr unnamed_addr constant [1 x i8] c"\01"
; LINUX: .type G6,@object
-; LINUX: .section .rodata.G6,"aG",@progbits,G6,comdat
+; LINUX: .section ".rodata.G6","aG",@progbits,G6,comdat
; LINUX: .weak G6
; LINUX: G6:
; LINUX: .byte 1
; DARWIN: _G7:
; DARWIN: .asciz "abcdefghi"
-; LINUX: .section .rodata.str1.1,"aMS",@progbits,1
+; LINUX: .section ".rodata.str1.1","aMS",@progbits,1
; LINUX: .globl G7
; LINUX: G7:
; LINUX: .asciz "abcdefghi"
-; LINUX-SECTIONS: .section .rodata.G7,"aMS",@progbits,1
+; LINUX-SECTIONS: .section ".rodata.G7","aMS",@progbits,1
; LINUX-SECTIONS: .globl G7
; DARWIN: .globl _G8
; DARWIN: _G8:
-; LINUX: .section .rodata.str2.2,"aMS",@progbits,2
+; LINUX: .section ".rodata.str2.2","aMS",@progbits,2
; LINUX: .globl G8
; LINUX:G8:
; DARWIN: .globl _G9
; DARWIN: _G9:
-; LINUX: .section .rodata.str4.4,"aMS",@progbits,4
+; LINUX: .section ".rodata.str4.4","aMS",@progbits,4
; LINUX: .globl G9
; LINUX:G9
-; RUN: llc < %s -relocation-model=pic -mtriple=i386-linux-gnu -asm-verbose=false | grep -F .text._Z3fooILi1EEvi,"axG",@progbits,_Z3fooILi1EEvi,comdat
+; RUN: llc < %s -relocation-model=pic -mtriple=i386-linux-gnu -asm-verbose=false | grep -F .text._Z3fooILi1EEvi","axG",@progbits,_Z3fooILi1EEvi,comdat
; RUN: llc < %s -relocation-model=pic -mtriple=i686-apple-darwin -asm-verbose=false | FileCheck %s
; RUN: llc < %s -mtriple=x86_64-apple-darwin | not grep 'lJTI'
; rdar://6971437
; RUN: llc < %s -march=xcore -mcpu=xs1b-generic | FileCheck %s
-; CHECK: .section .cp.rodata.cst4,"aMc",@progbits,4
+; CHECK: .section ".cp.rodata.cst4","aMc",@progbits,4
; CHECK: .LCPI0_0:
; CHECK: .long 12345678
; CHECK: f:
}
@G1 = global i32 4712
-; CHECK: .section .dp.data,"awd",@progbits
+; CHECK: .section ".dp.data","awd",@progbits
; CHECK: G1:
@G2 = global i32 0
-; CHECK: .section .dp.bss,"awd",@nobits
+; CHECK: .section ".dp.bss","awd",@nobits
; CHECK: G2:
@G3 = unnamed_addr constant i32 9401
-; CHECK: .section .cp.rodata.cst4,"aMc",@progbits,4
+; CHECK: .section ".cp.rodata.cst4","aMc",@progbits,4
; CHECK: G3:
@G4 = global i32* @G1
-; CHECK: .section .dp.data,"awd",@progbits
+; CHECK: .section ".dp.data","awd",@progbits
; CHECK: G4:
@G5 = unnamed_addr constant i32* @G1
-; CHECK: .section .cp.rodata,"ac",@progbits
+; CHECK: .section ".cp.rodata","ac",@progbits
; CHECK: G5:
@G6 = global i32* @G8
-; CHECK: .section .dp.data,"awd",@progbits
+; CHECK: .section ".dp.data","awd",@progbits
; CHECK: G6:
@G7 = unnamed_addr constant i32* @G8
-; CHECK: .section .cp.rodata,"ac",@progbits
+; CHECK: .section ".cp.rodata","ac",@progbits
; CHECK: G7:
@G8 = internal global i32 9312
-; CHECK: .section .dp.data,"awd",@progbits
+; CHECK: .section ".dp.data","awd",@progbits
; CHECK: G8:
}
@G = thread_local global i32 15
-; CHECK: .section .dp.data,"awd",@progbits
+; CHECK: .section ".dp.data","awd",@progbits
; CHECK: G:
; CHECK: .long 15
; CHECK: .long 15
--- /dev/null
+// RUN: llvm-mc -triple x86_64-pc-linux-gnu %s -o - | FileCheck %s
+
+// Test that we handle the strings like gas
+.section bar-"foo"
+.section "foo"
+.section "foo bar"
+
+// CHECK: .section "bar-\"foo\""
+// CHECK: .section "foo"
+// CHECK: .section "foo bar"