mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
WinCOFF: Add support for -ffunction-sections
This is a pretty straight forward translation for COFF, we just need to stick the function in a COMDAT section marked as IMAGE_COMDAT_SELECT_NODUPLICATES. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204565 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -768,18 +768,23 @@ static const char *getCOFFSectionNameForUniqueGlobal(SectionKind Kind) {
|
||||
const MCSection *TargetLoweringObjectFileCOFF::
|
||||
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();
|
||||
|
||||
// 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()) {
|
||||
if (GV->isWeakForLinker() || EmitUniquedSection) {
|
||||
const char *Name = getCOFFSectionNameForUniqueGlobal(Kind);
|
||||
unsigned Characteristics = getCOFFSectionFlags(Kind);
|
||||
|
||||
Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
|
||||
MCSymbol *Sym = TM.getSymbol(GV, Mang);
|
||||
return getContext().getCOFFSection(Name, Characteristics,
|
||||
Kind, Sym->getName(),
|
||||
COFF::IMAGE_COMDAT_SELECT_ANY);
|
||||
return getContext().getCOFFSection(
|
||||
Name, Characteristics, Kind, Sym->getName(),
|
||||
GV->isWeakForLinker() ? COFF::IMAGE_COMDAT_SELECT_ANY
|
||||
: COFF::IMAGE_COMDAT_SELECT_NODUPLICATES);
|
||||
}
|
||||
|
||||
if (Kind.isText())
|
||||
|
Reference in New Issue
Block a user