aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2015-01-15 16:14:34 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2015-01-15 16:14:34 +0000
commitf5adf13facb2a6ef4872501f4a2b3b746efcdb8e (patch)
treeea2e8bd51de9f22f026369e00dae40a7c6a944ab /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent4babd689f922b150f37ab3df8d5b2c7d1ee08548 (diff)
downloadllvm-f5adf13facb2a6ef4872501f4a2b3b746efcdb8e.zip
llvm-f5adf13facb2a6ef4872501f4a2b3b746efcdb8e.tar.gz
llvm-f5adf13facb2a6ef4872501f4a2b3b746efcdb8e.tar.bz2
Revert Don't create new comdats in CodeGen
It breaks AddressSanitizer on Windows. llvm-svn: 226173
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index b9a3ad2..9f1e06b 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -257,7 +257,8 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
// If this global is linkonce/weak and the target handles this by emitting it
// into a 'uniqued' section name, create and return the section now.
- if ((EmitUniquedSection && !Kind.isCommon()) || GV->hasComdat()) {
+ if ((GV->isWeakForLinker() || EmitUniquedSection || GV->hasComdat()) &&
+ !Kind.isCommon()) {
StringRef Prefix = getSectionPrefixForGlobal(Kind);
SmallString<128> Name(Prefix);
@@ -265,9 +266,12 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
StringRef Group = "";
unsigned Flags = getELFSectionFlags(Kind);
- if (const Comdat *C = getELFComdat(GV)) {
+ if (GV->isWeakForLinker() || GV->hasComdat()) {
+ if (const Comdat *C = getELFComdat(GV))
+ Group = C->getName();
+ else
+ Group = Name.substr(Prefix.size());
Flags |= ELF::SHF_GROUP;
- Group = C->getName();
}
return getContext().getELFSection(Name.str(),
@@ -797,7 +801,7 @@ const MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal(
unsigned Characteristics = getCOFFSectionFlags(Kind);
StringRef Name = GV->getSection();
StringRef COMDATSymName = "";
- if (GV->hasComdat()) {
+ if ((GV->isWeakForLinker() || GV->hasComdat()) && !Kind.isCommon()) {
Selection = getSelectionForCOFF(GV);
const GlobalValue *ComdatGV;
if (Selection == COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE)
@@ -844,7 +848,12 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
else
EmitUniquedSection = TM.getDataSections();
- if ((EmitUniquedSection && !Kind.isCommon()) || GV->hasComdat()) {
+ // If this global is linkonce/weak and the target handles this by emitting it
+ // into a 'uniqued' section name, create and return the section now.
+ // Section names depend on the name of the symbol which is not feasible if the
+ // symbol has private linkage.
+ if ((GV->isWeakForLinker() || EmitUniquedSection || GV->hasComdat()) &&
+ !Kind.isCommon()) {
const char *Name = getCOFFSectionNameForUniqueGlobal(Kind);
unsigned Characteristics = getCOFFSectionFlags(Kind);