diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-03-25 06:14:26 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-03-25 06:14:26 +0000 |
commit | 4fd5cd06c815724fa410c0bea276d919dea868c3 (patch) | |
tree | e27e203429de11eeb68146260f2142dcdde9524c /lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | 9d5961d0d89b561be9ef91ea6cca81ef00672d17 (diff) | |
download | llvm-4fd5cd06c815724fa410c0bea276d919dea868c3.tar.gz llvm-4fd5cd06c815724fa410c0bea276d919dea868c3.tar.bz2 llvm-4fd5cd06c815724fa410c0bea276d919dea868c3.tar.xz |
WinCOFF: Add support for -fdata-sections
This is a pretty straight forward translation for COFF, we just need to
stick the data in a COMDAT section marked as
IMAGE_COMDAT_SELECT_NODUPLICATES.
N.B. We must be careful to avoid sticking entities with private linkage
in COMDAT groups. COFF is pretty hostile to the renaming of entities so
we must be careful to disallow GlobalVariables with unstable names.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204703 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 8f113d7916..e41fbfc6d3 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -770,12 +770,18 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, const TargetMachine &TM) const { // If we have -ffunction-sections then we should emit the global value to a // uniqued section specifically for it. - // TODO: Implement -fdata-sections. - bool EmitUniquedSection = Kind.isText() && TM.getFunctionSections(); + bool EmitUniquedSection; + if (Kind.isText()) + EmitUniquedSection = TM.getFunctionSections(); + else + EmitUniquedSection = TM.getDataSections(); // 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 (GV->isWeakForLinker() || EmitUniquedSection) { + // Section names depend on the name of the symbol which is not feasible if the + // symbol has private linkage. + if ((GV->isWeakForLinker() || EmitUniquedSection) && + !GV->hasPrivateLinkage()) { const char *Name = getCOFFSectionNameForUniqueGlobal(Kind); unsigned Characteristics = getCOFFSectionFlags(Kind); |