forked from Imagelibrary/binutils-gdb
2010-04-09 Doug Kwan <dougkwan@google.com>
* layout.cc (Layout::choose_output_section): Handle script section types. (Layout::make_output_section_for_script): Add section type parameter. Handle script section types. * layout.h (Layout::make_output_section_for_script): Add section type parameter. * output.cc (Output_section::Output_section): Initialize data member is_noload_. (Output_section::do_reset_address_and_file_offset): Do not set address to 0 if section is a NOLOAD section. * output.h (Output_section::is_noload): New method. (Output_section::set_is_noload): Ditto. (Output_section::is_noload_): New data member. * script-c.h (Script_section_type): New enum type. (struct Parser_output_section_header): Add new file section_type. * script-sections.cc (Sections_element::output_section_name): Add parameter for returning script section type. (Output_section_definition::output_section_name): Ditto. (Output_section_definition::section_type)P; New method. (Output_section_definiton::script_section_type_name): Ditto. (Output_section_definition::script_section_type_): New data member. (Output_section_definition::Output_section_definition): Initialize data member Output_section_definition::script_section_type_. (Output_section_definition::create_sections): Pass script section type to Layout::make_output_section_for_script. (Output_section_definition::output_section_name): Return script section type to caller. (Output_section_definition::set_section_address): Do not advance dot value and load address if section type is NOLOAD. Set address of NOLOAD sections regardless of section flags. (Output_section_definition::print): Print section type if it is not SCRIPT_SECTION_TYPE_NONE. (Output_section_definition::section_type): New method. (Output_section_definition::script_section_type_name): Ditto. (Script_sections::output_section_name): Add new parameter PSECTION_TYPE for returning script section type. Pass it to section elements. Handle discard sections. (Sort_output_sections::operator()): Handle NOLOAD sections. * script-sections.h (Script_sections::Section_type): New enum type. (Script_sections::output_section_name): Add a new parameter for returning script section type. * script.cc (script_keyword_parsecodes): Add keywords COPY, DSECT, INFO and NOLOAD. * yyscript.y (union): Add new field SECTION_TYPE. (COPY, DSECT, INFO, NOLOAD): New tokens. (opt_address_and_section_type): Change type to output_section_header. (section_type): New non-terminal (section_header): Handle section type. (opt_address_and_section_type): Return section type value.
This commit is contained in:
@@ -77,6 +77,7 @@
|
||||
struct Version_dependency_list* deplist;
|
||||
struct Version_expression_list* versyms;
|
||||
struct Version_tree* versnode;
|
||||
enum Script_section_type section_type;
|
||||
}
|
||||
|
||||
/* Operators, including a precedence table for expressions. */
|
||||
@@ -121,11 +122,13 @@
|
||||
%token BYTE
|
||||
%token CONSTANT
|
||||
%token CONSTRUCTORS
|
||||
%token COPY
|
||||
%token CREATE_OBJECT_SYMBOLS
|
||||
%token DATA_SEGMENT_ALIGN
|
||||
%token DATA_SEGMENT_END
|
||||
%token DATA_SEGMENT_RELRO_END
|
||||
%token DEFINED
|
||||
%token DSECT
|
||||
%token ENTRY
|
||||
%token EXCLUDE_FILE
|
||||
%token EXTERN
|
||||
@@ -137,6 +140,7 @@
|
||||
%token HLL
|
||||
%token INCLUDE
|
||||
%token INHIBIT_COMMON_ALLOCATION
|
||||
%token INFO
|
||||
%token INPUT
|
||||
%token KEEP
|
||||
%token LENGTH /* LENGTH, l, len */
|
||||
@@ -150,6 +154,7 @@
|
||||
%token NEXT
|
||||
%token NOCROSSREFS
|
||||
%token NOFLOAT
|
||||
%token NOLOAD
|
||||
%token ONLY_IF_RO
|
||||
%token ONLY_IF_RW
|
||||
%token ORIGIN /* ORIGIN, o, org */
|
||||
@@ -197,9 +202,10 @@
|
||||
|
||||
/* Non-terminal types, where needed. */
|
||||
|
||||
%type <expr> parse_exp exp opt_address_and_section_type
|
||||
%type <expr> parse_exp exp
|
||||
%type <expr> opt_at opt_align opt_subalign opt_fill
|
||||
%type <output_section_header> section_header
|
||||
%type <output_section_header> section_header opt_address_and_section_type
|
||||
%type <section_type> section_type
|
||||
%type <output_section_trailer> section_trailer
|
||||
%type <constraint> opt_constraint
|
||||
%type <string_list> opt_phdr
|
||||
@@ -343,7 +349,8 @@ section_header:
|
||||
{ script_pop_lex_mode(closure); }
|
||||
opt_constraint
|
||||
{
|
||||
$$.address = $2;
|
||||
$$.address = $2.address;
|
||||
$$.section_type = $2.section_type;
|
||||
$$.load_address = $3;
|
||||
$$.align = $4;
|
||||
$$.subalign = $5;
|
||||
@@ -356,18 +363,61 @@ section_header:
|
||||
'(' in section_header. */
|
||||
|
||||
opt_address_and_section_type:
|
||||
':'
|
||||
{ $$ = NULL; }
|
||||
| '(' ')' ':'
|
||||
{ $$ = NULL; }
|
||||
| exp ':'
|
||||
{ $$ = $1; }
|
||||
| exp '(' ')' ':'
|
||||
{ $$ = $1; }
|
||||
| exp '(' string ')' ':'
|
||||
':'
|
||||
{
|
||||
yyerror(closure, "section types are not supported");
|
||||
$$ = $1;
|
||||
$$.address = NULL;
|
||||
$$.section_type = SCRIPT_SECTION_TYPE_NONE;
|
||||
}
|
||||
| '(' ')' ':'
|
||||
{
|
||||
$$.address = NULL;
|
||||
$$.section_type = SCRIPT_SECTION_TYPE_NONE;
|
||||
}
|
||||
| exp ':'
|
||||
{
|
||||
$$.address = $1;
|
||||
$$.section_type = SCRIPT_SECTION_TYPE_NONE;
|
||||
}
|
||||
| exp '(' ')' ':'
|
||||
{
|
||||
$$.address = $1;
|
||||
$$.section_type = SCRIPT_SECTION_TYPE_NONE;
|
||||
}
|
||||
| '(' section_type ')' ':'
|
||||
{
|
||||
$$.address = NULL;
|
||||
$$.section_type = $2;
|
||||
}
|
||||
| exp '(' section_type ')' ':'
|
||||
{
|
||||
$$.address = $1;
|
||||
$$.section_type = $3;
|
||||
}
|
||||
;
|
||||
|
||||
/* We only support NOLOAD. */
|
||||
section_type:
|
||||
NOLOAD
|
||||
{ $$ = SCRIPT_SECTION_TYPE_NOLOAD; }
|
||||
| DSECT
|
||||
{
|
||||
yyerror(closure, "DSECT section type is unsupported");
|
||||
$$ = SCRIPT_SECTION_TYPE_DSECT;
|
||||
}
|
||||
| COPY
|
||||
{
|
||||
yyerror(closure, "COPY section type is unsupported");
|
||||
$$ = SCRIPT_SECTION_TYPE_COPY;
|
||||
}
|
||||
| INFO
|
||||
{
|
||||
yyerror(closure, "INFO section type is unsupported");
|
||||
$$ = SCRIPT_SECTION_TYPE_INFO;
|
||||
}
|
||||
| OVERLAY
|
||||
{
|
||||
yyerror(closure, "OVERLAY section type is unsupported");
|
||||
$$ = SCRIPT_SECTION_TYPE_OVERLAY;
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user