WinCOFF: Emit common symbols as specified in the COFF spec

Summary:
Local common symbols were properly inserted into the .bss section.
However, putting external common symbols in the .bss section would give
them a strong definition.

Instead, encode them as undefined, external symbols who's symbol value
is equivalent to their size.

Reviewers: Bigcheese, rafael, rnk

CC: llvm-commits

Differential Revision: http://reviews.llvm.org/D3324

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205811 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer
2014-04-08 22:33:40 +00:00
parent 1507319299
commit e4d89ec8de
6 changed files with 45 additions and 36 deletions

View File

@@ -394,7 +394,7 @@ void WinCOFFObjectWriter::DefineSection(MCSectionData const &SectionData) {
SectionMap[&SectionData.getSection()] = coff_section;
}
/// This function takes a section data object from the assembler
/// This function takes a symbol data object from the assembler
/// and creates the associated COFF symbol staging object.
void WinCOFFObjectWriter::DefineSymbol(MCSymbolData const &SymbolData,
MCAssembler &Assembler,
@@ -443,6 +443,8 @@ void WinCOFFObjectWriter::DefineSymbol(MCSymbolData const &SymbolData,
int64_t Addr;
if (Symbol.getVariableValue()->EvaluateAsAbsolute(Addr, Layout))
coff_symbol->Data.Value = Addr;
} else if (SymbolData.isExternal() && SymbolData.isCommon()) {
coff_symbol->Data.Value = SymbolData.getCommonSize();
}
coff_symbol->Data.Type = (ResSymData.getFlags() & 0x0000FFFF) >> 0;