From b892430f0968ae7f80f0d6fe2883f1ad6c452a22 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 24 Jun 2016 17:23:49 +0000 Subject: [PATCH] [codeview] Use one byte for S_FRAMECOOKIE CookieKind and add flags byte We bailed out while printing codeview for an MSVC compiled SemaExprCXX.cpp that used this record. The MS reference headers look incorrect here, which is probably why we had this bug. They use a 32-bit enum as the field type, but the actual record appears to use one byte for the cookie kind followed by a flags byte. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273691 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/CodeView/CodeView.h | 2 +- include/llvm/DebugInfo/CodeView/EnumTables.h | 2 +- include/llvm/DebugInfo/CodeView/SymbolRecord.h | 3 ++- lib/DebugInfo/CodeView/EnumTables.cpp | 4 ++-- lib/DebugInfo/CodeView/SymbolDumper.cpp | 1 + 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/llvm/DebugInfo/CodeView/CodeView.h b/include/llvm/DebugInfo/CodeView/CodeView.h index 0c5813f35ee..1ee203b4f8f 100644 --- a/include/llvm/DebugInfo/CodeView/CodeView.h +++ b/include/llvm/DebugInfo/CodeView/CodeView.h @@ -465,7 +465,7 @@ enum class BinaryAnnotationsOpCode : uint32_t { }; // Corresponds to CV_cookietype_e enum. -enum class FrameCookieKind : uint32_t { +enum class FrameCookieKind : uint8_t { Copy, XorStackPointer, XorFramePointer, diff --git a/include/llvm/DebugInfo/CodeView/EnumTables.h b/include/llvm/DebugInfo/CodeView/EnumTables.h index 0999f211d64..021288e5761 100644 --- a/include/llvm/DebugInfo/CodeView/EnumTables.h +++ b/include/llvm/DebugInfo/CodeView/EnumTables.h @@ -23,7 +23,7 @@ ArrayRef> getSymbolTypeNames(); ArrayRef> getRegisterNames(); ArrayRef> getProcSymFlagNames(); ArrayRef> getLocalFlagNames(); -ArrayRef> getFrameCookieKindNames(); +ArrayRef> getFrameCookieKindNames(); ArrayRef> getSourceLanguageNames(); ArrayRef> getCompileSym2FlagNames(); ArrayRef> getCompileSym3FlagNames(); diff --git a/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/include/llvm/DebugInfo/CodeView/SymbolRecord.h index 0677f5c9cc8..77e894fba4a 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolRecord.h +++ b/include/llvm/DebugInfo/CodeView/SymbolRecord.h @@ -1213,7 +1213,8 @@ public: struct Hdr { ulittle32_t CodeOffset; ulittle16_t Register; - ulittle32_t CookieKind; + uint8_t CookieKind; + uint8_t Flags; }; FrameCookieSym(uint32_t RecordOffset, const Hdr *H) diff --git a/lib/DebugInfo/CodeView/EnumTables.cpp b/lib/DebugInfo/CodeView/EnumTables.cpp index d71fec61344..d59271b2367 100644 --- a/lib/DebugInfo/CodeView/EnumTables.cpp +++ b/lib/DebugInfo/CodeView/EnumTables.cpp @@ -101,7 +101,7 @@ static const EnumEntry LocalFlags[] = { CV_ENUM_CLASS_ENT(LocalSymFlags, IsEnregisteredStatic), }; -static const EnumEntry FrameCookieKinds[] = { +static const EnumEntry FrameCookieKinds[] = { CV_ENUM_CLASS_ENT(FrameCookieKind, Copy), CV_ENUM_CLASS_ENT(FrameCookieKind, XorStackPointer), CV_ENUM_CLASS_ENT(FrameCookieKind, XorFramePointer), @@ -334,7 +334,7 @@ ArrayRef> getProcSymFlagNames() { ArrayRef> getLocalFlagNames() { return makeArrayRef(LocalFlags); } -ArrayRef> getFrameCookieKindNames() { +ArrayRef> getFrameCookieKindNames() { return makeArrayRef(FrameCookieKinds); } ArrayRef> getSourceLanguageNames() { diff --git a/lib/DebugInfo/CodeView/SymbolDumper.cpp b/lib/DebugInfo/CodeView/SymbolDumper.cpp index c2881546c0c..133f9fac19f 100644 --- a/lib/DebugInfo/CodeView/SymbolDumper.cpp +++ b/lib/DebugInfo/CodeView/SymbolDumper.cpp @@ -396,6 +396,7 @@ void CVSymbolDumperImpl::visitFrameCookieSym(SymbolKind Kind, W.printHex("Register", FrameCookie.Header.Register); W.printEnum("CookieKind", uint16_t(FrameCookie.Header.CookieKind), getFrameCookieKindNames()); + W.printHex("Flags", FrameCookie.Header.Flags); } void CVSymbolDumperImpl::visitFrameProcSym(SymbolKind Kind, -- 2.50.1