aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Sonnenberger <joerg@bec.de>2011-03-03 22:31:08 +0000
committerJoerg Sonnenberger <joerg@bec.de>2011-03-03 22:31:08 +0000
commitea83b133503afcd6589cf317cbb54ccd9e100f57 (patch)
treef282cb26d95a61d769e218e0ef5e5245e4d75bb0
parentbbd0f45b4711ee54f1c636a6de7afa766c855327 (diff)
downloadexternal_llvm-ea83b133503afcd6589cf317cbb54ccd9e100f57.zip
external_llvm-ea83b133503afcd6589cf317cbb54ccd9e100f57.tar.gz
external_llvm-ea83b133503afcd6589cf317cbb54ccd9e100f57.tar.bz2
Bug#9033: For the ELF assembler output, always quote the section name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126963 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/MC/MCSectionELF.cpp18
-rw-r--r--test/CodeGen/ARM/ctors_dtors.ll8
-rw-r--r--test/CodeGen/ARM/section.ll2
-rw-r--r--test/CodeGen/Blackfin/jumptable.ll2
-rw-r--r--test/CodeGen/CellSPU/bss.ll2
-rw-r--r--test/CodeGen/Mips/2008-07-15-InternalConstant.ll4
-rw-r--r--test/CodeGen/Mips/2008-07-22-Cstpool.ll2
-rw-r--r--test/CodeGen/PowerPC/sections.ll2
-rw-r--r--test/CodeGen/X86/attribute-sections.ll6
-rw-r--r--test/CodeGen/X86/bss_pagealigned.ll2
-rw-r--r--test/CodeGen/X86/global-sections-tls.ll2
-rw-r--r--test/CodeGen/X86/global-sections.ll16
-rw-r--r--test/CodeGen/X86/pic_jumptable.ll2
-rw-r--r--test/CodeGen/XCore/constants.ll2
-rw-r--r--test/CodeGen/XCore/globals.ll16
-rw-r--r--test/CodeGen/XCore/tls.ll2
-rw-r--r--test/MC/ELF/section-quoting.s10
17 files changed, 61 insertions, 37 deletions
diff --git a/lib/MC/MCSectionELF.cpp b/lib/MC/MCSectionELF.cpp
index d32aea1..b908a74 100644
--- a/lib/MC/MCSectionELF.cpp
+++ b/lib/MC/MCSectionELF.cpp
@@ -39,8 +39,22 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
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)) {
diff --git a/test/CodeGen/ARM/ctors_dtors.ll b/test/CodeGen/ARM/ctors_dtors.ll
index fb94626..4ed2dee 100644
--- a/test/CodeGen/ARM/ctors_dtors.ll
+++ b/test/CodeGen/ARM/ctors_dtors.ll
@@ -5,11 +5,11 @@
; 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]
diff --git a/test/CodeGen/ARM/section.ll b/test/CodeGen/ARM/section.ll
index 7a566d4..ff708d5 100644
--- a/test/CodeGen/ARM/section.ll
+++ b/test/CodeGen/ARM/section.ll
@@ -1,7 +1,7 @@
; 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]
diff --git a/test/CodeGen/Blackfin/jumptable.ll b/test/CodeGen/Blackfin/jumptable.ll
index 263533c..21fc1df 100644
--- a/test/CodeGen/Blackfin/jumptable.ll
+++ b/test/CodeGen/Blackfin/jumptable.ll
@@ -1,6 +1,6 @@
; RUN: llc < %s -march=bfin -verify-machineinstrs | FileCheck %s
-; CHECK: .section .rodata
+; CHECK: .section ".rodata"
; CHECK: JTI0_0:
; CHECK: .long .BB0_1
diff --git a/test/CodeGen/CellSPU/bss.ll b/test/CodeGen/CellSPU/bss.ll
index 327800d..7731e30 100644
--- a/test/CodeGen/CellSPU/bss.ll
+++ b/test/CodeGen/CellSPU/bss.ll
@@ -1,7 +1,7 @@
; 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
diff --git a/test/CodeGen/Mips/2008-07-15-InternalConstant.ll b/test/CodeGen/Mips/2008-07-15-InternalConstant.ll
index c3db638..df9b2eb 100644
--- a/test/CodeGen/Mips/2008-07-15-InternalConstant.ll
+++ b/test/CodeGen/Mips/2008-07-15-InternalConstant.ll
@@ -1,6 +1,6 @@
; 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
diff --git a/test/CodeGen/Mips/2008-07-22-Cstpool.ll b/test/CodeGen/Mips/2008-07-22-Cstpool.ll
index 20bd888..0457415 100644
--- a/test/CodeGen/Mips/2008-07-22-Cstpool.ll
+++ b/test/CodeGen/Mips/2008-07-22-Cstpool.ll
@@ -1,6 +1,6 @@
; 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"
diff --git a/test/CodeGen/PowerPC/sections.ll b/test/CodeGen/PowerPC/sections.ll
index 0ff4a89..260b91e 100644
--- a/test/CodeGen/PowerPC/sections.ll
+++ b/test/CodeGen/PowerPC/sections.ll
@@ -3,6 +3,6 @@
@A = global i32 0
-; CHECK: .section .bss,"aw",@nobits
+; CHECK: .section ".bss","aw",@nobits
; CHECK: .globl A
diff --git a/test/CodeGen/X86/attribute-sections.ll b/test/CodeGen/X86/attribute-sections.ll
index 3035334..19e56ee 100644
--- a/test/CodeGen/X86/attribute-sections.ll
+++ b/test/CodeGen/X86/attribute-sections.ll
@@ -3,16 +3,16 @@
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
diff --git a/test/CodeGen/X86/bss_pagealigned.ll b/test/CodeGen/X86/bss_pagealigned.ll
index da95aca..746364e 100644
--- a/test/CodeGen/X86/bss_pagealigned.ll
+++ b/test/CodeGen/X86/bss_pagealigned.ll
@@ -14,7 +14,7 @@ define void @unxlate_dev_mem_ptr(i64 %phis, i8* %addr) nounwind {
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
diff --git a/test/CodeGen/X86/global-sections-tls.ll b/test/CodeGen/X86/global-sections-tls.ll
index 2c23030..e1e5fb3 100644
--- a/test/CodeGen/X86/global-sections-tls.ll
+++ b/test/CodeGen/X86/global-sections-tls.ll
@@ -2,7 +2,7 @@
; PR4639
@G1 = internal thread_local global i32 0 ; <i32*> [#uses=1]
-; LINUX: .section .tbss,"awT",@nobits
+; LINUX: .section ".tbss","awT",@nobits
; LINUX: G1:
diff --git a/test/CodeGen/X86/global-sections.ll b/test/CodeGen/X86/global-sections.ll
index 39a69e1..7625a40 100644
--- a/test/CodeGen/X86/global-sections.ll
+++ b/test/CodeGen/X86/global-sections.ll
@@ -33,10 +33,10 @@
; 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
@@ -66,7 +66,7 @@
@"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:
@@ -79,7 +79,7 @@
@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
@@ -99,12 +99,12 @@
; 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
@@ -114,7 +114,7 @@
; 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:
@@ -123,7 +123,7 @@
; 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
diff --git a/test/CodeGen/X86/pic_jumptable.ll b/test/CodeGen/X86/pic_jumptable.ll
index b6761e3..8ddba4a 100644
--- a/test/CodeGen/X86/pic_jumptable.ll
+++ b/test/CodeGen/X86/pic_jumptable.ll
@@ -1,4 +1,4 @@
-; 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
diff --git a/test/CodeGen/XCore/constants.ll b/test/CodeGen/XCore/constants.ll
index cad1a21..10cf9a7 100644
--- a/test/CodeGen/XCore/constants.ll
+++ b/test/CodeGen/XCore/constants.ll
@@ -1,6 +1,6 @@
; 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:
diff --git a/test/CodeGen/XCore/globals.ll b/test/CodeGen/XCore/globals.ll
index 7487561..f6ff335 100644
--- a/test/CodeGen/XCore/globals.ll
+++ b/test/CodeGen/XCore/globals.ll
@@ -60,33 +60,33 @@ entry:
}
@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:
diff --git a/test/CodeGen/XCore/tls.ll b/test/CodeGen/XCore/tls.ll
index ed41afa..b4f1671 100644
--- a/test/CodeGen/XCore/tls.ll
+++ b/test/CodeGen/XCore/tls.ll
@@ -8,7 +8,7 @@ entry:
}
@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
diff --git a/test/MC/ELF/section-quoting.s b/test/MC/ELF/section-quoting.s
new file mode 100644
index 0000000..5335af1
--- /dev/null
+++ b/test/MC/ELF/section-quoting.s
@@ -0,0 +1,10 @@
+// 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"