[PATCH] D138477: MC: Add .data. and .rodata. prefixes to MCContext section classification
Dave Marchevsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 15 23:12:27 PST 2022
davemarchevsky updated this revision to Diff 483438.
davemarchevsky marked an inline comment as done.
davemarchevsky added a comment.
Add test data and FileCheck annotations to exercise `.rodata.suffix` logic
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138477/new/
https://reviews.llvm.org/D138477
Files:
llvm/lib/MC/MCContext.cpp
llvm/test/MC/ELF/data-section-prefix.ll
Index: llvm/test/MC/ELF/data-section-prefix.ll
===================================================================
--- /dev/null
+++ llvm/test/MC/ELF/data-section-prefix.ll
@@ -0,0 +1,25 @@
+; RUN: llc -filetype obj -o - %s | llvm-readobj --sections - | FileCheck --check-prefix="SECTIONS" %s
+;
+; SECTIONS: Name: .data.A
+; SECTIONS-NEXT: Type: SHT_PROGBITS (0x1)
+; SECTIONS-NEXT: Flags [ (0x3)
+; SECTIONS-NEXT: SHF_ALLOC (0x2)
+; SECTIONS-NEXT: SHF_WRITE (0x1)
+; SECTIONS-NEXT: ]
+;
+; SECTIONS: Name: .rodata.A
+; SECTIONS-NEXT: Type: SHT_PROGBITS (0x1)
+; SECTIONS-NEXT: Flags [ (0x3)
+; SECTIONS-NEXT: SHF_ALLOC (0x2)
+; SECTIONS-NEXT: SHF_WRITE (0x1)
+; SECTIONS-NEXT: ]
+
+
+target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
+target triple = "bpf"
+
+ at glock = dso_local local_unnamed_addr global i32 0, section ".data.A", align 8
+ at ghead = dso_local local_unnamed_addr global i32 0, section ".data.A", align 8
+
+ at glock2 = dso_local local_unnamed_addr global i32 0, section ".rodata.A", align 8
+ at ghead2 = dso_local local_unnamed_addr global i32 0, section ".rodata.A", align 8
Index: llvm/lib/MC/MCContext.cpp
===================================================================
--- llvm/lib/MC/MCContext.cpp
+++ llvm/lib/MC/MCContext.cpp
@@ -577,8 +577,10 @@
.Case(".data", SectionKind::getData())
.Case(".data1", SectionKind::getData())
.Case(".data.rel.ro", SectionKind::getReadOnlyWithRel())
+ .StartsWith(".data.", SectionKind::getData())
.Case(".rodata", SectionKind::getReadOnly())
.Case(".rodata1", SectionKind::getReadOnly())
+ .StartsWith(".rodata.", SectionKind::getReadOnly())
.Case(".tbss", SectionKind::getThreadBSS())
.StartsWith(".tbss.", SectionKind::getThreadData())
.StartsWith(".gnu.linkonce.tb.", SectionKind::getThreadData())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138477.483438.patch
Type: text/x-patch
Size: 2007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221216/d1dc72f3/attachment.bin>
More information about the llvm-commits
mailing list