aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ObjectYAML
diff options
context:
space:
mode:
authorDaniel Paoliello <danpao@microsoft.com>2023-08-31 12:06:50 -0700
committerDaniel Paoliello <danpao@microsoft.com>2023-08-31 12:06:50 -0700
commit0c5c7b52f0f395a6beb7956ba210b8ca727c0471 (patch)
tree1276e579895de3151c7a1de5131443c5b8f05bc1 /llvm/lib/ObjectYAML
parentcf552493a417c838783568887337c99671b088fd (diff)
downloadllvm-0c5c7b52f0f395a6beb7956ba210b8ca727c0471.tar.gz
llvm-0c5c7b52f0f395a6beb7956ba210b8ca727c0471.tar.bz2
llvm-0c5c7b52f0f395a6beb7956ba210b8ca727c0471.zip
Emit the CodeView `S_ARMSWITCHTABLE` debug symbol for jump tables
The CodeView `S_ARMSWITCHTABLE` debug symbol is used to describe the layout of a jump table, it contains the following information: * The address of the branch instruction that uses the jump table. * The address of the jump table. * The "base" address that the values in the jump table are relative to. * The type of each entry (absolute pointer, a relative integer, a relative integer that is shifted). Together this information can be used by debuggers and binary analysis tools to understand what an jump table indirect branch is doing and where it might jump to. Documentation for the symbol can be found in the Microsoft PDB library dumper: https://github.com/microsoft/microsoft-pdb/blob/0fe89a942f9a0f8e061213313e438884f4c9b876/cvdump/dumpsym7.cpp#L5518 This change adds support to LLVM to emit the `S_ARMSWITCHTABLE` debug symbol as well as to dump it out (for testing purposes). Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D149367
Diffstat (limited to 'llvm/lib/ObjectYAML')
-rw-r--r--llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
index 8d2028abfe9b..64e1a58aa71a 100644
--- a/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
+++ b/llvm/lib/ObjectYAML/CodeViewYAMLSymbols.cpp
@@ -61,6 +61,7 @@ LLVM_YAML_DECLARE_ENUM_TRAITS(CPUType)
LLVM_YAML_DECLARE_ENUM_TRAITS(RegisterId)
LLVM_YAML_DECLARE_ENUM_TRAITS(TrampolineType)
LLVM_YAML_DECLARE_ENUM_TRAITS(ThunkOrdinal)
+LLVM_YAML_DECLARE_ENUM_TRAITS(JumpTableEntrySize)
LLVM_YAML_STRONG_TYPEDEF(StringRef, TypeName)
@@ -207,6 +208,15 @@ void ScalarEnumerationTraits<FrameCookieKind>::enumeration(
}
}
+void ScalarEnumerationTraits<JumpTableEntrySize>::enumeration(
+ IO &io, JumpTableEntrySize &FC) {
+ auto ThunkNames = getJumpTableEntrySizeNames();
+ for (const auto &E : ThunkNames) {
+ io.enumCase(FC, E.Name.str().c_str(),
+ static_cast<JumpTableEntrySize>(E.Value));
+ }
+}
+
namespace llvm {
namespace yaml {
template <> struct MappingTraits<LocalVariableAddrRange> {
@@ -586,6 +596,17 @@ template <> void SymbolRecordImpl<AnnotationSym>::map(IO &IO) {
IO.mapRequired("Strings", Symbol.Strings);
}
+template <> void SymbolRecordImpl<JumpTableSym>::map(IO &IO) {
+ IO.mapRequired("BaseOffset", Symbol.BaseOffset);
+ IO.mapRequired("BaseSegment", Symbol.BaseSegment);
+ IO.mapRequired("SwitchType", Symbol.SwitchType);
+ IO.mapRequired("BranchOffset", Symbol.BranchOffset);
+ IO.mapRequired("TableOffset", Symbol.TableOffset);
+ IO.mapRequired("BranchSegment", Symbol.BranchSegment);
+ IO.mapRequired("TableSegment", Symbol.TableSegment);
+ IO.mapRequired("EntriesCount", Symbol.EntriesCount);
+}
+
} // end namespace detail
} // end namespace CodeViewYAML
} // end namespace llvm