From fb6c220ebdae893d7d955827363010342fa1afa5 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Sat, 30 Jan 2021 09:05:50 +1030 Subject: [PATCH] ld --defsym This makes --defsym support the same expressions as assignment in a script. For example, --defsym 'HIDDEN(foo=0)', will define a hidden visibility foo. * ldgram.y (defsym_expr): Use assignment rule. * ldlex.h (ldlex_defsym): Delete. * ldlex.l (DEFSYMEXP, ldlex_defsym): Delete. --- ld/ChangeLog | 6 ++++++ ld/ldgram.y | 9 +++------ ld/ldlex.h | 1 - ld/ldlex.l | 19 ++----------------- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index c5f73f8646b..a84da33f8a7 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2021-02-01 Alan Modra + + * ldgram.y (defsym_expr): Use assignment rule. + * ldlex.h (ldlex_defsym): Delete. + * ldlex.l (DEFSYMEXP, ldlex_defsym): Delete. + 2021-02-01 Alan Modra * ldgram.y (section): Call ldlex_backup. Remove empty action. diff --git a/ld/ldgram.y b/ld/ldgram.y index 08dc110f3da..5912329c778 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -176,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 */ diff --git a/ld/ldlex.h b/ld/ldlex.h index d9b36ea2702..3ce1ad44716 100644 --- a/ld/ldlex.h +++ b/ld/ldlex.h @@ -187,7 +187,6 @@ extern void ldlex_inputlist (void); extern void ldlex_mri_script (void); extern void ldlex_version_script (void); extern void ldlex_version_file (void); -extern void ldlex_defsym (void); extern void ldlex_expression (void); extern void ldlex_both (void); extern void ldlex_popstate (void); diff --git a/ld/ldlex.l b/ld/ldlex.l index 7652e8d2a29..c1b15263587 100644 --- a/ld/ldlex.l +++ b/ld/ldlex.l @@ -79,7 +79,6 @@ static void lex_warn_invalid (char *where, char *what); SCRIPT definitely in a script INPUTLIST definitely in a script, a filename-list BOTH either EXPRESSION or SCRIPT - DEFSYMEXP in an argument to -defsym MRI in an MRI script VERS_START starting a Sun style mapfile VERS_SCRIPT a Sun style mapfile @@ -107,7 +106,6 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* %s INPUTLIST %s EXPRESSION %s BOTH -%s DEFSYMEXP %s MRI %s VERS_START %s VERS_SCRIPT @@ -133,12 +131,6 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* "/*" { comment (); } -"-" { RTOKEN('-');} -"+" { RTOKEN('+');} -{SYMBOLNAMECHAR1}{SYMBOLNAMECHAR}* { yylval.name = xstrdup (yytext); - return NAME; } -"=" { RTOKEN('='); } - "$"([0-9A-Fa-f])+ { yylval.integer = bfd_scan_vma (yytext + 1, 0, 16); yylval.bigint.str = NULL; @@ -170,7 +162,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; @@ -480,7 +472,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)* } . lex_warn_invalid (" in script", yytext); -. lex_warn_invalid (" in expression", yytext); +. lex_warn_invalid (" in expression", yytext); %% @@ -609,13 +601,6 @@ ldlex_version_file (void) BEGIN (VERS_SCRIPT); } -void -ldlex_defsym (void) -{ - *(state_stack_p)++ = yy_start; - BEGIN (DEFSYMEXP); -} - void ldlex_expression (void) { -- 2.30.2