forked from OSchip/llvm-project
COFF: Check for auxiliary symbol's type.
We forgot to check for auxiliary symbol's type. So we sometimes read garbage as associative section definitions. Associative sections are considered as not live themselves by the garbage collector because they are live only when associaited sections are live. By reading more data (or garbage) as associative section definitions, we treated more sections as non-GC-roots, that caused the linker to discard too many sections by mistake. That caused another mysterious bug (such as some global constructors don't run at all for some reason.) llvm-svn: 239287
This commit is contained in:
parent
056decbfee
commit
80141a4bcd
|
@ -22,6 +22,7 @@
|
|||
using namespace llvm::object;
|
||||
using namespace llvm::support::endian;
|
||||
using llvm::COFF::ImportHeader;
|
||||
using llvm::COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE;
|
||||
using llvm::RoundUpToAlignment;
|
||||
using llvm::sys::fs::identify_magic;
|
||||
using llvm::sys::fs::file_magic;
|
||||
|
@ -200,13 +201,16 @@ SymbolBody *ObjectFile::createSymbolBody(StringRef Name, COFFSymbolRef Sym,
|
|||
auto *Aux = (const coff_aux_weak_external *)AuxP;
|
||||
return new (Alloc) Undefined(Name, &SparseSymbolBodies[Aux->TagIndex]);
|
||||
}
|
||||
// Handle associative sections
|
||||
if (IsFirst && AuxP) {
|
||||
if (Chunk *C = SparseChunks[Sym.getSectionNumber()]) {
|
||||
auto *Aux = reinterpret_cast<const coff_aux_section_definition *>(AuxP);
|
||||
auto *Parent =
|
||||
if (Aux->Selection == IMAGE_COMDAT_SELECT_ASSOCIATIVE) {
|
||||
auto *Parent =
|
||||
(SectionChunk *)(SparseChunks[Aux->getNumber(Sym.isBigObj())]);
|
||||
if (Parent)
|
||||
Parent->addAssociative((SectionChunk *)C);
|
||||
if (Parent)
|
||||
Parent->addAssociative((SectionChunk *)C);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Chunk *C = SparseChunks[Sym.getSectionNumber()])
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
; TEXT-11-NEXT: movl $2, %eax
|
||||
; TEXT-11-NEXT: retq
|
||||
|
||||
; HEADERS-01: AddressOfEntryPoint: 0x1000
|
||||
; HEADERS-01: AddressOfEntryPoint: 0x2000
|
||||
; TEXT-01: Disassembly of section .text:
|
||||
; TEXT-01-NEXT: .text:
|
||||
; TEXT-01-NEXT: subq $40, %rsp
|
||||
|
@ -60,7 +60,7 @@
|
|||
; TEXT-01-NEXT: retq
|
||||
; TEXT-01-NEXT: retq
|
||||
|
||||
; HEADERS-10: AddressOfEntryPoint: 0x1010
|
||||
; HEADERS-10: AddressOfEntryPoint: 0x2010
|
||||
; TEXT-10: Disassembly of section .text:
|
||||
; TEXT-10-NEXT: .text:
|
||||
; TEXT-10-NEXT: retq
|
||||
|
|
Loading…
Reference in New Issue