src/blfwk/SRecordSourceFile.h
/*
* Copyright (c) 2013-14, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(_SRecordSourceFile_h_)
#define _SRecordSourceFile_h_
#include "SourceFile.h"
#include "StSRecordFile.h"
#include "StExecutableImage.h"
namespace blfwk
{
class SRecordSourceFile : public SourceFile
{
public:
SRecordSourceFile(const std::string &path);
virtual ~SRecordSourceFile() {}
static bool isSRecordFile(std::istream &stream);
virtual void open();
virtual void close();
virtual bool supportsNamedSections() const { return false; }
virtual bool supportsNamedSymbols() const { return false; }
virtual DataSource *createDataSource();
virtual bool hasEntryPoint();
virtual uint32_t getEntryPointAddress();
protected:
StSRecordFile *m_file;
StExecutableImage *m_image;
bool m_hasEntryRecord;
StSRecordFile::SRecord m_entryRecord;
protected:
void buildMemoryImage();
};
}; // namespace blfwk
#endif // _SRecordSourceFile_h_
StSRecordFile::SRecord
Definition: apps/elftosb/common/StSRecordFile.h:44
blfwk
Definition: BlfwkErrors.h:16
blfwk::SRecordSourceFile::m_file
StSRecordFile * m_file
S-record parser instance.
Definition: src/blfwk/SRecordSourceFile.h:92
blfwk::SRecordSourceFile::hasEntryPoint
virtual bool hasEntryPoint()
Returns true if an entry point was set in the file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:97
blfwk::SRecordSourceFile::isSRecordFile
static bool isSRecordFile(std::istream &stream)
Test whether the stream contains a valid S-record file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:53
blfwk::SRecordSourceFile::m_image
StExecutableImage * m_image
Memory image of the S-record file.
Definition: src/blfwk/SRecordSourceFile.h:93
blfwk::SRecordSourceFile::buildMemoryImage
void buildMemoryImage()
Build memory image of the S-record file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:130
StSRecordFile
S-record parser.
Definition: apps/elftosb/common/StSRecordFile.h:38
blfwk::SRecordSourceFile::~SRecordSourceFile
virtual ~SRecordSourceFile()
Destructor.
Definition: src/blfwk/SRecordSourceFile.h:57
StExecutableImage
Used to build a representation of memory regions.
Definition: apps/elftosb/common/StExecutableImage.h:27
blfwk::SourceFile
Abstract base class for a source file containing executable code.
Definition: src/blfwk/SourceFile.h:56
blfwk::SRecordSourceFile::createDataSource
virtual DataSource * createDataSource()
Returns data source for the entire file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:89
blfwk::SRecordSourceFile
Executable file in the Motorola S-record format.
Definition: src/blfwk/SRecordSourceFile.h:50
blfwk::SRecordSourceFile::open
virtual void open()
Opens the file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:59
blfwk::SRecordSourceFile::m_hasEntryRecord
bool m_hasEntryRecord
Whether an S7,8,9 record was found.
Definition: src/blfwk/SRecordSourceFile.h:94
blfwk::SRecordSourceFile::getEntryPointAddress
virtual uint32_t getEntryPointAddress()
Returns the entry point address.
Definition: src/blfwk/src/SRecordSourceFile.cpp:108
blfwk::SRecordSourceFile::close
virtual void close()
Closes the file.
Definition: src/blfwk/src/SRecordSourceFile.cpp:76
blfwk::SRecordSourceFile::SRecordSourceFile
SRecordSourceFile(const std::string &path)
Default constructor.
Definition: src/blfwk/src/SRecordSourceFile.cpp:46
blfwk::DataSource
Abstract base class for data sources.
Definition: src/blfwk/DataSource.h:56
blfwk::SRecordSourceFile::m_entryRecord
StSRecordFile::SRecord m_entryRecord
Record for the entry point.
Definition: src/blfwk/SRecordSourceFile.h:95