@@ -153,7 +153,7 @@ class WinCOFFObjectWriter : public MCObjectWriter {
153
153
void MakeSymbolReal (COFFSymbol &S, size_t Index);
154
154
void MakeSectionReal (COFFSection &S, size_t Number);
155
155
156
- bool ExportSymbol (MCSymbolData const &SymbolData , MCAssembler &Asm);
156
+ bool ExportSymbol (const MCSymbol &Symbol , MCAssembler &Asm);
157
157
158
158
bool IsPhysicalSection (COFFSection *S);
159
159
@@ -456,10 +456,13 @@ void WinCOFFObjectWriter::DefineSymbol(MCSymbolData const &SymbolData,
456
456
457
457
// If no storage class was specified in the streamer, define it here.
458
458
if (coff_symbol->Data .StorageClass == 0 ) {
459
- bool external = ResSymData.isExternal () || !ResSymData.Fragment ;
459
+ bool IsExternal =
460
+ ResSymData.isExternal () ||
461
+ (!ResSymData.getFragment () && !ResSymData.getSymbol ().isVariable ());
460
462
461
- coff_symbol->Data .StorageClass =
462
- external ? COFF::IMAGE_SYM_CLASS_EXTERNAL : COFF::IMAGE_SYM_CLASS_STATIC;
463
+ coff_symbol->Data .StorageClass = IsExternal
464
+ ? COFF::IMAGE_SYM_CLASS_EXTERNAL
465
+ : COFF::IMAGE_SYM_CLASS_STATIC;
463
466
}
464
467
465
468
if (!Base) {
@@ -546,16 +549,24 @@ void WinCOFFObjectWriter::MakeSymbolReal(COFFSymbol &S, size_t Index) {
546
549
S.Index = Index;
547
550
}
548
551
549
- bool WinCOFFObjectWriter::ExportSymbol (MCSymbolData const &SymbolData ,
552
+ bool WinCOFFObjectWriter::ExportSymbol (const MCSymbol &Symbol ,
550
553
MCAssembler &Asm) {
551
554
// This doesn't seem to be right. Strings referred to from the .data section
552
555
// need symbols so they can be linked to code in the .text section right?
553
556
554
- // return Asm.isSymbolLinkerVisible(SymbolData.getSymbol());
557
+ // return Asm.isSymbolLinkerVisible(Symbol);
558
+
559
+ // Non-temporary labels should always be visible to the linker.
560
+ if (!Symbol.isTemporary ())
561
+ return true ;
562
+
563
+ // Absolute temporary labels are never visible.
564
+ if (!Symbol.isInSection ())
565
+ return false ;
555
566
556
567
// For now, all non-variable symbols are exported,
557
568
// the linker will sort the rest out for us.
558
- return SymbolData. isExternal () || !SymbolData. getSymbol () .isVariable ();
569
+ return !Symbol .isVariable ();
559
570
}
560
571
561
572
bool WinCOFFObjectWriter::IsPhysicalSection (COFFSection *S) {
@@ -689,7 +700,7 @@ void WinCOFFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm,
689
700
DefineSection (Section);
690
701
691
702
for (MCSymbolData &SD : Asm.symbols ())
692
- if (ExportSymbol (SD, Asm))
703
+ if (ExportSymbol (SD. getSymbol () , Asm))
693
704
DefineSymbol (SD, Asm, Layout);
694
705
}
695
706
0 commit comments