diff --git a/ld/ldfile.c b/ld/ldfile.c index 43b1116b1d5..22271fd6810 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -193,7 +193,7 @@ ldfile_try_open_bfd (const char *attempt, ldfile_assumed_script = true; parser_input = input_selected; - ldlex_both (); + ldlex_script (); token = INPUT_SCRIPT; while (token != 0) { diff --git a/ld/ldgram.y b/ld/ldgram.y index 77442818587..4910e17ab4a 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -297,9 +297,9 @@ extern_name_list_body: ; script_file: - { ldlex_both(); } + { ldlex_script (); } ifile_list - { ldlex_popstate(); } + { ldlex_popstate (); } ; ifile_list: @@ -1021,10 +1021,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); } ; @@ -1069,50 +1069,38 @@ section: NAME opt_align opt_align_with_input opt_subalign - { ldlex_popstate (); ldlex_script (); } sect_constraint - '{' { + ldlex_popstate (); + ldlex_wild (); lang_enter_output_section_statement($1, $3, sectype, $5, $7, $4, - $9, $6); + $8, $6); } + '{' statement_list_opt '}' - { ldlex_popstate (); ldlex_expression (); } + { ldlex_popstate (); } memspec_opt memspec_at_opt phdr_opt fill_opt { - if (yychar == NAME) - { - yyclearin; - ldlex_backup (); - } - ldlex_popstate (); - lang_leave_output_section_statement ($18, $15, - $17, $16); + 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 { - if (yychar == NAME) - { - yyclearin; - ldlex_backup (); - } - ldlex_popstate (); 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 @@ -1204,18 +1192,15 @@ overlay_section: | overlay_section NAME { + ldlex_wild (); lang_enter_overlay_section ($2); } - '{' statement_list_opt '}' - { ldlex_expression (); } + '{' + statement_list_opt + '}' + { ldlex_popstate (); } phdr_opt fill_opt { - if (yychar == NAME) - { - yyclearin; - ldlex_backup (); - } - ldlex_popstate (); lang_leave_overlay_section ($9, $8); } opt_comma diff --git a/ld/ldlex.h b/ld/ldlex.h index 9707d57caf8..04ee0e40dc1 100644 --- a/ld/ldlex.h +++ b/ld/ldlex.h @@ -191,7 +191,7 @@ extern void ldlex_mri_script (void); extern void ldlex_version_script (void); extern void ldlex_version_file (void); extern void ldlex_expression (void); -extern void ldlex_both (void); +extern void ldlex_wild (void); extern void ldlex_popstate (void); extern void ldlex_backup (void); extern const char* ldlex_filename (void); diff --git a/ld/ldlex.l b/ld/ldlex.l index f588bd3adc5..dfe8382d0bb 100644 --- a/ld/ldlex.l +++ b/ld/ldlex.l @@ -75,11 +75,12 @@ static void comment (void); static void lex_warn_invalid (char *where, char *what); /* STATES - EXPRESSION definitely in an expression - SCRIPT definitely in a script - INPUTLIST definitely in a script, a filename-list - BOTH either EXPRESSION or SCRIPT + EXPRESSION in an expression + SCRIPT in a script + INPUTLIST in a script, a filename-list MRI in an MRI script + WILD inside the braces of an output section or overlay, + for input section wildcards VERS_START starting a Sun style mapfile VERS_SCRIPT a Sun style mapfile VERS_NODE a node within a Sun style mapfile @@ -105,8 +106,8 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* %s SCRIPT %s INPUTLIST %s EXPRESSION -%s BOTH %s MRI +%s WILD %s VERS_START %s VERS_SCRIPT %s VERS_NODE @@ -128,8 +129,8 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* } } -"/*" { comment (); } - +"/*" { + comment (); } "$"([0-9A-Fa-f])+ { yylval.integer = bfd_scan_vma (yytext + 1, 0, 16); @@ -162,7 +163,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* yylval.bigint.str = NULL; return INT; } -((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? { +((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? { char *s = yytext; int ibase = 0; @@ -191,133 +192,134 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* } return INT; } -"]" { RTOKEN(']');} -"[" { RTOKEN('[');} -"<<=" { RTOKEN(LSHIFTEQ);} -">>=" { RTOKEN(RSHIFTEQ);} -"||" { RTOKEN(OROR);} -"==" { RTOKEN(EQ);} -"!=" { RTOKEN(NE);} -">=" { RTOKEN(GE);} -"<=" { RTOKEN(LE);} -"<<" { RTOKEN(LSHIFT);} -">>" { RTOKEN(RSHIFT);} -"+=" { RTOKEN(PLUSEQ);} -"-=" { RTOKEN(MINUSEQ);} -"*=" { RTOKEN(MULTEQ);} -"/=" { RTOKEN(DIVEQ);} -"&=" { RTOKEN(ANDEQ);} -"|=" { RTOKEN(OREQ);} -"&&" { RTOKEN(ANDAND);} -">" { RTOKEN('>');} -"," { RTOKEN(',');} -"&" { RTOKEN('&');} -"|" { RTOKEN('|');} -"~" { RTOKEN('~');} -"!" { RTOKEN('!');} -"?" { RTOKEN('?');} -"*" { RTOKEN('*');} -"+" { RTOKEN('+');} -"-" { RTOKEN('-');} -"/" { RTOKEN('/');} -"%" { RTOKEN('%');} -"<" { RTOKEN('<');} -"=" { RTOKEN('=');} -"}" { RTOKEN('}') ; } -"{" { RTOKEN('{'); } -")" { RTOKEN(')');} -"(" { RTOKEN('(');} -":" { RTOKEN(':'); } -";" { RTOKEN(';');} -"MEMORY" { RTOKEN(MEMORY);} -"REGION_ALIAS" { RTOKEN(REGION_ALIAS);} -"LD_FEATURE" { RTOKEN(LD_FEATURE);} -"ORIGIN" { RTOKEN(ORIGIN);} -"VERSION" { RTOKEN(VERSIONK);} -"BLOCK" { RTOKEN(BLOCK);} -"BIND" { RTOKEN(BIND);} -"LENGTH" { RTOKEN(LENGTH);} -"ALIGN" { RTOKEN(ALIGN_K);} -"DATA_SEGMENT_ALIGN" { RTOKEN(DATA_SEGMENT_ALIGN);} -"DATA_SEGMENT_RELRO_END" { RTOKEN(DATA_SEGMENT_RELRO_END);} -"DATA_SEGMENT_END" { RTOKEN(DATA_SEGMENT_END);} -"ADDR" { RTOKEN(ADDR);} -"LOADADDR" { RTOKEN(LOADADDR);} -"ALIGNOF" { RTOKEN(ALIGNOF); } -"MAX" { RTOKEN(MAX_K); } -"MIN" { RTOKEN(MIN_K); } -"LOG2CEIL" { RTOKEN(LOG2CEIL); } -"ASSERT" { RTOKEN(ASSERT_K); } -"ENTRY" { RTOKEN(ENTRY);} -"EXTERN" { RTOKEN(EXTERN);} -"NEXT" { RTOKEN(NEXT);} -"sizeof_headers" { RTOKEN(SIZEOF_HEADERS);} -"SIZEOF_HEADERS" { RTOKEN(SIZEOF_HEADERS);} -"SEGMENT_START" { RTOKEN(SEGMENT_START);} -"MAP" { RTOKEN(MAP);} -"SIZEOF" { RTOKEN(SIZEOF);} -"TARGET" { RTOKEN(TARGET_K);} -"SEARCH_DIR" { RTOKEN(SEARCH_DIR);} -"OUTPUT" { RTOKEN(OUTPUT);} -"INPUT" { RTOKEN(INPUT);} -"GROUP" { RTOKEN(GROUP);} -"AS_NEEDED" { RTOKEN(AS_NEEDED);} -"DEFINED" { RTOKEN(DEFINED);} -"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);} -"AFTER" { RTOKEN(AFTER);} -"BEFORE" { RTOKEN(BEFORE);} -"FILL" { RTOKEN(FILL);} -"STARTUP" { RTOKEN(STARTUP);} -"OUTPUT_FORMAT" { RTOKEN(OUTPUT_FORMAT);} -"OUTPUT_ARCH" { RTOKEN( OUTPUT_ARCH);} -"HLL" { RTOKEN(HLL);} -"SYSLIB" { RTOKEN(SYSLIB);} -"FLOAT" { RTOKEN(FLOAT);} -"QUAD" { RTOKEN( QUAD);} -"SQUAD" { RTOKEN( SQUAD);} -"LONG" { RTOKEN( LONG);} -"SHORT" { RTOKEN( SHORT);} -"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); } -"SORT" { RTOKEN(SORT_BY_NAME); } -"SORT_BY_INIT_PRIORITY" { RTOKEN(SORT_BY_INIT_PRIORITY); } -"SORT_NONE" { RTOKEN(SORT_NONE); } -"NOLOAD" { RTOKEN(NOLOAD);} -"READONLY" { RTOKEN(READONLY);} -"DSECT" { RTOKEN(DSECT);} -"COPY" { RTOKEN(COPY);} -"INFO" { RTOKEN(INFO);} -"OVERLAY" { RTOKEN(OVERLAY);} -"ONLY_IF_RO" { RTOKEN(ONLY_IF_RO); } -"ONLY_IF_RW" { RTOKEN(ONLY_IF_RW); } -"SPECIAL" { RTOKEN(SPECIAL); } -"o" { RTOKEN(ORIGIN);} -"org" { RTOKEN(ORIGIN);} -"l" { RTOKEN( LENGTH);} -"len" { RTOKEN( LENGTH);} -"INPUT_SECTION_FLAGS" { RTOKEN(INPUT_SECTION_FLAGS); } -"INCLUDE" { RTOKEN(INCLUDE);} -"PHDRS" { RTOKEN (PHDRS); } -"AT" { RTOKEN(AT);} -"ALIGN_WITH_INPUT" { RTOKEN(ALIGN_WITH_INPUT);} -"SUBALIGN" { RTOKEN(SUBALIGN);} -"HIDDEN" { RTOKEN(HIDDEN); } -"PROVIDE" { RTOKEN(PROVIDE); } -"PROVIDE_HIDDEN" { RTOKEN(PROVIDE_HIDDEN); } -"KEEP" { RTOKEN(KEEP); } -"EXCLUDE_FILE" { RTOKEN(EXCLUDE_FILE); } -"CONSTANT" { RTOKEN(CONSTANT);} +"]" { RTOKEN(']');} +"[" { RTOKEN('[');} +"<<=" { RTOKEN(LSHIFTEQ);} +">>=" { RTOKEN(RSHIFTEQ);} +"||" { RTOKEN(OROR);} +"==" { RTOKEN(EQ);} +"!=" { RTOKEN(NE);} +">=" { RTOKEN(GE);} +"<=" { RTOKEN(LE);} +"<<" { RTOKEN(LSHIFT);} +">>" { RTOKEN(RSHIFT);} +"+=" { RTOKEN(PLUSEQ);} +"-=" { RTOKEN(MINUSEQ);} +"*=" { RTOKEN(MULTEQ);} +"/=" { RTOKEN(DIVEQ);} +"&=" { RTOKEN(ANDEQ);} +"|=" { RTOKEN(OREQ);} +"&&" { RTOKEN(ANDAND);} +">" { RTOKEN('>');} +"," { RTOKEN(',');} +"&" { RTOKEN('&');} +"|" { RTOKEN('|');} +"~" { RTOKEN('~');} +"!" { RTOKEN('!');} +"?" { RTOKEN('?');} +"*" { RTOKEN('*');} +"+" { RTOKEN('+');} +"-" { RTOKEN('-');} +"/" { RTOKEN('/');} +"%" { RTOKEN('%');} +"<" { RTOKEN('<');} +"=" { RTOKEN('=');} +"}" { RTOKEN('}'); } +"{" { RTOKEN('{'); } +")" { RTOKEN(')');} +"(" { RTOKEN('(');} +":" { RTOKEN(':'); } +";" { RTOKEN(';');} +