*** empty log message ***
[deliverable/binutils-gdb.git] / ld / ldgram.y
index 2b1ae7715c17af2b992c544f13fb4bbedc0e3bfe..8bde4e4babb9c96c0d08e9661499ad7c667d6eb0 100644 (file)
@@ -1,4 +1,4 @@
-
+%{
 /*
  * $Id$ 
  *
@@ -33,7 +33,8 @@ extern boolean write_map;
 
 boolean hex_mode;
 
-
+strip_symbols_type strip_symbols=STRIP_NONE;
+discard_locals_type discard_locals=DISCARD_NONE;
 
 
 lang_memory_region_type *region;
@@ -59,11 +60,9 @@ char *current_file;
 boolean ldgram_want_filename = true;
 boolean had_script = false;
 boolean force_make_executable = false;
-boolean ldgram_has_inputfile = false;
 
-boolean ldgram_in_expression = false;
-
-boolean ldgram_in_defsym = false;
+boolean ldgram_in_script = false;
+boolean ldgram_had_equals = false;
 /* LOCALS */
 
 
@@ -96,7 +95,7 @@ boolean ldgram_in_defsym = false;
 %token <name> NAME
 %type  <integer> length
 
-%right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ  '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
+%right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ  '=' LSHIFTEQ RSHIFTEQ   ANDEQ OREQ 
 %right <token> '?' ':'
 %left <token> OROR
 %left <token>  ANDAND
@@ -113,17 +112,17 @@ boolean ldgram_in_defsym = false;
 %token <token> ALIGN_K BLOCK LONG SHORT BYTE
 %token SECTIONS  
 %token '{' '}'
-%token ALIGNMENT SIZEOF_HEADERS
-%token NEXT SIZEOF ADDR 
+%token ALIGNMENT SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
+%token NEXT SIZEOF ADDR  SCRIPT ENDSCRIPT
 %token MEMORY 
 %token DSECT NOLOAD COPY INFO OVERLAY 
 %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY 
 %token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S
-%token OPTION_format  OPTION_F
+%token OPTION_format  OPTION_F OPTION_u
 
-%token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X
-%token OPTION_v OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT OPTION_defsym
-%token OPTION_n OPTION_r OPTION_o OPTION_b  OPTION_A
+%token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X OPTION_defsym
+%token OPTION_v OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT 
+%token OPTION_n OPTION_r OPTION_o OPTION_b  OPTION_A OPTION_R
 %token <name> OPTION_l OPTION_L  OPTION_T OPTION_Aarch OPTION_Tfile  OPTION_Texp
 %token OPTION_Ur 
 %token ORIGIN FILL OPTION_g
@@ -152,7 +151,12 @@ command_line:
        ;
 
 command_line_option:
-               OPTION_v
+               '{'
+                       { ldgram_in_script = true; }
+               ifile_list 
+                       { ldgram_in_script = false; }
+               '}'
+       |       OPTION_v
                        {       
                        ldversion();
                        option_v = true;
@@ -173,7 +177,10 @@ command_line_option:
        |       OPTION_S {
                        strip_symbols = STRIP_DEBUGGER;
                        }
-                       
+        |       OPTION_u NAME {
+                       ldlang_add_undef($2);
+               }
+           
        |       OPTION_r {
                        config.relocateable_output = true;
                        config.build_constructors = false;
@@ -202,10 +209,10 @@ command_line_option:
                        {
                        force_make_executable = true;
                        }
-    |      OPTION_d {
+       |      OPTION_d {
                          command_line.force_common_definition = true;
                        }
-    |      OPTION_dc
+       |      OPTION_dc
                         {
                          command_line.force_common_definition = true;
                        }
@@ -213,23 +220,28 @@ command_line_option:
                        {
                        /* Ignored */
                        }
-    |          OPTION_dp
+       |       OPTION_dp
                         {
                          command_line.force_common_definition = true;
                        }
-    |  OPTION_format NAME
+       |       OPTION_format NAME
                   {
                          lang_add_target($2);
                           }
-
        |       OPTION_Texp 
-               { hex_mode  =true; } 
-                 exp
-               { lang_section_start($1, $3);
-                 hex_mode = false; }
+               { 
+                       hex_mode  =true; 
+               } 
+               INT
+               { 
+                       lang_section_start($1,exp_intop($3));
+                       hex_mode = false; 
+               }
        
        |       OPTION_Aarch 
-               { ldfile_add_arch($1); }
+               { 
+                       ldfile_add_arch($1); 
+               }
        |        OPTION_b NAME
                        {
                        lang_add_target($2);
@@ -237,21 +249,21 @@ command_line_option:
        |       OPTION_L
                        {
                        ldfile_add_library_path($1);
-               }
+                       }
        |       OPTION_F
                {
                /* Ignore */
                }
-
-       |       ifile_p1
-       |       input_list
-       |       OPTION_c filename
+        |      NAME
+               { lang_add_input_file($1,lang_input_file_is_file_enum,
+                                (char *)NULL); }
+       |       OPTION_c filename script_file
                        { ldfile_open_command_file($2); }
-       |       OPTION_Tfile
-                       { ldfile_open_command_file($1); }
+       |       OPTION_Tfile 
+                       { ldfile_open_command_file($1); } script_file
 
-       |       OPTION_T filename
-                       { ldfile_open_command_file($2); }
+       |       OPTION_T filename 
+                       { ldfile_open_command_file($2); } script_file
 
        |       OPTION_l
                        {
@@ -259,7 +271,7 @@ command_line_option:
                                         lang_input_file_is_l_enum,
                                         (char *)NULL);
                        }
-       |       OPTION_A filename
+       |       OPTION_R filename
                        {
                        lang_add_input_file($2,
                                lang_input_file_is_symbols_only_enum,
@@ -267,48 +279,35 @@ command_line_option:
                        }
        |       OPTION_defsym 
                        {
-                       ldgram_in_defsym = true;
-                       hex_mode = true;
                        }
-                        assignment
+               NAME     '='
+               exp_head 
                        {
-                       hex_mode = false;
-                       ldgram_in_defsym = false;
+                       lang_add_assignment(exp_assop($4,$3,$5));
                        }       
+       | '-' NAME
+                { info("%P%F Unrecognised option -%s\n", $2);  }
 
        ;
 
 
-input_section_spec:
-               NAME
-               {
-               lang_add_wild((char *)NULL, $1);
-               }
-        |      '[' 
-                       {
-                       current_file = (char *)NULL;
-                       }
-                       file_NAME_list  
-               ']' 
-       |       NAME
-                       {
-                       current_file  =$1;
-                       } 
-               '(' file_NAME_list ')'
-       |       '*' 
-                       {       
-                       current_file = (char *)NULL;
-                       } 
-               '(' file_NAME_list ')'
-       ;
+  
 
 
 
-file_NAME_list:
-               NAME
-                       { lang_add_wild($1, current_file); }
-       |       file_NAME_list opt_comma NAME 
-                       { lang_add_wild($3, current_file); }
+
+
+script_file:
+       { ldgram_in_script = true; }
+       ifile_list '}'
+        { ldgram_in_script = false; }
+
+        ;
+
+
+ifile_list:
+       ifile_list ifile_p1 
+        |
        ;
 
 
@@ -320,13 +319,19 @@ ifile_p1:
        |       high_level_library
        |       low_level_library
        |       floating_point_support
-       |       assignment end
+       |       statement_anywhere
        |       TARGET_K '(' NAME ')'
                { lang_add_target($3); }
        |       SEARCH_DIR '(' filename ')'
                { ldfile_add_library_path($3); }
        |       OUTPUT '(' filename ')'
                { lang_add_output($3); }
+        |       OUTPUT_FORMAT '(' NAME ')'
+                 { lang_add_output_format($3); }
+        |       OUTPUT_ARCH '(' NAME ')'
+                 { ldfile_set_output_arch($3); }
+       |       FORCE_COMMON_ALLOCATION
+               { command_line.force_common_definition = true ; }
        |       INPUT '(' input_list ')'
        |       MAP '(' filename ')'
                { lang_add_map($3); }
@@ -360,10 +365,42 @@ statement_anywhere:
        |       assignment end
        ;
 
+file_NAME_list:
+               NAME
+                       { lang_add_wild($1, current_file); }
+       |       file_NAME_list opt_comma NAME 
+                       { lang_add_wild($3, current_file); }
+       ;
+
+input_section_spec:
+               NAME
+               {
+               lang_add_wild((char *)NULL, $1);
+               }
+        |      '[' 
+                       {
+                       current_file = (char *)NULL;
+                       }
+                       file_NAME_list  
+               ']' 
+       |       NAME
+                       {
+                       current_file  =$1;
+                       } 
+               '(' file_NAME_list ')'
+       |       '*' 
+                       {       
+                       current_file = (char *)NULL;
+                       } 
+               '(' file_NAME_list ')'
+       ;
+
 statement:
                statement assignment end
        |       statement CREATE_OBJECT_SYMBOLS
-               { lang_add_attribute(lang_object_symbols_statement_enum); }
+               {
+                 lang_add_attribute(lang_object_symbols_statement_enum); }
+
        |       statement input_section_spec
         |       statement length '(' exp_head ')'
                        {
@@ -616,14 +653,7 @@ opt_things:
        ;
 
 exp_head:
-               { 
-               ldgram_in_expression = true; 
-               }
-       exp
-               {
-               ldgram_in_expression = false; 
-               $$ = $2;
-               }
+       exp { $$ = $1; }
        ;
 
 opt_exp:
This page took 0.047817 seconds and 4 git commands to generate.