| //===- ELFObjectReader.h --------------------------------------------------===// |
| // |
| // The MCLinker Project |
| // |
| // This file is distributed under the University of Illinois Open Source |
| // License. See LICENSE.TXT for details. |
| // |
| //===----------------------------------------------------------------------===// |
| #ifndef MCLD_ELF_OBJECT_READER_H |
| #define MCLD_ELF_OBJECT_READER_H |
| #ifdef ENABLE_UNITTEST |
| #include <gtest.h> |
| #endif |
| |
| #include <mcld/LD/ObjectReader.h> |
| #include <mcld/ADT/Flags.h> |
| |
| namespace mcld { |
| |
| class Module; |
| class Input; |
| class FragmentLinker; |
| class GNULDBackend; |
| class ELFReaderIF; |
| class EhFrameReader; |
| |
| /** \lclass ELFObjectReader |
| * \brief ELFObjectReader reads target-independent parts of ELF object file |
| */ |
| class ELFObjectReader : public ObjectReader |
| { |
| public: |
| enum ReadFlagType { |
| ParseEhFrame = 0x1, ///< parse .eh_frame section if the bit is set. |
| NumOfReadFlags = 1 |
| }; |
| |
| typedef Flags<ReadFlagType> ReadFlag; |
| |
| public: |
| ELFObjectReader(GNULDBackend& pBackend, FragmentLinker& pLinker); |
| |
| ~ELFObjectReader(); |
| |
| // ----- observers ----- // |
| bool isMyFormat(Input &pFile) const; |
| |
| // ----- readers ----- // |
| bool readHeader(Input& pFile); |
| |
| virtual bool readSections(Input& pFile); |
| |
| virtual bool readSymbols(Input& pFile); |
| |
| /// readRelocations - read relocation sections |
| /// |
| /// This function should be called after symbol resolution. |
| virtual bool readRelocations(Input& pFile); |
| |
| private: |
| ELFReaderIF* m_pELFReader; |
| EhFrameReader* m_pEhFrameReader; |
| FragmentLinker& m_Linker; |
| ReadFlag m_ReadFlag; |
| GNULDBackend& m_Backend; |
| }; |
| |
| } // namespace of mcld |
| |
| #endif |
| |