X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FMC%2FWinCOFFObjectWriter.cpp;h=824895be32de851e30dbdb56a71f94827a75a59e;hb=0e9c68e6bc8768143308b0162e900ba8bd10dc01;hp=6f9c73b9cc5ad072f815ed24ec635ea2fb4863d4;hpb=013321a0f9e9f784ebb9a78ebf19e5f5099d5b16;p=oota-llvm.git diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index 6f9c73b9cc5..824895be32d 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/lib/MC/WinCOFFObjectWriter.cpp @@ -153,7 +153,7 @@ public: void MakeSymbolReal(COFFSymbol &S, size_t Index); void MakeSectionReal(COFFSection &S, size_t Number); - bool ExportSymbol(MCSymbolData const &SymbolData, MCAssembler &Asm); + bool ExportSymbol(const MCSymbol &Symbol, MCAssembler &Asm); bool IsPhysicalSection(COFFSection *S); @@ -456,10 +456,13 @@ void WinCOFFObjectWriter::DefineSymbol(MCSymbolData const &SymbolData, // If no storage class was specified in the streamer, define it here. if (coff_symbol->Data.StorageClass == 0) { - bool external = ResSymData.isExternal() || !ResSymData.Fragment; + bool IsExternal = + ResSymData.isExternal() || + (!ResSymData.getFragment() && !ResSymData.getSymbol().isVariable()); - coff_symbol->Data.StorageClass = - external ? COFF::IMAGE_SYM_CLASS_EXTERNAL : COFF::IMAGE_SYM_CLASS_STATIC; + coff_symbol->Data.StorageClass = IsExternal + ? COFF::IMAGE_SYM_CLASS_EXTERNAL + : COFF::IMAGE_SYM_CLASS_STATIC; } if (!Base) { @@ -546,16 +549,24 @@ void WinCOFFObjectWriter::MakeSymbolReal(COFFSymbol &S, size_t Index) { S.Index = Index; } -bool WinCOFFObjectWriter::ExportSymbol(MCSymbolData const &SymbolData, +bool WinCOFFObjectWriter::ExportSymbol(const MCSymbol &Symbol, MCAssembler &Asm) { // This doesn't seem to be right. Strings referred to from the .data section // need symbols so they can be linked to code in the .text section right? - // return Asm.isSymbolLinkerVisible (&SymbolData); + // return Asm.isSymbolLinkerVisible(Symbol); + + // Non-temporary labels should always be visible to the linker. + if (!Symbol.isTemporary()) + return true; + + // Absolute temporary labels are never visible. + if (!Symbol.isInSection()) + return false; // For now, all non-variable symbols are exported, // the linker will sort the rest out for us. - return SymbolData.isExternal() || !SymbolData.getSymbol().isVariable(); + return !Symbol.isVariable(); } bool WinCOFFObjectWriter::IsPhysicalSection(COFFSection *S) { @@ -689,7 +700,7 @@ void WinCOFFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm, DefineSection(Section); for (MCSymbolData &SD : Asm.symbols()) - if (ExportSymbol(SD, Asm)) + if (ExportSymbol(SD.getSymbol(), Asm)) DefineSymbol(SD, Asm, Layout); } @@ -833,13 +844,9 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm, DenseMap SectionIndices; for (auto & Section : Sections) { - if (Layout.getSectionAddressSize(Section->MCData) > 0) { - size_t Number = ++Header.NumberOfSections; - SectionIndices[Section.get()] = Number; - MakeSectionReal(*Section, Number); - } else { - Section->Number = -1; - } + size_t Number = ++Header.NumberOfSections; + SectionIndices[Section.get()] = Number; + MakeSectionReal(*Section, Number); } Header.NumberOfSymbols = 0;