Add missing prototypes
[deliverable/binutils-gdb.git] / ld / ldgram.y
index 002b9fbe1f556eee9c449173d738e08531cf1f08..a823bab76863d01732a2197176bb114b9ee9be64 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, 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 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
 
 This file is part of GNU ld.
@@ -33,8 +33,8 @@ 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"
@@ -49,9 +49,8 @@ static enum section_type sectype;
 
 lang_memory_region_type *region;
 
-struct wildcard_spec current_file;
 boolean ldgram_want_filename = true;
-boolean had_script = false;
+FILE *  saved_script_handle = NULL;
 boolean force_make_executable = false;
 
 boolean ldgram_in_script = false;
@@ -70,6 +69,8 @@ static int error_index;
   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
@@ -89,7 +90,10 @@ 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 <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  
@@ -392,66 +396,85 @@ wildcard_spec:
                        {
                          $$.name = $1;
                          $$.sorted = false;
-                         $$.exclude_name = NULL;
+                         $$.exclude_name_list = NULL;
                        }
-       |       EXCLUDE_FILE '(' wildcard_name ')' wildcard_name
+       |       EXCLUDE_FILE '(' exclude_name_list ')' wildcard_name
                        {
                          $$.name = $5;
                          $$.sorted = false;
-                         $$.exclude_name = $3;
+                         $$.exclude_name_list = $3;
                        }
        |       SORT '(' wildcard_name ')'
                        {
                          $$.name = $3;
                          $$.sorted = true;
-                         $$.exclude_name = NULL;
+                         $$.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;
+                         $$.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:
@@ -595,7 +618,9 @@ memory_spec:                NAME
                attributes_opt ':'
                origin_spec opt_comma length_spec
 
-       ; origin_spec:
+       ;
+
+origin_spec:
        ORIGIN '=' mustbe_exp
                { region->current =
                 region->origin =
@@ -776,6 +801,11 @@ exp        :
        ;
 
 
+memspec_at_opt:
+                AT '>' NAME { $$ = $3; }
+        |       { $$ = "*default*"; }
+        ;
+
 opt_at:
                AT '(' exp ')' { $$ = $3; }
        |       { $$ = 0; }
@@ -792,10 +822,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
@@ -809,10 +839,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
@@ -1084,6 +1114,7 @@ vers_defns:
                        }
                vers_defns '}'
                        {
+                         $$ = $5;
                          ldgram_vers_current_lang = $<name>4;
                        }
        ;
This page took 0.026092 seconds and 4 git commands to generate.