llvm.org GIT mirror llvm / 3168868
COFF: Emit all MCSymbols rather than filtering out some of them In particular, this means we emit non-external symbols defined to variables, such as aliases or absolute addresses. This is needed to implement /safeseh, and it appears there was some confusion about what symbols to emit previously. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190888 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 6 years ago
2 changed file(s) with 13 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
153153 void MakeSymbolReal(COFFSymbol &S, size_t Index);
154154 void MakeSectionReal(COFFSection &S, size_t Number);
155155
156 bool ExportSymbol(MCSymbolData const &SymbolData, MCAssembler &Asm);
157
158156 bool IsPhysicalSection(COFFSection *S);
159157
160158 // Entity writing methods.
493491 } else
494492 std::memcpy(S.Data.Name, S.Name.c_str(), S.Name.size());
495493 S.Index = Index;
496 }
497
498 bool WinCOFFObjectWriter::ExportSymbol(MCSymbolData const &SymbolData,
499 MCAssembler &Asm) {
500 // This doesn't seem to be right. Strings referred to from the .data section
501 // need symbols so they can be linked to code in the .text section right?
502
503 // return Asm.isSymbolLinkerVisible (&SymbolData);
504
505 // For now, all non-variable symbols are exported,
506 // the linker will sort the rest out for us.
507 return SymbolData.isExternal() || !SymbolData.getSymbol().isVariable();
508494 }
509495
510496 bool WinCOFFObjectWriter::IsPhysicalSection(COFFSection *S) {
608594 DefineSection(*i);
609595
610596 for (MCAssembler::const_symbol_iterator i = Asm.symbol_begin(),
611 e = Asm.symbol_end(); i != e; i++) {
612 if (ExportSymbol(*i, Asm)) {
613 DefineSymbol(*i, Asm);
614 }
615 }
597 e = Asm.symbol_end();
598 i != e; i++)
599 DefineSymbol(*i, Asm);
616600 }
617601
618602 void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
3636 // CHECK: }
3737 // CHECK: Symbol {
3838 // CHECK-NEXT: Name: local1
39 // CHECK-NEXT: Value: 0
40 // CHECK-NEXT: Section: .text (1)
41 // CHECK-NEXT: BaseType: Null (0x0)
42 // CHECK-NEXT: ComplexType: Null (0x0)
43 // CHECK-NEXT: StorageClass: Static (0x3)
44 // CHECK-NEXT: AuxSymbolCount: 0
45 // CHECK-NEXT: }
46 // CHECK-NEXT: Symbol {
47 // CHECK-NEXT: Name: external_aliased_to_local
3948 // CHECK-NEXT: Value: 0
4049 // CHECK-NEXT: Section: .text (1)
4150 // CHECK-NEXT: BaseType: Null (0x0)
8897 // CHECK-NEXT: StorageClass: WeakExternal (0x69)
8998 // CHECK-NEXT: AuxSymbolCount: 1
9099 // CHECK-NEXT: AuxWeakExternal {
91 // CHECK-NEXT: Linked: external2 (9)
100 // CHECK-NEXT: Linked: external2 (10)
92101 // CHECK-NEXT: Search: Library (0x2)
93102 // CHECK-NEXT: Unused: (00 00 00 00 00 00 00 00 00 00)
94103 // CHECK-NEXT: }