* dw2gencfi.c (cfi_parse_arg): Only use tc_regname_to_dw2regnum if
[binutils-gdb.git] / ld / ldgram.y
index 5904accce6125cbb1f25ba93d96b3179f4121d79..e9c8a9fe4905de07a8ab98a9f7f6d7f9598b75eb 100644 (file)
@@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "bfd.h"
 #include "sysdep.h"
 #include "bfdlink.h"
-#include "ld.h"    
+#include "ld.h"
 #include "ldexp.h"
 #include "ldver.h"
 #include "ldlang.h"
@@ -102,7 +102,7 @@ static int error_index;
 %type <name> memspec_at_opt
 %type <cname> wildcard_name
 %type <wildcard> wildcard_spec
-%token <bigint> INT  
+%token <bigint> INT
 %token <name> NAME LNAME
 %type <integer> length
 %type <phdr> phdr_qualifiers
@@ -110,7 +110,7 @@ static int error_index;
 %type <section_phdr> phdr_opt
 %type <integer> opt_nocrossrefs
 
-%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
@@ -125,7 +125,7 @@ static int error_index;
 %left  <token> '*' '/' '%'
 
 %right UNARY
-%token END 
+%token END
 %left <token> '('
 %token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE
 %token SECTIONS PHDRS SORT DATA_SEGMENT_ALIGN DATA_SEGMENT_END
@@ -158,7 +158,7 @@ static int error_index;
 
 %%
 
-file:  
+file:
                INPUT_SCRIPT script_file
        |       INPUT_MRI_SCRIPT mri_script_file
        |       INPUT_VERSION_SCRIPT version_script_file
@@ -178,7 +178,7 @@ defsym_expr:
                }
        ;
 
-/* SYNTAX WITHIN AN MRI SCRIPT FILE */  
+/* SYNTAX WITHIN AN MRI SCRIPT FILE */
 mri_script_file:
                {
                  ldlex_mri_script ();
@@ -198,7 +198,7 @@ mri_script_lines:
        ;
 
 mri_script_command:
-               CHIP  exp 
+               CHIP  exp
        |       CHIP  exp ',' exp
        |       NAME    {
                        einfo(_("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1);
@@ -207,12 +207,12 @@ mri_script_command:
                        config.map_filename = "-";
                        }
         |       ORDER ordernamelist
-       |       ENDWORD 
+       |       ENDWORD
         |       PUBLIC NAME '=' exp
                        { mri_public($2, $4); }
         |       PUBLIC NAME ',' exp
                        { mri_public($2, $4); }
-        |       PUBLIC NAME  exp 
+        |       PUBLIC NAME  exp
                        { mri_public($2, $3); }
        |       FORMAT NAME
                        { mri_format($2); }
@@ -232,8 +232,8 @@ mri_script_command:
                        { mri_alignmod($2,$4); }
        |       ABSOLUTE mri_abs_name_list
        |       LOAD     mri_load_name_list
-       |       NAMEWORD NAME 
-                       { mri_name($2); }   
+       |       NAMEWORD NAME
+                       { mri_name($2); }
        |       ALIAS NAME ',' NAME
                        { mri_alias($2,$4,0);}
        |       ALIAS NAME ',' INT
@@ -340,7 +340,7 @@ ifile_p1:
                  { lang_leave_group (); }
        |       MAP '(' filename ')'
                { lang_add_map($3); }
-       |       INCLUDE filename 
+       |       INCLUDE filename
                { ldlex_script (); ldfile_open_command_file($2); }
                ifile_list END
                { ldlex_popstate (); }
@@ -439,7 +439,7 @@ exclude_name_list:
                          tmp = (struct name_list *) xmalloc (sizeof *tmp);
                          tmp->name = $2;
                          tmp->next = $1;
-                         $$ = tmp;     
+                         $$ = tmp;
                        }
        |
                wildcard_name
@@ -503,13 +503,13 @@ statement:
                assignment end
        |       CREATE_OBJECT_SYMBOLS
                {
-               lang_add_attribute(lang_object_symbols_statement_enum); 
+               lang_add_attribute(lang_object_symbols_statement_enum);
                }
         |      ';'
         |      CONSTRUCTORS
                {
-               
-                 lang_add_attribute(lang_constructors_statement_enum); 
+
+                 lang_add_attribute(lang_constructors_statement_enum);
                }
        | SORT '(' CONSTRUCTORS ')'
                {
@@ -521,7 +521,7 @@ statement:
                        {
                          lang_add_data ((int) $1, $3);
                        }
-  
+
        | FILL '(' fill_exp ')'
                        {
                          lang_add_fill ($3);
@@ -532,7 +532,7 @@ statement_list:
                statement_list statement
        |       statement
        ;
-  
+
 statement_list_opt:
                /* empty */
        |       statement_list
@@ -701,7 +701,7 @@ floating_point_support:
        |       NOFLOAT
                        { lang_float(FALSE); }
        ;
-               
+
 nocrossref_list:
                /* empty */
                {
@@ -829,7 +829,7 @@ opt_at:
        ;
 
 section:       NAME            { ldlex_expression(); }
-               opt_exp_with_type 
+               opt_exp_with_type
                opt_at          { ldlex_popstate (); ldlex_script (); }
                '{'
                        {
@@ -837,7 +837,7 @@ section:    NAME            { ldlex_expression(); }
                                                              sectype,
                                                              0, 0, 0, $4);
                        }
-               statement_list_opt      
+               statement_list_opt
                '}' { ldlex_popstate (); ldlex_expression (); }
                memspec_opt memspec_at_opt phdr_opt fill_opt
                {
@@ -850,7 +850,7 @@ section:    NAME            { ldlex_expression(); }
                        { ldlex_expression (); }
                opt_exp_without_type opt_nocrossrefs opt_at
                        { ldlex_popstate (); ldlex_script (); }
-               '{' 
+               '{'
                        {
                          lang_enter_overlay ($3);
                        }
@@ -990,7 +990,7 @@ phdr_type:
                        {
                          "PT_NULL", "PT_LOAD", "PT_DYNAMIC",
                          "PT_INTERP", "PT_NOTE", "PT_SHLIB",
-                         "PT_PHDR"
+                         "PT_PHDR", "PT_TLS"
                        };
 
                      s = $1->name.name;
@@ -1002,6 +1002,18 @@ phdr_type:
                            $$ = exp_intop (i);
                            break;
                          }
+                     if (i == sizeof phdr_types / sizeof phdr_types[0])
+                       {
+                         if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
+                           $$ = exp_intop (0x6474e550);
+                         else
+                           {
+                             einfo (_("\
+%X%P:%S: unknown phdr type `%s' (try integer literal)\n"),
+                                    s);
+                             $$ = exp_intop (0);
+                           }
+                       }
                    }
                }
        ;
@@ -1130,23 +1142,38 @@ vers_defns:
                {
                  $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang);
                }
+       |       vers_defns ';' EXTERN NAME '{'
+                       {
+                         $<name>$ = ldgram_vers_current_lang;
+                         ldgram_vers_current_lang = $4;
+                       }
+               vers_defns opt_semicolon '}'
+                       {
+                         $$ = $7;
+                         ldgram_vers_current_lang = $<name>6;
+                       }
        |       EXTERN NAME '{'
                        {
                          $<name>$ = ldgram_vers_current_lang;
                          ldgram_vers_current_lang = $2;
                        }
-               vers_defns '}'
+               vers_defns opt_semicolon '}'
                        {
                          $$ = $5;
                          ldgram_vers_current_lang = $<name>4;
                        }
        ;
 
+opt_semicolon:
+               /* empty */
+       |       ';'
+       ;
+
 %%
 void
-yyerror(arg) 
+yyerror(arg)
      const char *arg;
-{ 
+{
   if (ldfile_assumed_script)
     einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
           ldfile_input_filename);