view 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
line wrap: on
line source

//===- UnwindInfoSection.h ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLD_MACHO_UNWIND_INFO_H
#define LLD_MACHO_UNWIND_INFO_H

#include "ConcatOutputSection.h"
#include "SyntheticSections.h"

#include "mach-o/compact_unwind_encoding.h"
#include "llvm/ADT/DenseMap.h"

#include <vector>

namespace lld {
namespace macho {

template <class Ptr> struct CompactUnwindEntry {
  Ptr functionAddress;
  uint32_t functionLength;
  compact_unwind_encoding_t encoding;
  Ptr personality;
  Ptr lsda;
};

class UnwindInfoSection : public SyntheticSection {
public:
  bool isNeeded() const override { return compactUnwindSection != nullptr; }
  uint64_t getSize() const override { return unwindInfoSize; }
  virtual void prepareRelocations(InputSection *) = 0;

  void setCompactUnwindSection(ConcatOutputSection *cuSection) {
    compactUnwindSection = cuSection;
  }

protected:
  UnwindInfoSection()
      : SyntheticSection(segment_names::text, section_names::unwindInfo) {
    align = 4;
  }

  ConcatOutputSection *compactUnwindSection = nullptr;
  uint64_t unwindInfoSize = 0;
};

UnwindInfoSection *makeUnwindInfoSection();

} // namespace macho
} // namespace lld

#endif