aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-11-13 22:04:09 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-11-13 22:04:09 +0000
commitf1aef758a7902c73ef7f2dd568bef8ad47f93006 (patch)
tree706235ff661c5f0316aa131a1a9dd1bf681ca505 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent472264c6b4a44c089643b67d6f4faaffb96bd4b6 (diff)
downloadllvm-f1aef758a7902c73ef7f2dd568bef8ad47f93006.zip
llvm-f1aef758a7902c73ef7f2dd568bef8ad47f93006.tar.gz
llvm-f1aef758a7902c73ef7f2dd568bef8ad47f93006.tar.bz2
[MC][COFF] Emit weak symbols to the correct section. Patch by Dmitry Puzirev!
llvm-svn: 167877
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 8f5d770..2ee9436 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -701,8 +701,19 @@ getCOFFSectionFlags(SectionKind K) {
const MCSection *TargetLoweringObjectFileCOFF::
getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
Mangler *Mang, const TargetMachine &TM) const {
- return getContext().getCOFFSection(GV->getSection(),
- getCOFFSectionFlags(Kind),
+ int Selection = 0;
+ unsigned Characteristics = getCOFFSectionFlags(Kind);
+ SmallString<128> Name(GV->getSection().c_str());
+ if (GV->isWeakForLinker()) {
+ Selection = COFF::IMAGE_COMDAT_SELECT_ANY;
+ Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
+ MCSymbol *Sym = Mang->getSymbol(GV);
+ Name.append("$");
+ Name.append(Sym->getName().begin() + 1, Sym->getName().end());
+ }
+ return getContext().getCOFFSection(Name,
+ Characteristics,
+ Selection,
Kind);
}