Home | History | Annotate | Download | only in LD
      1 //===- ELFObjectReader.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_ELF_OBJECT_READER_H
     10 #define MCLD_ELF_OBJECT_READER_H
     11 
     12 #include <mcld/LD/ObjectReader.h>
     13 #include <mcld/ADT/Flags.h>
     14 
     15 namespace mcld {
     16 
     17 class Module;
     18 class Input;
     19 class IRBuilder;
     20 class GNULDBackend;
     21 class ELFReaderIF;
     22 class EhFrameReader;
     23 class LinkerConfig;
     24 
     25 /** \lclass ELFObjectReader
     26  *  \brief ELFObjectReader reads target-independent parts of ELF object file
     27  */
     28 class ELFObjectReader : public ObjectReader
     29 {
     30 public:
     31   enum ReadFlagType {
     32     ParseEhFrame    = 0x1, ///< parse .eh_frame section if the bit is set.
     33     NumOfReadFlags  = 1
     34   };
     35 
     36   typedef Flags<ReadFlagType> ReadFlag;
     37 
     38 public:
     39   ELFObjectReader(GNULDBackend& pBackend,
     40                   IRBuilder& pBuilder,
     41                   const LinkerConfig& pConfig);
     42 
     43   ~ELFObjectReader();
     44 
     45   // -----  observers  ----- //
     46   bool isMyFormat(Input &pFile, bool &pContinue) const;
     47 
     48   // -----  readers  ----- //
     49   bool readHeader(Input& pFile);
     50 
     51   virtual bool readSections(Input& pFile);
     52 
     53   virtual bool readSymbols(Input& pFile);
     54 
     55   /// readRelocations - read relocation sections
     56   ///
     57   /// This function should be called after symbol resolution.
     58   virtual bool readRelocations(Input& pFile);
     59 
     60 private:
     61   ELFReaderIF* m_pELFReader;
     62   EhFrameReader* m_pEhFrameReader;
     63   IRBuilder& m_Builder;
     64   ReadFlag m_ReadFlag;
     65   GNULDBackend& m_Backend;
     66   const LinkerConfig& m_Config;
     67 };
     68 
     69 } // namespace of mcld
     70 
     71 #endif
     72 
     73