summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-02-17 20:48:01 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-02-17 20:48:01 +0000
commit68fa249cb5a9755f05e437db618d85e0097de8c3 (patch)
treeb8a223ea649e474a993233c5738e73fba8e83932 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent3dcb3934c6072f5e2eed15fd63cdc1a35bb5cad4 (diff)
downloadbcm5719-llvm-68fa249cb5a9755f05e437db618d85e0097de8c3.tar.gz
bcm5719-llvm-68fa249cb5a9755f05e437db618d85e0097de8c3.zip
Add r228980 back.
Add support for having multiple sections with the same name and comdat. Using this in combination with -ffunction-sections allows LLVM to output a .o file with mulitple sections named .text. This saves space by avoiding long unique names of the form .text.<C++ mangled name>. llvm-svn: 229541
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 17bd024ad28..07d9576222e 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -228,25 +228,25 @@ const MCSection *TargetLoweringObjectFileELF::getExplicitSectionGlobal(
/// DataSections.
static StringRef getSectionPrefixForGlobal(SectionKind Kind) {
if (Kind.isText())
- return ".text.";
+ return ".text";
if (Kind.isReadOnly())
- return ".rodata.";
+ return ".rodata";
if (Kind.isBSS())
- return ".bss.";
+ return ".bss";
if (Kind.isThreadData())
- return ".tdata.";
+ return ".tdata";
if (Kind.isThreadBSS())
- return ".tbss.";
+ return ".tbss";
if (Kind.isDataNoRel())
- return ".data.";
+ return ".data";
if (Kind.isDataRelLocal())
- return ".data.rel.local.";
+ return ".data.rel.local";
if (Kind.isDataRel())
- return ".data.rel.";
+ return ".data.rel";
if (Kind.isReadOnlyWithRelLocal())
- return ".data.rel.ro.local.";
+ return ".data.rel.ro.local";
assert(Kind.isReadOnlyWithRel() && "Unknown section kind");
- return ".data.rel.ro.";
+ return ".data.rel.ro";
}
const MCSection *TargetLoweringObjectFileELF::
@@ -268,16 +268,19 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
StringRef Prefix = getSectionPrefixForGlobal(Kind);
SmallString<128> Name(Prefix);
- TM.getNameWithPrefix(Name, GV, Mang, true);
-
+ bool UniqueSectionNames = TM.getUniqueSectionNames();
+ if (UniqueSectionNames) {
+ Name.push_back('.');
+ TM.getNameWithPrefix(Name, GV, Mang, true);
+ }
StringRef Group = "";
if (const Comdat *C = getELFComdat(GV)) {
Flags |= ELF::SHF_GROUP;
Group = C->getName();
}
- return getContext().getELFSection(
- Name.str(), getELFSectionType(Name.str(), Kind), Flags, 0, Group);
+ return getContext().getELFSection(Name, getELFSectionType(Name, Kind),
+ Flags, 0, Group, !UniqueSectionNames);
}
if (Kind.isText()) return TextSection;
OpenPOWER on IntegriCloud