EhFrameHdr.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
1//===- EhFrameHdr.h -------------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#ifndef MCLD_LD_EHFRAMEHDR_H 10#define MCLD_LD_EHFRAMEHDR_H 11#ifdef ENABLE_UNITTEST 12#include <gtest.h> 13#endif 14#include <mcld/ADT/SizeTraits.h> 15#include <cassert> 16 17#include <mcld/LD/EhFrame.h> 18#include <mcld/Support/FileOutputBuffer.h> 19namespace mcld { 20 21class LDSection; 22class FileOutputBuffer; 23 24/** \class EhFrameHdr 25 * \brief EhFrameHdr represents .eh_frame_hdr section. 26 * 27 * @ref lsb core generic 4.1 28 * .eh_frame_hdr section format 29 * uint8_t : version 30 * uint8_t : eh_frame_ptr_enc 31 * uint8_t : fde_count_enc 32 * uint8_t : table_enc 33 * uint32_t : eh_frame_ptr 34 * uint32_t : fde_count 35 * __________________________ when fde_count > 0 36 * <uint32_t, uint32_t>+ : binary search table 37 */ 38class EhFrameHdr 39{ 40public: 41 EhFrameHdr(LDSection& pEhFrameHdr, const LDSection& pEhFrame); 42 43 ~EhFrameHdr(); 44 45 /// sizeOutput - base on the fde count to size output 46 void sizeOutput(); 47 48 /// emitOutput - write out eh_frame_hdr 49 template<size_t size> 50 void emitOutput(FileOutputBuffer& pOutput) 51 { assert(false && "Call invalid EhFrameHdr::emitOutput"); } 52 53private: 54 /// computePCBegin - return the address of FDE's pc 55 /// @ref binutils gold: ehframe.cc:222 56 uint32_t computePCBegin(const EhFrame::FDE& pFDE, 57 const MemoryRegion& pEhFrameRegion); 58 59private: 60 /// .eh_frame_hdr section 61 LDSection& m_EhFrameHdr; 62 63 /// eh_frame 64 const LDSection& m_EhFrame; 65}; 66 67//===----------------------------------------------------------------------===// 68// Template Specification Functions 69//===----------------------------------------------------------------------===// 70/// emitOutput - write out eh_frame_hdr 71template<> 72void EhFrameHdr::emitOutput<32>(FileOutputBuffer& pOutput); 73 74} // namespace of mcld 75 76#endif 77 78