Add KBOOT.
This commit is contained in:
79
apps/elftosb/elftosb2/BootImageGenerator.cpp
Normal file
79
apps/elftosb/elftosb2/BootImageGenerator.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* BootImageGenerator.cpp
|
||||
* elftosb
|
||||
*
|
||||
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
|
||||
* See included license file for license details.
|
||||
*/
|
||||
|
||||
#include "BootImageGenerator.h"
|
||||
#include "Logging.h"
|
||||
|
||||
//! Name of product version option.
|
||||
#define kProductVersionOption "productVersion"
|
||||
|
||||
//! Name of component version option.
|
||||
#define kComponentVersionOption "componentVersion"
|
||||
|
||||
//! Name of option that specifies the drive tag for this .sb file.
|
||||
#define kDriveTagOption "driveTag"
|
||||
|
||||
using namespace elftosb;
|
||||
|
||||
void BootImageGenerator::processVersionOptions(BootImage *image)
|
||||
{
|
||||
// bail if no option context was set
|
||||
if (!m_options)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const StringValue *stringValue;
|
||||
version_t version;
|
||||
|
||||
// productVersion
|
||||
if (m_options->hasOption(kProductVersionOption))
|
||||
{
|
||||
stringValue = dynamic_cast<const StringValue *>(m_options->getOption(kProductVersionOption));
|
||||
if (stringValue)
|
||||
{
|
||||
version.set(*stringValue);
|
||||
image->setProductVersion(version);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::log(Logger::WARNING, "warning: productVersion option is an unexpected type\n");
|
||||
}
|
||||
}
|
||||
|
||||
// componentVersion
|
||||
if (m_options->hasOption(kComponentVersionOption))
|
||||
{
|
||||
stringValue = dynamic_cast<const StringValue *>(m_options->getOption(kComponentVersionOption));
|
||||
if (stringValue)
|
||||
{
|
||||
version.set(*stringValue);
|
||||
image->setComponentVersion(version);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::log(Logger::WARNING, "warning: componentVersion option is an unexpected type\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BootImageGenerator::processDriveTagOption(BootImage *image)
|
||||
{
|
||||
if (m_options->hasOption(kDriveTagOption))
|
||||
{
|
||||
const IntegerValue *intValue = dynamic_cast<const IntegerValue *>(m_options->getOption(kDriveTagOption));
|
||||
if (intValue)
|
||||
{
|
||||
image->setDriveTag(static_cast<uint16_t>(intValue->getValue()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::log(Logger::WARNING, "warning: driveTag option is an unexpected type\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
63
apps/elftosb/elftosb2/BootImageGenerator.h
Normal file
63
apps/elftosb/elftosb2/BootImageGenerator.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* File: BootImageGenerator.h
|
||||
*
|
||||
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
|
||||
* See included license file for license details.
|
||||
*/
|
||||
#if !defined(_BootImageGenerator_h_)
|
||||
#define _BootImageGenerator_h_
|
||||
|
||||
#include "OutputSection.h"
|
||||
#include "BootImage.h"
|
||||
#include "OptionContext.h"
|
||||
|
||||
namespace elftosb
|
||||
{
|
||||
/*!
|
||||
* \brief Abstract base class for generators of specific boot image formats.
|
||||
*
|
||||
* Subclasses implement a concrete generator for a certain boot image format, but
|
||||
* they all have the same interface.
|
||||
*
|
||||
* After creating an instance of a subclass the user adds OutputSection objects
|
||||
* to the generator. These objects describe discrete sections within the resulting
|
||||
* boot image file. If the format does not support multiple sections then only
|
||||
* the first will be used.
|
||||
*
|
||||
* Options that are common to all boot image formats are handled by methods
|
||||
* defined in this class. These are the current common options:
|
||||
* - productVersion
|
||||
* - componentVersion
|
||||
* - driveTag
|
||||
*/
|
||||
class BootImageGenerator
|
||||
{
|
||||
public:
|
||||
//! \brief Constructor.
|
||||
BootImageGenerator() {}
|
||||
//! \brief Destructor.
|
||||
virtual ~BootImageGenerator() {}
|
||||
//! \brief Add another section to the output.
|
||||
void addOutputSection(OutputSection *section) { m_sections.push_back(section); }
|
||||
//! \brief Set the global option context.
|
||||
void setOptionContext(OptionContext *context) { m_options = context; }
|
||||
//! \brief Pure virtual method to generate the output BootImage from input sections.
|
||||
virtual BootImage *generate() = 0;
|
||||
|
||||
protected:
|
||||
//! Type for a list of model output sections.
|
||||
typedef std::vector<OutputSection *> section_vector_t;
|
||||
|
||||
section_vector_t m_sections; //!< Requested output sections.
|
||||
OptionContext *m_options; //!< Global option context.
|
||||
|
||||
//! \brief Handle common product and component version options.
|
||||
void processVersionOptions(BootImage *image);
|
||||
|
||||
//! \brief Handle the common option which sets the system drive tag.
|
||||
void processDriveTagOption(BootImage *image);
|
||||
};
|
||||
|
||||
}; // namespace elftosb
|
||||
|
||||
#endif // _BootImageGenerator_h_
|
||||
1934
apps/elftosb/elftosb2/ConversionController.cpp
Normal file
1934
apps/elftosb/elftosb2/ConversionController.cpp
Normal file
File diff suppressed because it is too large
Load Diff
164
apps/elftosb/elftosb2/ConversionController.h
Normal file
164
apps/elftosb/elftosb2/ConversionController.h
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* File: ConversionController.h
|
||||
*
|
||||
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
|
||||
* See included license file for license details.
|
||||
*/
|
||||
#if !defined(_ConversionController_h_)
|
||||
#define _ConversionController_h_
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include "smart_ptr.h"
|
||||
#include "ElftosbLexer.h"
|
||||
#include "ElftosbAST.h"
|
||||
#include "EvalContext.h"
|
||||
#include "Value.h"
|
||||
#include "SourceFile.h"
|
||||
#include "Operation.h"
|
||||
#include "DataSource.h"
|
||||
#include "DataTarget.h"
|
||||
#include "OutputSection.h"
|
||||
#include "BootImage.h"
|
||||
#include "OptionDictionary.h"
|
||||
#include "BootImageGenerator.h"
|
||||
#include "Keyblob.h"
|
||||
|
||||
namespace elftosb
|
||||
{
|
||||
/*!
|
||||
* \brief Manages the entire elftosb file conversion process.
|
||||
*
|
||||
* Instances of this class are intended to be used only once. There is no
|
||||
* way to reset an instance once it has started or completed a conversion.
|
||||
* Thus the run() method is not reentrant. State information is stored in
|
||||
* the object during the conversion process.
|
||||
*
|
||||
* Two things need to be done before the conversion can be started. The
|
||||
* command file path has to be set with the setCommandFilePath() method,
|
||||
* and the paths of any externally provided (i.e., from the command line)
|
||||
* files need to be added with addExternalFilePath(). Once these tasks
|
||||
* are completed, the run() method can be called to parse and execute the
|
||||
* command file. After run() returns, pass an instance of
|
||||
* BootImageGenerator to the generateOutput() method in order to get
|
||||
* an instance of BootImage that can be written to the output file.
|
||||
*/
|
||||
class ConversionController : public OptionDictionary, public EvalContext::SourceFileManager
|
||||
{
|
||||
public:
|
||||
//! \brief Default constructor.
|
||||
ConversionController();
|
||||
|
||||
//! \brief Destructor.
|
||||
virtual ~ConversionController();
|
||||
|
||||
//! \name Paths
|
||||
//@{
|
||||
//! \brief Specify the command file that controls the conversion process.
|
||||
void setCommandFilePath(const std::string &path);
|
||||
|
||||
//! \brief Specify the path of a file provided by the user from outside the command file.
|
||||
void addExternalFilePath(const std::string &path);
|
||||
//@}
|
||||
|
||||
//! \name Conversion
|
||||
//@{
|
||||
//! \brief Process input files.
|
||||
void run();
|
||||
|
||||
//! \brief Uses a BootImageGenerator object to create the final output boot image.
|
||||
BootImage *generateOutput(BootImageGenerator *generator);
|
||||
//@}
|
||||
|
||||
//! \name SourceFileManager interface
|
||||
//@{
|
||||
//! \brief Returns true if a source file with the name \a name exists.
|
||||
virtual bool hasSourceFile(const std::string &name);
|
||||
|
||||
//! \brief Gets the requested source file.
|
||||
virtual SourceFile *getSourceFile(const std::string &name);
|
||||
|
||||
//! \brief Returns the default source file, or NULL if none is set.
|
||||
virtual SourceFile *getDefaultSourceFile();
|
||||
//@}
|
||||
|
||||
//! \brief Returns a reference to the context used for expression evaluation.
|
||||
inline EvalContext &getEvalContext() { return m_context; }
|
||||
protected:
|
||||
//! \name AST processing
|
||||
//@{
|
||||
void parseCommandFile();
|
||||
void processOptions(ListASTNode *options);
|
||||
void processConstants(ListASTNode *constants);
|
||||
void processSources(ListASTNode *sources);
|
||||
void processKeyblob(ExprASTNode *idExpr, ListASTNode *entires);
|
||||
void processSections(ListASTNode *sections);
|
||||
OutputSection *convertDataSection(DataSectionContentsASTNode *dataSection,
|
||||
uint32_t sectionID,
|
||||
OptionDictionary *optionsDict);
|
||||
//@}
|
||||
|
||||
//! \name Statement conversion
|
||||
//@{
|
||||
OperationSequence *convertStatementList(ListASTNode *statements);
|
||||
OperationSequence *convertOneStatement(StatementASTNode *statement);
|
||||
OperationSequence *convertLoadStatement(LoadStatementASTNode *statement);
|
||||
OperationSequence *convertCallStatement(CallStatementASTNode *statement);
|
||||
OperationSequence *convertFromStatement(FromStatementASTNode *statement);
|
||||
OperationSequence *convertModeStatement(ModeStatementASTNode *statement);
|
||||
OperationSequence *convertResetStatement(ResetStatementASTNode *statement);
|
||||
OperationSequence *convertIfStatement(IfStatementASTNode *statement);
|
||||
OperationSequence *convertEraseStatement(EraseStatementASTNode *statement);
|
||||
OperationSequence *convertMemEnableStatement(MemEnableStatementASTNode *statement);
|
||||
OperationSequence *convertKeywrapStatement(KeywrapStatementASTNode *statement);
|
||||
OperationSequence *convertEncryptStatement(EncryptStatementASTNode *statement);
|
||||
void handleMessageStatement(MessageStatementASTNode *statement);
|
||||
//@}
|
||||
|
||||
//! \name Utilities
|
||||
//@{
|
||||
Value *convertAssignmentNodeToValue(ASTNode *node, std::string &ident);
|
||||
SourceFile *getSourceFromName(std::string *sourceName, int line);
|
||||
DataSource *createSourceFromNode(ASTNode *dataNode);
|
||||
DataTarget *createTargetFromNode(ASTNode *targetNode);
|
||||
std::string *substituteVariables(const std::string *message);
|
||||
DataSource *createIVTDataSource(IVTConstASTNode *ivtNode);
|
||||
//@}
|
||||
|
||||
//! \name Debugging
|
||||
//@{
|
||||
void testLexer(ElftosbLexer &lexer);
|
||||
void printIntConstExpr(const std::string &ident, IntConstExprASTNode *expr);
|
||||
//@}
|
||||
|
||||
protected:
|
||||
typedef std::map<std::string, SourceFile *> source_map_t; //!< Map from source name to object.
|
||||
typedef std::vector<std::string> path_vector_t; //!< List of file paths.
|
||||
typedef std::vector<OutputSection *> section_vector_t; //!< List of output sections.
|
||||
typedef std::vector<std::string> source_name_vector_t; //!< List of source names.
|
||||
typedef std::vector<Keyblob *> keyblob_vector_t; //!< List of keyblobs.
|
||||
|
||||
smart_ptr<std::string> m_commandFilePath; //!< Path to command file.
|
||||
smart_ptr<CommandFileASTNode> m_ast; //!< Root of the abstract syntax tree.
|
||||
EvalContext m_context; //!< Evaluation context for expressions.
|
||||
source_map_t m_sources; //!< Map of source names to file objects.
|
||||
path_vector_t m_externPaths; //!< Paths provided on the command line by the user.
|
||||
SourceFile *m_defaultSource; //!< Source to use when one isn't provided.
|
||||
section_vector_t m_outputSections; //!< List of output sections the user wants.
|
||||
source_name_vector_t m_failedSources; //!< List of sources that failed to open successfully.
|
||||
keyblob_vector_t m_keyblobs; //!< List of keyblobs the user defines.
|
||||
Keyblob *m_keywrapKeyblob; //!< Keyblob used for keywrapping
|
||||
Keyblob *m_encryptKeyblob; //!< Keyblob used for OTFAD encryption
|
||||
};
|
||||
|
||||
//! \brief Whether to support HAB keywords during parsing.
|
||||
//!
|
||||
//! This is a standalone global solely so that the bison-generated parser code can get to it
|
||||
//! as simply as possible.
|
||||
extern bool g_enableHABSupport;
|
||||
|
||||
}; // namespace elftosb
|
||||
|
||||
#endif // _ConversionController_h_
|
||||
1618
apps/elftosb/elftosb2/ElftosbAST.cpp
Normal file
1618
apps/elftosb/elftosb2/ElftosbAST.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1475
apps/elftosb/elftosb2/ElftosbAST.h
Normal file
1475
apps/elftosb/elftosb2/ElftosbAST.h
Normal file
File diff suppressed because it is too large
Load Diff
29
apps/elftosb/elftosb2/ElftosbErrors.h
Normal file
29
apps/elftosb/elftosb2/ElftosbErrors.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* File: ConversionController.h
|
||||
*
|
||||
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
|
||||
* See included license file for license details.
|
||||
*/
|
||||
#if !defined(_ElftosbErrors_h_)
|
||||
#define _ElftosbErrors_h_
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace elftosb
|
||||
{
|
||||
/*!
|
||||
* \brief A semantic error discovered while processing the command file AST.
|
||||
*/
|
||||
class semantic_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit semantic_error(const std::string &msg)
|
||||
: std::runtime_error(msg)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}; // namespace elftosb
|
||||
|
||||
#endif // _ElftosbErrors_h_
|
||||
152
apps/elftosb/elftosb2/ElftosbLexer.cpp
Normal file
152
apps/elftosb/elftosb2/ElftosbLexer.cpp
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* File: ElftosbLexer.cpp
|
||||
*
|
||||
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
|
||||
* See included license file for license details.
|
||||
*/
|
||||
#include "ElftosbLexer.h"
|
||||
#include <algorithm>
|
||||
#include "HexValues.h"
|
||||
|
||||
using namespace elftosb;
|
||||
|
||||
ElftosbLexer::ElftosbLexer(istream &inputStream)
|
||||
: yyFlexLexer(&inputStream)
|
||||
, m_line(1)
|
||||
, m_blob(0)
|
||||
, m_blobFirstLine(0)
|
||||
{
|
||||
}
|
||||
|
||||
void ElftosbLexer::getSymbolValue(YYSTYPE *value)
|
||||
{
|
||||
if (!value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
*value = m_symbolValue;
|
||||
}
|
||||
|
||||
void ElftosbLexer::addSourceName(std::string *ident)
|
||||
{
|
||||
m_sources.push_back(*ident);
|
||||
}
|
||||
|
||||
bool ElftosbLexer::isSourceName(std::string *ident)
|
||||
{
|
||||
string_vector_t::iterator it = find(m_sources.begin(), m_sources.end(), *ident);
|
||||
return it != m_sources.end();
|
||||
}
|
||||
|
||||
void ElftosbLexer::LexerError(const char *msg)
|
||||
{
|
||||
throw elftosb::lexical_error(msg);
|
||||
}
|
||||
|
||||
//! Reads the \a in string and writes to the \a out string. These strings can be the same
|
||||
//! string since the read head is always in front of the write head.
|
||||
//!
|
||||
//! \param[in] in Input string containing C-style escape sequences.
|
||||
//! \param[out] out Output string. All escape sequences in the input string have been converted
|
||||
//! to the actual characters. May point to the same string as \a in.
|
||||
//! \return The length of the resulting \a out string. This length is necessary because
|
||||
//! the string may have contained escape sequences that inserted null characters.
|
||||
int ElftosbLexer::processStringEscapes(const char *in, char *out)
|
||||
{
|
||||
int count = 0;
|
||||
while (*in)
|
||||
{
|
||||
switch (*in)
|
||||
{
|
||||
case '\\':
|
||||
{
|
||||
// start of an escape sequence
|
||||
char c = *++in;
|
||||
switch (c)
|
||||
{
|
||||
case 0: // end of the string, bail
|
||||
break;
|
||||
case 'x':
|
||||
{
|
||||
// start of a hex char escape sequence
|
||||
|
||||
// read high and low nibbles, checking for end of string
|
||||
char hi = *++in;
|
||||
if (hi == 0)
|
||||
break;
|
||||
char lo = *++in;
|
||||
if (lo == 0)
|
||||
break;
|
||||
|
||||
if (isHexDigit(hi) && isHexDigit(lo))
|
||||
{
|
||||
if (hi >= '0' && hi <= '9')
|
||||
c = (hi - '0') << 4;
|
||||
else if (hi >= 'A' && hi <= 'F')
|
||||
c = (hi - 'A' + 10) << 4;
|
||||
else if (hi >= 'a' && hi <= 'f')
|
||||
c = (hi - 'a' + 10) << 4;
|
||||
|
||||
if (lo >= '0' && lo <= '9')
|
||||
c |= lo - '0';
|
||||
else if (lo >= 'A' && lo <= 'F')
|
||||
c |= lo - 'A' + 10;
|
||||
else if (lo >= 'a' && lo <= 'f')
|
||||
c |= lo - 'a' + 10;
|
||||
|
||||
*out++ = c;
|
||||
count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
// not hex digits, the \x must have wanted an 'x' char
|
||||
*out++ = 'x';
|
||||
*out++ = hi;
|
||||
*out++ = lo;
|
||||
count += 3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'n':
|
||||
*out++ = '\n';
|
||||
count++;
|
||||
break;
|
||||
case 't':
|
||||
*out++ = '\t';
|
||||
count++;
|
||||
break;
|
||||
case 'r':
|
||||
*out++ = '\r';
|
||||
count++;
|
||||
break;
|
||||
case 'b':
|
||||
*out++ = '\b';
|
||||
count++;
|
||||
break;
|
||||
case 'f':
|
||||
*out++ = '\f';
|
||||
count++;
|
||||
break;
|
||||
case '0':
|
||||
*out++ = '\0';
|
||||
count++;
|
||||
break;
|
||||
default:
|
||||
*out++ = c;
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// copy all other chars directly
|
||||
*out++ = *in++;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// place terminating null char on output
|
||||
*out = 0;
|
||||
return count;
|
||||
}
|
||||
101
apps/elftosb/elftosb2/ElftosbLexer.h
Normal file
101
apps/elftosb/elftosb2/ElftosbLexer.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* File: ElftosbLexer.h
|
||||
*
|
||||
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
|
||||
* See included license file for license details.
|
||||
*/
|
||||
|
||||
// This header just wraps the standard flex C++ header to make it easier to include
|
||||
// without having to worry about redefinitions of the class name every time.
|
||||
|
||||
#if !defined(_ElftosbLexer_h_)
|
||||
#define _ElftosbLexer_h_
|
||||
|
||||
#include "ElftosbAST.h"
|
||||
#include "FlexLexer.h"
|
||||
#include "elftosb_parser.tab.hpp"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include "Blob.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace elftosb
|
||||
{
|
||||
/*!
|
||||
* \brief Exception class for syntax errors.
|
||||
*/
|
||||
class syntax_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit syntax_error(const std::string &__arg)
|
||||
: std::runtime_error(__arg)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Exception class for lexical errors.
|
||||
*/
|
||||
class lexical_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
explicit lexical_error(const std::string &__arg)
|
||||
: std::runtime_error(__arg)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Lexical scanner class for elftosb command files.
|
||||
*
|
||||
* This class is a subclass of the standard C++ lexer class produced by
|
||||
* Flex. It's primary purpose is to provide a clean way to report values
|
||||
* for symbols, without using the yylval global. This is necessary because
|
||||
* the parser produced by Bison is a "pure" parser.
|
||||
*
|
||||
* In addition, this class manages a list of source names generated by
|
||||
* parsing. The lexer uses this list to determine if an identifier is
|
||||
* a source name or a constant identifier.
|
||||
*/
|
||||
class ElftosbLexer : public yyFlexLexer
|
||||
{
|
||||
public:
|
||||
//! \brief Constructor.
|
||||
ElftosbLexer(istream &inputStream);
|
||||
|
||||
//! \brief Lexer interface. Returns one token.
|
||||
virtual int yylex();
|
||||
|
||||
//! \brief Returns the value for the most recently produced token in \a value.
|
||||
virtual void getSymbolValue(YYSTYPE *value);
|
||||
|
||||
//! \brief Returns the current token's location in \a loc.
|
||||
inline token_loc_t &getLocation() { return m_location; }
|
||||
//! \name Source names
|
||||
//@{
|
||||
void addSourceName(std::string *ident);
|
||||
bool isSourceName(std::string *ident);
|
||||
//@}
|
||||
|
||||
protected:
|
||||
YYSTYPE m_symbolValue; //!< Value for the current token.
|
||||
int m_line; //!< Current line number.
|
||||
token_loc_t m_location; //!< Location for the current token.
|
||||
Blob *m_blob; //!< The binary object value as its being constructed.
|
||||
int m_blobFirstLine; //!< Line number for the first character of a blob.
|
||||
|
||||
typedef std::vector<std::string> string_vector_t;
|
||||
string_vector_t m_sources; //!< Vector of source identifiers;
|
||||
|
||||
//! \brief Throw an elftosb::lexical_error exception.
|
||||
virtual void LexerError(const char *msg);
|
||||
|
||||
//! \brief Process a string containing escape sequences.
|
||||
int processStringEscapes(const char *in, char *out);
|
||||
};
|
||||
|
||||
}; // namespace elftosb
|
||||
|
||||
#endif // _ElftosbLexer_h_
|
||||
581
apps/elftosb/elftosb2/EncoreBootImageGenerator.cpp
Normal file
581
apps/elftosb/elftosb2/EncoreBootImageGenerator.cpp
Normal file
File diff suppressed because it is too large
Load Diff
65
apps/elftosb/elftosb2/EncoreBootImageGenerator.h
Normal file
65
apps/elftosb/elftosb2/EncoreBootImageGenerator.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* File: EncoreBootImageGenerator.h
|
||||
*
|
||||
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
|
||||
* See included license file for license details.
|
||||
*/
|
||||
#if !defined(_EncoreBootImageGenerator_h_)
|
||||
#define _EncoreBootImageGenerator_h_
|
||||
|
||||
#include "BootImageGenerator.h"
|
||||
#include "EncoreBootImage.h"
|
||||
#include "Keyblob.h"
|
||||
|
||||
namespace elftosb
|
||||
{
|
||||
/*!
|
||||
* \brief Generator for Encore boot images.
|
||||
*
|
||||
* Takes the abstract model of the output file and processes it into a
|
||||
* concrete boot image for the STMP37xx.
|
||||
*
|
||||
* In order to enable full i.mx28 support, you must call the setSupportHAB() method and
|
||||
* pass true.
|
||||
*/
|
||||
class EncoreBootImageGenerator : public BootImageGenerator
|
||||
{
|
||||
public:
|
||||
//! \brief Default constructor.
|
||||
EncoreBootImageGenerator()
|
||||
: BootImageGenerator()
|
||||
, m_encryptKeyBlob(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
//! \brief Builds the resulting boot image from previously added output sections.
|
||||
virtual BootImage *generate();
|
||||
|
||||
//! \brief Enable or disable HAB support.
|
||||
void setSupportHAB(bool supportHAB) { m_supportHAB = supportHAB; }
|
||||
protected:
|
||||
bool m_supportHAB; //!< True if HAB features are enabled.
|
||||
Keyblob *m_encryptKeyBlob; //!< Keyblob to use during load if encrypting for OTFAD.
|
||||
|
||||
void processOptions(EncoreBootImage *image);
|
||||
void processSectionOptions(EncoreBootImage::Section *imageSection, OutputSection *modelSection);
|
||||
|
||||
void processOperationSection(OperationSequenceSection *section, EncoreBootImage *image);
|
||||
void processDataSection(BinaryDataSection *section, EncoreBootImage *image);
|
||||
|
||||
void processLoadOperation(LoadOperation *op, EncoreBootImage::BootSection *section);
|
||||
void processExecuteOperation(ExecuteOperation *op, EncoreBootImage::BootSection *section);
|
||||
void processBootModeOperation(BootModeOperation *op, EncoreBootImage::BootSection *section);
|
||||
void processFlashEraseOperation(FlashEraseOperation *op, EncoreBootImage::BootSection *section);
|
||||
void processResetOperation(ResetOperation *op, EncoreBootImage::BootSection *section);
|
||||
void processMemEnableOperation(MemEnableOperation *op, EncoreBootImage::BootSection *section);
|
||||
void processProgramOperation(ProgramOperation *op, EncoreBootImage::BootSection *section);
|
||||
void processKeywrapOperation(KeywrapOperation *op, EncoreBootImage::BootSection *section);
|
||||
void processEncryptOperation(EncryptOperation *op, EncoreBootImage::BootSection *section);
|
||||
|
||||
void setFillPatternFromValue(EncoreBootImage::FillCommand &command, SizedIntegerValue &pattern);
|
||||
};
|
||||
|
||||
}; // namespace elftosb
|
||||
|
||||
#endif // _EncoreBootImageGenerator_h_
|
||||
199
apps/elftosb/elftosb2/FlexLexer.h
Normal file
199
apps/elftosb/elftosb2/FlexLexer.h
Normal file
@@ -0,0 +1,199 @@
|
||||
// -*-C++-*-
|
||||
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
|
||||
// by flex
|
||||
|
||||
// Copyright (c) 1993 The Regents of the University of California.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This code is derived from software contributed to Berkeley by
|
||||
// Kent Williams and Tom Epperly.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. 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.
|
||||
|
||||
// Neither the name of the University 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE.
|
||||
|
||||
// This file defines FlexLexer, an abstract class which specifies the
|
||||
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
|
||||
// which defines a particular lexer class.
|
||||
//
|
||||
// If you want to create multiple lexer classes, you use the -P flag
|
||||
// to rename each yyFlexLexer to some other xxFlexLexer. You then
|
||||
// include <FlexLexer.h> in your other sources once per lexer class:
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer xxFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
//
|
||||
// #undef yyFlexLexer
|
||||
// #define yyFlexLexer zzFlexLexer
|
||||
// #include <FlexLexer.h>
|
||||
// ...
|
||||
|
||||
#ifndef __FLEX_LEXER_H
|
||||
// Never included before - need to define base class.
|
||||
#define __FLEX_LEXER_H
|
||||
|
||||
#include <iostream>
|
||||
#ifndef FLEX_STD
|
||||
#define FLEX_STD std::
|
||||
#endif
|
||||
|
||||
extern "C++" {
|
||||
|
||||
struct yy_buffer_state;
|
||||
typedef int yy_state_type;
|
||||
|
||||
class FlexLexer
|
||||
{
|
||||
public:
|
||||
virtual ~FlexLexer() {}
|
||||
const char *YYText() const { return yytext; }
|
||||
int YYLeng() const { return yyleng; }
|
||||
virtual void yy_switch_to_buffer(struct yy_buffer_state *new_buffer) = 0;
|
||||
virtual struct yy_buffer_state *yy_create_buffer(FLEX_STD istream *s, int size) = 0;
|
||||
virtual void yy_delete_buffer(struct yy_buffer_state *b) = 0;
|
||||
virtual void yyrestart(FLEX_STD istream *s) = 0;
|
||||
|
||||
virtual int yylex() = 0;
|
||||
|
||||
// Call yylex with new input/output sources.
|
||||
int yylex(FLEX_STD istream *new_in, FLEX_STD ostream *new_out = 0)
|
||||
{
|
||||
switch_streams(new_in, new_out);
|
||||
return yylex();
|
||||
}
|
||||
|
||||
// Switch to new input/output streams. A nil stream pointer
|
||||
// indicates "keep the current one".
|
||||
virtual void switch_streams(FLEX_STD istream *new_in = 0, FLEX_STD ostream *new_out = 0) = 0;
|
||||
|
||||
int lineno() const { return yylineno; }
|
||||
int debug() const { return yy_flex_debug; }
|
||||
void set_debug(int flag) { yy_flex_debug = flag; }
|
||||
protected:
|
||||
char *yytext;
|
||||
int yyleng;
|
||||
int yylineno; // only maintained if you use %option yylineno
|
||||
int yy_flex_debug; // only has effect with -d or "%option debug"
|
||||
};
|
||||
}
|
||||
#endif // FLEXLEXER_H
|
||||
|
||||
//#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
|
||||
// had to disable the 'defined(yyFlexLexer)' part because it was causing duplicate class defs
|
||||
#if !defined(yyFlexLexerOnce)
|
||||
// Either this is the first time through (yyFlexLexerOnce not defined),
|
||||
// or this is a repeated include to define a different flavor of
|
||||
// yyFlexLexer, as discussed in the flex manual.
|
||||
#define yyFlexLexerOnce
|
||||
|
||||
extern "C++" {
|
||||
|
||||
class yyFlexLexer : public FlexLexer
|
||||
{
|
||||
public:
|
||||
// arg_yyin and arg_yyout default to the cin and cout, but we
|
||||
// only make that assignment when initializing in yylex().
|
||||
yyFlexLexer(FLEX_STD istream *arg_yyin = 0, FLEX_STD ostream *arg_yyout = 0);
|
||||
|
||||
virtual ~yyFlexLexer();
|
||||
|
||||
void yy_switch_to_buffer(struct yy_buffer_state *new_buffer);
|
||||
struct yy_buffer_state *yy_create_buffer(FLEX_STD istream *s, int size);
|
||||
void yy_delete_buffer(struct yy_buffer_state *b);
|
||||
void yyrestart(FLEX_STD istream *s);
|
||||
|
||||
void yypush_buffer_state(struct yy_buffer_state *new_buffer);
|
||||
void yypop_buffer_state();
|
||||
|
||||
virtual int yylex();
|
||||
virtual void switch_streams(FLEX_STD istream *new_in, FLEX_STD ostream *new_out = 0);
|
||||
virtual int yywrap();
|
||||
|
||||
protected:
|
||||
virtual size_t LexerInput(char *buf, size_t max_size);
|
||||
virtual void LexerOutput(const char *buf, size_t size);
|
||||
virtual void LexerError(const char *msg);
|
||||
|
||||
void yyunput(int c, char *buf_ptr);
|
||||
int yyinput();
|
||||
|
||||
void yy_load_buffer_state();
|
||||
void yy_init_buffer(struct yy_buffer_state *b, FLEX_STD istream *s);
|
||||
void yy_flush_buffer(struct yy_buffer_state *b);
|
||||
|
||||
int yy_start_stack_ptr;
|
||||
int yy_start_stack_depth;
|
||||
int *yy_start_stack;
|
||||
|
||||
void yy_push_state(int new_state);
|
||||
void yy_pop_state();
|
||||
int yy_top_state();
|
||||
|
||||
yy_state_type yy_get_previous_state();
|
||||
yy_state_type yy_try_NUL_trans(yy_state_type current_state);
|
||||
int yy_get_next_buffer();
|
||||
|
||||
FLEX_STD istream *yyin; // input source for default LexerInput
|
||||
FLEX_STD ostream *yyout; // output sink for default LexerOutput
|
||||
|
||||
// yy_hold_char holds the character lost when yytext is formed.
|
||||
char yy_hold_char;
|
||||
|
||||
// Number of characters read into yy_ch_buf.
|
||||
int yy_n_chars;
|
||||
|
||||
// Points to current character in buffer.
|
||||
char *yy_c_buf_p;
|
||||
|
||||
int yy_init; // whether we need to initialize
|
||||
int yy_start; // start state number
|
||||
|
||||
// Flag which is used to allow yywrap()'s to do buffer switches
|
||||
// instead of setting up a fresh yyin. A bit of a hack ...
|
||||
int yy_did_buffer_switch_on_eof;
|
||||
|
||||
size_t yy_buffer_stack_top; /**< index of top of stack. */
|
||||
size_t yy_buffer_stack_max; /**< capacity of stack. */
|
||||
struct yy_buffer_state **yy_buffer_stack; /**< Stack as an array. */
|
||||
void yyensure_buffer_stack(void);
|
||||
|
||||
// The following are not always needed, but may be depending
|
||||
// on use of certain flex features (like REJECT or yymore()).
|
||||
|
||||
yy_state_type yy_last_accepting_state;
|
||||
char *yy_last_accepting_cpos;
|
||||
|
||||
yy_state_type *yy_state_buf;
|
||||
yy_state_type *yy_state_ptr;
|
||||
|
||||
char *yy_full_match;
|
||||
int *yy_full_state;
|
||||
int yy_full_lp;
|
||||
|
||||
int yy_lp;
|
||||
int yy_looking_for_trail_begin;
|
||||
|
||||
int yy_more_flag;
|
||||
int yy_more_len;
|
||||
int yy_more_offset;
|
||||
int yy_prev_more_offset;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // yyFlexLexer || ! yyFlexLexerOnce
|
||||
1217
apps/elftosb/elftosb2/elftosb.cpp
Normal file
1217
apps/elftosb/elftosb2/elftosb.cpp
Normal file
File diff suppressed because it is too large
Load Diff
585
apps/elftosb/elftosb2/elftosb2.vcproj
Normal file
585
apps/elftosb/elftosb2/elftosb2.vcproj
Normal file
File diff suppressed because it is too large
Load Diff
214
apps/elftosb/elftosb2/elftosb2.vcxproj
Normal file
214
apps/elftosb/elftosb2/elftosb2.vcxproj
Normal file
@@ -0,0 +1,214 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{ACBF9A30-8865-4DAA-B686-D8DC823CBF5C}</ProjectGuid>
|
||||
<RootNamespace>elftosb2</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v140_xp</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>12.0.21005.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>Debug\</OutDir>
|
||||
<IntDir>Debug\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>elftosb</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>Release\</OutDir>
|
||||
<IntDir>Release\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>elftosb</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.;..\winsupport;..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader />
|
||||
<BrowseInformation>true</BrowseInformation>
|
||||
<WarningLevel>Level2</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4355;%(DisableSpecificWarnings);4068;4800;4005</DisableSpecificWarnings>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>$(OutDir)elftosb.exe</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ProgramDatabaseFile>$(OutDir)elftosb.pdb</ProgramDatabaseFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention />
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4800;4068;4005;4018;4244</DisableSpecificWarnings>
|
||||
<AdditionalIncludeDirectories>.;..\winsupport;..\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<OutputFile>$(OutDir)elftosb.exe</OutputFile>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention />
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\common\aes128_key_wrap_unwrap.c" />
|
||||
<ClCompile Include="..\common\AESKey.cpp" />
|
||||
<ClCompile Include="..\common\Blob.cpp" />
|
||||
<ClCompile Include="..\common\bytes_aes.c" />
|
||||
<ClCompile Include="..\common\crc.cpp" />
|
||||
<ClCompile Include="..\common\DataSource.cpp" />
|
||||
<ClCompile Include="..\common\DataSourceImager.cpp" />
|
||||
<ClCompile Include="..\common\DataTarget.cpp" />
|
||||
<ClCompile Include="..\common\ELFSourceFile.cpp" />
|
||||
<ClCompile Include="..\common\EncoreBootImage.cpp" />
|
||||
<ClCompile Include="..\common\EncoreBootImageReader.cpp" />
|
||||
<ClCompile Include="..\common\EvalContext.cpp" />
|
||||
<ClCompile Include="..\common\ExcludesListMatcher.cpp" />
|
||||
<ClCompile Include="..\common\format_string.cpp" />
|
||||
<ClCompile Include="..\common\GHSSecInfo.cpp" />
|
||||
<ClCompile Include="..\common\GlobMatcher.cpp" />
|
||||
<ClCompile Include="..\common\HexValues.cpp" />
|
||||
<ClCompile Include="..\common\IVTDataSource.cpp" />
|
||||
<ClCompile Include="..\common\Keyblob.cpp" />
|
||||
<ClCompile Include="..\common\Logging.cpp" />
|
||||
<ClCompile Include="..\common\Operation.cpp" />
|
||||
<ClCompile Include="..\common\OptionDictionary.cpp" />
|
||||
<ClCompile Include="..\common\options.cpp" />
|
||||
<ClCompile Include="..\common\OutputSection.cpp" />
|
||||
<ClCompile Include="..\common\Random.cpp" />
|
||||
<ClCompile Include="..\common\rijndael.cpp" />
|
||||
<ClCompile Include="..\common\RijndaelCBCMAC.cpp" />
|
||||
<ClCompile Include="..\common\RijndaelCTR.cpp" />
|
||||
<ClCompile Include="..\common\SearchPath.cpp" />
|
||||
<ClCompile Include="..\common\SHA1.cpp" />
|
||||
<ClCompile Include="..\common\SourceFile.cpp" />
|
||||
<ClCompile Include="..\common\SRecordSourceFile.cpp" />
|
||||
<ClCompile Include="..\common\stdafx.cpp" />
|
||||
<ClCompile Include="..\common\StELFFile.cpp" />
|
||||
<ClCompile Include="..\common\StExecutableImage.cpp" />
|
||||
<ClCompile Include="..\common\StSRecordFile.cpp" />
|
||||
<ClCompile Include="..\common\Value.cpp" />
|
||||
<ClCompile Include="..\common\Version.cpp" />
|
||||
<ClCompile Include="BootImageGenerator.cpp" />
|
||||
<ClCompile Include="ConversionController.cpp" />
|
||||
<ClCompile Include="elftosb.cpp" />
|
||||
<ClCompile Include="elftosb_lexer.cpp" />
|
||||
<ClCompile Include="elftosb_parser.tab.cpp" />
|
||||
<ClCompile Include="ElftosbAST.cpp" />
|
||||
<ClCompile Include="ElftosbLexer.cpp" />
|
||||
<ClCompile Include="EncoreBootImageGenerator.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\common\aes128_key_wrap_unwrap.h" />
|
||||
<ClInclude Include="..\common\AESCounter.h" />
|
||||
<ClInclude Include="..\common\AESKey.h" />
|
||||
<ClInclude Include="..\common\Blob.h" />
|
||||
<ClInclude Include="..\common\BootImage.h" />
|
||||
<ClInclude Include="..\common\crc.h" />
|
||||
<ClInclude Include="..\common\DataSource.h" />
|
||||
<ClInclude Include="..\common\DataSourceImager.h" />
|
||||
<ClInclude Include="..\common\DataTarget.h" />
|
||||
<ClInclude Include="..\common\ELF.h" />
|
||||
<ClInclude Include="..\common\ELFSourceFile.h" />
|
||||
<ClInclude Include="..\common\EncoreBootImage.h" />
|
||||
<ClInclude Include="..\common\EncoreBootImageReader.h" />
|
||||
<ClInclude Include="..\common\EndianUtilities.h" />
|
||||
<ClInclude Include="..\common\EvalContext.h" />
|
||||
<ClInclude Include="..\common\ExcludesListMatcher.h" />
|
||||
<ClInclude Include="..\common\format_string.h" />
|
||||
<ClInclude Include="..\common\GHSSecInfo.h" />
|
||||
<ClInclude Include="..\common\GlobMatcher.h" />
|
||||
<ClInclude Include="..\common\HexValues.h" />
|
||||
<ClInclude Include="..\common\int_size.h" />
|
||||
<ClInclude Include="..\common\IVTDataSource.h" />
|
||||
<ClInclude Include="..\common\Keyblob.h" />
|
||||
<ClInclude Include="..\common\KeyblobEntry.h" />
|
||||
<ClInclude Include="..\common\Logging.h" />
|
||||
<ClInclude Include="..\common\Operation.h" />
|
||||
<ClInclude Include="..\common\OptionContext.h" />
|
||||
<ClInclude Include="..\common\OptionDictionary.h" />
|
||||
<ClInclude Include="..\common\options.h" />
|
||||
<ClInclude Include="..\common\OutputSection.h" />
|
||||
<ClInclude Include="..\common\Random.h" />
|
||||
<ClInclude Include="..\common\rijndael.h" />
|
||||
<ClInclude Include="..\common\RijndaelCBCMAC.h" />
|
||||
<ClInclude Include="..\common\RijndaelCTR.h" />
|
||||
<ClInclude Include="..\common\SearchPath.h" />
|
||||
<ClInclude Include="..\common\SHA1.h" />
|
||||
<ClInclude Include="..\common\smart_ptr.h" />
|
||||
<ClInclude Include="..\common\SourceFile.h" />
|
||||
<ClInclude Include="..\common\SRecordSourceFile.h" />
|
||||
<ClInclude Include="..\common\stdafx.h" />
|
||||
<ClInclude Include="..\common\StELFFile.h" />
|
||||
<ClInclude Include="..\common\StExecutableImage.h" />
|
||||
<ClInclude Include="..\common\StringMatcher.h" />
|
||||
<ClInclude Include="..\common\StSRecordFile.h" />
|
||||
<ClInclude Include="..\common\Value.h" />
|
||||
<ClInclude Include="..\common\Version.h" />
|
||||
<ClInclude Include="BootImageGenerator.h" />
|
||||
<ClInclude Include="ConversionController.h" />
|
||||
<ClInclude Include="crypto.h" />
|
||||
<ClInclude Include="default_rom_key.h" />
|
||||
<ClInclude Include="elftosb.h" />
|
||||
<ClInclude Include="elftosb_parser.tab.hpp" />
|
||||
<ClInclude Include="ElftosbAST.h" />
|
||||
<ClInclude Include="ElftosbErrors.h" />
|
||||
<ClInclude Include="ElftosbLexer.h" />
|
||||
<ClInclude Include="EncoreBootImageGenerator.h" />
|
||||
<ClInclude Include="FlexLexer.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
342
apps/elftosb/elftosb2/elftosb2.vcxproj.filters
Normal file
342
apps/elftosb/elftosb2/elftosb2.vcxproj.filters
Normal file
@@ -0,0 +1,342 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\common">
|
||||
<UniqueIdentifier>{9453b333-3419-4bc0-8fb8-b0a65cfa5ab7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\elftosb">
|
||||
<UniqueIdentifier>{7a5e4903-3272-4bca-8ed5-629eb0d880a2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\common">
|
||||
<UniqueIdentifier>{55b0f525-56b7-4c59-8bf4-7a118c172b82}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files\elftosb">
|
||||
<UniqueIdentifier>{297df138-bad7-4418-bf8b-b2638afffb61}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\common\AESKey.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\Blob.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\crc.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\DataSource.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\DataSourceImager.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\DataTarget.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\ELFSourceFile.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\EncoreBootImage.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\EvalContext.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\ExcludesListMatcher.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\format_string.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\GHSSecInfo.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\GlobMatcher.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\HexValues.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\IVTDataSource.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\Logging.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\Operation.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\OptionDictionary.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\options.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\OutputSection.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\Random.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\rijndael.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\RijndaelCBCMAC.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\SearchPath.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\SHA1.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\SourceFile.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\SRecordSourceFile.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\stdafx.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\StELFFile.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\StExecutableImage.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\StSRecordFile.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\Value.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\Version.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="BootImageGenerator.cpp">
|
||||
<Filter>Source Files\elftosb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ConversionController.cpp">
|
||||
<Filter>Source Files\elftosb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="elftosb.cpp">
|
||||
<Filter>Source Files\elftosb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="elftosb_lexer.cpp">
|
||||
<Filter>Source Files\elftosb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="elftosb_parser.tab.cpp">
|
||||
<Filter>Source Files\elftosb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ElftosbAST.cpp">
|
||||
<Filter>Source Files\elftosb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ElftosbLexer.cpp">
|
||||
<Filter>Source Files\elftosb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EncoreBootImageGenerator.cpp">
|
||||
<Filter>Source Files\elftosb</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\aes128_key_wrap_unwrap.c">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\bytes_aes.c">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\Keyblob.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\RijndaelCTR.cpp">
|
||||
<Filter>Source Files\common</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\common\EncoreBootImageReader.cpp">
|
||||
<Filter>Source Files\elftosb</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\common\AESKey.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\Blob.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\BootImage.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\crc.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\DataSource.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\DataSourceImager.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\DataTarget.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\ELF.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\ELFSourceFile.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\EncoreBootImage.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\EndianUtilities.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\EvalContext.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\ExcludesListMatcher.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\format_string.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\GHSSecInfo.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\GlobMatcher.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\HexValues.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\int_size.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\IVTDataSource.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\Logging.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\Operation.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\OptionContext.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\OptionDictionary.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\options.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\OutputSection.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\Random.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\rijndael.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\RijndaelCBCMAC.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\SearchPath.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\SHA1.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\smart_ptr.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\SourceFile.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\SRecordSourceFile.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\stdafx.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\StELFFile.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\StExecutableImage.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\StringMatcher.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\StSRecordFile.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\Value.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\Version.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BootImageGenerator.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ConversionController.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="crypto.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="default_rom_key.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elftosb.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="elftosb_parser.tab.hpp">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ElftosbAST.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ElftosbErrors.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ElftosbLexer.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EncoreBootImageGenerator.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FlexLexer.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\Keyblob.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\aes128_key_wrap_unwrap.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\AESCounter.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\KeyblobEntry.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\RijndaelCTR.h">
|
||||
<Filter>Header Files\common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\common\EncoreBootImageReader.h">
|
||||
<Filter>Header Files\elftosb</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
2318
apps/elftosb/elftosb2/elftosb_lexer.cpp
Normal file
2318
apps/elftosb/elftosb2/elftosb_lexer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
308
apps/elftosb/elftosb2/elftosb_lexer.l
Normal file
308
apps/elftosb/elftosb2/elftosb_lexer.l
Normal file
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
|
||||
* See included license file for license details.
|
||||
*/
|
||||
|
||||
%option c++
|
||||
/* %option prefix="Elftosb" */
|
||||
%option yylineno
|
||||
%option never-interactive
|
||||
%option yyclass="ElftosbLexer"
|
||||
%option noyywrap
|
||||
|
||||
%{
|
||||
#include "ElftosbLexer.h"
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <string>
|
||||
#include "HexValues.h"
|
||||
#include "Value.h"
|
||||
|
||||
using namespace elftosb;
|
||||
|
||||
//! Always executed before all other actions when a token is matched.
|
||||
//! This action just assign the first and last lines of the token to
|
||||
//! the current line. In most cases this is correct.
|
||||
#define YY_USER_ACTION do { \
|
||||
m_location.m_firstLine = m_line; \
|
||||
m_location.m_lastLine = m_line; \
|
||||
} while (0);
|
||||
|
||||
%}
|
||||
|
||||
DIGIT [0-9]
|
||||
HEXDIGIT [0-9a-fA-F]
|
||||
BINDIGIT [0-1]
|
||||
IDENT [a-zA-Z_][a-zA-Z0-9_]*
|
||||
ESC \\(x{HEXDIGIT}{2}|.)
|
||||
|
||||
/* start conditions */
|
||||
%x blob mlcmt
|
||||
|
||||
%%
|
||||
|
||||
options { return TOK_OPTIONS; }
|
||||
constants { return TOK_CONSTANTS; }
|
||||
sources { return TOK_SOURCES; }
|
||||
filters { return TOK_FILTERS; }
|
||||
section { return TOK_SECTION; }
|
||||
extern { return TOK_EXTERN; }
|
||||
from { return TOK_FROM; }
|
||||
raw { return TOK_RAW; }
|
||||
load { return TOK_LOAD; }
|
||||
jump { return TOK_JUMP; }
|
||||
call { return TOK_CALL; }
|
||||
mode { return TOK_MODE; }
|
||||
erase { return TOK_ERASE; }
|
||||
all { return TOK_ALL; }
|
||||
if { return TOK_IF; }
|
||||
else { return TOK_ELSE; }
|
||||
defined { return TOK_DEFINED; }
|
||||
info { return TOK_INFO; }
|
||||
warning { return TOK_WARNING; }
|
||||
error { return TOK_ERROR; }
|
||||
sizeof { return TOK_SIZEOF; }
|
||||
dcd { return TOK_DCD; }
|
||||
hab { return TOK_HAB; }
|
||||
ivt { return TOK_IVT; }
|
||||
unsecure { return TOK_UNSECURE; }
|
||||
reset { return TOK_RESET; }
|
||||
jump_sp { return TOK_JUMP_SP; }
|
||||
enable { return TOK_ENABLE; }
|
||||
keyblob { return TOK_KEYBLOB; }
|
||||
encrypt { return TOK_ENCRYPT; }
|
||||
keywrap { return TOK_KEYWRAP; }
|
||||
|
||||
[whb]/[^a-zA-Z_0-9] { // must be followed by any non-ident char
|
||||
int_size_t theSize;
|
||||
switch (yytext[0])
|
||||
{
|
||||
case 'w':
|
||||
theSize = kWordSize;
|
||||
break;
|
||||
case 'h':
|
||||
theSize = kHalfWordSize;
|
||||
break;
|
||||
case 'b':
|
||||
theSize = kByteSize;
|
||||
break;
|
||||
}
|
||||
m_symbolValue.m_int = new elftosb::SizedIntegerValue(0, theSize);
|
||||
return TOK_INT_SIZE;
|
||||
}
|
||||
|
||||
true|yes {
|
||||
m_symbolValue.m_int = new elftosb::SizedIntegerValue(1, kWordSize);
|
||||
return TOK_INT_LITERAL;
|
||||
}
|
||||
|
||||
false|no {
|
||||
m_symbolValue.m_int = new elftosb::SizedIntegerValue(0, kWordSize);
|
||||
return TOK_INT_LITERAL;
|
||||
}
|
||||
|
||||
{IDENT} {
|
||||
m_symbolValue.m_str = new std::string(yytext);
|
||||
if (isSourceName(m_symbolValue.m_str))
|
||||
{
|
||||
return TOK_SOURCE_NAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TOK_IDENT;
|
||||
}
|
||||
}
|
||||
|
||||
({DIGIT}+|0x{HEXDIGIT}+|0b{BINDIGIT}+)([ \t]*[GMK])? {
|
||||
int base = 0;
|
||||
uint32_t value;
|
||||
int mult;
|
||||
|
||||
// check for binary number
|
||||
if (yytext[0] == '0' && yytext[1] == 'b')
|
||||
{
|
||||
base = 2; // this is a binary number
|
||||
yytext += 2; // skip over the "0b"
|
||||
}
|
||||
|
||||
// convert value
|
||||
value = (uint32_t)strtoul(yytext, NULL, base);
|
||||
|
||||
// find multiplier
|
||||
switch (yytext[strlen(yytext) - 1])
|
||||
{
|
||||
case 'G':
|
||||
mult = 1024 * 1024 * 1024;
|
||||
break;
|
||||
case 'M':
|
||||
mult = 1024 * 1024;
|
||||
break;
|
||||
case 'K':
|
||||
mult = 1024;
|
||||
break;
|
||||
default:
|
||||
mult = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
// set resulting symbol value
|
||||
m_symbolValue.m_int = new elftosb::SizedIntegerValue(value * mult, kWordSize);
|
||||
return TOK_INT_LITERAL;
|
||||
}
|
||||
|
||||
\'(.|ESC)\'|\'(.|ESC){2}\'|\'(.|ESC){4}\' {
|
||||
uint32_t value = 0;
|
||||
int_size_t theSize;
|
||||
int len = strlen(yytext);
|
||||
if (len >= 3)
|
||||
{
|
||||
value = yytext[1];
|
||||
theSize = kByteSize;
|
||||
}
|
||||
if (len >= 4)
|
||||
{
|
||||
value = (value << 8) | yytext[2];
|
||||
theSize = kHalfWordSize;
|
||||
}
|
||||
if (len >= 6)
|
||||
{
|
||||
value = (value << 8) | yytext[3];
|
||||
value = (value << 8) | yytext[4];
|
||||
theSize = kWordSize;
|
||||
}
|
||||
m_symbolValue.m_int = new elftosb::SizedIntegerValue(value, theSize);
|
||||
return TOK_INT_LITERAL;
|
||||
}
|
||||
|
||||
\$[\.\*a-zA-Z0-9_\[\]\^\?\-]+ {
|
||||
// remove $ from string
|
||||
m_symbolValue.m_str = new std::string(&yytext[1]);
|
||||
return TOK_SECTION_NAME;
|
||||
}
|
||||
|
||||
|
||||
"/*" { BEGIN(mlcmt); }
|
||||
|
||||
"{{" {
|
||||
m_blob = new Blob();
|
||||
m_blobFirstLine = yylineno;
|
||||
BEGIN(blob);
|
||||
}
|
||||
|
||||
"{" { return '{'; }
|
||||
|
||||
"}" { return '}'; }
|
||||
|
||||
"(" { return '('; }
|
||||
|
||||
")" { return ')'; }
|
||||
|
||||
"[" { return '['; }
|
||||
|
||||
"]" { return ']'; }
|
||||
|
||||
"=" { return '='; }
|
||||
|
||||
"," { return ','; }
|
||||
|
||||
":" { return ':'; }
|
||||
|
||||
";" { return ';'; }
|
||||
|
||||
"." { return '.'; }
|
||||
|
||||
">" { return '>'; }
|
||||
|
||||
".." { return TOK_DOT_DOT; }
|
||||
|
||||
"+" { return '+'; }
|
||||
|
||||
"-" { return '-'; }
|
||||
|
||||
"*" { return '*'; }
|
||||
|
||||
"/" { return '/'; }
|
||||
|
||||
"%" { return '%'; }
|
||||
|
||||
"~" { return '~'; }
|
||||
|
||||
"^" { return '^'; }
|
||||
|
||||
"<<" { return TOK_LSHIFT; }
|
||||
|
||||
">>" { return TOK_RSHIFT; }
|
||||
|
||||
"&" { return '&'; }
|
||||
|
||||
"|" { return '|'; }
|
||||
|
||||
"**" { return TOK_POWER; }
|
||||
|
||||
"<" { return '<'; }
|
||||
|
||||
">=" { return TOK_GEQ; }
|
||||
|
||||
"<=" { return TOK_LEQ; }
|
||||
|
||||
"==" { return TOK_EQ; }
|
||||
|
||||
"!=" { return TOK_NEQ; }
|
||||
|
||||
"&&" { return TOK_AND; }
|
||||
|
||||
"||" { return TOK_OR; }
|
||||
|
||||
"!" { return '!'; }
|
||||
|
||||
\"(ESC|[^\"])*\" {
|
||||
// get rid of quotes
|
||||
yytext++;
|
||||
yytext[strlen(yytext) - 1] = 0;
|
||||
// processStringEscapes(yytext, yytext);
|
||||
m_symbolValue.m_str = new std::string(yytext);
|
||||
return TOK_STRING_LITERAL;
|
||||
}
|
||||
|
||||
<blob>{HEXDIGIT}{2} {
|
||||
uint8_t x = (hexCharToInt(yytext[0]) << 4) | hexCharToInt(yytext[1]);
|
||||
m_blob->append(&x, 1);
|
||||
}
|
||||
|
||||
<blob>"}}" {
|
||||
BEGIN(INITIAL);
|
||||
m_symbolValue.m_blob = m_blob;
|
||||
m_blob = NULL;
|
||||
m_location.m_firstLine = m_blobFirstLine;
|
||||
return TOK_BLOB;
|
||||
}
|
||||
|
||||
<mlcmt>\*\/ {
|
||||
// end of multi-line comment, return to initial state
|
||||
BEGIN(INITIAL);
|
||||
}
|
||||
|
||||
|
||||
(#|\/\/).*$ /* absorb single-line comment */
|
||||
|
||||
<*>[ \t] /* eat up whitespace in all states */
|
||||
|
||||
<*>(\r\n|\r|\n) {
|
||||
/* eat up whitespace and count lines in all states */
|
||||
m_line++;
|
||||
}
|
||||
|
||||
<mlcmt>. /* ignore all other chars in a multi-line comment */
|
||||
|
||||
<*>. {
|
||||
/* all other chars produce errors */
|
||||
char msg[50];
|
||||
sprintf(msg, "unexpected character '%c' on line %d", yytext[0], m_line);
|
||||
LexerError(msg);
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
// verbatim code copied to the bottom of the output
|
||||
|
||||
|
||||
3398
apps/elftosb/elftosb2/elftosb_parser.tab.cpp
Normal file
3398
apps/elftosb/elftosb2/elftosb_parser.tab.cpp
Normal file
File diff suppressed because it is too large
Load Diff
180
apps/elftosb/elftosb2/elftosb_parser.tab.hpp
Normal file
180
apps/elftosb/elftosb2/elftosb_parser.tab.hpp
Normal file
@@ -0,0 +1,180 @@
|
||||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
/* Put the tokens into the symbol table, so that GDB and other debuggers
|
||||
know about them. */
|
||||
enum yytokentype {
|
||||
TOK_IDENT = 258,
|
||||
TOK_STRING_LITERAL = 259,
|
||||
TOK_INT_LITERAL = 260,
|
||||
TOK_SECTION_NAME = 261,
|
||||
TOK_SOURCE_NAME = 262,
|
||||
TOK_BLOB = 263,
|
||||
TOK_DOT_DOT = 264,
|
||||
TOK_AND = 265,
|
||||
TOK_OR = 266,
|
||||
TOK_GEQ = 267,
|
||||
TOK_LEQ = 268,
|
||||
TOK_EQ = 269,
|
||||
TOK_NEQ = 270,
|
||||
TOK_POWER = 271,
|
||||
TOK_LSHIFT = 272,
|
||||
TOK_RSHIFT = 273,
|
||||
TOK_INT_SIZE = 274,
|
||||
TOK_OPTIONS = 275,
|
||||
TOK_CONSTANTS = 276,
|
||||
TOK_SOURCES = 277,
|
||||
TOK_FILTERS = 278,
|
||||
TOK_SECTION = 279,
|
||||
TOK_EXTERN = 280,
|
||||
TOK_FROM = 281,
|
||||
TOK_RAW = 282,
|
||||
TOK_LOAD = 283,
|
||||
TOK_JUMP = 284,
|
||||
TOK_CALL = 285,
|
||||
TOK_MODE = 286,
|
||||
TOK_ERASE = 287,
|
||||
TOK_ALL = 288,
|
||||
TOK_IF = 289,
|
||||
TOK_ELSE = 290,
|
||||
TOK_DEFINED = 291,
|
||||
TOK_INFO = 292,
|
||||
TOK_WARNING = 293,
|
||||
TOK_ERROR = 294,
|
||||
TOK_SIZEOF = 295,
|
||||
TOK_DCD = 296,
|
||||
TOK_HAB = 297,
|
||||
TOK_IVT = 298,
|
||||
TOK_UNSECURE = 299,
|
||||
TOK_RESET = 300,
|
||||
TOK_JUMP_SP = 301,
|
||||
TOK_ENABLE = 302,
|
||||
TOK_KEYBLOB = 303,
|
||||
TOK_ENCRYPT = 304,
|
||||
TOK_KEYWRAP = 305,
|
||||
UNARY_OP = 306
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
#define TOK_IDENT 258
|
||||
#define TOK_STRING_LITERAL 259
|
||||
#define TOK_INT_LITERAL 260
|
||||
#define TOK_SECTION_NAME 261
|
||||
#define TOK_SOURCE_NAME 262
|
||||
#define TOK_BLOB 263
|
||||
#define TOK_DOT_DOT 264
|
||||
#define TOK_AND 265
|
||||
#define TOK_OR 266
|
||||
#define TOK_GEQ 267
|
||||
#define TOK_LEQ 268
|
||||
#define TOK_EQ 269
|
||||
#define TOK_NEQ 270
|
||||
#define TOK_POWER 271
|
||||
#define TOK_LSHIFT 272
|
||||
#define TOK_RSHIFT 273
|
||||
#define TOK_INT_SIZE 274
|
||||
#define TOK_OPTIONS 275
|
||||
#define TOK_CONSTANTS 276
|
||||
#define TOK_SOURCES 277
|
||||
#define TOK_FILTERS 278
|
||||
#define TOK_SECTION 279
|
||||
#define TOK_EXTERN 280
|
||||
#define TOK_FROM 281
|
||||
#define TOK_RAW 282
|
||||
#define TOK_LOAD 283
|
||||
#define TOK_JUMP 284
|
||||
#define TOK_CALL 285
|
||||
#define TOK_MODE 286
|
||||
#define TOK_ERASE 287
|
||||
#define TOK_ALL 288
|
||||
#define TOK_IF 289
|
||||
#define TOK_ELSE 290
|
||||
#define TOK_DEFINED 291
|
||||
#define TOK_INFO 292
|
||||
#define TOK_WARNING 293
|
||||
#define TOK_ERROR 294
|
||||
#define TOK_SIZEOF 295
|
||||
#define TOK_DCD 296
|
||||
#define TOK_HAB 297
|
||||
#define TOK_IVT 298
|
||||
#define TOK_UNSECURE 299
|
||||
#define TOK_RESET 300
|
||||
#define TOK_JUMP_SP 301
|
||||
#define TOK_ENABLE 302
|
||||
#define TOK_KEYBLOB 303
|
||||
#define TOK_ENCRYPT 304
|
||||
#define TOK_KEYWRAP 305
|
||||
#define UNARY_OP 306
|
||||
|
||||
|
||||
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
#line 62 "/Users/MADUser1/elftosb/elftosb2/elftosb_parser.y"
|
||||
{
|
||||
int m_num;
|
||||
elftosb::SizedIntegerValue * m_int;
|
||||
Blob * m_blob;
|
||||
std::string * m_str;
|
||||
elftosb::ASTNode * m_ast; // must use full name here because this is put into *.tab.hpp
|
||||
}
|
||||
/* Line 1529 of yacc.c. */
|
||||
#line 159 "/Users/MADUser1/Library/Developer/Xcode/DerivedData/elftosb-dxrbhxxtpndhpgdxujwltedpntjq/Build/Intermediates/elftosb.build/Debug/elftosb.build/DerivedSources/elftosb_parser.tab.hpp"
|
||||
YYSTYPE;
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
|
||||
typedef struct YYLTYPE
|
||||
{
|
||||
int first_line;
|
||||
int first_column;
|
||||
int last_line;
|
||||
int last_column;
|
||||
} YYLTYPE;
|
||||
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYLTYPE_IS_DECLARED 1
|
||||
# define YYLTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
|
||||
1116
apps/elftosb/elftosb2/elftosb_parser.y
Normal file
1116
apps/elftosb/elftosb2/elftosb_parser.y
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user