forked from OSchip/llvm-project
Revert "[PDB] Use a more appropriate message for a fatal error"
Revert "[PDB] Tweak bad type index error handling" check-lld with asan detects use-after-poison. This reverts commits r307733 and r307726. llvm-svn: 307752
This commit is contained in:
parent
7e17e52b87
commit
e970c2b706
|
|
@ -125,25 +125,26 @@ static bool remapTypeIndex(TypeIndex &TI, ArrayRef<TypeIndex> TypeIndexMap) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remapTypesInSymbolRecord(ObjectFile *File,
|
static bool remapTypesInSymbolRecord(ObjectFile *File,
|
||||||
MutableArrayRef<uint8_t> Contents,
|
MutableArrayRef<uint8_t> Contents,
|
||||||
ArrayRef<TypeIndex> TypeIndexMap,
|
ArrayRef<TypeIndex> TypeIndexMap,
|
||||||
ArrayRef<TiReference> TypeRefs) {
|
ArrayRef<TiReference> TypeRefs) {
|
||||||
for (const TiReference &Ref : TypeRefs) {
|
for (const TiReference &Ref : TypeRefs) {
|
||||||
unsigned ByteSize = Ref.Count * sizeof(TypeIndex);
|
unsigned ByteSize = Ref.Count * sizeof(TypeIndex);
|
||||||
if (Contents.size() < Ref.Offset + ByteSize)
|
if (Contents.size() < Ref.Offset + ByteSize) {
|
||||||
fatal("symbol record too short");
|
log("ignoring short symbol record");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
MutableArrayRef<TypeIndex> TIs(
|
MutableArrayRef<TypeIndex> TIs(
|
||||||
reinterpret_cast<TypeIndex *>(Contents.data() + Ref.Offset), Ref.Count);
|
reinterpret_cast<TypeIndex *>(Contents.data() + Ref.Offset), Ref.Count);
|
||||||
for (TypeIndex &TI : TIs) {
|
for (TypeIndex &TI : TIs)
|
||||||
if (!remapTypeIndex(TI, TypeIndexMap)) {
|
if (!remapTypeIndex(TI, TypeIndexMap)) {
|
||||||
TI = TypeIndex(SimpleTypeKind::NotTranslated);
|
|
||||||
log("ignoring symbol record in " + File->getName() +
|
log("ignoring symbol record in " + File->getName() +
|
||||||
" with bad type index 0x" + utohexstr(TI.getIndex()));
|
" with bad type index 0x" + utohexstr(TI.getIndex()));
|
||||||
continue;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// MSVC translates S_PROC_ID_END to S_END.
|
/// MSVC translates S_PROC_ID_END to S_END.
|
||||||
|
|
@ -264,7 +265,8 @@ static void mergeSymbolRecords(BumpPtrAllocator &Alloc, ObjectFile *File,
|
||||||
// Re-map all the type index references.
|
// Re-map all the type index references.
|
||||||
MutableArrayRef<uint8_t> Contents =
|
MutableArrayRef<uint8_t> Contents =
|
||||||
NewData.drop_front(sizeof(RecordPrefix));
|
NewData.drop_front(sizeof(RecordPrefix));
|
||||||
remapTypesInSymbolRecord(File, Contents, TypeIndexMap, TypeRefs);
|
if (!remapTypesInSymbolRecord(File, Contents, TypeIndexMap, TypeRefs))
|
||||||
|
continue;
|
||||||
|
|
||||||
// Fill in "Parent" and "End" fields by maintaining a stack of scopes.
|
// Fill in "Parent" and "End" fields by maintaining a stack of scopes.
|
||||||
CVSymbol NewSym(Sym.kind(), NewData);
|
CVSymbol NewSym(Sym.kind(), NewData);
|
||||||
|
|
|
||||||
|
|
@ -1,146 +0,0 @@
|
||||||
# This test has an S_GPROC32_ID symbol with an invalid type index. Make sure we
|
|
||||||
# keep the record, or we'll have unbalanced scopes, which is bad. This situation
|
|
||||||
# can arise when we can't find the type server PDB.
|
|
||||||
|
|
||||||
# RUN: yaml2obj %s -o %t.obj
|
|
||||||
# RUN: lld-link %t.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main
|
|
||||||
# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s
|
|
||||||
|
|
||||||
# CHECK: Mod 0000 | `{{.*}}pdb-invalid-func-type.yaml.tmp.obj`:
|
|
||||||
# CHECK: 4 | S_GPROC32_ID [size = 44] `main`
|
|
||||||
# CHECK: parent = 0, end = 80, addr = 0000:0000, code size = 3
|
|
||||||
# CHECK: 48 | S_FRAMEPROC [size = 32]
|
|
||||||
# CHECK: 80 | S_END [size = 4]
|
|
||||||
|
|
||||||
--- !COFF
|
|
||||||
header:
|
|
||||||
Machine: IMAGE_FILE_MACHINE_AMD64
|
|
||||||
Characteristics: [ ]
|
|
||||||
sections:
|
|
||||||
- Name: '.debug$S'
|
|
||||||
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
|
|
||||||
Alignment: 1
|
|
||||||
Subsections:
|
|
||||||
- !Symbols
|
|
||||||
Records:
|
|
||||||
- Kind: S_GPROC32_ID
|
|
||||||
ProcSym:
|
|
||||||
CodeSize: 3
|
|
||||||
DbgStart: 0
|
|
||||||
DbgEnd: 2
|
|
||||||
# Corrupt function type!
|
|
||||||
FunctionType: 4101
|
|
||||||
Flags: [ ]
|
|
||||||
DisplayName: main
|
|
||||||
- Kind: S_FRAMEPROC
|
|
||||||
FrameProcSym:
|
|
||||||
TotalFrameBytes: 0
|
|
||||||
PaddingFrameBytes: 0
|
|
||||||
OffsetToPadding: 0
|
|
||||||
BytesOfCalleeSavedRegisters: 0
|
|
||||||
OffsetOfExceptionHandler: 0
|
|
||||||
SectionIdOfExceptionHandler: 0
|
|
||||||
Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ]
|
|
||||||
- Kind: S_PROC_ID_END
|
|
||||||
ScopeEndSym:
|
|
||||||
- !Lines
|
|
||||||
CodeSize: 3
|
|
||||||
Flags: [ ]
|
|
||||||
RelocOffset: 0
|
|
||||||
RelocSegment: 0
|
|
||||||
Blocks:
|
|
||||||
- FileName: 'c:\src\llvm-project\build\t.c'
|
|
||||||
Lines:
|
|
||||||
- Offset: 0
|
|
||||||
LineStart: 1
|
|
||||||
IsStatement: true
|
|
||||||
EndDelta: 0
|
|
||||||
Columns:
|
|
||||||
- !FileChecksums
|
|
||||||
Checksums:
|
|
||||||
- FileName: 'c:\src\llvm-project\build\t.c'
|
|
||||||
Kind: MD5
|
|
||||||
Checksum: 270A878DCC1B845655B162F56C4F5020
|
|
||||||
- !StringTable
|
|
||||||
Strings:
|
|
||||||
- 'c:\src\llvm-project\build\t.c'
|
|
||||||
Relocations:
|
|
||||||
- VirtualAddress: 152
|
|
||||||
SymbolName: main
|
|
||||||
Type: IMAGE_REL_AMD64_SECREL
|
|
||||||
- VirtualAddress: 156
|
|
||||||
SymbolName: main
|
|
||||||
Type: IMAGE_REL_AMD64_SECTION
|
|
||||||
- VirtualAddress: 208
|
|
||||||
SymbolName: main
|
|
||||||
Type: IMAGE_REL_AMD64_SECREL
|
|
||||||
- VirtualAddress: 212
|
|
||||||
SymbolName: main
|
|
||||||
Type: IMAGE_REL_AMD64_SECTION
|
|
||||||
- Name: '.debug$T'
|
|
||||||
Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
|
|
||||||
Alignment: 1
|
|
||||||
Types:
|
|
||||||
- Kind: LF_ARGLIST
|
|
||||||
ArgList:
|
|
||||||
ArgIndices: [ 0 ]
|
|
||||||
- Kind: LF_PROCEDURE
|
|
||||||
Procedure:
|
|
||||||
ReturnType: 116
|
|
||||||
CallConv: NearC
|
|
||||||
Options: [ None ]
|
|
||||||
ParameterCount: 0
|
|
||||||
ArgumentList: 4096
|
|
||||||
- Kind: LF_FUNC_ID
|
|
||||||
FuncId:
|
|
||||||
ParentScope: 0
|
|
||||||
FunctionType: 4097
|
|
||||||
Name: main
|
|
||||||
- Name: '.text$mn'
|
|
||||||
Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
|
|
||||||
Alignment: 16
|
|
||||||
SectionData: 33C0C3
|
|
||||||
symbols:
|
|
||||||
- Name: '.debug$S'
|
|
||||||
Value: 0
|
|
||||||
SectionNumber: 1
|
|
||||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
|
||||||
ComplexType: IMAGE_SYM_DTYPE_NULL
|
|
||||||
StorageClass: IMAGE_SYM_CLASS_STATIC
|
|
||||||
SectionDefinition:
|
|
||||||
Length: 328
|
|
||||||
NumberOfRelocations: 4
|
|
||||||
NumberOfLinenumbers: 0
|
|
||||||
CheckSum: 0
|
|
||||||
Number: 0
|
|
||||||
- Name: '.debug$T'
|
|
||||||
Value: 0
|
|
||||||
SectionNumber: 2
|
|
||||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
|
||||||
ComplexType: IMAGE_SYM_DTYPE_NULL
|
|
||||||
StorageClass: IMAGE_SYM_CLASS_STATIC
|
|
||||||
SectionDefinition:
|
|
||||||
Length: 564
|
|
||||||
NumberOfRelocations: 0
|
|
||||||
NumberOfLinenumbers: 0
|
|
||||||
CheckSum: 0
|
|
||||||
Number: 0
|
|
||||||
- Name: '.text$mn'
|
|
||||||
Value: 0
|
|
||||||
SectionNumber: 3
|
|
||||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
|
||||||
ComplexType: IMAGE_SYM_DTYPE_NULL
|
|
||||||
StorageClass: IMAGE_SYM_CLASS_STATIC
|
|
||||||
SectionDefinition:
|
|
||||||
Length: 3
|
|
||||||
NumberOfRelocations: 0
|
|
||||||
NumberOfLinenumbers: 0
|
|
||||||
CheckSum: 4021952397
|
|
||||||
Number: 0
|
|
||||||
- Name: main
|
|
||||||
Value: 0
|
|
||||||
SectionNumber: 3
|
|
||||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
|
||||||
ComplexType: IMAGE_SYM_DTYPE_FUNCTION
|
|
||||||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
|
||||||
...
|
|
||||||
Loading…
Reference in New Issue