* ldexp.c (exp_print_tree): Print function-like binary nodes as
[binutils-gdb.git] / ld / ldgram.y
index f481f54c7d4fa8d7a9f4f0dcce5fc4f7c66ce4d4..49d9ff1bc3a658a6cb7ccc0c75ccbaa89984a120 100644 (file)
@@ -1,6 +1,7 @@
 /* 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, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
 
    This file is part of the GNU Binutils.
@@ -131,6 +132,7 @@ static int error_index;
 %token SEGMENT_START
 %token INCLUDE
 %token MEMORY
+%token REGION_ALIAS
 %token NOLOAD DSECT COPY INFO OVERLAY
 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
 %token <integer> NEXT
@@ -352,6 +354,8 @@ ifile_p1:
                { lang_add_insert ($3, 0); }
        |       INSERT_K BEFORE NAME
                { lang_add_insert ($3, 1); }
+       |       REGION_ALIAS '(' NAME ',' NAME ')'
+               { lang_memory_region_alias ($3, $5); }
        ;
 
 input_list:
@@ -374,17 +378,17 @@ input_list:
                { lang_add_input_file($2,lang_input_file_is_l_enum,
                                 (char *)NULL); }
        |       AS_NEEDED '('
-                 { $<integer>$ = as_needed; as_needed = TRUE; }
+                 { $<integer>$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
                     input_list ')'
-                 { as_needed = $<integer>3; }
+                 { add_DT_NEEDED_for_regular = $<integer>3; }
        |       input_list ',' AS_NEEDED '('
-                 { $<integer>$ = as_needed; as_needed = TRUE; }
+                 { $<integer>$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
                     input_list ')'
-                 { as_needed = $<integer>5; }
+                 { add_DT_NEEDED_for_regular = $<integer>5; }
        |       input_list AS_NEEDED '('
-                 { $<integer>$ = as_needed; as_needed = TRUE; }
+                 { $<integer>$ = add_DT_NEEDED_for_regular; add_DT_NEEDED_for_regular = TRUE; }
                     input_list ')'
-                 { as_needed = $<integer>4; }
+                 { add_DT_NEEDED_for_regular = $<integer>4; }
        ;
 
 sections:
@@ -577,6 +581,10 @@ statement:
        | ASSERT_K  {ldlex_expression ();} '(' exp ',' NAME ')' end
                        { ldlex_popstate ();
                          lang_add_assignment (exp_assert ($4, $6)); }
+       | INCLUDE filename
+               { ldlex_script (); ldfile_open_command_file($2); }
+               statement_list_opt END
+               { ldlex_popstate (); }
        ;
 
 statement_list:
@@ -668,13 +676,14 @@ opt_comma:
 
 
 memory:
-               MEMORY '{' memory_spec memory_spec_list '}'
+               MEMORY '{' memory_spec_list_opt '}'
        ;
 
+memory_spec_list_opt: memory_spec_list | ;
+
 memory_spec_list:
-               memory_spec_list memory_spec
-       |       memory_spec_list ',' memory_spec
-       |
+               memory_spec_list opt_comma memory_spec
+       |       memory_spec
        ;
 
 
@@ -683,6 +692,10 @@ memory_spec:       NAME
                attributes_opt ':'
                origin_spec opt_comma length_spec
                {}
+       |       INCLUDE filename
+               { ldlex_script (); ldfile_open_command_file($2); }
+               memory_spec_list_opt END
+               { ldlex_popstate (); }
        ;
 
 origin_spec:
@@ -966,6 +979,10 @@ section:   NAME            { ldlex_expression(); }
                  lang_add_assignment (exp_assop ('=', ".", $3));
                }
                '{' sec_or_group_p1 '}'
+       |       INCLUDE filename
+               { ldlex_script (); ldfile_open_command_file($2); }
+               sec_or_group_p1 END
+               { ldlex_popstate (); }
        ;
 
 type: