1*993229b6Sjkunz /* 2*993229b6Sjkunz * File: GHSSecInfo.h 3*993229b6Sjkunz * 4*993229b6Sjkunz * Copyright (c) Freescale Semiconductor, Inc. All rights reserved. 5*993229b6Sjkunz * See included license file for license details. 6*993229b6Sjkunz */ 7*993229b6Sjkunz #if !defined(_GHSSecInfo_h_) 8*993229b6Sjkunz #define _GHSSecInfo_h_ 9*993229b6Sjkunz 10*993229b6Sjkunz #include "StELFFile.h" 11*993229b6Sjkunz #include "smart_ptr.h" 12*993229b6Sjkunz 13*993229b6Sjkunz namespace elftosb 14*993229b6Sjkunz { 15*993229b6Sjkunz 16*993229b6Sjkunz /*! 17*993229b6Sjkunz * \brief Wrapper around the GHS-specific .secinfo ELF section. 18*993229b6Sjkunz * 19*993229b6Sjkunz * ELF files produced by the Green Hills MULTI toolset will have a 20*993229b6Sjkunz * special .secinfo section. For the most part, this section contains 21*993229b6Sjkunz * a list of address 22*993229b6Sjkunz * ranges that should be filled by the C runtime startup code. The 23*993229b6Sjkunz * address ranges correspond to those of ELF sections whose type is 24*993229b6Sjkunz * #SHT_NOBITS. The GHS runtime uses this table instead of just filling 25*993229b6Sjkunz * all #SHT_NOBITS sections because the linker command file can 26*993229b6Sjkunz * be used to optionally not fill individual sections. 27*993229b6Sjkunz * 28*993229b6Sjkunz * The isSectionFilled() methods let calling code determine if an ELF 29*993229b6Sjkunz * section is found in the .secinfo table. If the section is found, 30*993229b6Sjkunz * then it should be filled. 31*993229b6Sjkunz */ 32*993229b6Sjkunz class GHSSecInfo 33*993229b6Sjkunz { 34*993229b6Sjkunz public: 35*993229b6Sjkunz //! \brief Default constructor. 36*993229b6Sjkunz GHSSecInfo(StELFFile * elf); 37*993229b6Sjkunz 38*993229b6Sjkunz //! \brief Returns true if there is a .secinfo section present in the ELF file. hasSecinfo()39*993229b6Sjkunz bool hasSecinfo() const { return m_hasInfo; } 40*993229b6Sjkunz 41*993229b6Sjkunz //! \brief Determines if a section should be filled. 42*993229b6Sjkunz bool isSectionFilled(uint32_t addr, uint32_t length); 43*993229b6Sjkunz 44*993229b6Sjkunz //! \brief Determines if \a section should be filled. 45*993229b6Sjkunz bool isSectionFilled(const Elf32_Shdr & section); 46*993229b6Sjkunz 47*993229b6Sjkunz protected: 48*993229b6Sjkunz 49*993229b6Sjkunz #pragma pack(1) 50*993229b6Sjkunz 51*993229b6Sjkunz /*! 52*993229b6Sjkunz * \brief The structure of one .secinfo entry. 53*993229b6Sjkunz */ 54*993229b6Sjkunz struct ghs_secinfo_t 55*993229b6Sjkunz { 56*993229b6Sjkunz uint32_t m_clearAddr; //!< Address to start filling from. 57*993229b6Sjkunz uint32_t m_clearValue; //!< Value to fill with. 58*993229b6Sjkunz uint32_t m_numBytesToClear; //!< Number of bytes to fill. 59*993229b6Sjkunz }; 60*993229b6Sjkunz 61*993229b6Sjkunz #pragma pack() 62*993229b6Sjkunz 63*993229b6Sjkunz protected: 64*993229b6Sjkunz StELFFile * m_elf; //!< The parser object for our ELF file. 65*993229b6Sjkunz bool m_hasInfo; //!< Whether .secinfo is present in the ELF file. 66*993229b6Sjkunz smart_array_ptr<ghs_secinfo_t> m_info; //!< Pointer to the .secinfo entries. Will be NULL if there is no .secinfo section in the file. 67*993229b6Sjkunz unsigned m_entryCount; //!< Number of entries in #m_info. 68*993229b6Sjkunz }; 69*993229b6Sjkunz 70*993229b6Sjkunz }; // namespace elftosb 71*993229b6Sjkunz 72*993229b6Sjkunz #endif // _GHSSecInfo_h_ 73