[PATCH] D51361: [llvm-mc] - Allow to set custom flags for debug sections.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 29 01:44:00 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340904: [llvm-mc] - Allow to set custom flags for debug sections. (authored by grimar, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D51361?vs=162876&id=163027#toc
Repository:
rL LLVM
https://reviews.llvm.org/D51361
Files:
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/trunk/lib/MC/MCContext.cpp
llvm/trunk/test/MC/ELF/section-flags.s
Index: llvm/trunk/test/MC/ELF/section-flags.s
===================================================================
--- llvm/trunk/test/MC/ELF/section-flags.s
+++ llvm/trunk/test/MC/ELF/section-flags.s
@@ -0,0 +1,12 @@
+# RUN: llvm-mc -triple x86_64-pc-linux-gnu %s -filetype=obj -o %t.o
+# RUN: llvm-readobj -s --elf-output-style=GNU %t.o | FileCheck %s
+
+## Check we are able to set the custom flag ('E') for debug sections.
+# CHECK: .debug_info {{.*}} E
+# CHECK: .debug_str {{.*}} EMS
+
+.section .debug_info,"e"
+nop
+
+.section .debug_str,"eMS", at progbits,1
+nop
Index: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -424,6 +424,9 @@
Name.startswith(".llvm.linkonce.tb."))
return SectionKind::getThreadBSS();
+ if (Name.startswith(".debug_"))
+ return SectionKind::getMetadata();
+
return K;
}
Index: llvm/trunk/lib/MC/MCContext.cpp
===================================================================
--- llvm/trunk/lib/MC/MCContext.cpp
+++ llvm/trunk/lib/MC/MCContext.cpp
@@ -394,6 +394,15 @@
auto IterBool = ELFUniquingMap.insert(
std::make_pair(ELFSectionKey{Section.str(), Group, UniqueID}, nullptr));
auto &Entry = *IterBool.first;
+ MCSectionELF *&Sec = Entry.second;
+ if (!IterBool.second) {
+ // We want to let users add additional flags even for sections with
+ // defaults. For example, .debug_str has "MS" flags by default and user
+ // might want to add "E".
+ Sec->setFlags(Sec->getFlags() | Flags);
+ return Sec;
+ }
+
if (!IterBool.second)
return Entry.second;
@@ -407,10 +416,9 @@
else
Kind = SectionKind::getReadOnly();
- MCSectionELF *Result = createELFSectionImpl(
- CachedName, Type, Flags, Kind, EntrySize, GroupSym, UniqueID, Associated);
- Entry.second = Result;
- return Result;
+ Sec = createELFSectionImpl(CachedName, Type, Flags, Kind, EntrySize, GroupSym,
+ UniqueID, Associated);
+ return Sec;
}
MCSectionELF *MCContext::createELFGroupSection(const MCSymbolELF *Group) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51361.163027.patch
Type: text/x-patch
Size: 2230 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180829/ecf7cc6b/attachment.bin>
More information about the llvm-commits
mailing list