X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=ld%2Fldlex.l;h=ba618ecc2715bdb380752e97a919c33563042e31;hb=aefd8b33d97bded58e51d75271f99e1eaec9fb28;hp=d1621289d6ee11322defa12844308e012a059e84;hpb=eeed9cc785ca447868967e5c84dae63e9ca8e6c2;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/ldlex.l b/ld/ldlex.l index d1621289d6..ba618ecc27 100644 --- a/ld/ldlex.l +++ b/ld/ldlex.l @@ -1,8 +1,8 @@ -%option nounput +%option nounput noyywrap %{ -/* Copyright (C) 1991-2014 Free Software Foundation, Inc. +/* Copyright (C) 1991-2017 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support. This file is part of the GNU Binutils. @@ -39,9 +39,8 @@ yylex and yyparse (indirectly) both check this. */ input_type parser_input; -/* Line number in the current input file. - (FIXME Actually, it doesn't appear to get reset for each file?) */ -unsigned int lineno = 1; +/* Line number in the current input file. */ +unsigned int lineno; /* The string we are currently lexing, or NULL if we are reading a file. */ @@ -87,10 +86,6 @@ static void lex_warn_invalid (char *where, char *what); */ #define RTOKEN(x) { yylval.token = x; return x; } -/* Some versions of flex want this. */ -#ifndef yywrap -int yywrap (void) { return 1; } -#endif %} %a 4000 @@ -279,6 +274,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* "CREATE_OBJECT_SYMBOLS" { RTOKEN(CREATE_OBJECT_SYMBOLS);} "CONSTRUCTORS" { RTOKEN( CONSTRUCTORS);} "FORCE_COMMON_ALLOCATION" { RTOKEN(FORCE_COMMON_ALLOCATION);} +"FORCE_GROUP_ALLOCATION" { RTOKEN(FORCE_GROUP_ALLOCATION);} "INHIBIT_COMMON_ALLOCATION" { RTOKEN(INHIBIT_COMMON_ALLOCATION);} "SECTIONS" { RTOKEN(SECTIONS);} "INSERT" { RTOKEN(INSERT_K);} @@ -298,6 +294,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* "BYTE" { RTOKEN( BYTE);} "NOFLOAT" { RTOKEN(NOFLOAT);} "NOCROSSREFS" { RTOKEN(NOCROSSREFS);} +"NOCROSSREFS_TO" { RTOKEN(NOCROSSREFS_TO);} "OVERLAY" { RTOKEN(OVERLAY); } "SORT_BY_NAME" { RTOKEN(SORT_BY_NAME); } "SORT_BY_ALIGNMENT" { RTOKEN(SORT_BY_ALIGNMENT); } @@ -380,6 +377,11 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* return NAME; } "="{FILENAMECHAR1}{FILENAMECHAR}* { +/* Filename to be prefixed by --sysroot or when non-sysrooted, nothing. */ + yylval.name = xstrdup (yytext); + return NAME; + } +"$SYSROOT"{FILENAMECHAR1}{FILENAMECHAR}* { /* Filename to be prefixed by --sysroot or when non-sysrooted, nothing. */ yylval.name = xstrdup (yytext); return NAME; @@ -415,9 +417,15 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* "\""[^\"]*"\"" { /* No matter the state, quotes - give what's inside */ + give what's inside. */ + bfd_size_type len; yylval.name = xstrdup (yytext + 1); - yylval.name[yyleng - 2] = 0; + /* PR ld/20906. A corrupt input file + can contain bogus strings. */ + len = strlen (yylval.name); + if (len > yyleng - 2) + len = yyleng - 2; + yylval.name[len] = 0; return NAME; } "\n" { lineno++;} @@ -450,7 +458,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* return *yytext; } -[\n] { lineno++; } +[\n] { lineno++; } #.* { /* Eat up comments */ } @@ -459,7 +467,10 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* <> { include_stack_ptr--; if (include_stack_ptr == 0) - yyterminate (); + { + lineno = 0; + yyterminate (); + } else yy_switch_to_buffer (include_stack[include_stack_ptr]);