llvm.org GIT mirror llvm / 789d4d2
[DebugInfo][COFF] Fix reading variable-length encoded records While reading Codeview records which contain variable-length encoded integers, such as LF_BCLASS, LF_ENUMERATE, LF_MEMBER, LF_VBCLASS or LF_IVBCLASS, the record's size would be improperly calculated in cases where the value was indeed of a variable length (>= LF_NUMERIC). This caused a bad alignement on the next record, which would/might crash later on. Differential Revision: https://reviews.llvm.org/D45104 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329659 91177308-0d34-0410-b5e6-96231b3b80d8 Alexandre Ganea 1 year, 7 months ago
2 changed file(s) with 10 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
5757 8, // LF_UQUADWORD
5858 };
5959
60 return Sizes[N - LF_NUMERIC];
60 return 2 + Sizes[N - LF_NUMERIC];
6161 }
6262
6363 static inline uint32_t getCStringLength(ArrayRef Data) {
392392 Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type
393393 break;
394394 case SymbolKind::S_REGISTER:
395 Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type;
395 Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type
396396 break;
397397 case SymbolKind::S_CONSTANT:
398398 Refs.push_back({TiRefKind::TypeRef, 0, 1}); // Type
592592 writeTypeRecords(P, EP);
593593 checkTypeReferences(0);
594594 }
595
596 // This is a test for getEncodedIntegerLength()
597 TEST_F(TypeIndexIteratorTest, VariableSizeIntegers) {
598 BaseClassRecord BaseClass1(MemberAccess::Public, TypeIndex(47), (uint64_t)-1);
599 BaseClassRecord BaseClass2(MemberAccess::Public, TypeIndex(48), 1);
600 writeFieldList(BaseClass1, BaseClass2);
601 checkTypeReferences(0, TypeIndex(47), TypeIndex(48));
602 }