binutils/testsuite/
[deliverable/binutils-gdb.git] / ld / ldlex.l
index 013c07e473afa49044779c0aeee34809152eb499..1695c278a46014212803422df73089f4f9f616b4 100644 (file)
@@ -2,9 +2,7 @@
 
 %{
 
-/* Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+/* Copyright 1991-2013 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support.
 
    This file is part of the GNU Binutils.
@@ -68,6 +66,7 @@ const char *lex_string = NULL;
 static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH];
 static const char *file_name_stack[MAX_INCLUDE_DEPTH];
 static unsigned int lineno_stack[MAX_INCLUDE_DEPTH];
+static unsigned int sysrooted_stack[MAX_INCLUDE_DEPTH];
 static unsigned int include_stack_ptr = 0;
 static int vers_node_nesting = 0;
 
@@ -258,6 +257,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
 <EXPRESSION,BOTH,SCRIPT>"ALIGNOF"      { RTOKEN(ALIGNOF); }
 <EXPRESSION,BOTH>"MAX"                 { RTOKEN(MAX_K); }
 <EXPRESSION,BOTH>"MIN"                 { RTOKEN(MIN_K); }
+<EXPRESSION,BOTH>"LOG2CEIL"            { RTOKEN(LOG2CEIL); }
 <EXPRESSION,BOTH,SCRIPT>"ASSERT"       { RTOKEN(ASSERT_K); }
 <BOTH,SCRIPT>"ENTRY"                   { RTOKEN(ENTRY);}
 <BOTH,SCRIPT,MRI>"EXTERN"              { RTOKEN(EXTERN);}
@@ -301,6 +301,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
 <BOTH,SCRIPT>"SORT_BY_ALIGNMENT"       { RTOKEN(SORT_BY_ALIGNMENT); }
 <BOTH,SCRIPT>"SORT"                    { RTOKEN(SORT_BY_NAME); }
 <BOTH,SCRIPT>"SORT_BY_INIT_PRIORITY"   { RTOKEN(SORT_BY_INIT_PRIORITY); }
+<BOTH,SCRIPT>"SORT_NONE"               { RTOKEN(SORT_NONE); }
 <EXPRESSION,BOTH,SCRIPT>"NOLOAD"       { RTOKEN(NOLOAD);}
 <EXPRESSION,BOTH,SCRIPT>"DSECT"                { RTOKEN(DSECT);}
 <EXPRESSION,BOTH,SCRIPT>"COPY"         { RTOKEN(COPY);}
@@ -313,10 +314,13 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
 <BOTH,SCRIPT>"org"                     { RTOKEN(ORIGIN);}
 <BOTH,SCRIPT>"l"                       { RTOKEN( LENGTH);}
 <BOTH,SCRIPT>"len"                     { RTOKEN( LENGTH);}
+<EXPRESSION,BOTH,SCRIPT>"INPUT_SECTION_FLAGS"  { RTOKEN(INPUT_SECTION_FLAGS); }
 <EXPRESSION,BOTH,SCRIPT>"INCLUDE"      { RTOKEN(INCLUDE);}
 <BOTH,SCRIPT>"PHDRS"                   { RTOKEN (PHDRS); }
 <EXPRESSION,BOTH,SCRIPT>"AT"           { RTOKEN(AT);}
+<EXPRESSION,BOTH,SCRIPT>"ALIGN_WITH_INPUT"     { RTOKEN(ALIGN_WITH_INPUT);}
 <EXPRESSION,BOTH,SCRIPT>"SUBALIGN"     { RTOKEN(SUBALIGN);}
+<EXPRESSION,BOTH,SCRIPT>"HIDDEN"       { RTOKEN(HIDDEN); }
 <EXPRESSION,BOTH,SCRIPT>"PROVIDE"      { RTOKEN(PROVIDE); }
 <EXPRESSION,BOTH,SCRIPT>"PROVIDE_HIDDEN" { RTOKEN(PROVIDE_HIDDEN); }
 <EXPRESSION,BOTH,SCRIPT>"KEEP"         { RTOKEN(KEEP); }
@@ -447,18 +451,13 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
 
 <<EOF>> {
   include_stack_ptr--;
-
   if (include_stack_ptr == 0)
-  {
     yyterminate ();
-  }
   else
-  {
     yy_switch_to_buffer (include_stack[include_stack_ptr]);
-  }
 
-  ldfile_input_filename = file_name_stack[include_stack_ptr - 1];
   lineno = lineno_stack[include_stack_ptr];
+  input_flags.sysrooted = sysrooted_stack[include_stack_ptr];
 
   return END;
 }
@@ -473,7 +472,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
    saving the current input info on the include stack.  */
 
 void
-lex_push_file (FILE *file, const char *name)
+lex_push_file (FILE *file, const char *name, unsigned int sysrooted)
 {
   if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
     {
@@ -481,10 +480,12 @@ lex_push_file (FILE *file, const char *name)
     }
   file_name_stack[include_stack_ptr] = name;
   lineno_stack[include_stack_ptr] = lineno;
+  sysrooted_stack[include_stack_ptr] = input_flags.sysrooted;
   include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
 
   include_stack_ptr++;
   lineno = 1;
+  input_flags.sysrooted = sysrooted;
   yyin = file;
   yy_switch_to_buffer (yy_create_buffer (yyin, YY_BUF_SIZE));
 }
@@ -533,7 +534,7 @@ yy_create_string_buffer (const char *string, size_t size)
    on the include stack.  */
 
 void
-lex_redirect (const char *string)
+lex_redirect (const char *string, const char *fake_filename, unsigned int count)
 {
   YY_BUFFER_STATE tmp;
 
@@ -542,11 +543,11 @@ lex_redirect (const char *string)
     {
       einfo("%F: macros nested too deeply\n");
     }
-  file_name_stack[include_stack_ptr] = "redirect";
+  file_name_stack[include_stack_ptr] = fake_filename;
   lineno_stack[include_stack_ptr] = lineno;
   include_stack[include_stack_ptr] = YY_CURRENT_BUFFER;
   include_stack_ptr++;
-  lineno = 1;
+  lineno = count;
   tmp = yy_create_string_buffer (string, strlen (string));
   yy_switch_to_buffer (tmp);
 }
@@ -611,6 +612,15 @@ ldlex_popstate (void)
 {
   yy_start = *(--state_stack_p);
 }
+
+/* Return the current file name, or the previous file if no file is
+   current.  */
+
+const char*
+ldlex_filename (void)
+{
+  return file_name_stack[include_stack_ptr - (include_stack_ptr != 0)];
+}
 \f
 
 /* Place up to MAX_SIZE characters in BUF and return
@@ -684,7 +694,7 @@ lex_warn_invalid (char *where, char *what)
   if (ldfile_assumed_script)
     {
       bfd_set_error (bfd_error_file_not_recognized);
-      einfo ("%F%s: file not recognized: %E\n", ldfile_input_filename);
+      einfo ("%F%s: file not recognized: %E\n", ldlex_filename ());
     }
 
   if (! ISPRINT (*what))
@@ -693,5 +703,5 @@ lex_warn_invalid (char *where, char *what)
       what = buf;
     }
 
-  einfo ("%P:%S: ignoring invalid character `%s'%s\n", what, where);
+  einfo ("%P:%S: ignoring invalid character `%s'%s\n", NULL, what, where);
 }
This page took 0.02464 seconds and 4 git commands to generate.