xref: /freebsd/contrib/llvm-project/lld/MachO/UnwindInfoSection.h (revision 1f1e2261e341e6ca6862f82261066ef1705f0a7a)
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 #include "llvm/ADT/MapVector.h"
15 
16 #include "mach-o/compact_unwind_encoding.h"
17 
18 namespace lld {
19 namespace macho {
20 
21 class UnwindInfoSection : public SyntheticSection {
22 public:
23   // If all functions are free of unwind info, we can omit the unwind info
24   // section entirely.
25   bool isNeeded() const override { return !allEntriesAreOmitted; }
26   uint64_t getSize() const override { return unwindInfoSize; }
27   void addSymbol(const Defined *);
28   void prepareRelocations();
29 
30 protected:
31   UnwindInfoSection();
32   virtual void prepareRelocations(ConcatInputSection *) = 0;
33 
34   llvm::MapVector<std::pair<const InputSection *, uint64_t /*Defined::value*/>,
35                   const Defined *>
36       symbols;
37   std::vector<decltype(symbols)::value_type> symbolsVec;
38   uint64_t unwindInfoSize = 0;
39   bool allEntriesAreOmitted = true;
40 };
41 
42 UnwindInfoSection *makeUnwindInfoSection();
43 
44 } // namespace macho
45 } // namespace lld
46 
47 #endif
48