-/* A YACC grammer to parse a superset of the AT&T linker scripting languaue.
- Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 1999
- Free Software Foundation, Inc.
+/* A YACC grammar to parse a superset of the AT&T linker scripting language.
+ Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+ 2001, 2002 Free Software Foundation, Inc.
Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
This file is part of GNU ld.
#include "ldexp.h"
#include "ldver.h"
#include "ldlang.h"
-#include "ldemul.h"
#include "ldfile.h"
+#include "ldemul.h"
#include "ldmisc.h"
#include "ldmain.h"
#include "mri.h"
lang_memory_region_type *region;
-struct wildcard_spec current_file;
-boolean ldgram_want_filename = true;
-boolean had_script = false;
-boolean force_make_executable = false;
+bfd_boolean ldgram_want_filename = TRUE;
+FILE *saved_script_handle = NULL;
+bfd_boolean force_make_executable = FALSE;
-boolean ldgram_in_script = false;
-boolean ldgram_had_equals = false;
-boolean ldgram_had_keep = false;
+bfd_boolean ldgram_in_script = FALSE;
+bfd_boolean ldgram_had_equals = FALSE;
+bfd_boolean ldgram_had_keep = FALSE;
char *ldgram_vers_current_lang = NULL;
#define ERROR_NAME_MAX 20
%}
%union {
bfd_vma integer;
+ struct big_int
+ {
+ bfd_vma integer;
+ char *str;
+ } bigint;
+ fill_type *fill;
char *name;
const char *cname;
struct wildcard_spec wildcard;
+ struct wildcard_list *wildcard_list;
+ struct name_list *name_list;
int token;
union etree_union *etree;
struct phdr_info
{
- boolean filehdr;
- boolean phdrs;
+ bfd_boolean filehdr;
+ bfd_boolean phdrs;
union etree_union *at;
union etree_union *flags;
} phdr;
%type <etree> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val
%type <etree> opt_exp_without_type
-%type <integer> fill_opt
+%type <fill> fill_opt fill_exp
+%type <name_list> exclude_name_list
+%type <wildcard_list> file_NAME_list
%type <name> memspec_opt casesymlist
+%type <name> memspec_at_opt
%type <cname> wildcard_name
%type <wildcard> wildcard_spec
-%token <integer> INT
+%token <bigint> INT
%token <name> NAME LNAME
%type <integer> length
%type <phdr> phdr_qualifiers
%token END
%left <token> '('
%token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE
-%token SECTIONS PHDRS SORT
+%token SECTIONS PHDRS SORT DATA_SEGMENT_ALIGN DATA_SEGMENT_END
%token '{' '}'
%token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
+%token INHIBIT_COMMON_ALLOCATION
%token SIZEOF_HEADERS
%token INCLUDE
%token MEMORY DEFSYMEND
ldlex_popstate();
lang_add_assignment(exp_assop($3,$2,$4));
}
+ ;
/* SYNTAX WITHIN AN MRI SCRIPT FILE */
mri_script_file:
| ALIAS NAME ',' NAME
{ mri_alias($2,$4,0);}
| ALIAS NAME ',' INT
- { mri_alias($2,0,(int) $4);}
+ { mri_alias ($2, 0, (int) $4.integer); }
| BASE exp
{ mri_base($2); }
- | TRUNCATE INT
- { mri_truncate((unsigned int) $2); }
+ | TRUNCATE INT
+ { mri_truncate ((unsigned int) $2.integer); }
| CASE casesymlist
| EXTERN extern_name_list
| INCLUDE filename
- { ldfile_open_command_file ($2); } mri_script_lines END
+ { ldlex_script (); ldfile_open_command_file($2); }
+ mri_script_lines END
+ { ldlex_popstate (); }
| START NAME
- { lang_add_entry ($2, false); }
+ { lang_add_entry ($2, FALSE); }
|
;
| TARGET_K '(' NAME ')'
{ lang_add_target($3); }
| SEARCH_DIR '(' filename ')'
- { ldfile_add_library_path ($3, false); }
+ { ldfile_add_library_path ($3, FALSE); }
| OUTPUT '(' filename ')'
{ lang_add_output($3, 1); }
| OUTPUT_FORMAT '(' NAME ')'
| OUTPUT_ARCH '(' NAME ')'
{ ldfile_set_output_arch($3); }
| FORCE_COMMON_ALLOCATION
- { command_line.force_common_definition = true ; }
+ { command_line.force_common_definition = TRUE ; }
+ | INHIBIT_COMMON_ALLOCATION
+ { command_line.inhibit_common_definition = TRUE ; }
| INPUT '(' input_list ')'
| GROUP
{ lang_enter_group (); }
| MAP '(' filename ')'
{ lang_add_map($3); }
| INCLUDE filename
- { ldfile_open_command_file($2); } ifile_list END
+ { ldlex_script (); ldfile_open_command_file($2); }
+ ifile_list END
+ { ldlex_popstate (); }
| NOCROSSREFS '(' nocrossref_list ')'
{
lang_add_nocrossref ($3);
statement_anywhere:
ENTRY '(' NAME ')'
- { lang_add_entry ($3, false); }
+ { lang_add_entry ($3, FALSE); }
| assignment end
;
wildcard_name
{
$$.name = $1;
- $$.sorted = false;
- $$.exclude_name = NULL;
+ $$.sorted = FALSE;
+ $$.exclude_name_list = NULL;
}
- | EXCLUDE_FILE '(' wildcard_name ')' wildcard_name
+ | EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
{
$$.name = $5;
- $$.sorted = false;
- $$.exclude_name = $3;
+ $$.sorted = FALSE;
+ $$.exclude_name_list = $3;
}
| SORT '(' wildcard_name ')'
{
$$.name = $3;
- $$.sorted = true;
- $$.exclude_name = NULL;
+ $$.sorted = TRUE;
+ $$.exclude_name_list = NULL;
}
- | SORT '(' EXCLUDE_FILE '(' wildcard_name ')' wildcard_name ')'
+ | SORT '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
{
$$.name = $7;
- $$.sorted = true;
- $$.exclude_name = $5;
+ $$.sorted = TRUE;
+ $$.exclude_name_list = $5;
}
;
+exclude_name_list:
+ exclude_name_list wildcard_name
+ {
+ struct name_list *tmp;
+ tmp = (struct name_list *) xmalloc (sizeof *tmp);
+ tmp->name = $2;
+ tmp->next = $1;
+ $$ = tmp;
+ }
+ |
+ wildcard_name
+ {
+ struct name_list *tmp;
+ tmp = (struct name_list *) xmalloc (sizeof *tmp);
+ tmp->name = $1;
+ tmp->next = NULL;
+ $$ = tmp;
+ }
+ ;
file_NAME_list:
- wildcard_spec
+ file_NAME_list opt_comma wildcard_spec
{
- lang_add_wild ($1.name, $1.sorted,
- current_file.name,
- current_file.sorted,
- ldgram_had_keep, $1.exclude_name);
+ struct wildcard_list *tmp;
+ tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
+ tmp->next = $1;
+ tmp->spec = $3;
+ $$ = tmp;
}
- | file_NAME_list opt_comma wildcard_spec
+ |
+ wildcard_spec
{
- lang_add_wild ($3.name, $3.sorted,
- current_file.name,
- current_file.sorted,
- ldgram_had_keep, $3.exclude_name);
+ struct wildcard_list *tmp;
+ tmp = (struct wildcard_list *) xmalloc (sizeof *tmp);
+ tmp->next = NULL;
+ tmp->spec = $1;
+ $$ = tmp;
}
;
input_section_spec_no_keep:
NAME
{
- lang_add_wild (NULL, false, $1, false,
- ldgram_had_keep, NULL);
+ struct wildcard_spec tmp;
+ tmp.name = $1;
+ tmp.exclude_name_list = NULL;
+ tmp.sorted = FALSE;
+ lang_add_wild (&tmp, NULL, ldgram_had_keep);
}
- | '['
+ | '[' file_NAME_list ']'
{
- current_file.name = NULL;
- current_file.sorted = false;
+ lang_add_wild (NULL, $2, ldgram_had_keep);
}
- file_NAME_list ']'
- | wildcard_spec
+ | wildcard_spec '(' file_NAME_list ')'
{
- current_file = $1;
- /* '*' matches any file name. */
- if (strcmp (current_file.name, "*") == 0)
- current_file.name = NULL;
+ lang_add_wild (&$1, $3, ldgram_had_keep);
}
- '(' file_NAME_list ')'
;
input_section_spec:
input_section_spec_no_keep
| KEEP '('
- { ldgram_had_keep = true; }
+ { ldgram_had_keep = TRUE; }
input_section_spec_no_keep ')'
- { ldgram_had_keep = false; }
+ { ldgram_had_keep = FALSE; }
;
statement:
}
| SORT '(' CONSTRUCTORS ')'
{
- constructors_sorted = true;
+ constructors_sorted = TRUE;
lang_add_attribute (lang_constructors_statement_enum);
}
| input_section_spec
| length '(' mustbe_exp ')'
{
- lang_add_data((int) $1,$3);
+ lang_add_data ((int) $1, $3);
}
- | FILL '(' mustbe_exp ')'
+ | FILL '(' fill_exp ')'
{
- lang_add_fill
- (exp_get_value_int($3,
- 0,
- "fill value",
- lang_first_phase_enum));
+ lang_add_fill ($3);
}
;
{ $$ = $1; }
;
-fill_opt:
- '=' mustbe_exp
+fill_exp:
+ mustbe_exp
{
- $$ = exp_get_value_int($2,
- 0,
- "fill value",
- lang_first_phase_enum);
+ $$ = exp_get_fill ($1,
+ 0,
+ "fill value",
+ lang_first_phase_enum);
}
- | { $$ = 0; }
;
-
+fill_opt:
+ '=' fill_exp
+ { $$ = $2; }
+ | { $$ = (fill_type *) 0; }
+ ;
assign_op:
PLUSEQ
;
-memory_spec: NAME
- { region = lang_memory_region_lookup($1); }
+memory_spec: NAME
+ { region = lang_memory_region_lookup($1); }
attributes_opt ':'
origin_spec opt_comma length_spec
+ {}
+ ;
- ; origin_spec:
+origin_spec:
ORIGIN '=' mustbe_exp
{ region->current =
region->origin =
floating_point_support:
FLOAT
- { lang_float(true); }
+ { lang_float(TRUE); }
| NOFLOAT
- { lang_float(false); }
+ { lang_float(FALSE); }
;
nocrossref_list:
| DEFINED '(' NAME ')'
{ $$ = exp_nameop(DEFINED, $3); }
| INT
- { $$ = exp_intop($1); }
+ { $$ = exp_bigintop ($1.integer, $1.str); }
| SIZEOF_HEADERS
{ $$ = exp_nameop(SIZEOF_HEADERS,0); }
{ $$ = exp_unop(ABSOLUTE, $3); }
| ALIGN_K '(' exp ')'
{ $$ = exp_unop(ALIGN_K,$3); }
+ | DATA_SEGMENT_ALIGN '(' exp ',' exp ')'
+ { $$ = exp_binop (DATA_SEGMENT_ALIGN, $3, $5); }
+ | DATA_SEGMENT_END '(' exp ')'
+ { $$ = exp_unop(DATA_SEGMENT_END, $3); }
| BLOCK '(' exp ')'
{ $$ = exp_unop(ALIGN_K,$3); }
| NAME
;
+memspec_at_opt:
+ AT '>' NAME { $$ = $3; }
+ | { $$ = 0; }
+ ;
+
opt_at:
AT '(' exp ')' { $$ = $3; }
| { $$ = 0; }
}
statement_list_opt
'}' { ldlex_popstate (); ldlex_expression (); }
- memspec_opt phdr_opt fill_opt
+ memspec_opt memspec_at_opt phdr_opt fill_opt
{
ldlex_popstate ();
- lang_leave_output_section_statement ($13, $11, $12);
+ lang_leave_output_section_statement ($14, $11, $13, $12);
}
opt_comma
+ {}
| OVERLAY
{ ldlex_expression (); }
opt_exp_without_type opt_nocrossrefs opt_at
{ ldlex_popstate (); ldlex_script (); }
'{'
{
- lang_enter_overlay ($3, $5, (int) $4);
+ lang_enter_overlay ($3);
}
overlay_section
'}'
{ ldlex_popstate (); ldlex_expression (); }
- memspec_opt phdr_opt fill_opt
+ memspec_opt memspec_at_opt phdr_opt fill_opt
{
ldlex_popstate ();
- lang_leave_overlay ($14, $12, $13);
+ lang_leave_overlay ($5, (int) $4,
+ $15, $12, $14, $13);
}
opt_comma
| /* The GROUP case is just enough to support the gcc
n = ((struct lang_output_section_phdr_list *)
xmalloc (sizeof *n));
n->name = $3;
- n->used = false;
+ n->used = FALSE;
n->next = $1;
$$ = n;
}
{
$$ = $3;
if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
- $$.filehdr = true;
+ $$.filehdr = TRUE;
else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
- $$.phdrs = true;
+ $$.phdrs = TRUE;
else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
$$.flags = $2;
else
;
vers_node:
- VERS_TAG '{' vers_tag '}' ';'
+ '{' vers_tag '}' ';'
+ {
+ lang_register_vers_node (NULL, $2, NULL);
+ }
+ | VERS_TAG '{' vers_tag '}' ';'
{
lang_register_vers_node ($1, $3, NULL);
}
vers_defns:
VERS_IDENTIFIER
{
- $$ = lang_new_vers_regex (NULL, $1, ldgram_vers_current_lang);
+ $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang);
}
| vers_defns ';' VERS_IDENTIFIER
{
- $$ = lang_new_vers_regex ($1, $3, ldgram_vers_current_lang);
+ $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang);
}
| EXTERN NAME '{'
{
}
vers_defns '}'
{
+ $$ = $5;
ldgram_vers_current_lang = $<name>4;
}
;