//===- EhFrame.cpp -------------------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // // .eh_frame section contains information on how to unwind the stack when // an exception is thrown. The section consists of sequence of CIE and FDE // records. The linker needs to merge CIEs and associate FDEs to CIEs. // That means the linker has to understand the format of the section. // // This file contains a few utility functions to read .eh_frame contents. // //===----------------------------------------------------------------------===// #include "EhFrame.h" #include "Config.h" #include "InputSection.h" #include "Relocations.h" #include "Target.h" #include "lld/Common/ErrorHandler.h" #include "lld/Common/Strings.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/Object/ELF.h" usingnamespacellvm; usingnamespacellvm::ELF; usingnamespacellvm::dwarf; usingnamespacellvm::object; usingnamespacelld; usingnamespacelld::elf; namespace { class EhReader { … }; } // Read a byte and advance D by one byte. uint8_t EhReader::readByte() { … } void EhReader::skipBytes(size_t count) { … } // Read a null-terminated string. StringRef EhReader::readString() { … } // Skip an integer encoded in the LEB128 format. // Actual number is not of interest because only the runtime needs it. // But we need to be at least able to skip it so that we can read // the field that follows a LEB128 number. void EhReader::skipLeb128() { … } static size_t getAugPSize(Ctx &ctx, unsigned enc) { … } void EhReader::skipAugP() { … } uint8_t elf::getFdeEncoding(EhSectionPiece *p) { … } bool elf::hasLSDA(const EhSectionPiece &p) { … } StringRef EhReader::getAugmentation() { … } uint8_t EhReader::getFdeEncoding() { … } bool EhReader::hasLSDA() { … }