Reland "[clang-repl] Re-implement clang-interpreter as a test case."
[llvm-project.git] / lld / MachO / UnwindInfoSection.h
blobfca11de6eeb1a572993ea8652f80d9cca4f27d5f
1 //===- UnwindInfoSection.h ------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_MACHO_UNWIND_INFO_H
10 #define LLD_MACHO_UNWIND_INFO_H
12 #include "ConcatOutputSection.h"
13 #include "SyntheticSections.h"
15 #include "mach-o/compact_unwind_encoding.h"
17 namespace lld {
18 namespace macho {
20 template <class Ptr> struct CompactUnwindEntry {
21 Ptr functionAddress;
22 uint32_t functionLength;
23 compact_unwind_encoding_t encoding;
24 Ptr personality;
25 Ptr lsda;
28 class UnwindInfoSection : public SyntheticSection {
29 public:
30 bool isNeeded() const override {
31 return !compactUnwindSection->inputs.empty() && !allEntriesAreOmitted;
33 uint64_t getSize() const override { return unwindInfoSize; }
34 virtual void addInput(ConcatInputSection *) = 0;
35 std::vector<ConcatInputSection *> getInputs() {
36 return compactUnwindSection->inputs;
38 void prepareRelocations();
40 protected:
41 UnwindInfoSection();
42 virtual void prepareRelocations(ConcatInputSection *) = 0;
44 ConcatOutputSection *compactUnwindSection;
45 uint64_t unwindInfoSize = 0;
46 bool allEntriesAreOmitted = true;
49 UnwindInfoSection *makeUnwindInfoSection();
51 } // namespace macho
52 } // namespace lld
54 #endif