Change version number to 2.38.50 and regenerate files
[binutils-gdb.git] / ld / ldgram.y
index 335624b386cca3e3d73c65885562508a823375d0..11c2f219c05d0c3b8f9cd2579faf41a831e4a396 100644 (file)
@@ -1,5 +1,5 @@
 /* A YACC grammar to parse a superset of the AT&T linker scripting language.
-   Copyright (C) 1991-2018 Free Software Foundation, Inc.
+   Copyright (C) 1991-2022 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
 
    This file is part of the GNU Binutils.
@@ -29,6 +29,7 @@
 #include "sysdep.h"
 #include "bfd.h"
 #include "bfdlink.h"
+#include "ctf-api.h"
 #include "ld.h"
 #include "ldexp.h"
 #include "ldver.h"
@@ -48,7 +49,7 @@
 static enum section_type sectype;
 static lang_memory_region_type *region;
 
-static bfd_boolean ldgram_had_keep = FALSE;
+static bool ldgram_had_keep = false;
 static char *ldgram_vers_current_lang = NULL;
 
 #define ERROR_NAME_MAX 20
@@ -76,8 +77,8 @@ static int error_index;
   union etree_union *etree;
   struct phdr_info
     {
-      bfd_boolean filehdr;
-      bfd_boolean phdrs;
+      bool filehdr;
+      bool phdrs;
       union etree_union *at;
       union etree_union *flags;
     } phdr;
@@ -95,8 +96,7 @@ static int error_index;
 %type <wildcard_list> section_name_list
 %type <flag_info_list> sect_flag_list
 %type <flag_info> sect_flags
-%type <name> memspec_opt casesymlist
-%type <name> memspec_at_opt
+%type <name> memspec_opt memspec_at_opt paren_script_name casesymlist
 %type <cname> wildcard_name
 %type <wildcard> section_name_spec filename_spec wildcard_maybe_exclude
 %token <bigint> INT
@@ -138,6 +138,7 @@ static int error_index;
 %token REGION_ALIAS
 %token LD_FEATURE
 %token NOLOAD DSECT COPY INFO OVERLAY
+%token READONLY
 %token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
 %token <integer> NEXT
 %token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
@@ -175,12 +176,9 @@ filename:  NAME;
 
 
 defsym_expr:
-               { ldlex_defsym(); }
-               NAME '=' exp
-               {
-                 ldlex_popstate();
-                 lang_add_assignment (exp_defsym ($2, $4));
-               }
+               { ldlex_expression(); }
+               assignment
+               { ldlex_popstate(); }
        ;
 
 /* SYNTAX WITHIN AN MRI SCRIPT FILE */
@@ -206,7 +204,7 @@ mri_script_command:
                CHIP  exp
        |       CHIP  exp ',' exp
        |       NAME    {
-                       einfo(_("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1);
+                       einfo(_("%F%P: unrecognised keyword in MRI style script '%s'\n"),$1);
                        }
        |       LIST    {
                        config.map_filename = "-";
@@ -250,11 +248,10 @@ mri_script_command:
        |       CASE casesymlist
        |       EXTERN extern_name_list
        |       INCLUDE filename
-               { ldlex_script (); ldfile_open_command_file($2); }
+               { ldfile_open_command_file ($2); }
                mri_script_lines END
-               { ldlex_popstate (); }
        |       START NAME
-               { lang_add_entry ($2, FALSE); }
+               { lang_add_entry ($2, false); }
        |
        ;
 
@@ -283,25 +280,19 @@ casesymlist:
        | casesymlist ',' NAME
        ;
 
-/* Parsed as expressions so that commas separate entries */
 extern_name_list:
-       { ldlex_expression (); }
-       extern_name_list_body
-       { ldlex_popstate (); }
-
-extern_name_list_body:
-         NAME
-                       { ldlang_add_undef ($1, FALSE); }
-       | extern_name_list_body NAME
-                       { ldlang_add_undef ($2, FALSE); }
-       | extern_name_list_body ',' NAME
-                       { ldlang_add_undef ($3, FALSE); }
+       NAME
+                       { ldlang_add_undef ($1, false); }
+       | extern_name_list NAME
+                       { ldlang_add_undef ($2, false); }
+       | extern_name_list ',' NAME
+                       { ldlang_add_undef ($3, false); }
        ;
 
 script_file:
-       { ldlex_both(); }
+       { ldlex_script (); }
        ifile_list
-       { ldlex_popstate(); }
+       { ldlex_popstate (); }
        ;
 
 ifile_list:
@@ -324,7 +315,7 @@ ifile_p1:
        |       TARGET_K '(' NAME ')'
                { lang_add_target($3); }
        |       SEARCH_DIR '(' filename ')'
-               { ldfile_add_library_path ($3, FALSE); }
+               { ldfile_add_library_path ($3, false); }
        |       OUTPUT '(' filename ')'
                { lang_add_output($3, 1); }
        |       OUTPUT_FORMAT '(' NAME ')'
@@ -335,11 +326,11 @@ ifile_p1:
        |       OUTPUT_ARCH '(' NAME ')'
                  { ldfile_set_output_arch ($3, bfd_arch_unknown); }
        |       FORCE_COMMON_ALLOCATION
-               { command_line.force_common_definition = TRUE ; }
+               { command_line.force_common_definition = true ; }
        |       FORCE_GROUP_ALLOCATION
-               { command_line.force_group_allocation = TRUE ; }
+               { command_line.force_group_allocation = true ; }
        |       INHIBIT_COMMON_ALLOCATION
-               { link_info.inhibit_common_definition = TRUE ; }
+               { link_info.inhibit_common_definition = true ; }
        |       INPUT '(' input_list ')'
        |       GROUP
                  { lang_enter_group (); }
@@ -348,9 +339,8 @@ ifile_p1:
        |       MAP '(' filename ')'
                { lang_add_map($3); }
        |       INCLUDE filename
-               { ldlex_script (); ldfile_open_command_file($2); }
+               { ldfile_open_command_file ($2); }
                ifile_list END
-               { ldlex_popstate (); }
        |       NOCROSSREFS '(' nocrossref_list ')'
                {
                  lang_add_nocrossref ($3);
@@ -359,7 +349,8 @@ ifile_p1:
                {
                  lang_add_nocrossref_to ($3);
                }
-       |       EXTERN '(' extern_name_list ')'
+       |       EXTERN '(' { ldlex_expression (); } extern_name_list ')'
+                       { ldlex_popstate (); }
        |       INSERT_K AFTER NAME
                { lang_add_insert ($3, 0); }
        |       INSERT_K BEFORE NAME
@@ -396,17 +387,17 @@ input_list1:
                                 (char *)NULL); }
        |       AS_NEEDED '('
                  { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
-                   input_flags.add_DT_NEEDED_for_regular = TRUE; }
+                   input_flags.add_DT_NEEDED_for_regular = true; }
                     input_list1 ')'
                  { input_flags.add_DT_NEEDED_for_regular = $<integer>3; }
        |       input_list1 ',' AS_NEEDED '('
                  { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
-                   input_flags.add_DT_NEEDED_for_regular = TRUE; }
+                   input_flags.add_DT_NEEDED_for_regular = true; }
                     input_list1 ')'
                  { input_flags.add_DT_NEEDED_for_regular = $<integer>5; }
        |       input_list1 AS_NEEDED '('
                  { $<integer>$ = input_flags.add_DT_NEEDED_for_regular;
-                   input_flags.add_DT_NEEDED_for_regular = TRUE; }
+                   input_flags.add_DT_NEEDED_for_regular = true; }
                     input_list1 ')'
                  { input_flags.add_DT_NEEDED_for_regular = $<integer>4; }
        ;
@@ -423,28 +414,18 @@ sec_or_group_p1:
 
 statement_anywhere:
                ENTRY '(' NAME ')'
-               { lang_add_entry ($3, FALSE); }
-       |       assignment end
+               { lang_add_entry ($3, false); }
+       |       assignment separator
        |       ASSERT_K  {ldlex_expression ();} '(' exp ',' NAME ')'
                { ldlex_popstate ();
                  lang_add_assignment (exp_assert ($4, $6)); }
        ;
 
-/* The '*' and '?' cases are there because the lexer returns them as
-   separate tokens rather than as NAME.  */
 wildcard_name:
                NAME
                        {
                          $$ = $1;
                        }
-       |       '*'
-                       {
-                         $$ = "*";
-                       }
-       |       '?'
-                       {
-                         $$ = "?";
-                       }
        ;
 
 wildcard_maybe_exclude:
@@ -536,7 +517,7 @@ sect_flag_list:     NAME
                              n->with = with_flags;
                              n->name = $1;
                            }
-                         n->valid = FALSE;
+                         n->valid = false;
                          n->next = NULL;
                          $$ = n;
                        }
@@ -554,7 +535,7 @@ sect_flag_list:     NAME
                              n->with = with_flags;
                              n->name = $3;
                            }
-                         n->valid = FALSE;
+                         n->valid = false;
                          n->next = $1;
                          $$ = n;
                        }
@@ -566,7 +547,7 @@ sect_flags:
                          struct flag_info *n;
                          n = ((struct flag_info *) xmalloc (sizeof *n));
                          n->flag_list = $3;
-                         n->flags_initialized = FALSE;
+                         n->flags_initialized = false;
                          n->not_with_flags = 0;
                          n->only_with_flags = 0;
                          $$ = n;
@@ -659,26 +640,25 @@ input_section_spec_no_keep:
 input_section_spec:
                input_section_spec_no_keep
        |       KEEP '('
-                       { ldgram_had_keep = TRUE; }
+                       { ldgram_had_keep = true; }
                input_section_spec_no_keep ')'
-                       { ldgram_had_keep = FALSE; }
+                       { ldgram_had_keep = false; }
        ;
 
 statement:
-               assignment end
-       |       CREATE_OBJECT_SYMBOLS
+       ';'
+       | assignment separator
+       | CREATE_OBJECT_SYMBOLS
                {
-               lang_add_attribute(lang_object_symbols_statement_enum);
+                 lang_add_attribute (lang_object_symbols_statement_enum);
                }
-       |       ';'
-       |       CONSTRUCTORS
+       | CONSTRUCTORS
                {
-
-                 lang_add_attribute(lang_constructors_statement_enum);
+                 lang_add_attribute (lang_constructors_statement_enum);
                }
        | SORT_BY_NAME '(' CONSTRUCTORS ')'
                {
-                 constructors_sorted = TRUE;
+                 constructors_sorted = true;
                  lang_add_attribute (lang_constructors_statement_enum);
                }
        | input_section_spec
@@ -691,13 +671,18 @@ statement:
                {
                  lang_add_fill ($3);
                }
-       | ASSERT_K  {ldlex_expression ();} '(' exp ',' NAME ')' end
-                       { ldlex_popstate ();
-                         lang_add_assignment (exp_assert ($4, $6)); }
+       | ASSERT_K
+               { ldlex_expression (); }
+         '(' exp ',' NAME ')' separator
+               {
+                 ldlex_popstate ();
+                 lang_add_assignment (exp_assert ($4, $6));
+               }
        | INCLUDE filename
-               { ldlex_script (); ldfile_open_command_file($2); }
-               statement_list_opt END
-               { ldlex_popstate (); }
+               {
+                 ldfile_open_command_file ($2);
+               }
+         statement_list_opt END
        ;
 
 statement_list:
@@ -756,14 +741,14 @@ assign_op:
 
        ;
 
-end:   ';' | ','
+separator:     ';' | ','
        ;
 
 
 assignment:
                NAME '=' mustbe_exp
                {
-                 lang_add_assignment (exp_assign ($1, $3, FALSE));
+                 lang_add_assignment (exp_assign ($1, $3, false));
                }
        |       NAME assign_op mustbe_exp
                {
@@ -771,19 +756,19 @@ assignment:
                                                   exp_binop ($2,
                                                              exp_nameop (NAME,
                                                                          $1),
-                                                             $3), FALSE));
+                                                             $3), false));
                }
        |       HIDDEN '(' NAME '=' mustbe_exp ')'
                {
-                 lang_add_assignment (exp_assign ($3, $5, TRUE));
+                 lang_add_assignment (exp_assign ($3, $5, true));
                }
        |       PROVIDE '(' NAME '=' mustbe_exp ')'
                {
-                 lang_add_assignment (exp_provide ($3, $5, FALSE));
+                 lang_add_assignment (exp_provide ($3, $5, false));
                }
        |       PROVIDE_HIDDEN '(' NAME '=' mustbe_exp ')'
                {
-                 lang_add_assignment (exp_provide ($3, $5, TRUE));
+                 lang_add_assignment (exp_provide ($3, $5, true));
                }
        ;
 
@@ -805,27 +790,30 @@ memory_spec_list:
 
 
 memory_spec:   NAME
-               { region = lang_memory_region_lookup ($1, TRUE); }
+               { region = lang_memory_region_lookup ($1, true); }
                attributes_opt ':'
                origin_spec opt_comma length_spec
                {}
        |       INCLUDE filename
-               { ldlex_script (); ldfile_open_command_file($2); }
+               { ldfile_open_command_file ($2); }
                memory_spec_list_opt END
-               { ldlex_popstate (); }
        ;
 
 origin_spec:
        ORIGIN '=' mustbe_exp
                {
                  region->origin_exp = $3;
-                 region->current = region->origin;
                }
        ;
 
 length_spec:
             LENGTH '=' mustbe_exp
                {
+                 if (yychar == NAME)
+                   {
+                     yyclearin;
+                     ldlex_backup ();
+                   }
                  region->length_exp = $3;
                }
        ;
@@ -864,12 +852,13 @@ high_level_library_NAME_list:
                        { ldemul_hll($3); }
        |       filename
                        { ldemul_hll($1); }
-
        ;
 
 low_level_library:
        SYSLIB '(' low_level_library_NAME_list ')'
-       ; low_level_library_NAME_list:
+       ;
+
+low_level_library_NAME_list:
                low_level_library_NAME_list opt_comma filename
                        { ldemul_syslib($3); }
        |
@@ -877,9 +866,9 @@ low_level_library:
 
 floating_point_support:
                FLOAT
-                       { lang_float(TRUE); }
+                       { lang_float(true); }
        |       NOFLOAT
-                       { lang_float(FALSE); }
+                       { lang_float(false); }
        ;
 
 nocrossref_list:
@@ -907,9 +896,13 @@ nocrossref_list:
                }
        ;
 
-mustbe_exp:             { ldlex_expression (); }
+paren_script_name:     { ldlex_script (); }
+               '(' NAME ')'
+                       { ldlex_popstate (); $$ = $3; }
+
+mustbe_exp:            { ldlex_expression (); }
                exp
-                        { ldlex_popstate (); $$=$2;}
+                       { ldlex_popstate (); $$ = $2; }
        ;
 
 exp    :
@@ -971,14 +964,14 @@ exp       :
        |       SIZEOF_HEADERS
                        { $$ = exp_nameop (SIZEOF_HEADERS,0); }
 
-       |       ALIGNOF '(' NAME ')'
-                       { $$ = exp_nameop (ALIGNOF,$3); }
-       |       SIZEOF '(' NAME ')'
-                       { $$ = exp_nameop (SIZEOF,$3); }
-       |       ADDR '(' NAME ')'
-                       { $$ = exp_nameop (ADDR,$3); }
-       |       LOADADDR '(' NAME ')'
-                       { $$ = exp_nameop (LOADADDR,$3); }
+       |       ALIGNOF paren_script_name
+                       { $$ = exp_nameop (ALIGNOF, $2); }
+       |       SIZEOF  paren_script_name
+                       { $$ = exp_nameop (SIZEOF, $2); }
+       |       ADDR    paren_script_name
+                       { $$ = exp_nameop (ADDR, $2); }
+       |       LOADADDR paren_script_name
+                       { $$ = exp_nameop (LOADADDR, $2); }
        |       CONSTANT '(' NAME ')'
                        { $$ = exp_nameop (CONSTANT,$3); }
        |       ABSOLUTE '(' exp ')'
@@ -993,15 +986,16 @@ exp       :
                        { $$ = exp_binop (DATA_SEGMENT_RELRO_END, $5, $3); }
        |       DATA_SEGMENT_END '(' exp ')'
                        { $$ = exp_unop (DATA_SEGMENT_END, $3); }
-       |       SEGMENT_START '(' NAME ',' exp ')'
+       |       SEGMENT_START { ldlex_script (); } '(' NAME
+                       { ldlex_popstate (); } ',' exp ')'
                        { /* The operands to the expression node are
                             placed in the opposite order from the way
                             in which they appear in the script as
                             that allows us to reuse more code in
                             fold_binary.  */
                          $$ = exp_binop (SEGMENT_START,
-                                         $5,
-                                         exp_nameop (NAME, $3)); }
+                                         $7,
+                                         exp_nameop (NAME, $4)); }
        |       BLOCK '(' exp ')'
                        { $$ = exp_unop (ALIGN_K,$3); }
        |       NAME
@@ -1012,10 +1006,10 @@ exp     :
                        { $$ = exp_binop (MIN_K, $3, $5 ); }
        |       ASSERT_K '(' exp ',' NAME ')'
                        { $$ = exp_assert ($3, $5); }
-       |       ORIGIN '(' NAME ')'
-                       { $$ = exp_nameop (ORIGIN, $3); }
-       |       LENGTH '(' NAME ')'
-                       { $$ = exp_nameop (LENGTH, $3); }
+       |       ORIGIN paren_script_name
+                       { $$ = exp_nameop (ORIGIN, $2); }
+       |       LENGTH paren_script_name
+                       { $$ = exp_nameop (LENGTH, $2); }
        |       LOG2CEIL '(' exp ')'
                        { $$ = exp_unop (LOG2CEIL, $3); }
        ;
@@ -1053,61 +1047,81 @@ sect_constraint:
        |       { $$ = 0; }
        ;
 
-section:       NAME            { ldlex_expression(); }
+section:       NAME
+                       { ldlex_expression(); }
                opt_exp_with_type
                opt_at
                opt_align
                opt_align_with_input
-               opt_subalign    { ldlex_popstate (); ldlex_script (); }
+               opt_subalign
                sect_constraint
-               '{'
                        {
-                         lang_enter_output_section_statement($1, $3,
-                                                             sectype,
-                                                             $5, $7, $4, $9, $6);
+                         ldlex_popstate ();
+                         ldlex_wild ();
+                         lang_enter_output_section_statement($1, $3, sectype,
+                                                             $5, $7, $4,
+                                                             $8, $6);
                        }
+               '{'
                statement_list_opt
-               '}' { ldlex_popstate (); ldlex_expression (); }
+               '}'
+                       { ldlex_popstate (); }
                memspec_opt memspec_at_opt phdr_opt fill_opt
-               {
-                 ldlex_popstate ();
-                 lang_leave_output_section_statement ($18, $15, $17, $16);
-               }
+                       {
+                         /* fill_opt may have switched the lexer into
+                            expression state, and back again, but in
+                            order to find the end of the fill
+                            expression the parser must look ahead one
+                            token.  If it is a NAME, throw it away as
+                            it will have been lexed in the wrong
+                            state.  */
+                         if (yychar == NAME)
+                           {
+                             yyclearin;
+                             ldlex_backup ();
+                           }
+                         lang_leave_output_section_statement ($17, $14,
+                                                              $16, $15);
+                       }
                opt_comma
-               {}
        |       OVERLAY
                        { ldlex_expression (); }
                opt_exp_without_type opt_nocrossrefs opt_at opt_subalign
-                       { ldlex_popstate (); ldlex_script (); }
+                       { ldlex_popstate (); }
                '{'
                        {
                          lang_enter_overlay ($3, $6);
                        }
                overlay_section
                '}'
-                       { ldlex_popstate (); ldlex_expression (); }
                memspec_opt memspec_at_opt phdr_opt fill_opt
                        {
-                         ldlex_popstate ();
+                         if (yychar == NAME)
+                           {
+                             yyclearin;
+                             ldlex_backup ();
+                           }
                          lang_leave_overlay ($5, (int) $4,
-                                             $16, $13, $15, $14);
+                                             $15, $12, $14, $13);
                        }
                opt_comma
        |       /* The GROUP case is just enough to support the gcc
                   svr3.ifile script.  It is not intended to be full
                   support.  I'm not even sure what GROUP is supposed
                   to mean.  */
-               GROUP { ldlex_expression (); }
+               GROUP
+                       { ldlex_expression (); }
                opt_exp_with_type
-               {
-                 ldlex_popstate ();
-                 lang_add_assignment (exp_assign (".", $3, FALSE));
-               }
+                       {
+                         ldlex_popstate ();
+                         lang_add_assignment (exp_assign (".", $3, false));
+                       }
                '{' sec_or_group_p1 '}'
        |       INCLUDE filename
-               { ldlex_script (); ldfile_open_command_file($2); }
+                       {
+                         ldfile_open_command_file ($2);
+                       }
                sec_or_group_p1 END
-               { ldlex_popstate (); }
        ;
 
 type:
@@ -1116,6 +1130,7 @@ type:
        |  COPY    { sectype = noalloc_section; }
        |  INFO    { sectype = noalloc_section; }
        |  OVERLAY { sectype = noalloc_section; }
+       |  READONLY { sectype = readonly_section; }
        ;
 
 atype:
@@ -1166,7 +1181,7 @@ phdr_opt:
                  n = ((struct lang_output_section_phdr_list *)
                       xmalloc (sizeof *n));
                  n->name = $3;
-                 n->used = FALSE;
+                 n->used = false;
                  n->next = $1;
                  $$ = n;
                }
@@ -1177,14 +1192,20 @@ overlay_section:
        |       overlay_section
                NAME
                        {
-                         ldlex_script ();
+                         ldlex_wild ();
                          lang_enter_overlay_section ($2);
                        }
-               '{' statement_list_opt '}'
-                       { ldlex_popstate (); ldlex_expression (); }
+               '{'
+               statement_list_opt
+               '}'
+                       { ldlex_popstate (); }
                phdr_opt fill_opt
                        {
-                         ldlex_popstate ();
+                         if (yychar == NAME)
+                           {
+                             yyclearin;
+                             ldlex_backup ();
+                           }
                          lang_leave_overlay_section ($9, $8);
                        }
                opt_comma
@@ -1241,6 +1262,10 @@ phdr_type:
                            $$ = exp_intop (0x6474e550);
                          else if (strcmp (s, "PT_GNU_STACK") == 0)
                            $$ = exp_intop (0x6474e551);
+                         else if (strcmp (s, "PT_GNU_RELRO") == 0)
+                           $$ = exp_intop (0x6474e552);
+                         else if (strcmp (s, "PT_GNU_PROPERTY") == 0)
+                           $$ = exp_intop (0x6474e553);
                          else
                            {
                              einfo (_("\
@@ -1262,9 +1287,9 @@ phdr_qualifiers:
                {
                  $$ = $3;
                  if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL)
-                   $$.filehdr = TRUE;
+                   $$.filehdr = true;
                  else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL)
-                   $$.phdrs = TRUE;
+                   $$.phdrs = true;
                  else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL)
                    $$.flags = $2;
                  else
@@ -1313,7 +1338,7 @@ dynamic_list_node:
 dynamic_list_tag:
                vers_defns ';'
                {
-                 lang_append_dynamic_list ($1);
+                 lang_append_dynamic_list (current_dynamic_list_p, $1);
                }
        ;
 
@@ -1400,19 +1425,19 @@ vers_tag:
 vers_defns:
                VERS_IDENTIFIER
                {
-                 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, FALSE);
+                 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, false);
                }
        |       NAME
                {
-                 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, TRUE);
+                 $$ = lang_new_vers_pattern (NULL, $1, ldgram_vers_current_lang, true);
                }
        |       vers_defns ';' VERS_IDENTIFIER
                {
-                 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, FALSE);
+                 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, false);
                }
        |       vers_defns ';' NAME
                {
-                 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, TRUE);
+                 $$ = lang_new_vers_pattern ($1, $3, ldgram_vers_current_lang, true);
                }
        |       vers_defns ';' EXTERN NAME '{'
                        {
@@ -1439,27 +1464,27 @@ vers_defns:
                        }
        |       GLOBAL
                {
-                 $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, FALSE);
+                 $$ = lang_new_vers_pattern (NULL, "global", ldgram_vers_current_lang, false);
                }
        |       vers_defns ';' GLOBAL
                {
-                 $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, FALSE);
+                 $$ = lang_new_vers_pattern ($1, "global", ldgram_vers_current_lang, false);
                }
        |       LOCAL
                {
-                 $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, FALSE);
+                 $$ = lang_new_vers_pattern (NULL, "local", ldgram_vers_current_lang, false);
                }
        |       vers_defns ';' LOCAL
                {
-                 $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, FALSE);
+                 $$ = lang_new_vers_pattern ($1, "local", ldgram_vers_current_lang, false);
                }
        |       EXTERN
                {
-                 $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, FALSE);
+                 $$ = lang_new_vers_pattern (NULL, "extern", ldgram_vers_current_lang, false);
                }
        |       vers_defns ';' EXTERN
                {
-                 $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, FALSE);
+                 $$ = lang_new_vers_pattern ($1, "extern", ldgram_vers_current_lang, false);
                }
        ;
 
@@ -1477,7 +1502,7 @@ yyerror(arg)
     einfo (_("%P:%s: file format not recognized; treating as linker script\n"),
           ldlex_filename ());
   if (error_index > 0 && error_index < ERROR_NAME_MAX)
-    einfo ("%P%F:%pS: %s in %s\n", NULL, arg, error_names[error_index - 1]);
+    einfo ("%F%P:%pS: %s in %s\n", NULL, arg, error_names[error_index - 1]);
   else
-    einfo ("%P%F:%pS: %s\n", NULL, arg);
+    einfo ("%F%P:%pS: %s\n", NULL, arg);
 }