diff options
author | Chris Lattner <sabre@nondot.org> | 2010-05-07 21:49:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-05-07 21:49:09 +0000 |
commit | 028449325b8c58f1c24daf63a6f00c1bdcf57cb4 (patch) | |
tree | 3958d204b992c30afe4b856c38d43b74494b2f1b /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | 8d6a2b74284a04b701074b64253fcdebc96b2d24 (diff) | |
download | bcm5719-llvm-028449325b8c58f1c24daf63a6f00c1bdcf57cb4.tar.gz bcm5719-llvm-028449325b8c58f1c24daf63a6f00c1bdcf57cb4.zip |
add COFF support for COMDAT sections, patch by Nathan Jeffords!
llvm-svn: 103304
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index b74ed567ae4..00e1e83cf18 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -912,11 +912,17 @@ getCOFFSectionFlags(SectionKind K) { unsigned Flags = 0; if (!K.isMetadata()) - Flags |= MCSectionCOFF::IMAGE_SCN_MEM_DISCARDABLE; + Flags |= + MCSectionCOFF::IMAGE_SCN_MEM_DISCARDABLE; else if (K.isText()) Flags |= MCSectionCOFF::IMAGE_SCN_MEM_EXECUTE | MCSectionCOFF::IMAGE_SCN_CNT_CODE; + else if (K.isBSS ()) + Flags |= + MCSectionCOFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA | + MCSectionCOFF::IMAGE_SCN_MEM_READ | + MCSectionCOFF::IMAGE_SCN_MEM_WRITE; else if (K.isReadOnly()) Flags |= MCSectionCOFF::IMAGE_SCN_CNT_INITIALIZED_DATA | @@ -941,6 +947,8 @@ getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, static const char *getCOFFSectionPrefixForUniqueGlobal(SectionKind Kind) { if (Kind.isText()) return ".text$linkonce"; + if (Kind.isBSS ()) + return ".bss$linkonce"; if (Kind.isWriteable()) return ".data$linkonce"; return ".rdata$linkonce"; @@ -959,9 +967,13 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); MCSymbol *Sym = Mang->getSymbol(GV); Name.append(Sym->getName().begin(), Sym->getName().end()); - return getContext().getCOFFSection(Name.str(), - getCOFFSectionFlags(Kind), - Kind); + + unsigned Characteristics = getCOFFSectionFlags(Kind); + + Characteristics |= MCSectionCOFF::IMAGE_SCN_LNK_COMDAT; + + return getContext().getCOFFSection(Name.str(), Characteristics, + MCSectionCOFF::IMAGE_COMDAT_SELECT_EXACT_MATCH, Kind); } if (Kind.isText()) |