Do not require any exception support library. Check results against NRV.
[deliverable/binutils-gdb.git] / ld / ldgram.y
index 68ff0a244e1b020a745f9c0210e6e912a374241f..e7f4a590d4b075dd9cb699cbaea63afbe6a62417 100644 (file)
@@ -1,6 +1,6 @@
-/* A YACC grammer to parse a superset of the AT&T linker scripting languaue.
-   Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 1998
-   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 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
 
 This file is part of GNU ld.
@@ -33,11 +33,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #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"
+#include "ldctor.h"
 #include "ldlex.h"
 
 #ifndef YYDEBUG
@@ -56,6 +57,7 @@ boolean force_make_executable = false;
 boolean ldgram_in_script = false;
 boolean ldgram_had_equals = false;
 boolean ldgram_had_keep = false;
+char *ldgram_vers_current_lang = NULL;
 
 #define ERROR_NAME_MAX 20
 static char *error_names[ERROR_NAME_MAX];
@@ -68,6 +70,7 @@ static int error_index;
   char *name;
   const char *cname;
   struct wildcard_spec wildcard;
+  struct name_list *name_list;
   int token;
   union etree_union *etree;
   struct phdr_info
@@ -87,7 +90,9 @@ static int error_index;
 %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 <name_list> exclude_name_list
 %type <name> memspec_opt casesymlist
+%type <name> memspec_at_opt
 %type <cname> wildcard_name
 %type <wildcard> wildcard_spec
 %token <integer> INT  
@@ -125,19 +130,20 @@ static int error_index;
 %token NOLOAD DSECT COPY INFO OVERLAY
 %token NAME LNAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY
 %token <integer> NEXT
-%token SIZEOF ADDR LOADADDR MAX MIN
+%token SIZEOF ADDR LOADADDR MAX_K MIN_K
 %token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS
 %token ORIGIN FILL
 %token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS
 %token ALIGNMOD AT PROVIDE
-%type <token> assign_op atype
+%type <token> assign_op atype attributes_opt
 %type <name>  filename
-%token CHIP LIST SECT ABSOLUTE  LOAD NEWLINE ENDWORD ORDER NAMEWORD
+%token CHIP LIST SECT ABSOLUTE  LOAD NEWLINE ENDWORD ORDER NAMEWORD ASSERT_K
 %token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL
 %token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START
 %token <name> VERS_TAG VERS_IDENTIFIER
 %token GLOBAL LOCAL VERSIONK INPUT_VERSION_SCRIPT
 %token KEEP
+%token EXCLUDE_FILE
 %type <versyms> vers_defns
 %type <versnode> vers_tag
 %type <deflist> verdep
@@ -389,11 +395,47 @@ wildcard_spec:
                        {
                          $$.name = $1;
                          $$.sorted = false;
+                         $$.exclude_name_list = NULL;
+                       }
+       |       EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
+                       {
+                         $$.name = $5;
+                         $$.sorted = false;
+                         $$.exclude_name_list = $3;
                        }
        |       SORT '(' wildcard_name ')'
                        {
                          $$.name = $3;
                          $$.sorted = true;
+                         $$.exclude_name_list = NULL;
+                       }
+       |       SORT '(' EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name ')'
+                       {
+                         $$.name = $7;
+                         $$.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;
                        }
        ;
 
@@ -403,14 +445,14 @@ file_NAME_list:
                          lang_add_wild ($1.name, $1.sorted,
                                         current_file.name,
                                         current_file.sorted,
-                                        ldgram_had_keep);
+                                        ldgram_had_keep, $1.exclude_name_list);
                        }
        |       file_NAME_list opt_comma wildcard_spec
                        {
                          lang_add_wild ($3.name, $3.sorted,
                                         current_file.name,
                                         current_file.sorted,
-                                        ldgram_had_keep);
+                                        ldgram_had_keep, $3.exclude_name_list);
                        }
        ;
 
@@ -418,7 +460,7 @@ input_section_spec_no_keep:
                NAME
                        {
                          lang_add_wild (NULL, false, $1, false,
-                                        ldgram_had_keep);
+                                        ldgram_had_keep, NULL);
                        }
         |      '['
                        {
@@ -456,6 +498,11 @@ statement:
                
                  lang_add_attribute(lang_constructors_statement_enum); 
                }
+       | SORT '(' CONSTRUCTORS ')'
+               {
+                 constructors_sorted = true;
+                 lang_add_attribute (lang_constructors_statement_enum);
+               }
        | input_section_spec
         | length '(' mustbe_exp ')'
                        {
@@ -572,7 +619,9 @@ memory_spec:                NAME
                attributes_opt ':'
                origin_spec opt_comma length_spec
 
-       ; origin_spec:
+       ;
+
+origin_spec:
        ORIGIN '=' mustbe_exp
                { region->current =
                 region->origin =
@@ -587,15 +636,24 @@ length_spec:
                                               "length",
                                               lang_first_phase_enum);
                }
-       
+       ;
 
 attributes_opt:
-                 '(' NAME ')'
-                       {
-                       lang_set_flags(region, $2);
-                       }
-       |
-  
+               /* empty */
+                 { /* dummy action to avoid bison 1.25 error message */ }
+       |       '(' attributes_list ')'
+       ;
+
+attributes_list:
+               attributes_string
+       |       attributes_list attributes_string
+       ;
+
+attributes_string:
+               NAME
+                 { lang_set_flags (region, $1, 0); }
+       |       '!' NAME
+                 { lang_set_flags (region, $2, 1); }
        ;
 
 startup:
@@ -735,13 +793,20 @@ exp       :
                        { $$ = exp_unop(ALIGN_K,$3); }
        |       NAME
                        { $$ = exp_nameop(NAME,$1); }
-       |       MAX '(' exp ',' exp ')'
-                       { $$ = exp_binop (MAX, $3, $5 ); }
-       |       MIN '(' exp ',' exp ')'
-                       { $$ = exp_binop (MIN, $3, $5 ); }
+       |       MAX_K '(' exp ',' exp ')'
+                       { $$ = exp_binop (MAX_K, $3, $5 ); }
+       |       MIN_K '(' exp ',' exp ')'
+                       { $$ = exp_binop (MIN_K, $3, $5 ); }
+       |       ASSERT_K '(' exp ',' NAME ')'
+                       { $$ = exp_assert ($3, $5); }
        ;
 
 
+memspec_at_opt:
+                AT '>' NAME { $$ = $3; }
+        |       { $$ = "*default*"; }
+        ;
+
 opt_at:
                AT '(' exp ')' { $$ = $3; }
        |       { $$ = 0; }
@@ -758,10 +823,10 @@ section:  NAME            { ldlex_expression(); }
                        }
                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
@@ -775,10 +840,10 @@ section:  NAME            { ldlex_expression(); }
                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 ($15, $12, $14, $13);
                        }
                opt_comma
        |       /* The GROUP case is just enough to support the gcc
@@ -1037,12 +1102,22 @@ vers_tag:
 vers_defns:
                VERS_IDENTIFIER
                {
-                 $$ = lang_new_vers_regex (NULL, $1);
+                 $$ = lang_new_vers_regex (NULL, $1, ldgram_vers_current_lang);
                }
        |       vers_defns ';' VERS_IDENTIFIER
                {
-                 $$ = lang_new_vers_regex ($1, $3);
+                 $$ = lang_new_vers_regex ($1, $3, ldgram_vers_current_lang);
                }
+       |       EXTERN NAME '{'
+                       {
+                         $<name>$ = ldgram_vers_current_lang;
+                         ldgram_vers_current_lang = $2;
+                       }
+               vers_defns '}'
+                       {
+                         $$ = $5;
+                         ldgram_vers_current_lang = $<name>4;
+                       }
        ;
 
 %%
This page took 0.027348 seconds and 4 git commands to generate.