]> Git Repo - binutils.git/blobdiff - ld/ldgram.y
Added macros for the 'type' part of an fopen, freopen or fdopen.
[binutils.git] / ld / ldgram.y
index 304b0b2ab8e6124834f475fd3037a9202351e6f2..bd8d0b601ae77e08362157c794353c651bdda89a 100644 (file)
 */
 
 
+#define DONTDECLARE_MALLOC
 
-#include "sysdep.h"
 #include "bfd.h"
+#include "sysdep.h"
 #include "ld.h"    
 #include "ldexp.h"
-#include "ldversion.h"
+#include "ldver.h"
 #include "ldlang.h"
-#include "ld-emul.h"
+#include "ldemul.h"
 #include "ldfile.h"
 #include "ldmisc.h"
+
+
 #define YYDEBUG 1
 
 boolean option_v;
@@ -46,7 +49,7 @@ lang_output_section_statement_type *lang_output_section_statement_lookup();
 #ifdef __STDC__
 
 void lang_add_data(int type, union etree_union *exp);
-void lang_enter_output_section_statement(char *output_section_statement_name, etree_type *address_exp, bfd_vma block_value);
+void lang_enter_output_section_statement(char *output_section_statement_name, etree_type *address_exp, int flags, bfd_vma block_value);
 
 #else
 
@@ -60,9 +63,9 @@ char *current_file;
 boolean ldgram_want_filename = true;
 boolean had_script = false;
 boolean force_make_executable = false;
-boolean ldgram_in_expression = false;
+
 boolean ldgram_in_script = false;
-boolean ldgram_in_defsym = false;
+boolean ldgram_had_equals = false;
 /* LOCALS */
 
 
@@ -88,14 +91,14 @@ boolean ldgram_in_defsym = false;
   
 }
 
-%type <etree> exp  opt_exp  exp_head
-%type <integer> fill_opt opt_block
+%type <etree> exp  opt_exp  
+%type <integer> fill_opt opt_block opt_type
 %type <name> memspec_opt
-%token <integer> INT CHAR 
+%token <integer> INT  
 %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
@@ -105,30 +108,33 @@ boolean ldgram_in_defsym = false;
 %left <token>  EQ NE
 %left  <token> '<' '>' LE GE
 %left  <token> LSHIFT RSHIFT
+
 %left  <token> '+' '-'
 %left  <token> '*' '/' '%'
+
+/*%token <token> '+' '-' '*' '/' '%'*/
 %right UNARY
 %left <token> '('
 %token <token> ALIGN_K BLOCK LONG SHORT BYTE
 %token SECTIONS  
 %token '{' '}'
-%token ALIGNMENT SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION
-%token NEXT SIZEOF ADDR  SCRIPT ENDSCRIPT
-%token MEMORY 
-%token DSECT NOLOAD COPY INFO OVERLAY 
+%token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
+%token SIZEOF_HEADERS
+%token MEMORY  
+%token NOLOAD DSECT 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 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 OPTION_R
+%token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S OPTION_sort_common
+%token OPTION_format  OPTION_F OPTION_u OPTION_Bstatic OPTION_N
+%token <integer> SIZEOF NEXT ADDR 
+%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_R
 %token <name> OPTION_l OPTION_L  OPTION_T OPTION_Aarch OPTION_Tfile  OPTION_Texp
 %token OPTION_Ur 
 %token ORIGIN FILL OPTION_g
-%token LENGTH  BIND SUBSECTION_ALIGN   CREATE_OBJECT_SYMBOLS INPUT OUTPUT
-%type <token> assign_op SIZEOF NEXT ADDR 
-%type <etree> assignment
+%token LENGTH    CREATE_OBJECT_SYMBOLS INPUT OUTPUT  CONSTRUCTORS
+%type <token> assign_op 
+
 %type <name>  filename
 
 %{
@@ -151,11 +157,12 @@ command_line:
        ;
 
 command_line_option:
-               SCRIPT 
+               '{'
                        { ldgram_in_script = true; }
                ifile_list 
                        { ldgram_in_script = false; }
-               ENDSCRIPT
+               '}'
+        |      OPTION_Bstatic { }
        |       OPTION_v
                        {       
                        ldversion();
@@ -169,8 +176,11 @@ command_line_option:
                        }
        |       OPTION_n {
                        config.magic_demand_paged = false;
-                       config.make_executable = false;
+                       config.text_read_only = true;
                        }
+        |       OPTION_N {
+                       config.magic_demand_paged = false;
+                       }
         |       OPTION_s {
                        strip_symbols = STRIP_ALL;
                        }
@@ -209,6 +219,9 @@ command_line_option:
                        {
                        force_make_executable = true;
                        }
+        |      OPTION_sort_common {
+       config.sort_common = true;
+      }
        |      OPTION_d {
                          command_line.force_common_definition = true;
                        }
@@ -257,8 +270,8 @@ command_line_option:
         |      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_c filename 
+                       { ldfile_open_command_file($2); } script_file
        |       OPTION_Tfile 
                        { ldfile_open_command_file($1); } script_file
 
@@ -279,14 +292,11 @@ command_line_option:
                        }
        |       OPTION_defsym 
                        {
-                       ldgram_in_defsym = true;
-                       ldgram_in_expression = true;    
-
                        }
-                        assignment
+               NAME     '='
+               exp 
                        {
-                       ldgram_in_defsym = false;
-                       ldgram_in_expression = false;
+                       lang_add_assignment(exp_assop($4,$3,$5));
                        }       
        | '-' NAME
                 { info("%P%F Unrecognised option -%s\n", $2);  }
@@ -302,7 +312,7 @@ command_line_option:
 
 script_file:
        { ldgram_in_script = true; }
-       ifile_list ENDSCRIPT
+       ifile_list '}'
         { ldgram_in_script = false; }
 
         ;
@@ -323,6 +333,7 @@ ifile_p1:
        |       low_level_library
        |       floating_point_support
        |       statement_anywhere
+        |       ';'
        |       TARGET_K '(' NAME ')'
                { lang_add_target($3); }
        |       SEARCH_DIR '(' filename ')'
@@ -331,6 +342,8 @@ ifile_p1:
                { 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 ')'
@@ -401,14 +414,18 @@ statement:
        |       statement CREATE_OBJECT_SYMBOLS
                {
                  lang_add_attribute(lang_object_symbols_statement_enum); }
+        |      statement ';'
+        |      statement CONSTRUCTORS
+               {
+                 lang_add_attribute(lang_constructors_statement_enum); }
 
        |       statement input_section_spec
-        |       statement length '(' exp_head ')'
+        |       statement length '(' exp ')'
                        {
                        lang_add_data($2,$4);
                        }
   
-       |       statement FILL '(' exp_head ')'
+       |       statement FILL '(' exp ')'
                        {
                          lang_add_fill
                            (exp_get_value_int($4,
@@ -429,7 +446,7 @@ length:
        ;
 
 fill_opt:
-          '=' exp_head
+          '=' exp
                {
                  $$ =   exp_get_value_int($2,
                                           0,
@@ -466,12 +483,11 @@ end:      ';' | ','
 
 
 assignment:
-       
-               NAME '=' exp_head 
+               NAME '=' exp 
                {
                  lang_add_assignment(exp_assop($2,$1,$3));
                }
-       |       NAME assign_op exp_head 
+       |       NAME assign_op exp 
                {
                  lang_add_assignment(exp_assop('=',$1,exp_binop($2,exp_nameop(NAME,$1),$3)));
                }
@@ -622,13 +638,15 @@ exp       :
                        { $$ = exp_nameop(DEFINED, $3); }
        |       INT
                        { $$ = exp_intop($1); }
+        |      SIZEOF_HEADERS 
+                       { $$ = exp_nameop(SIZEOF_HEADERS,0); }
 
        |       SIZEOF  '('  NAME ')'
-                       { $$ = exp_nameop($1,$3); }
+                       { $$ = exp_nameop(SIZEOF,$3); }
        |       ADDR '(' NAME ')'
-                       { $$ = exp_nameop($1,$3); }
+                       { $$ = exp_nameop(ADDR,$3); }
        |       ALIGN_K '(' exp ')'
-                       { $$ = exp_unop($1,$3); }
+                       { $$ = exp_unop(ALIGN_K,$3); }
        |       NAME
                        { $$ = exp_nameop(NAME,$1); }
        ;
@@ -636,42 +654,44 @@ exp       :
 
 
 
-section:       NAME opt_exp opt_block ':' opt_things'{' 
+section:       NAME opt_exp opt_type opt_block ':' opt_things'{' 
                {
-               lang_enter_output_section_statement($1,$2,$3);
+               lang_enter_output_section_statement($1,$2,$3,$4);
                }
               statement        '}'     fill_opt memspec_opt
                {
-                 lang_leave_output_section_statement($10, $11);
+                 lang_leave_output_section_statement($11, $12);
                }
 
        ;
 
+opt_type:      
+         '(' NOLOAD ')' { $$ = SEC_NO_FLAGS; }
+       | '(' DSECT ')' { $$ = 0; }
+       | '(' COPY ')' { $$ = 0; }
+       | '(' INFO ')' { $$ = 0; }
+       | '(' OVERLAY ')' { $$ = 0; }
+       |    { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; }
+       ;
+
 opt_things: 
        {
 
        }
        ;
 
-exp_head:
-               { 
-               ldgram_in_expression = true; 
-               }
-       exp
-               {
-               ldgram_in_expression = false; 
-               $$ = $2;
-               }
-       ;
+
+
+
 
 opt_exp:
-               exp_head
+               exp
                        { $$ = $1; }
        |               { $$= (etree_type *)NULL; }
        ;
 
 opt_block:
-               BLOCK '(' exp_head ')'
+               BLOCK '(' exp ')'
                { $$ = exp_get_value_int($3,
                                         1L,
                                         "block",
This page took 0.036137 seconds and 4 git commands to generate.