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 //===----------------------------------------------------------------------===// 8 9 #ifndef LLD_MACHO_UNWIND_INFO_H 10 #define LLD_MACHO_UNWIND_INFO_H 11 12 #include "ConcatOutputSection.h" 13 #include "SyntheticSections.h" 14 15 #include "mach-o/compact_unwind_encoding.h" 16 17 namespace lld { 18 namespace macho { 19 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; 26 }; 27 28 class UnwindInfoSection : public SyntheticSection { 29 public: 30 bool isNeeded() const override { 31 return !compactUnwindSection->inputs.empty() && !allEntriesAreOmitted; 32 } 33 uint64_t getSize() const override { return unwindInfoSize; } 34 virtual void addInput(ConcatInputSection *) = 0; 35 std::vector<ConcatInputSection *> getInputs() { 36 return compactUnwindSection->inputs; 37 } 38 void prepareRelocations(); 39 40 protected: 41 UnwindInfoSection(); 42 virtual void prepareRelocations(ConcatInputSection *) = 0; 43 44 ConcatOutputSection *compactUnwindSection; 45 uint64_t unwindInfoSize = 0; 46 bool allEntriesAreOmitted = true; 47 }; 48 49 UnwindInfoSection *makeUnwindInfoSection(); 50 51 } // namespace macho 52 } // namespace lld 53 54 #endif 55