aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-01-30 09:05:50 +1030
committerAlan Modra <amodra@gmail.com>2021-02-02 01:27:12 +1030
commitfb6c220ebdae893d7d955827363010342fa1afa5 (patch)
tree72f615ae32e85635b5a6082e5839d155605b48b3 /ld
parent40726f16a8d7105761e36398054860a923d4efc9 (diff)
downloadgdb-fb6c220ebdae893d7d955827363010342fa1afa5.zip
gdb-fb6c220ebdae893d7d955827363010342fa1afa5.tar.gz
gdb-fb6c220ebdae893d7d955827363010342fa1afa5.tar.bz2
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.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/ldgram.y9
-rw-r--r--ld/ldlex.h1
-rw-r--r--ld/ldlex.l19
4 files changed, 11 insertions, 24 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index c5f73f8..a84da33 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,11 @@
2021-02-01 Alan Modra <amodra@gmail.com>
+ * ldgram.y (defsym_expr): Use assignment rule.
+ * ldlex.h (ldlex_defsym): Delete.
+ * ldlex.l (DEFSYMEXP, ldlex_defsym): Delete.
+
+2021-02-01 Alan Modra <amodra@gmail.com>
+
* ldgram.y (section): Call ldlex_backup. Remove empty action.
* ldlex.h (ldlex_backup): Declare.
* ldlex.l (<EXPRESSION>NAME): Don't use NOCFILENAMECHAR set of
diff --git a/ld/ldgram.y b/ld/ldgram.y
index 08dc110..5912329 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 d9b36ea..3ce1ad4 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 7652e8d..c1b1526 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\[\]\-\!\^\\]|::)*
<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>"/*" { comment (); }
-<DEFSYMEXP>"-" { RTOKEN('-');}
-<DEFSYMEXP>"+" { RTOKEN('+');}
-<DEFSYMEXP>{SYMBOLNAMECHAR1}{SYMBOLNAMECHAR}* { yylval.name = xstrdup (yytext);
- return NAME; }
-<DEFSYMEXP>"=" { RTOKEN('='); }
-
<MRI,EXPRESSION>"$"([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;
}
-<SCRIPT,DEFSYMEXP,MRI,BOTH,EXPRESSION>((("$"|0[xX])([0-9A-Fa-f])+)|(([0-9])+))(M|K|m|k)? {
+<SCRIPT,MRI,BOTH,EXPRESSION>((("$"|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\[\]\-\!\^\\]|::)*
}
<SCRIPT,MRI,VERS_START,VERS_SCRIPT,VERS_NODE>. lex_warn_invalid (" in script", yytext);
-<EXPRESSION,DEFSYMEXP,BOTH>. lex_warn_invalid (" in expression", yytext);
+<EXPRESSION,BOTH>. lex_warn_invalid (" in expression", yytext);
%%
@@ -610,13 +602,6 @@ ldlex_version_file (void)
}
void
-ldlex_defsym (void)
-{
- *(state_stack_p)++ = yy_start;
- BEGIN (DEFSYMEXP);
-}
-
-void
ldlex_expression (void)
{
*(state_stack_p)++ = yy_start;