1//===- DebugString.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_DEBUGSTRING_H_ 10#define MCLD_LD_DEBUGSTRING_H_ 11 12#include "mcld/LD/MergedStringTable.h" 13 14#include <vector> 15 16namespace mcld { 17 18class LDSection; 19class Relocation; 20class TargetLDBackend; 21 22/** \class DebugString 23 * \brief DebugString represents the output debug section .debug_str 24 */ 25class DebugString { 26 public: 27 DebugString() 28 : m_pSection(NULL) {} 29 30 static DebugString* Create(LDSection& pSection); 31 32 /// merge - process the strings in the given input .debug_str section and add 33 /// those strings into merged string map 34 void merge(LDSection& pSection); 35 36 /// computeOffsetSize - set up the output offset of each strings and the 37 /// section size 38 /// @return string table size 39 size_t computeOffsetSize(); 40 41 /// applyOffset - apply the relocation which refer to debug string. This 42 /// should be called after finalizeStringsOffset() 43 void applyOffset(Relocation& pReloc, TargetLDBackend& pBackend); 44 45 /// emit - emit the section .debug_str 46 void emit(MemoryRegion& pRegion); 47 48 void setOutputSection(LDSection& pSection) 49 { m_pSection = &pSection; } 50 51 /// ---- observers ----- /// 52 const LDSection* getSection() const { return m_pSection; } 53 LDSection* getSection() { return m_pSection; } 54 55 private: 56 /// m_Section - the output LDSection of this .debug_str 57 LDSection* m_pSection; 58 59 MergedStringTable m_StringTable; 60}; 61 62} // namespace mcld 63 64#endif // MCLD_LD_DEBUGSTRING_H_ 65 66