annotate lld/MachO/UnwindInfoSection.h @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents
children 5f17cb93ff66
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
207
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 //===- UnwindInfoSection.h ------------------------------------------------===//
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 //
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 //
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #ifndef LLD_MACHO_UNWIND_INFO_H
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #define LLD_MACHO_UNWIND_INFO_H
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #include "ConcatOutputSection.h"
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #include "SyntheticSections.h"
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 #include "mach-o/compact_unwind_encoding.h"
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #include "llvm/ADT/DenseMap.h"
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 #include <vector>
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 namespace lld {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 namespace macho {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 template <class Ptr> struct CompactUnwindEntry {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 Ptr functionAddress;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 uint32_t functionLength;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 compact_unwind_encoding_t encoding;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 Ptr personality;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 Ptr lsda;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 class UnwindInfoSection : public SyntheticSection {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 public:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 bool isNeeded() const override { return compactUnwindSection != nullptr; }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 uint64_t getSize() const override { return unwindInfoSize; }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 virtual void prepareRelocations(InputSection *) = 0;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 void setCompactUnwindSection(ConcatOutputSection *cuSection) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 compactUnwindSection = cuSection;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 protected:
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 UnwindInfoSection()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 : SyntheticSection(segment_names::text, section_names::unwindInfo) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 align = 4;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 ConcatOutputSection *compactUnwindSection = nullptr;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 uint64_t unwindInfoSize = 0;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 };
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 UnwindInfoSection *makeUnwindInfoSection();
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 } // namespace macho
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 } // namespace lld
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 #endif