summaryrefslogtreecommitdiff
path: root/include/mcld/Script
diff options
context:
space:
mode:
Diffstat (limited to 'include/mcld/Script')
-rw-r--r--include/mcld/Script/AssertCmd.h26
-rw-r--r--include/mcld/Script/Assignment.h50
-rw-r--r--include/mcld/Script/BinaryOp.h106
-rw-r--r--include/mcld/Script/EntryCmd.h27
-rw-r--r--include/mcld/Script/ExprToken.h35
-rw-r--r--include/mcld/Script/FileToken.h27
-rw-r--r--include/mcld/Script/FlexLexer.h219
-rw-r--r--include/mcld/Script/GroupCmd.h26
-rw-r--r--include/mcld/Script/InputCmd.h59
-rw-r--r--include/mcld/Script/InputSectDesc.h35
-rw-r--r--include/mcld/Script/InputToken.h33
-rw-r--r--include/mcld/Script/NameSpec.h27
-rw-r--r--include/mcld/Script/NullaryOp.h41
-rw-r--r--include/mcld/Script/Operand.h127
-rw-r--r--include/mcld/Script/Operator.h218
-rw-r--r--include/mcld/Script/OutputArchCmd.h27
-rw-r--r--include/mcld/Script/OutputCmd.h27
-rw-r--r--include/mcld/Script/OutputFormatCmd.h35
-rw-r--r--include/mcld/Script/OutputSectDesc.h57
-rw-r--r--include/mcld/Script/RpnEvaluator.h19
-rw-r--r--include/mcld/Script/RpnExpr.h36
-rw-r--r--include/mcld/Script/ScriptCommand.h37
-rw-r--r--include/mcld/Script/ScriptFile.h83
-rw-r--r--include/mcld/Script/ScriptReader.h39
-rw-r--r--include/mcld/Script/ScriptScanner.h32
-rw-r--r--include/mcld/Script/SearchDirCmd.h27
-rw-r--r--include/mcld/Script/SectionsCmd.h41
-rw-r--r--include/mcld/Script/StrToken.h40
-rw-r--r--include/mcld/Script/StringList.h42
-rw-r--r--include/mcld/Script/TernaryOp.h47
-rw-r--r--include/mcld/Script/UnaryOp.h68
-rw-r--r--include/mcld/Script/WildcardPattern.h32
32 files changed, 833 insertions, 912 deletions
diff --git a/include/mcld/Script/AssertCmd.h b/include/mcld/Script/AssertCmd.h
index 14ead49..9201891 100644
--- a/include/mcld/Script/AssertCmd.h
+++ b/include/mcld/Script/AssertCmd.h
@@ -6,14 +6,14 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_ASSERTCMD_H
-#define MCLD_SCRIPT_ASSERTCMD_H
+#ifndef MCLD_SCRIPT_ASSERTCMD_H_
+#define MCLD_SCRIPT_ASSERTCMD_H_
+
+#include "mcld/Script/ScriptCommand.h"
-#include <mcld/Script/ScriptCommand.h>
#include <string>
-namespace mcld
-{
+namespace mcld {
class RpnExpr;
class Module;
@@ -22,9 +22,8 @@ class Module;
* \brief This class defines the interfaces to assert command.
*/
-class AssertCmd : public ScriptCommand
-{
-public:
+class AssertCmd : public ScriptCommand {
+ public:
AssertCmd(RpnExpr& pRpnExpr, const std::string& pMessage);
~AssertCmd();
@@ -32,24 +31,23 @@ public:
AssertCmd& operator=(const AssertCmd& pAssertCmd);
const RpnExpr& getRpnExpr() const { return m_RpnExpr; }
- RpnExpr& getRpnExpr() { return m_RpnExpr; }
+ RpnExpr& getRpnExpr() { return m_RpnExpr; }
const std::string& message() const { return m_Message; }
void dump() const;
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::ASSERT;
}
void activate(Module& pModule);
-private:
+ private:
RpnExpr& m_RpnExpr;
std::string m_Message;
};
-} // namespace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_ASSERTCMD_H_
diff --git a/include/mcld/Script/Assignment.h b/include/mcld/Script/Assignment.h
index c81e871..ced4d19 100644
--- a/include/mcld/Script/Assignment.h
+++ b/include/mcld/Script/Assignment.h
@@ -6,44 +6,34 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_ASSIGNMENT_H
-#define MCLD_SCRIPT_ASSIGNMENT_H
+#ifndef MCLD_SCRIPT_ASSIGNMENT_H_
+#define MCLD_SCRIPT_ASSIGNMENT_H_
-#include <mcld/Script/ScriptCommand.h>
+#include "mcld/Script/ScriptCommand.h"
-namespace mcld
-{
+namespace mcld {
class Module;
+class RpnEvaluator;
class RpnExpr;
class SymOperand;
-class RpnEvaluator;
/** \class Assignment
* \brief This class defines the interfaces to assignment command.
*/
-class Assignment : public ScriptCommand
-{
-public:
+class Assignment : public ScriptCommand {
+ public:
enum Level {
- OUTSIDE_SECTIONS, // outside SECTIONS command
- OUTPUT_SECTION, // related to an output section
- INPUT_SECTION // related to an input section
+ OUTSIDE_SECTIONS, // outside SECTIONS command
+ OUTPUT_SECTION, // related to an output section
+ INPUT_SECTION // related to an input section
};
- enum Type {
- DEFAULT,
- HIDDEN,
- PROVIDE,
- PROVIDE_HIDDEN
- };
+ enum Type { DEFAULT, HIDDEN, PROVIDE, PROVIDE_HIDDEN };
-public:
- Assignment(Level pLevel,
- Type pType,
- SymOperand& pSymbol,
- RpnExpr& pRpnExpr);
+ public:
+ Assignment(Level pLevel, Type pType, SymOperand& pSymbol, RpnExpr& pRpnExpr);
~Assignment();
@@ -54,15 +44,14 @@ public:
Type type() const { return m_Type; }
const SymOperand& symbol() const { return m_Symbol; }
- SymOperand& symbol() { return m_Symbol; }
+ SymOperand& symbol() { return m_Symbol; }
const RpnExpr& getRpnExpr() const { return m_RpnExpr; }
- RpnExpr& getRpnExpr() { return m_RpnExpr; }
+ RpnExpr& getRpnExpr() { return m_RpnExpr; }
void dump() const;
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::ASSIGNMENT;
}
@@ -71,14 +60,13 @@ public:
/// assign - evaluate the rhs and assign the result to lhs.
bool assign(RpnEvaluator& pEvaluator);
-private:
+ private:
Level m_Level;
Type m_Type;
SymOperand& m_Symbol;
RpnExpr& m_RpnExpr;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_ASSIGNMENT_H_
diff --git a/include/mcld/Script/BinaryOp.h b/include/mcld/Script/BinaryOp.h
index c96521e..f684ffa 100644
--- a/include/mcld/Script/BinaryOp.h
+++ b/include/mcld/Script/BinaryOp.h
@@ -6,14 +6,14 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_BINARYOP_H
-#define MCLD_SCRIPT_BINARYOP_H
+#ifndef MCLD_SCRIPT_BINARYOP_H_
+#define MCLD_SCRIPT_BINARYOP_H_
+
+#include "mcld/Script/Operator.h"
-#include <mcld/Script/Operator.h>
#include <cstddef>
-namespace mcld
-{
+namespace mcld {
class Operand;
class IntOperand;
@@ -24,109 +24,97 @@ class TargetLDBackend;
* \brief This class defines the interfaces to an binary operator token.
*/
-template<Operator::Type TYPE>
-class BinaryOp : public Operator
-{
-private:
+template <Operator::Type TYPE>
+class BinaryOp : public Operator {
+ private:
friend class Operator;
- BinaryOp()
- : Operator(Operator::BINARY, TYPE), m_Size(0)
- {
+ BinaryOp() : Operator(Operator::BINARY, TYPE), m_Size(0) {
m_pOperand[0] = m_pOperand[1] = NULL;
}
-public:
- ~BinaryOp()
- {}
+ public:
+ ~BinaryOp() {}
IntOperand* eval(const Module& pModule, const TargetLDBackend& pBackend);
- void appendOperand(Operand* pOperand)
- {
+ void appendOperand(Operand* pOperand) {
m_pOperand[m_Size++] = pOperand;
if (m_Size == 2)
m_Size = 0;
}
-private:
+ private:
size_t m_Size;
Operand* m_pOperand[2];
};
-template<>
+template <>
IntOperand* BinaryOp<Operator::MUL>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::DIV>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::MOD>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::ADD>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::SUB>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::LSHIFT>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::RSHIFT>::eval(const Module&,
const TargetLDBackend&);
-template<>
-IntOperand* BinaryOp<Operator::LT>::eval(const Module&,
- const TargetLDBackend&);
-template<>
-IntOperand* BinaryOp<Operator::LE>::eval(const Module&,
- const TargetLDBackend&);
-template<>
-IntOperand* BinaryOp<Operator::GT>::eval(const Module&,
- const TargetLDBackend&);
-template<>
-IntOperand* BinaryOp<Operator::GE>::eval(const Module&,
- const TargetLDBackend&);
-template<>
-IntOperand* BinaryOp<Operator::EQ>::eval(const Module&,
- const TargetLDBackend&);
-template<>
-IntOperand* BinaryOp<Operator::NE>::eval(const Module&,
- const TargetLDBackend&);
-template<>
+template <>
+IntOperand* BinaryOp<Operator::LT>::eval(const Module&, const TargetLDBackend&);
+template <>
+IntOperand* BinaryOp<Operator::LE>::eval(const Module&, const TargetLDBackend&);
+template <>
+IntOperand* BinaryOp<Operator::GT>::eval(const Module&, const TargetLDBackend&);
+template <>
+IntOperand* BinaryOp<Operator::GE>::eval(const Module&, const TargetLDBackend&);
+template <>
+IntOperand* BinaryOp<Operator::EQ>::eval(const Module&, const TargetLDBackend&);
+template <>
+IntOperand* BinaryOp<Operator::NE>::eval(const Module&, const TargetLDBackend&);
+template <>
IntOperand* BinaryOp<Operator::BITWISE_AND>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::BITWISE_XOR>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::BITWISE_OR>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::LOGICAL_AND>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::LOGICAL_OR>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::ALIGN>::eval(const Module&,
const TargetLDBackend&);
-template<>
-IntOperand*
-BinaryOp<Operator::DATA_SEGMENT_RELRO_END>::eval(const Module&,
- const TargetLDBackend&);
-template<>
+template <>
+IntOperand* BinaryOp<Operator::DATA_SEGMENT_RELRO_END>::eval(
+ const Module&,
+ const TargetLDBackend&);
+template <>
IntOperand* BinaryOp<Operator::MAX>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::MIN>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* BinaryOp<Operator::SEGMENT_START>::eval(const Module&,
const TargetLDBackend&);
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_BINARYOP_H_
diff --git a/include/mcld/Script/EntryCmd.h b/include/mcld/Script/EntryCmd.h
index 509cc9a..90a4d8a 100644
--- a/include/mcld/Script/EntryCmd.h
+++ b/include/mcld/Script/EntryCmd.h
@@ -6,14 +6,14 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_ENTRYCMD_H
-#define MCLD_SCRIPT_ENTRYCMD_H
+#ifndef MCLD_SCRIPT_ENTRYCMD_H_
+#define MCLD_SCRIPT_ENTRYCMD_H_
+
+#include "mcld/Script/ScriptCommand.h"
-#include <mcld/Script/ScriptCommand.h>
#include <string>
-namespace mcld
-{
+namespace mcld {
class Module;
@@ -21,26 +21,23 @@ class Module;
* \brief This class defines the interfaces to Entry command.
*/
-class EntryCmd : public ScriptCommand
-{
-public:
- EntryCmd(const std::string& pEntry);
+class EntryCmd : public ScriptCommand {
+ public:
+ explicit EntryCmd(const std::string& pEntry);
~EntryCmd();
void dump() const;
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::ENTRY;
}
void activate(Module& pModule);
-private:
+ private:
std::string m_Entry;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_ENTRYCMD_H_
diff --git a/include/mcld/Script/ExprToken.h b/include/mcld/Script/ExprToken.h
index a182b3c..2e680b2 100644
--- a/include/mcld/Script/ExprToken.h
+++ b/include/mcld/Script/ExprToken.h
@@ -6,42 +6,33 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_EXPRTOKEN_H
-#define MCLD_SCRIPT_EXPRTOKEN_H
+#ifndef MCLD_SCRIPT_EXPRTOKEN_H_
+#define MCLD_SCRIPT_EXPRTOKEN_H_
-namespace mcld
-{
+namespace mcld {
/** \class ExprToken
* \brief This class defines the interfaces to an expression token.
*/
-class ExprToken
-{
-public:
- enum Kind {
- OPERATOR,
- OPERAND
- };
+class ExprToken {
+ public:
+ enum Kind { OPERATOR, OPERAND };
-protected:
- ExprToken(Kind pKind)
- : m_Kind(pKind)
- {}
+ protected:
+ explicit ExprToken(Kind pKind) : m_Kind(pKind) {}
-public:
- virtual ~ExprToken()
- {}
+ public:
+ virtual ~ExprToken() {}
virtual void dump() const = 0;
Kind kind() const { return m_Kind; }
-private:
+ private:
Kind m_Kind;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_EXPRTOKEN_H_
diff --git a/include/mcld/Script/FileToken.h b/include/mcld/Script/FileToken.h
index 4beaacb..e10e00e 100644
--- a/include/mcld/Script/FileToken.h
+++ b/include/mcld/Script/FileToken.h
@@ -6,33 +6,30 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_FILETOKEN_H
-#define MCLD_SCRIPT_FILETOKEN_H
+#ifndef MCLD_SCRIPT_FILETOKEN_H_
+#define MCLD_SCRIPT_FILETOKEN_H_
-#include <mcld/Script/InputToken.h>
-#include <mcld/Support/Allocators.h>
-#include <mcld/Config/Config.h>
+#include "mcld/Config/Config.h"
+#include "mcld/Script/InputToken.h"
+#include "mcld/Support/Allocators.h"
-namespace mcld
-{
+namespace mcld {
/** \class FileToken
* \brief This class defines the interfaces to a filename in INPUT/GROUP
* command.
*/
-class FileToken : public InputToken
-{
-private:
+class FileToken : public InputToken {
+ private:
friend class Chunk<FileToken, MCLD_SYMBOLS_PER_INPUT>;
FileToken();
FileToken(const std::string& pName, bool pAsNeeded);
-public:
+ public:
~FileToken();
- static bool classof(const InputToken* pToken)
- {
+ static bool classof(const InputToken* pToken) {
return pToken->type() == InputToken::File;
}
@@ -42,6 +39,6 @@ public:
static void clear();
};
-} // namepsace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_FILETOKEN_H_
diff --git a/include/mcld/Script/FlexLexer.h b/include/mcld/Script/FlexLexer.h
index f09ab20..3514ee1 100644
--- a/include/mcld/Script/FlexLexer.h
+++ b/include/mcld/Script/FlexLexer.h
@@ -58,158 +58,151 @@
#define __FLEX_LEXER_H
#include <iostream>
-# ifndef FLEX_STD
-# define FLEX_STD std::
-# endif
+#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"
-};
+ 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
+#endif // FLEXLEXER_H
-#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
+#if defined(yyFlexLexer) || !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 );
+ 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();
+ 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 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();
+ 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();
+ virtual int yylex();
+ virtual void switch_streams(FLEX_STD istream* new_in,
+ FLEX_STD ostream* new_out = 0);
+ virtual int yywrap();
-protected:
- virtual int LexerInput( char* buf, int max_size );
- virtual void LexerOutput( const char* buf, int size );
- virtual void LexerError( const char* msg );
+ protected:
+ virtual int LexerInput(char* buf, int max_size);
+ virtual void LexerOutput(const char* buf, int size);
+ virtual void LexerError(const char* msg);
- void yyunput( int c, char* buf_ptr );
- int yyinput();
+ 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 );
+ 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;
+ 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();
+ 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();
+ 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
+ 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;
+ // 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;
+ // Number of characters read into yy_ch_buf.
+ int yy_n_chars;
- // Points to current character in buffer.
- char* yy_c_buf_p;
+ // 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
+ 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;
+ // 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);
- 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()).
- // 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_last_accepting_state;
- char* yy_last_accepting_cpos;
+ yy_state_type* yy_state_buf;
+ yy_state_type* yy_state_ptr;
- yy_state_type* yy_state_buf;
- yy_state_type* yy_state_ptr;
+ char* yy_full_match;
+ int* yy_full_state;
+ int yy_full_lp;
- char* yy_full_match;
- int* yy_full_state;
- int yy_full_lp;
+ int yy_lp;
+ int yy_looking_for_trail_begin;
- 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;
+ int yy_more_flag;
+ int yy_more_len;
+ int yy_more_offset;
+ int yy_prev_more_offset;
};
-
}
-#endif // yyFlexLexer || ! yyFlexLexerOnce
-
+#endif // yyFlexLexer || ! yyFlexLexerOnce
diff --git a/include/mcld/Script/GroupCmd.h b/include/mcld/Script/GroupCmd.h
index 5a016db..8f3f171 100644
--- a/include/mcld/Script/GroupCmd.h
+++ b/include/mcld/Script/GroupCmd.h
@@ -6,27 +6,25 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_GROUPCMD_H
-#define MCLD_SCRIPT_GROUPCMD_H
+#ifndef MCLD_SCRIPT_GROUPCMD_H_
+#define MCLD_SCRIPT_GROUPCMD_H_
-#include <mcld/Script/ScriptCommand.h>
+#include "mcld/Script/ScriptCommand.h"
-namespace mcld
-{
+namespace mcld {
-class StringList;
class InputTree;
class InputBuilder;
class GroupReader;
class LinkerConfig;
+class StringList;
/** \class GroupCmd
* \brief This class defines the interfaces to Group command.
*/
-class GroupCmd : public ScriptCommand
-{
-public:
+class GroupCmd : public ScriptCommand {
+ public:
GroupCmd(StringList& pStringList,
InputTree& pInputTree,
InputBuilder& pBuilder,
@@ -36,14 +34,13 @@ public:
void dump() const;
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::GROUP;
}
void activate(Module& pModule);
-private:
+ private:
StringList& m_StringList;
InputTree& m_InputTree;
InputBuilder& m_Builder;
@@ -51,7 +48,6 @@ private:
const LinkerConfig& m_Config;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_GROUPCMD_H_
diff --git a/include/mcld/Script/InputCmd.h b/include/mcld/Script/InputCmd.h
new file mode 100644
index 0000000..694fcda
--- /dev/null
+++ b/include/mcld/Script/InputCmd.h
@@ -0,0 +1,59 @@
+//===- InputCmd.h ---------------------------------------------------------===//
+//
+// The MCLinker Project
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#ifndef MCLD_SCRIPT_INPUTCMD_H_
+#define MCLD_SCRIPT_INPUTCMD_H_
+
+#include "mcld/Script/ScriptCommand.h"
+
+namespace mcld {
+
+class ArchiveReader;
+class DynObjReader;
+class InputBuilder;
+class InputTree;
+class LinkerConfig;
+class ObjectReader;
+class StringList;
+
+/** \class InputCmd
+ * \brief This class defines the interfaces to Input command.
+ */
+
+class InputCmd : public ScriptCommand {
+ public:
+ InputCmd(StringList& pStringList,
+ InputTree& pInputTree,
+ InputBuilder& pBuilder,
+ ObjectReader& pObjectReader,
+ ArchiveReader& pArchiveReader,
+ DynObjReader& pDynObjReader,
+ const LinkerConfig& pConfig);
+ ~InputCmd();
+
+ void dump() const;
+
+ static bool classof(const ScriptCommand* pCmd) {
+ return pCmd->getKind() == ScriptCommand::INPUT;
+ }
+
+ void activate(Module& pModule);
+
+ private:
+ StringList& m_StringList;
+ InputTree& m_InputTree;
+ InputBuilder& m_Builder;
+ ObjectReader& m_ObjectReader;
+ ArchiveReader& m_ArchiveReader;
+ DynObjReader& m_DynObjReader;
+ const LinkerConfig& m_Config;
+};
+
+} // namespace mcld
+
+#endif // MCLD_SCRIPT_INPUTCMD_H_
diff --git a/include/mcld/Script/InputSectDesc.h b/include/mcld/Script/InputSectDesc.h
index ede2a3d..a883769 100644
--- a/include/mcld/Script/InputSectDesc.h
+++ b/include/mcld/Script/InputSectDesc.h
@@ -6,30 +6,26 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_INPUTSECTDESC_H
-#define MCLD_SCRIPT_INPUTSECTDESC_H
+#ifndef MCLD_SCRIPT_INPUTSECTDESC_H_
+#define MCLD_SCRIPT_INPUTSECTDESC_H_
+
+#include "mcld/Script/ScriptCommand.h"
+#include "mcld/Script/StringList.h"
-#include <mcld/Script/ScriptCommand.h>
-#include <mcld/Script/StringList.h>
#include <cassert>
-namespace mcld
-{
+namespace mcld {
-class WildcardPattern;
class OutputSectDesc;
+class WildcardPattern;
/** \class InputSectDesc
* \brief This class defines the interfaces to input section description.
*/
-class InputSectDesc : public ScriptCommand
-{
-public:
- enum KeepPolicy {
- Keep,
- NoKeep
- };
+class InputSectDesc : public ScriptCommand {
+ public:
+ enum KeepPolicy { Keep, NoKeep };
struct Spec {
bool hasFile() const { return m_pWildcardFile != NULL; }
@@ -72,7 +68,7 @@ public:
StringList* m_pWildcardSections;
};
-public:
+ public:
InputSectDesc(KeepPolicy pPolicy,
const Spec& pSpec,
const OutputSectDesc& pOutputDesc);
@@ -84,19 +80,18 @@ public:
void dump() const;
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::INPUT_SECT_DESC;
}
void activate(Module& pModule);
-private:
+ private:
KeepPolicy m_KeepPolicy;
Spec m_Spec;
const OutputSectDesc& m_OutputSectDesc;
};
-} // namespace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_INPUTSECTDESC_H_
diff --git a/include/mcld/Script/InputToken.h b/include/mcld/Script/InputToken.h
index 057c06d..9f761c3 100644
--- a/include/mcld/Script/InputToken.h
+++ b/include/mcld/Script/InputToken.h
@@ -6,48 +6,41 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_INPUTTOKEN_H
-#define MCLD_SCRIPT_INPUTTOKEN_H
+#ifndef MCLD_SCRIPT_INPUTTOKEN_H_
+#define MCLD_SCRIPT_INPUTTOKEN_H_
-#include <mcld/Script/StrToken.h>
+#include "mcld/Script/StrToken.h"
-namespace mcld
-{
+namespace mcld {
/** \class InputToken
* \brief This class defines the interfaces to a file/namespec token.
*/
-class InputToken : public StrToken
-{
-public:
- enum Type {
- Unknown,
- File,
- NameSpec
- };
+class InputToken : public StrToken {
+ public:
+ enum Type { Unknown, File, NameSpec };
-protected:
+ protected:
InputToken();
InputToken(Type pType, const std::string& pName, bool pAsNeeded);
-public:
+ public:
virtual ~InputToken();
Type type() const { return m_Type; }
bool asNeeded() const { return m_bAsNeeded; }
- static bool classof(const StrToken* pToken)
- {
+ static bool classof(const StrToken* pToken) {
return pToken->kind() == StrToken::Input;
}
-private:
+ private:
Type m_Type;
bool m_bAsNeeded;
};
-} // namepsace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_INPUTTOKEN_H_
diff --git a/include/mcld/Script/NameSpec.h b/include/mcld/Script/NameSpec.h
index 50040fa..a8db136 100644
--- a/include/mcld/Script/NameSpec.h
+++ b/include/mcld/Script/NameSpec.h
@@ -6,33 +6,30 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_NAMESPEC_H
-#define MCLD_SCRIPT_NAMESPEC_H
+#ifndef MCLD_SCRIPT_NAMESPEC_H_
+#define MCLD_SCRIPT_NAMESPEC_H_
-#include <mcld/Script/InputToken.h>
-#include <mcld/Support/Allocators.h>
-#include <mcld/Config/Config.h>
+#include "mcld/Config/Config.h"
+#include "mcld/Script/InputToken.h"
+#include "mcld/Support/Allocators.h"
-namespace mcld
-{
+namespace mcld {
/** \class NameSpec
* \brief This class defines the interfaces to a namespec in INPUT/GROUP
* command.
*/
-class NameSpec : public InputToken
-{
-private:
+class NameSpec : public InputToken {
+ private:
friend class Chunk<NameSpec, MCLD_SYMBOLS_PER_INPUT>;
NameSpec();
NameSpec(const std::string& pName, bool pAsNeeded);
-public:
+ public:
~NameSpec();
- static bool classof(const InputToken* pToken)
- {
+ static bool classof(const InputToken* pToken) {
return pToken->type() == InputToken::NameSpec;
}
@@ -42,6 +39,6 @@ public:
static void clear();
};
-} // namepsace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_NAMESPEC_H_
diff --git a/include/mcld/Script/NullaryOp.h b/include/mcld/Script/NullaryOp.h
index 00a7db2..129d756 100644
--- a/include/mcld/Script/NullaryOp.h
+++ b/include/mcld/Script/NullaryOp.h
@@ -6,14 +6,14 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_NULLOP_H
-#define MCLD_SCRIPT_NULLOP_H
+#ifndef MCLD_SCRIPT_NULLARYOP_H_
+#define MCLD_SCRIPT_NULLARYOP_H_
+
+#include "mcld/Script/Operator.h"
-#include <mcld/Script/Operator.h>
#include <cassert>
-namespace mcld
-{
+namespace mcld {
class Operand;
class IntOperand;
@@ -24,39 +24,32 @@ class TargetLDBackend;
* \brief This class defines the interfaces to an nullary operator token.
*/
-template<Operator::Type TYPE>
-class NullaryOp : public Operator
-{
-private:
+template <Operator::Type TYPE>
+class NullaryOp : public Operator {
+ private:
friend class Operator;
- NullaryOp()
- : Operator(Operator::NULLARY, TYPE)
- {}
+ NullaryOp() : Operator(Operator::NULLARY, TYPE) {}
-public:
- ~NullaryOp()
- {}
+ public:
+ ~NullaryOp() {}
IntOperand* eval(const Module& pModule, const TargetLDBackend& pBackend);
- void appendOperand(Operand* pOperand)
- {
- assert(0);
- }
+ void appendOperand(Operand* pOperand) { assert(0); }
};
-template<>
+template <>
IntOperand* NullaryOp<Operator::SIZEOF_HEADERS>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* NullaryOp<Operator::MAXPAGESIZE>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* NullaryOp<Operator::COMMONPAGESIZE>::eval(const Module&,
const TargetLDBackend&);
-} // namespace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_NULLARYOP_H_
diff --git a/include/mcld/Script/Operand.h b/include/mcld/Script/Operand.h
index 86c1228..9258a32 100644
--- a/include/mcld/Script/Operand.h
+++ b/include/mcld/Script/Operand.h
@@ -6,52 +6,46 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_OPERAND_H
-#define MCLD_SCRIPT_OPERAND_H
+#ifndef MCLD_SCRIPT_OPERAND_H_
+#define MCLD_SCRIPT_OPERAND_H_
+
+#include "mcld/Config/Config.h"
+#include "mcld/Object/SectionMap.h"
+#include "mcld/Script/ExprToken.h"
+#include "mcld/Support/Allocators.h"
-#include <mcld/Script/ExprToken.h>
-#include <mcld/Object/SectionMap.h>
-#include <mcld/Support/Allocators.h>
-#include <mcld/Config/Config.h>
#include <llvm/Support/DataTypes.h>
+
#include <string>
+
#include <cassert>
-namespace mcld
-{
+namespace mcld {
/** \class Operand
* \brief This class defines the interfaces to an operand token.
*/
-class Operand : public ExprToken
-{
-public:
- enum Type {
- SYMBOL,
- INTEGER,
- SECTION,
- SECTION_DESC,
- FRAGMENT
- };
-
-protected:
- Operand(Type pType);
+class Operand : public ExprToken {
+ public:
+ enum Type { SYMBOL, INTEGER, SECTION, SECTION_DESC, FRAGMENT };
+
+ protected:
+ explicit Operand(Type pType);
virtual ~Operand();
-public:
+ public:
Type type() const { return m_Type; }
virtual bool isDot() const { return false; }
virtual uint64_t value() const = 0;
- static bool classof(const ExprToken* pToken)
- {
+ static bool classof(const ExprToken* pToken) {
return pToken->kind() == ExprToken::OPERAND;
}
-private:
+ private:
Type m_Type;
};
@@ -59,14 +53,13 @@ private:
* \brief This class defines the interfaces to a symbol operand.
*/
-class SymOperand : public Operand
-{
-private:
+class SymOperand : public Operand {
+ private:
friend class Chunk<SymOperand, MCLD_SYMBOLS_PER_INPUT>;
SymOperand();
- SymOperand(const std::string& pName);
+ explicit SymOperand(const std::string& pName);
-public:
+ public:
void dump() const;
const std::string& name() const { return m_Name; }
@@ -77,8 +70,7 @@ public:
void setValue(uint64_t pValue) { m_Value = pValue; }
- static bool classof(const Operand* pOperand)
- {
+ static bool classof(const Operand* pOperand) {
return pOperand->type() == Operand::SYMBOL;
}
@@ -87,7 +79,7 @@ public:
static void destroy(SymOperand*& pOperand);
static void clear();
-private:
+ private:
std::string m_Name;
uint64_t m_Value;
};
@@ -96,22 +88,20 @@ private:
* \brief This class defines the interfaces to an integer operand.
*/
-class IntOperand : public Operand
-{
-private:
+class IntOperand : public Operand {
+ private:
friend class Chunk<IntOperand, MCLD_SYMBOLS_PER_INPUT>;
IntOperand();
- IntOperand(uint64_t pValue);
+ explicit IntOperand(uint64_t pValue);
-public:
+ public:
void dump() const;
uint64_t value() const { return m_Value; }
void setValue(uint64_t pValue) { m_Value = pValue; }
- static bool classof(const Operand* pOperand)
- {
+ static bool classof(const Operand* pOperand) {
return pOperand->type() == Operand::INTEGER;
}
@@ -120,7 +110,7 @@ public:
static void destroy(IntOperand*& pOperand);
static void clear();
-private:
+ private:
uint64_t m_Value;
};
@@ -129,26 +119,23 @@ private:
*/
class LDSection;
-class SectOperand : public Operand
-{
-private:
+class SectOperand : public Operand {
+ private:
friend class Chunk<SectOperand, MCLD_SECTIONS_PER_INPUT>;
SectOperand();
- SectOperand(const std::string& pName);
+ explicit SectOperand(const std::string& pName);
-public:
+ public:
void dump() const;
const std::string& name() const { return m_Name; }
- uint64_t value() const
- {
+ uint64_t value() const {
assert(0);
return 0;
}
- static bool classof(const Operand* pOperand)
- {
+ static bool classof(const Operand* pOperand) {
return pOperand->type() == Operand::SECTION;
}
@@ -157,7 +144,7 @@ public:
static void destroy(SectOperand*& pOperand);
static void clear();
-private:
+ private:
std::string m_Name;
};
@@ -165,26 +152,23 @@ private:
* \brief This class defines the interfaces to an section name operand.
*/
-class SectDescOperand : public Operand
-{
-private:
+class SectDescOperand : public Operand {
+ private:
friend class Chunk<SectDescOperand, MCLD_SECTIONS_PER_INPUT>;
SectDescOperand();
- SectDescOperand(const SectionMap::Output* pOutputDesc);
+ explicit SectDescOperand(const SectionMap::Output* pOutputDesc);
-public:
+ public:
void dump() const;
const SectionMap::Output* outputDesc() const { return m_pOutputDesc; }
- uint64_t value() const
- {
+ uint64_t value() const {
assert(0);
return 0;
}
- static bool classof(const Operand* pOperand)
- {
+ static bool classof(const Operand* pOperand) {
return pOperand->type() == Operand::SECTION_DESC;
}
@@ -193,7 +177,7 @@ public:
static void destroy(SectDescOperand*& pOperand);
static void clear();
-private:
+ private:
const SectionMap::Output* m_pOutputDesc;
};
@@ -203,23 +187,21 @@ private:
class Fragment;
-class FragOperand : public Operand
-{
-private:
+class FragOperand : public Operand {
+ private:
friend class Chunk<FragOperand, MCLD_SYMBOLS_PER_INPUT>;
FragOperand();
- FragOperand(Fragment& pFragment);
+ explicit FragOperand(Fragment& pFragment);
-public:
+ public:
void dump() const;
const Fragment* frag() const { return m_pFragment; }
- Fragment* frag() { return m_pFragment; }
+ Fragment* frag() { return m_pFragment; }
uint64_t value() const;
- static bool classof(const Operand* pOperand)
- {
+ static bool classof(const Operand* pOperand) {
return pOperand->type() == Operand::FRAGMENT;
}
@@ -228,11 +210,10 @@ public:
static void destroy(FragOperand*& pOperand);
static void clear();
-private:
+ private:
Fragment* m_pFragment;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_OPERAND_H_
diff --git a/include/mcld/Script/Operator.h b/include/mcld/Script/Operator.h
index b438b4d..017e735 100644
--- a/include/mcld/Script/Operator.h
+++ b/include/mcld/Script/Operator.h
@@ -6,100 +6,93 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_OPERATOR_INTERFACE_H
-#define MCLD_SCRIPT_OPERATOR_INTERFACE_H
+#ifndef MCLD_SCRIPT_OPERATOR_H_
+#define MCLD_SCRIPT_OPERATOR_H_
-#include <mcld/Script/ExprToken.h>
+#include "mcld/Script/ExprToken.h"
#include <llvm/Support/DataTypes.h>
-namespace mcld
-{
+namespace mcld {
-class Operand;
class IntOperand;
class Module;
+class Operand;
class TargetLDBackend;
/** \class Operator
* \brief This class defines the interfaces to an operator token.
*/
-class Operator : public ExprToken
-{
-public:
- enum Arity {
- NULLARY,
- UNARY,
- BINARY,
- TERNARY
- };
+class Operator : public ExprToken {
+ public:
+ enum Arity { NULLARY, UNARY, BINARY, TERNARY };
enum Type {
/* arithmetic operator */
- UNARY_PLUS = 0,
+ UNARY_PLUS = 0,
UNARY_MINUS = 1,
LOGICAL_NOT = 2,
BITWISE_NOT = 3,
- MUL = 4,
- DIV = 5,
- MOD = 6,
- ADD = 7,
- SUB = 8,
- LSHIFT = 9,
- RSHIFT = 10,
- LT = 11,
- LE = 12,
- GT = 13,
- GE = 14,
- EQ = 15,
- NE = 16,
+ MUL = 4,
+ DIV = 5,
+ MOD = 6,
+ ADD = 7,
+ SUB = 8,
+ LSHIFT = 9,
+ RSHIFT = 10,
+ LT = 11,
+ LE = 12,
+ GT = 13,
+ GE = 14,
+ EQ = 15,
+ NE = 16,
BITWISE_AND = 17,
BITWISE_XOR = 18,
- BITWISE_OR = 19,
+ BITWISE_OR = 19,
LOGICAL_AND = 20,
- LOGICAL_OR = 21,
- TERNARY_IF = 22,
- ASSIGN = 23,
- ADD_ASSIGN = 24,
- SUB_ASSIGN = 25,
- MUL_ASSIGN = 26,
- DIV_ASSIGN = 27,
- AND_ASSIGN = 28,
- OR_ASSIGN = 29,
- LS_ASSIGN = 30,
- RS_ASSIGN = 31,
+ LOGICAL_OR = 21,
+ TERNARY_IF = 22,
+ ASSIGN = 23,
+ ADD_ASSIGN = 24,
+ SUB_ASSIGN = 25,
+ MUL_ASSIGN = 26,
+ DIV_ASSIGN = 27,
+ AND_ASSIGN = 28,
+ OR_ASSIGN = 29,
+ LS_ASSIGN = 30,
+ RS_ASSIGN = 31,
/* function */
- ABSOLUTE = 32,
- ADDR = 33,
- ALIGN = 34,
- ALIGNOF = 35,
- BLOCK = 36,
- DATA_SEGMENT_ALIGN = 37,
- DATA_SEGMENT_END = 38,
+ ABSOLUTE = 32,
+ ADDR = 33,
+ ALIGN = 34,
+ ALIGNOF = 35,
+ BLOCK = 36,
+ DATA_SEGMENT_ALIGN = 37,
+ DATA_SEGMENT_END = 38,
DATA_SEGMENT_RELRO_END = 39,
- DEFINED = 40,
- LENGTH = 41,
- LOADADDR = 42,
- MAX = 43,
- MIN = 44,
- NEXT = 45,
- ORIGIN = 46,
- SEGMENT_START = 47,
- SIZEOF = 48,
- SIZEOF_HEADERS = 49,
- MAXPAGESIZE = 50,
- COMMONPAGESIZE = 51
+ DEFINED = 40,
+ LENGTH = 41,
+ LOADADDR = 42,
+ MAX = 43,
+ MIN = 44,
+ NEXT = 45,
+ ORIGIN = 46,
+ SEGMENT_START = 47,
+ SIZEOF = 48,
+ SIZEOF_HEADERS = 49,
+ MAXPAGESIZE = 50,
+ COMMONPAGESIZE = 51
};
static const char* OpNames[];
-protected:
+ protected:
Operator(Arity pArity, Type pType);
const IntOperand* result() const { return m_pIntOperand; }
- IntOperand* result() { return m_pIntOperand; }
+ IntOperand* result() { return m_pIntOperand; }
-public:
+ public:
virtual ~Operator();
Arity arity() const { return m_Arity; }
@@ -113,116 +106,113 @@ public:
virtual void appendOperand(Operand* pOperand) = 0;
- static bool classof(const ExprToken* pToken)
- {
+ static bool classof(const ExprToken* pToken) {
return pToken->kind() == ExprToken::OPERATOR;
}
- template<Operator::Type TYPE>
+ template <Operator::Type TYPE>
static Operator& create();
-private:
+ private:
Arity m_Arity;
Type m_Type;
IntOperand* m_pIntOperand;
};
/* Nullary operator */
-template<>
+template <>
Operator& Operator::create<Operator::SIZEOF_HEADERS>();
-template<>
+template <>
Operator& Operator::create<Operator::MAXPAGESIZE>();
-template<>
+template <>
Operator& Operator::create<Operator::COMMONPAGESIZE>();
/* Unary operator */
-template<>
+template <>
Operator& Operator::create<Operator::UNARY_PLUS>();
-template<>
+template <>
Operator& Operator::create<Operator::UNARY_MINUS>();
-template<>
+template <>
Operator& Operator::create<Operator::LOGICAL_NOT>();
-template<>
+template <>
Operator& Operator::create<Operator::BITWISE_NOT>();
-template<>
+template <>
Operator& Operator::create<Operator::ABSOLUTE>();
-template<>
+template <>
Operator& Operator::create<Operator::ADDR>();
-template<>
+template <>
Operator& Operator::create<Operator::ALIGNOF>();
-template<>
+template <>
Operator& Operator::create<Operator::DATA_SEGMENT_END>();
-template<>
+template <>
Operator& Operator::create<Operator::DEFINED>();
-template<>
+template <>
Operator& Operator::create<Operator::LENGTH>();
-template<>
+template <>
Operator& Operator::create<Operator::LOADADDR>();
-template<>
+template <>
Operator& Operator::create<Operator::NEXT>();
-template<>
+template <>
Operator& Operator::create<Operator::ORIGIN>();
-template<>
+template <>
Operator& Operator::create<Operator::SIZEOF>();
/* Binary operator */
-template<>
+template <>
Operator& Operator::create<Operator::MUL>();
-template<>
+template <>
Operator& Operator::create<Operator::DIV>();
-template<>
+template <>
Operator& Operator::create<Operator::MOD>();
-template<>
+template <>
Operator& Operator::create<Operator::ADD>();
-template<>
+template <>
Operator& Operator::create<Operator::SUB>();
-template<>
+template <>
Operator& Operator::create<Operator::LSHIFT>();
-template<>
+template <>
Operator& Operator::create<Operator::RSHIFT>();
-template<>
+template <>
Operator& Operator::create<Operator::LT>();
-template<>
+template <>
Operator& Operator::create<Operator::LE>();
-template<>
+template <>
Operator& Operator::create<Operator::GT>();
-template<>
+template <>
Operator& Operator::create<Operator::GE>();
-template<>
+template <>
Operator& Operator::create<Operator::EQ>();
-template<>
+template <>
Operator& Operator::create<Operator::NE>();
-template<>
+template <>
Operator& Operator::create<Operator::BITWISE_AND>();
-template<>
+template <>
Operator& Operator::create<Operator::BITWISE_XOR>();
-template<>
+template <>
Operator& Operator::create<Operator::BITWISE_OR>();
-template<>
+template <>
Operator& Operator::create<Operator::LOGICAL_AND>();
-template<>
+template <>
Operator& Operator::create<Operator::LOGICAL_OR>();
-template<>
+template <>
Operator& Operator::create<Operator::ALIGN>();
-template<>
+template <>
Operator& Operator::create<Operator::DATA_SEGMENT_RELRO_END>();
-template<>
+template <>
Operator& Operator::create<Operator::MAX>();
-template<>
+template <>
Operator& Operator::create<Operator::MIN>();
-template<>
+template <>
Operator& Operator::create<Operator::SEGMENT_START>();
/* Ternary operator */
-template<>
+template <>
Operator& Operator::create<Operator::TERNARY_IF>();
-template<>
-Operator&
-Operator::create<Operator::DATA_SEGMENT_ALIGN>();
-} // namespace of mcld
-
-#endif
+template <>
+Operator& Operator::create<Operator::DATA_SEGMENT_ALIGN>();
+} // namespace mcld
+#endif // MCLD_SCRIPT_OPERATOR_H_
diff --git a/include/mcld/Script/OutputArchCmd.h b/include/mcld/Script/OutputArchCmd.h
index aad97fc..1c22697 100644
--- a/include/mcld/Script/OutputArchCmd.h
+++ b/include/mcld/Script/OutputArchCmd.h
@@ -6,14 +6,14 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_OUTPUTARCHCMD_H
-#define MCLD_SCRIPT_OUTPUTARCHCMD_H
+#ifndef MCLD_SCRIPT_OUTPUTARCHCMD_H_
+#define MCLD_SCRIPT_OUTPUTARCHCMD_H_
+
+#include "mcld/Script/ScriptCommand.h"
-#include <mcld/Script/ScriptCommand.h>
#include <string>
-namespace mcld
-{
+namespace mcld {
class Module;
@@ -21,26 +21,23 @@ class Module;
* \brief This class defines the interfaces to OutputArch command.
*/
-class OutputArchCmd : public ScriptCommand
-{
-public:
- OutputArchCmd(const std::string& pArch);
+class OutputArchCmd : public ScriptCommand {
+ public:
+ explicit OutputArchCmd(const std::string& pArch);
~OutputArchCmd();
void dump() const;
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::OUTPUT_ARCH;
}
void activate(Module& pModule);
-private:
+ private:
std::string m_Arch;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_OUTPUTARCHCMD_H_
diff --git a/include/mcld/Script/OutputCmd.h b/include/mcld/Script/OutputCmd.h
index 0ee895f..d7afa25 100644
--- a/include/mcld/Script/OutputCmd.h
+++ b/include/mcld/Script/OutputCmd.h
@@ -6,14 +6,14 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_OUTPUTCMD_H
-#define MCLD_SCRIPT_OUTPUTCMD_H
+#ifndef MCLD_SCRIPT_OUTPUTCMD_H_
+#define MCLD_SCRIPT_OUTPUTCMD_H_
+
+#include "mcld/Script/ScriptCommand.h"
-#include <mcld/Script/ScriptCommand.h>
#include <string>
-namespace mcld
-{
+namespace mcld {
class Module;
@@ -21,27 +21,24 @@ class Module;
* \brief This class defines the interfaces to Output command.
*/
-class OutputCmd : public ScriptCommand
-{
-public:
- OutputCmd(const std::string& pOutputFile);
+class OutputCmd : public ScriptCommand {
+ public:
+ explicit OutputCmd(const std::string& pOutputFile);
~OutputCmd();
void dump() const;
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::OUTPUT;
}
void activate(Module& pModule);
-private:
+ private:
std::string m_OutputFile;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_OUTPUTCMD_H_
diff --git a/include/mcld/Script/OutputFormatCmd.h b/include/mcld/Script/OutputFormatCmd.h
index 0c34872..307f738 100644
--- a/include/mcld/Script/OutputFormatCmd.h
+++ b/include/mcld/Script/OutputFormatCmd.h
@@ -6,15 +6,15 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_OUTPUTFORMATCMD_H
-#define MCLD_SCRIPT_OUTPUTFORMATCMD_H
+#ifndef MCLD_SCRIPT_OUTPUTFORMATCMD_H_
+#define MCLD_SCRIPT_OUTPUTFORMATCMD_H_
+
+#include "mcld/Script/ScriptCommand.h"
-#include <mcld/Script/ScriptCommand.h>
#include <string>
#include <vector>
-namespace mcld
-{
+namespace mcld {
class Module;
@@ -22,39 +22,36 @@ class Module;
* \brief This class defines the interfaces to OutputFormat command.
*/
-class OutputFormatCmd : public ScriptCommand
-{
-public:
+class OutputFormatCmd : public ScriptCommand {
+ public:
typedef std::vector<std::string> FormatList;
typedef FormatList::const_iterator const_iterator;
typedef FormatList::iterator iterator;
-public:
- OutputFormatCmd(const std::string& pFormat);
+ public:
+ explicit OutputFormatCmd(const std::string& pFormat);
OutputFormatCmd(const std::string& pDefault,
const std::string& pBig,
const std::string& pLittle);
~OutputFormatCmd();
const_iterator begin() const { return m_FormatList.begin(); }
- iterator begin() { return m_FormatList.begin(); }
- const_iterator end() const { return m_FormatList.end(); }
- iterator end() { return m_FormatList.end(); }
+ iterator begin() { return m_FormatList.begin(); }
+ const_iterator end() const { return m_FormatList.end(); }
+ iterator end() { return m_FormatList.end(); }
void dump() const;
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::OUTPUT_FORMAT;
}
void activate(Module& pModule);
-private:
+ private:
FormatList m_FormatList;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_OUTPUTFORMATCMD_H_
diff --git a/include/mcld/Script/OutputSectDesc.h b/include/mcld/Script/OutputSectDesc.h
index abf4613..c8df493 100644
--- a/include/mcld/Script/OutputSectDesc.h
+++ b/include/mcld/Script/OutputSectDesc.h
@@ -6,16 +6,17 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_OUTPUTSECTDESC_H
-#define MCLD_SCRIPT_OUTPUTSECTDESC_H
+#ifndef MCLD_SCRIPT_OUTPUTSECTDESC_H_
+#define MCLD_SCRIPT_OUTPUTSECTDESC_H_
+
+#include "mcld/Script/ScriptCommand.h"
-#include <mcld/Script/ScriptCommand.h>
-#include <vector>
#include <string>
+#include <vector>
+
#include <cassert>
-namespace mcld
-{
+namespace mcld {
class RpnExpr;
class StringList;
@@ -24,11 +25,10 @@ class StringList;
* \brief This class defines the interfaces to output section description.
*/
-class OutputSectDesc : public ScriptCommand
-{
-public:
+class OutputSectDesc : public ScriptCommand {
+ public:
enum Type {
- LOAD, // ALLOC
+ LOAD, // ALLOC
NOLOAD,
DSECT,
COPY,
@@ -36,11 +36,7 @@ public:
OVERLAY
};
- enum Constraint {
- NO_CONSTRAINT,
- ONLY_IF_RO,
- ONLY_IF_RW
- };
+ enum Constraint { NO_CONSTRAINT, ONLY_IF_RO, ONLY_IF_RW };
struct Prolog {
bool hasVMA() const { return m_pVMA != NULL; }
@@ -53,9 +49,7 @@ public:
return *m_pVMA;
}
- void setType(Type pType) {
- m_Type = pType;
- }
+ void setType(Type pType) { m_Type = pType; }
Type type() const { return m_Type; }
@@ -91,7 +85,7 @@ public:
return false;
if (m_Type != pRHS.m_Type)
return false;
- if (m_pLMA!= pRHS.m_pLMA)
+ if (m_pLMA != pRHS.m_pLMA)
return false;
if (m_pAlign != pRHS.m_pAlign)
return false;
@@ -162,19 +156,19 @@ public:
typedef OutputSectCmds::const_reference const_reference;
typedef OutputSectCmds::reference reference;
-public:
+ public:
OutputSectDesc(const std::string& pName, const Prolog& pProlog);
~OutputSectDesc();
- const_iterator begin() const { return m_OutputSectCmds.begin(); }
- iterator begin() { return m_OutputSectCmds.begin(); }
- const_iterator end() const { return m_OutputSectCmds.end(); }
- iterator end() { return m_OutputSectCmds.end(); }
+ const_iterator begin() const { return m_OutputSectCmds.begin(); }
+ iterator begin() { return m_OutputSectCmds.begin(); }
+ const_iterator end() const { return m_OutputSectCmds.end(); }
+ iterator end() { return m_OutputSectCmds.end(); }
const_reference front() const { return m_OutputSectCmds.front(); }
- reference front() { return m_OutputSectCmds.front(); }
- const_reference back() const { return m_OutputSectCmds.back(); }
- reference back() { return m_OutputSectCmds.back(); }
+ reference front() { return m_OutputSectCmds.front(); }
+ const_reference back() const { return m_OutputSectCmds.back(); }
+ reference back() { return m_OutputSectCmds.back(); }
const std::string& name() const { return m_Name; }
@@ -184,8 +178,7 @@ public:
void dump() const;
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::OUTPUT_SECT_DESC;
}
@@ -199,13 +192,13 @@ public:
const Epilog& epilog() const { return m_Epilog; }
-private:
+ private:
OutputSectCmds m_OutputSectCmds;
std::string m_Name;
Prolog m_Prolog;
Epilog m_Epilog;
};
-} // namespace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_OUTPUTSECTDESC_H_
diff --git a/include/mcld/Script/RpnEvaluator.h b/include/mcld/Script/RpnEvaluator.h
index 7e35e86..d71366b 100644
--- a/include/mcld/Script/RpnEvaluator.h
+++ b/include/mcld/Script/RpnEvaluator.h
@@ -6,31 +6,32 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_RPNEVALUATOR_H
-#define MCLD_SCRIPT_RPNEVALUATOR_H
+#ifndef MCLD_SCRIPT_RPNEVALUATOR_H_
+#define MCLD_SCRIPT_RPNEVALUATOR_H_
+
+#include <cstdint>
namespace mcld {
-class RpnExpr;
class Module;
+class RpnExpr;
class TargetLDBackend;
/** \class RpnEvaluator
* \brief RpnEvaluator evaluate a rpn expression
*/
-class RpnEvaluator
-{
-public:
+class RpnEvaluator {
+ public:
RpnEvaluator(const Module& pModule, const TargetLDBackend& pBackend);
// evaluate a valid expression and set the value in the second parameter
bool eval(const RpnExpr& pExpr, uint64_t& pResult);
-private:
+ private:
const Module& m_Module;
const TargetLDBackend& m_Backend;
};
-} // mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_RPNEVALUATOR_H_
diff --git a/include/mcld/Script/RpnExpr.h b/include/mcld/Script/RpnExpr.h
index eaf4f72..c80314d 100644
--- a/include/mcld/Script/RpnExpr.h
+++ b/include/mcld/Script/RpnExpr.h
@@ -6,16 +6,16 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_RPNEXPR_H
-#define MCLD_SCRIPT_RPNEXPR_H
+#ifndef MCLD_SCRIPT_RPNEXPR_H_
+#define MCLD_SCRIPT_RPNEXPR_H_
+
+#include "mcld/Config/Config.h"
+#include "mcld/Object/SectionMap.h"
+#include "mcld/Support/Allocators.h"
-#include <mcld/Support/Allocators.h>
-#include <mcld/Config/Config.h>
-#include <mcld/Object/SectionMap.h>
#include <vector>
-namespace mcld
-{
+namespace mcld {
class ExprToken;
class Fragment;
@@ -24,24 +24,23 @@ class Fragment;
* \brief This class defines the interfaces to a rpn expression.
*/
-class RpnExpr
-{
-public:
+class RpnExpr {
+ public:
typedef std::vector<ExprToken*> TokenQueue;
typedef TokenQueue::const_iterator const_iterator;
typedef TokenQueue::iterator iterator;
-private:
+ private:
friend class Chunk<RpnExpr, MCLD_SYMBOLS_PER_INPUT>;
RpnExpr();
-public:
+ public:
~RpnExpr();
const_iterator begin() const { return m_TokenQueue.begin(); }
- iterator begin() { return m_TokenQueue.begin(); }
- const_iterator end() const { return m_TokenQueue.end(); }
- iterator end() { return m_TokenQueue.end(); }
+ iterator begin() { return m_TokenQueue.begin(); }
+ const_iterator end() const { return m_TokenQueue.end(); }
+ iterator end() { return m_TokenQueue.end(); }
size_t size() const { return m_TokenQueue.size(); }
@@ -68,11 +67,10 @@ public:
// buildHelperExpr - build the helper expr: `fragment'
static RpnExpr* buildHelperExpr(Fragment& pFrag);
-private:
+ private:
TokenQueue m_TokenQueue;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_RPNEXPR_H_
diff --git a/include/mcld/Script/ScriptCommand.h b/include/mcld/Script/ScriptCommand.h
index d670b01..f8d3a6e 100644
--- a/include/mcld/Script/ScriptCommand.h
+++ b/include/mcld/Script/ScriptCommand.h
@@ -6,8 +6,8 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_COMMAND_H
-#define MCLD_SCRIPT_COMMAND_H
+#ifndef MCLD_SCRIPT_SCRIPTCOMMAND_H_
+#define MCLD_SCRIPT_SCRIPTCOMMAND_H_
namespace mcld {
@@ -16,29 +16,27 @@ class Module;
/** \class ScriptCommand
* \brief This class defines the interfaces to a script command.
*/
-class ScriptCommand
-{
-public:
+class ScriptCommand {
+ public:
enum Kind {
+ ASSERT,
+ ASSIGNMENT,
ENTRY,
- OUTPUT_FORMAT,
GROUP,
+ INPUT,
+ INPUT_SECT_DESC,
OUTPUT,
- SEARCH_DIR,
OUTPUT_ARCH,
- ASSERT,
- ASSIGNMENT,
- SECTIONS,
+ OUTPUT_FORMAT,
+ SEARCH_DIR,
OUTPUT_SECT_DESC,
- INPUT_SECT_DESC
+ SECTIONS
};
-protected:
- ScriptCommand(Kind pKind)
- : m_Kind(pKind)
- {}
+ protected:
+ explicit ScriptCommand(Kind pKind) : m_Kind(pKind) {}
-public:
+ public:
virtual ~ScriptCommand() = 0;
virtual void dump() const = 0;
@@ -47,11 +45,10 @@ public:
Kind getKind() const { return m_Kind; }
-private:
+ private:
Kind m_Kind;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_SCRIPTCOMMAND_H_
diff --git a/include/mcld/Script/ScriptFile.h b/include/mcld/Script/ScriptFile.h
index b54ba1f..dad2776 100644
--- a/include/mcld/Script/ScriptFile.h
+++ b/include/mcld/Script/ScriptFile.h
@@ -6,40 +6,42 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_SCRIPTFILE_H
-#define MCLD_SCRIPT_SCRIPTFILE_H
+#ifndef MCLD_SCRIPT_SCRIPTFILE_H_
+#define MCLD_SCRIPT_SCRIPTFILE_H_
+
+#include "mcld/Script/Assignment.h"
+#include "mcld/Script/InputSectDesc.h"
+#include "mcld/Script/OutputSectDesc.h"
-#include <mcld/Script/Assignment.h>
-#include <mcld/Script/OutputSectDesc.h>
-#include <mcld/Script/InputSectDesc.h>
-#include <vector>
#include <string>
+#include <vector>
-namespace mcld
-{
+namespace mcld {
-class ScriptCommand;
+class ArchiveReader;
+class DynObjReader;
+class GroupReader;
class Input;
-class InputTree;
class InputBuilder;
-class GroupReader;
+class InputTree;
class LinkerConfig;
-class RpnExpr;
-class StringList;
class Module;
+class ObjectReader;
+class ScriptCommand;
+class StringList;
+class RpnExpr;
/** \class ScriptFile
* \brief This class defines the interfaces to a linker script file.
*/
-class ScriptFile
-{
-public:
+class ScriptFile {
+ public:
enum Kind {
- LDScript, // -T
- Expression, // --defsym
- VersionScript, // --version-script
- DynamicList, // --dynamic-list
+ LDScript, // -T
+ Expression, // --defsym
+ VersionScript, // --version-script
+ DynamicList, // --dynamic-list
Unknown
};
@@ -49,32 +51,32 @@ public:
typedef CommandQueue::const_reference const_reference;
typedef CommandQueue::reference reference;
-public:
+ public:
ScriptFile(Kind pKind, Input& pInput, InputBuilder& pBuilder);
~ScriptFile();
- const_iterator begin() const { return m_CommandQueue.begin(); }
- iterator begin() { return m_CommandQueue.begin(); }
- const_iterator end() const { return m_CommandQueue.end(); }
- iterator end() { return m_CommandQueue.end(); }
+ const_iterator begin() const { return m_CommandQueue.begin(); }
+ iterator begin() { return m_CommandQueue.begin(); }
+ const_iterator end() const { return m_CommandQueue.end(); }
+ iterator end() { return m_CommandQueue.end(); }
const_reference front() const { return m_CommandQueue.front(); }
- reference front() { return m_CommandQueue.front(); }
- const_reference back() const { return m_CommandQueue.back(); }
- reference back() { return m_CommandQueue.back(); }
+ reference front() { return m_CommandQueue.front(); }
+ const_reference back() const { return m_CommandQueue.back(); }
+ reference back() { return m_CommandQueue.back(); }
const Input& input() const { return m_Input; }
- Input& input() { return m_Input; }
+ Input& input() { return m_Input; }
size_t size() const { return m_CommandQueue.size(); }
Kind getKind() const { return m_Kind; }
const InputTree& inputs() const { return *m_pInputTree; }
- InputTree& inputs() { return *m_pInputTree; }
+ InputTree& inputs() { return *m_pInputTree; }
const std::string& name() const { return m_Name; }
- std::string& name() { return m_Name; }
+ std::string& name() { return m_Name; }
void dump() const;
void activate(Module& pModule);
@@ -89,6 +91,14 @@ public:
const std::string& pBig,
const std::string& pLittle);
+ /// INPUT(file, file, ...)
+ /// INPUT(file file ...)
+ void addInputCmd(StringList& pStringList,
+ ObjectReader& pObjectReader,
+ ArchiveReader& pArchiveReader,
+ DynObjReader& pDynObjReader,
+ const LinkerConfig& pConfig);
+
/// GROUP(file, file, ...)
/// GROUP(file file ...)
void addGroupCmd(StringList& pStringList,
@@ -128,11 +138,11 @@ public:
RpnExpr* createRpnExpr();
const RpnExpr* getCurrentRpnExpr() const { return m_pRpnExpr; }
- RpnExpr* getCurrentRpnExpr() { return m_pRpnExpr; }
+ RpnExpr* getCurrentRpnExpr() { return m_pRpnExpr; }
StringList* createStringList();
const StringList* getCurrentStringList() const { return m_pStringList; }
- StringList* getCurrentStringList() { return m_pStringList; }
+ StringList* getCurrentStringList() { return m_pStringList; }
void setAsNeeded(bool pEnable = true);
bool asNeeded() const { return m_bAsNeeded; }
@@ -141,7 +151,7 @@ public:
static void clearParserStrPool();
-private:
+ private:
Kind m_Kind;
Input& m_Input;
std::string m_Name;
@@ -156,7 +166,6 @@ private:
bool m_bAsNeeded;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_SCRIPTFILE_H_
diff --git a/include/mcld/Script/ScriptReader.h b/include/mcld/Script/ScriptReader.h
index a3f91c4..a04b89f 100644
--- a/include/mcld/Script/ScriptReader.h
+++ b/include/mcld/Script/ScriptReader.h
@@ -6,25 +6,30 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_SCRIPTREADER_H
-#define MCLD_SCRIPT_SCRIPTREADER_H
+#ifndef MCLD_SCRIPT_SCRIPTREADER_H_
+#define MCLD_SCRIPT_SCRIPTREADER_H_
-#include <mcld/LD/LDReader.h>
+#include "mcld/LD/LDReader.h"
namespace mcld {
-class Module;
-class ScriptFile;
-class Input;
+class ArchiveReader;
+class DynObjReader;
class GroupReader;
+class Input;
class LinkerConfig;
class LinkerScript;
+class Module;
+class ObjectReader;
+class ScriptFile;
class TargetLDBackend;
-class ScriptReader : public LDReader
-{
-public:
- ScriptReader(GroupReader& pGroupReader);
+class ScriptReader : public LDReader {
+ public:
+ ScriptReader(ObjectReader& pObjectReader,
+ ArchiveReader& pArchiveReader,
+ DynObjReader& pDynObjReader,
+ GroupReader& pGroupReader);
~ScriptReader();
@@ -32,15 +37,15 @@ public:
bool readScript(const LinkerConfig& pConfig, ScriptFile& pScriptFile);
/// isMyFormat
- bool isMyFormat(Input& pInput, bool &pContinue) const;
+ bool isMyFormat(Input& pInput, bool& pContinue) const;
- GroupReader& getGroupReader() { return m_GroupReader; }
-
-private:
+ private:
+ ObjectReader& m_ObjectReader;
+ ArchiveReader& m_ArchiveReader;
+ DynObjReader& m_DynObjReader;
GroupReader& m_GroupReader;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_SCRIPTREADER_H_
diff --git a/include/mcld/Script/ScriptScanner.h b/include/mcld/Script/ScriptScanner.h
index 4cab6ec..4a572a1 100644
--- a/include/mcld/Script/ScriptScanner.h
+++ b/include/mcld/Script/ScriptScanner.h
@@ -6,22 +6,22 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_SCRIPTSCANNER_H
-#define MCLD_SCRIPT_SCRIPTSCANNER_H
+#ifndef MCLD_SCRIPT_SCRIPTSCANNER_H_
+#define MCLD_SCRIPT_SCRIPTSCANNER_H_
#ifndef __FLEX_LEXER_H
#include "FlexLexer.h"
#endif
#ifndef YY_DECL
-#define YY_DECL \
- mcld::ScriptParser::token_type \
- mcld::ScriptScanner::lex(mcld::ScriptParser::semantic_type* yylval, \
- mcld::ScriptParser::location_type* yylloc, \
- const mcld::ScriptFile& pScriptFile)
+#define YY_DECL \
+ mcld::ScriptParser::token_type mcld::ScriptScanner::lex( \
+ mcld::ScriptParser::semantic_type* yylval, \
+ mcld::ScriptParser::location_type* yylloc, \
+ const mcld::ScriptFile& pScriptFile)
#endif
-#include <mcld/Script/ScriptFile.h>
+#include "mcld/Script/ScriptFile.h"
#include "ScriptParser.h"
#include <stack>
@@ -30,10 +30,9 @@ namespace mcld {
/** \class ScriptScanner
*
*/
-class ScriptScanner : public yyFlexLexer
-{
-public:
- ScriptScanner(std::istream* yyin = NULL, std::ostream* yyout = NULL);
+class ScriptScanner : public yyFlexLexer {
+ public:
+ explicit ScriptScanner(std::istream* yyin = NULL, std::ostream* yyout = NULL);
virtual ~ScriptScanner();
@@ -45,15 +44,14 @@ public:
void popLexState();
-private:
+ private:
void enterComments(ScriptParser::location_type& pLocation);
-private:
+ private:
ScriptFile::Kind m_Kind;
std::stack<ScriptFile::Kind> m_StateStack;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_SCRIPTSCANNER_H_
diff --git a/include/mcld/Script/SearchDirCmd.h b/include/mcld/Script/SearchDirCmd.h
index 3358b6e..ceb584b 100644
--- a/include/mcld/Script/SearchDirCmd.h
+++ b/include/mcld/Script/SearchDirCmd.h
@@ -6,14 +6,14 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_SEARCHDIRCMD_H
-#define MCLD_SCRIPT_SEARCHDIRCMD_H
+#ifndef MCLD_SCRIPT_SEARCHDIRCMD_H_
+#define MCLD_SCRIPT_SEARCHDIRCMD_H_
+
+#include "mcld/Script/ScriptCommand.h"
-#include <mcld/Script/ScriptCommand.h>
#include <string>
-namespace mcld
-{
+namespace mcld {
class Module;
@@ -21,26 +21,23 @@ class Module;
* \brief This class defines the interfaces to SEARCH_DIR command.
*/
-class SearchDirCmd : public ScriptCommand
-{
-public:
- SearchDirCmd(const std::string& pPath);
+class SearchDirCmd : public ScriptCommand {
+ public:
+ explicit SearchDirCmd(const std::string& pPath);
~SearchDirCmd();
void dump() const;
void activate(Module& pModule);
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::SEARCH_DIR;
}
-private:
+ private:
std::string m_Path;
};
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_SEARCHDIRCMD_H_
diff --git a/include/mcld/Script/SectionsCmd.h b/include/mcld/Script/SectionsCmd.h
index f64a841..93a55c2 100644
--- a/include/mcld/Script/SectionsCmd.h
+++ b/include/mcld/Script/SectionsCmd.h
@@ -6,15 +6,16 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_SECTIONSCMD_H
-#define MCLD_SCRIPT_SECTIONSCMD_H
+#ifndef MCLD_SCRIPT_SECTIONSCMD_H_
+#define MCLD_SCRIPT_SECTIONSCMD_H_
+
+#include "mcld/Script/ScriptCommand.h"
-#include <mcld/Script/ScriptCommand.h>
#include <llvm/Support/DataTypes.h>
+
#include <vector>
-namespace mcld
-{
+namespace mcld {
class Module;
@@ -22,28 +23,27 @@ class Module;
* \brief This class defines the interfaces to SECTIONS command.
*/
-class SectionsCmd : public ScriptCommand
-{
-public:
+class SectionsCmd : public ScriptCommand {
+ public:
typedef std::vector<ScriptCommand*> SectionCommands;
typedef SectionCommands::const_iterator const_iterator;
typedef SectionCommands::iterator iterator;
typedef SectionCommands::const_reference const_reference;
typedef SectionCommands::reference reference;
-public:
+ public:
SectionsCmd();
~SectionsCmd();
- const_iterator begin() const { return m_SectionCommands.begin(); }
- iterator begin() { return m_SectionCommands.begin(); }
- const_iterator end() const { return m_SectionCommands.end(); }
- iterator end() { return m_SectionCommands.end(); }
+ const_iterator begin() const { return m_SectionCommands.begin(); }
+ iterator begin() { return m_SectionCommands.begin(); }
+ const_iterator end() const { return m_SectionCommands.end(); }
+ iterator end() { return m_SectionCommands.end(); }
const_reference front() const { return m_SectionCommands.front(); }
- reference front() { return m_SectionCommands.front(); }
- const_reference back() const { return m_SectionCommands.back(); }
- reference back() { return m_SectionCommands.back(); }
+ reference front() { return m_SectionCommands.front(); }
+ const_reference back() const { return m_SectionCommands.back(); }
+ reference back() { return m_SectionCommands.back(); }
size_t size() const { return m_SectionCommands.size(); }
@@ -51,8 +51,7 @@ public:
void dump() const;
- static bool classof(const ScriptCommand* pCmd)
- {
+ static bool classof(const ScriptCommand* pCmd) {
return pCmd->getKind() == ScriptCommand::SECTIONS;
}
@@ -60,10 +59,10 @@ public:
void push_back(ScriptCommand* pCommand);
-private:
+ private:
SectionCommands m_SectionCommands;
};
-} // namespace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_SECTIONSCMD_H_
diff --git a/include/mcld/Script/StrToken.h b/include/mcld/Script/StrToken.h
index 08aef06..2800367 100644
--- a/include/mcld/Script/StrToken.h
+++ b/include/mcld/Script/StrToken.h
@@ -6,46 +6,40 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_STRTOKEN_H
-#define MCLD_SCRIPT_STRTOKEN_H
+#ifndef MCLD_SCRIPT_STRTOKEN_H_
+#define MCLD_SCRIPT_STRTOKEN_H_
+
+#include "mcld/Config/Config.h"
+#include "mcld/Support/Allocators.h"
-#include <mcld/Support/Allocators.h>
-#include <mcld/Config/Config.h>
#include <string>
-namespace mcld
-{
+namespace mcld {
/** \class StrToken
* \brief This class defines the interfaces to a element in EXCLUDE_FILE list
* or in Output Section Phdr, or be a base class of other str token.
*/
-class StrToken
-{
-public:
- enum Kind {
- Unknown,
- String,
- Input,
- Wildcard
- };
+class StrToken {
+ public:
+ enum Kind { Unknown, String, Input, Wildcard };
-private:
+ private:
friend class Chunk<StrToken, MCLD_SYMBOLS_PER_INPUT>;
-protected:
+
+ protected:
StrToken();
StrToken(Kind pKind, const std::string& pString);
-public:
+ public:
virtual ~StrToken();
Kind kind() const { return m_Kind; }
const std::string& name() const { return m_Name; }
- static bool classof(const StrToken* pToken)
- {
+ static bool classof(const StrToken* pToken) {
return pToken->kind() == StrToken::String;
}
@@ -54,11 +48,11 @@ public:
static void destroy(StrToken*& pToken);
static void clear();
-private:
+ private:
Kind m_Kind;
std::string m_Name;
};
-} // namepsace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_STRTOKEN_H_
diff --git a/include/mcld/Script/StringList.h b/include/mcld/Script/StringList.h
index 76255d0..7c938b1 100644
--- a/include/mcld/Script/StringList.h
+++ b/include/mcld/Script/StringList.h
@@ -6,15 +6,15 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_STRINGLIST_H
-#define MCLD_SCRIPT_STRINGLIST_H
+#ifndef MCLD_SCRIPT_STRINGLIST_H_
+#define MCLD_SCRIPT_STRINGLIST_H_
+
+#include "mcld/Config/Config.h"
+#include "mcld/Support/Allocators.h"
-#include <mcld/Config/Config.h>
-#include <mcld/Support/Allocators.h>
#include <vector>
-namespace mcld
-{
+namespace mcld {
class StrToken;
@@ -22,31 +22,30 @@ class StrToken;
* \brief This class defines the interfaces to StringList.
*/
-class StringList
-{
-public:
+class StringList {
+ public:
typedef std::vector<StrToken*> Tokens;
typedef Tokens::const_iterator const_iterator;
typedef Tokens::iterator iterator;
typedef Tokens::const_reference const_reference;
typedef Tokens::reference reference;
-private:
+ private:
friend class Chunk<StringList, MCLD_SYMBOLS_PER_INPUT>;
StringList();
-public:
+ public:
~StringList();
- const_iterator begin() const { return m_Tokens.begin(); }
- iterator begin() { return m_Tokens.begin(); }
- const_iterator end() const { return m_Tokens.end(); }
- iterator end() { return m_Tokens.end(); }
+ const_iterator begin() const { return m_Tokens.begin(); }
+ iterator begin() { return m_Tokens.begin(); }
+ const_iterator end() const { return m_Tokens.end(); }
+ iterator end() { return m_Tokens.end(); }
const_reference front() const { return m_Tokens.front(); }
- reference front() { return m_Tokens.front(); }
- const_reference back() const { return m_Tokens.back(); }
- reference back() { return m_Tokens.back(); }
+ reference front() { return m_Tokens.front(); }
+ const_reference back() const { return m_Tokens.back(); }
+ reference back() { return m_Tokens.back(); }
bool empty() const { return m_Tokens.empty(); }
@@ -59,11 +58,10 @@ public:
static void destroy(StringList*& pStringList);
static void clear();
-private:
+ private:
Tokens m_Tokens;
};
-} // namepsace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_STRINGLIST_H_
diff --git a/include/mcld/Script/TernaryOp.h b/include/mcld/Script/TernaryOp.h
index bf47bca..a837c14 100644
--- a/include/mcld/Script/TernaryOp.h
+++ b/include/mcld/Script/TernaryOp.h
@@ -6,63 +6,58 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_TERNARYOP_H
-#define MCLD_SCRIPT_TERNARYOP_H
+#ifndef MCLD_SCRIPT_TERNARYOP_H_
+#define MCLD_SCRIPT_TERNARYOP_H_
+
+#include "mcld/Script/Operator.h"
-#include <mcld/Script/Operator.h>
#include <cstddef>
-namespace mcld
-{
+namespace mcld {
-class Operand;
class IntOperand;
class Module;
+class Operand;
class TargetLDBackend;
/** \class TernaryOP
* \brief This class defines the interfaces to an binary operator token.
*/
-template<Operator::Type TYPE>
-class TernaryOp : public Operator
-{
-private:
+template <Operator::Type TYPE>
+class TernaryOp : public Operator {
+ private:
friend class Operator;
- TernaryOp()
- : Operator(Operator::TERNARY, TYPE)
- {
+ TernaryOp() : Operator(Operator::TERNARY, TYPE) {
m_pOperand[0] = m_pOperand[1] = m_pOperand[2] = NULL;
}
-public:
- ~TernaryOp()
- {}
+ public:
+ ~TernaryOp() {}
IntOperand* eval(const Module& pModule, const TargetLDBackend& pBackend);
- void appendOperand(Operand* pOperand)
- {
+ void appendOperand(Operand* pOperand) {
m_pOperand[m_Size++] = pOperand;
if (m_Size == 3)
m_Size = 0;
}
-private:
+ private:
size_t m_Size;
Operand* m_pOperand[3];
};
-template<>
+template <>
IntOperand* TernaryOp<Operator::TERNARY_IF>::eval(const Module&,
const TargetLDBackend&);
-template<>
-IntOperand*
-TernaryOp<Operator::DATA_SEGMENT_ALIGN>::eval(const Module&,
- const TargetLDBackend&);
+template <>
+IntOperand* TernaryOp<Operator::DATA_SEGMENT_ALIGN>::eval(
+ const Module&,
+ const TargetLDBackend&);
-} // namespace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_TERNARYOP_H_
diff --git a/include/mcld/Script/UnaryOp.h b/include/mcld/Script/UnaryOp.h
index b7f69c6..922e192 100644
--- a/include/mcld/Script/UnaryOp.h
+++ b/include/mcld/Script/UnaryOp.h
@@ -6,94 +6,86 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_UNARYOP_H
-#define MCLD_SCRIPT_UNARYOP_H
+#ifndef MCLD_SCRIPT_UNARYOP_H_
+#define MCLD_SCRIPT_UNARYOP_H_
+
+#include "mcld/Script/Operator.h"
-#include <mcld/Script/Operator.h>
#include <cstddef>
-namespace mcld
-{
+namespace mcld {
-class Operand;
class IntOperand;
class Module;
+class Operand;
class TargetLDBackend;
/** \class UnaryOp
* \brief This class defines the interfaces to an unary operator token.
*/
-template<Operator::Type TYPE>
-class UnaryOp : public Operator
-{
-private:
+template <Operator::Type TYPE>
+class UnaryOp : public Operator {
+ private:
friend class Operator;
- UnaryOp()
- : Operator(Operator::UNARY, TYPE), m_pOperand(NULL)
- {}
+ UnaryOp() : Operator(Operator::UNARY, TYPE), m_pOperand(NULL) {}
-public:
- ~UnaryOp()
- {}
+ public:
+ ~UnaryOp() {}
IntOperand* eval(const Module& pModule, const TargetLDBackend& pBackend);
- void appendOperand(Operand* pOperand)
- {
- m_pOperand = pOperand;
- }
+ void appendOperand(Operand* pOperand) { m_pOperand = pOperand; }
-private:
+ private:
Operand* m_pOperand;
};
-template<>
+template <>
IntOperand* UnaryOp<Operator::UNARY_PLUS>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::UNARY_MINUS>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::LOGICAL_NOT>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::BITWISE_NOT>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::ABSOLUTE>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::ADDR>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::ALIGNOF>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::DATA_SEGMENT_END>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::DEFINED>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::LENGTH>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::LOADADDR>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::NEXT>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::ORIGIN>::eval(const Module&,
const TargetLDBackend&);
-template<>
+template <>
IntOperand* UnaryOp<Operator::SIZEOF>::eval(const Module&,
const TargetLDBackend&);
-} // namespace of mcld
-
-#endif
+} // namespace mcld
+#endif // MCLD_SCRIPT_UNARYOP_H_
diff --git a/include/mcld/Script/WildcardPattern.h b/include/mcld/Script/WildcardPattern.h
index fe81ee3..75b1405 100644
--- a/include/mcld/Script/WildcardPattern.h
+++ b/include/mcld/Script/WildcardPattern.h
@@ -6,24 +6,23 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-#ifndef MCLD_SCRIPT_WILDCARDPATTERN_H
-#define MCLD_SCRIPT_WILDCARDPATTERN_H
+#ifndef MCLD_SCRIPT_WILDCARDPATTERN_H_
+#define MCLD_SCRIPT_WILDCARDPATTERN_H_
+
+#include "mcld/Config/Config.h"
+#include "mcld/Script/StrToken.h"
+#include "mcld/Support/Allocators.h"
-#include <mcld/Script/StrToken.h>
-#include <mcld/Support/Allocators.h>
-#include <mcld/Config/Config.h>
#include <llvm/ADT/StringRef.h>
-namespace mcld
-{
+namespace mcld {
/** \class WildcardPattern
* \brief This class defines the interfaces to Input Section Wildcard Patterns
*/
-class WildcardPattern : public StrToken
-{
-public:
+class WildcardPattern : public StrToken {
+ public:
enum SortPolicy {
SORT_NONE,
SORT_BY_NAME,
@@ -33,12 +32,12 @@ public:
SORT_BY_INIT_PRIORITY
};
-private:
+ private:
friend class Chunk<WildcardPattern, MCLD_SYMBOLS_PER_INPUT>;
WildcardPattern();
WildcardPattern(const std::string& pPattern, SortPolicy pPolicy);
-public:
+ public:
~WildcardPattern();
SortPolicy sortPolicy() const { return m_SortPolicy; }
@@ -47,8 +46,7 @@ public:
llvm::StringRef prefix() const;
- static bool classof(const StrToken* pToken)
- {
+ static bool classof(const StrToken* pToken) {
return pToken->kind() == StrToken::Wildcard;
}
@@ -58,11 +56,11 @@ public:
static void destroy(WildcardPattern*& pToken);
static void clear();
-private:
+ private:
SortPolicy m_SortPolicy;
bool m_bIsPrefix;
};
-} // namepsace of mcld
+} // namespace mcld
-#endif
+#endif // MCLD_SCRIPT_WILDCARDPATTERN_H_