PR28198, Support # as linker script comment marker

Message ID YROjdtlSlJ/GIbD7@squeak.grove.modra.org
State New
Headers show
Series
  • PR28198, Support # as linker script comment marker
Related show

Commit Message

Cooper Qu via Binutils Aug. 11, 2021, 10:16 a.m.
PR 28198
	* ldlex.l: Combine rules for handling newline, whitespace and
	comments.  Extend # comment handling to all states.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/ld/ldlex.l b/ld/ldlex.l
index 25b4bcaae01..f588bd3adc5 100644
--- a/ld/ldlex.l
+++ b/ld/ldlex.l
@@ -420,8 +420,13 @@  V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
 					yylval.name[len] = 0;
 					return NAME;
 				}
-<BOTH,SCRIPT,EXPRESSION>"\n"		{ lineno++;}
-<MRI,BOTH,SCRIPT,EXPRESSION>[ \t\r]+	{ }
+
+<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>"\n" {
+				lineno++; }
+<MRI,BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>[ \t\r]+ {
+				/* Eat up whitespace */ }
+<BOTH,SCRIPT,EXPRESSION,VERS_START,VERS_NODE,VERS_SCRIPT>#.* {
+				/* Eat up comments */ }
 
 <VERS_NODE,VERS_SCRIPT>[:,;]	{ return *yytext; }
 
@@ -450,12 +455,6 @@  V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
 				  return *yytext;
 				}
 
-<VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>[\n]	{ lineno++; }
-
-<VERS_START,VERS_NODE,VERS_SCRIPT>#.*		{ /* Eat up comments */ }
-
-<VERS_START,VERS_NODE,VERS_SCRIPT,INPUTLIST>[ \t\r]+	{ /* Eat up whitespace */ }
-
 <<EOF>> {
   include_stack_ptr--;
   if (include_stack_ptr == 0)