1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

Revert "[COFF] Make the autogenerated .weak.<name>.default symbols static"

This reverts commit 7ca86ee6494d4307333b300bae80e42df4a5140f.

Apparently this change causes MS link.exe to error out with
"LNK1235: corrupt or invalid COFF symbol table".
This commit is contained in:
Martin Storsjö 2019-12-28 23:38:41 +02:00
parent c86b4eb49f
commit afd996b220
4 changed files with 13 additions and 17 deletions

View File

@ -352,10 +352,9 @@ COFFSymbol *WinCOFFObjectWriter::getLinkedSymbol(const MCSymbol &Symbol) {
/// This function takes a symbol data object from the assembler
/// and creates the associated COFF symbol staging object.
void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &MCSymGeneric,
void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &MCSym,
MCAssembler &Assembler,
const MCAsmLayout &Layout) {
const auto &MCSym = cast<MCSymbolCOFF>(MCSymGeneric);
COFFSymbol *Sym = GetOrCreateCOFFSymbol(&MCSym);
const MCSymbol *Base = Layout.getBaseSymbol(MCSym);
COFFSection *Sec = nullptr;
@ -366,7 +365,7 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &MCSymGeneric,
}
COFFSymbol *Local = nullptr;
if (MCSym.isWeakExternal()) {
if (cast<MCSymbolCOFF>(MCSym).isWeakExternal()) {
Sym->Data.StorageClass = COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL;
COFFSymbol *WeakDefault = getLinkedSymbol(MCSym);
@ -377,9 +376,6 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &MCSymGeneric,
WeakDefault->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
else
WeakDefault->Section = Sec;
// Make the default symbol static, in order to not conflict with
// similar default symbols for the same weak in other objects.
WeakDefault->Data.StorageClass = COFF::IMAGE_SYM_CLASS_STATIC;
Local = WeakDefault;
}
@ -398,8 +394,14 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &MCSymGeneric,
else
Sym->Section = Sec;
Local = Sym;
}
Local->Data.StorageClass = MCSym.getClass();
if (Local) {
Local->Data.Value = getSymbolValue(MCSym, Layout);
const MCSymbolCOFF &SymbolCOFF = cast<MCSymbolCOFF>(MCSym);
Local->Data.Type = SymbolCOFF.getType();
Local->Data.StorageClass = SymbolCOFF.getClass();
// If no storage class was specified in the streamer, define it here.
if (Local->Data.StorageClass == COFF::IMAGE_SYM_CLASS_NULL) {
@ -411,12 +413,6 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &MCSymGeneric,
}
}
if (Local) {
Local->Data.Value = getSymbolValue(MCSym, Layout);
Local->Data.Type = MCSym.getType();
}
Sym->MC = &MCSym;
}

View File

@ -38,6 +38,6 @@ a=b
// CHECK-NEXT: Section: .data (2)
// CHECK-NEXT: BaseType: Null (0x0)
// CHECK-NEXT: ComplexType: Null (0x0)
// CHECK-NEXT: StorageClass: Static (0x3)
// CHECK-NEXT: StorageClass: External (0x2)
// CHECK-NEXT: AuxSymbolCount: 0
// CHECK-NEXT: }

View File

@ -28,6 +28,6 @@ b:
// CHECK-NEXT: Section: .data (2)
// CHECK-NEXT: BaseType: Null (0x0)
// CHECK-NEXT: ComplexType: Null (0x0)
// CHECK-NEXT: StorageClass: Static (0x3)
// CHECK-NEXT: StorageClass: External (0x2)
// CHECK-NEXT: AuxSymbolCount: 0
// CHECK-NEXT: }

View File

@ -64,7 +64,7 @@ LBB0_2: # %return
// CHECK-NEXT: Section: IMAGE_SYM_ABSOLUTE (-1)
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: Static
// CHECK-NEXT: StorageClass: External
// CHECK-NEXT: AuxSymbolCount: 0
// CHECK-NEXT: }
@ -88,6 +88,6 @@ LBB0_2: # %return
// CHECK-NEXT: Section: .text
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: Static
// CHECK-NEXT: StorageClass: External
// CHECK-NEXT: AuxSymbolCount: 0
// CHECK-NEXT: }