[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
Mon Sep 17 08:41:39 PDT 2018
grimar updated this revision to Diff 165773.
grimar added a comment.
This revision is now accepted and ready to land.
- Fix BB failure.
https://reviews.llvm.org/D51361
Files:
lib/CodeGen/TargetLoweringObjectFileImpl.cpp
lib/MC/MCContext.cpp
test/MC/ELF/section-flags.s
Index: lib/MC/MCContext.cpp
===================================================================
--- lib/MC/MCContext.cpp
+++ 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) {
Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -412,6 +412,9 @@
Name.startswith(".llvm.linkonce.sb."))
return SectionKind::getBSS();
+ if (Name == ".rodata" || Name.startswith(".rodata."))
+ return SectionKind::getReadOnly();
+
if (Name == ".tdata" ||
Name.startswith(".tdata.") ||
Name.startswith(".gnu.linkonce.td.") ||
@@ -424,6 +427,9 @@
Name.startswith(".llvm.linkonce.tb."))
return SectionKind::getThreadBSS();
+ if (Name.startswith(".debug_"))
+ return SectionKind::getMetadata();
+
return K;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51361.165773.patch
Type: text/x-patch
Size: 1902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180917/965385a9/attachment.bin>
More information about the llvm-commits
mailing list