Oops. forgot to add the moved files.
[deliverable/binutils-gdb.git] / gas / read.c
index 791ca8850469104e75a790f795b72616ae49bfd1..5c96735b12c65eb900f11fcd3a2a160ca6a94375 100644 (file)
@@ -128,9 +128,9 @@ char lex_type[256] =
 char is_end_of_line[256] =
 {
 #ifdef CR_EOL
-  _, _, _, _, _, _, _, _, _, _, 99, _, _, 99, _, _,    /* @abcdefghijklmno */
+  99, _, _, _, _, _, _, _, _, _, 99, _, _, 99, _, _,   /* @abcdefghijklmno */
 #else
-  _, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, _,     /* @abcdefghijklmno */
+  99, _, _, _, _, _, _, _, _, _, 99, _, _, _, _, _,    /* @abcdefghijklmno */
 #endif
   _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,      /* */
 #ifdef TC_HPPA
@@ -487,7 +487,7 @@ read_a_source_file (name)
   buffer = input_scrub_new_file (name);
 
   listing_file (name);
-  listing_newline ("");
+  listing_newline (NULL);
   register_dependency (name);
 
   while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
@@ -602,7 +602,39 @@ read_a_source_file (name)
              c = *input_line_pointer++;
            }
          know (c != ' ');      /* No further leading whitespace. */
-         LISTING_NEWLINE ();
+
+#ifndef NO_LISTING
+         /* If listing is on, and we are expanding a macro, then give
+            the listing code the contents of the expanded line.  */
+         if (listing)
+           {
+             if ((listing & LISTING_MACEXP) && macro_nest > 0)
+               {
+                 char *copy;
+                 int len;
+
+                 /* Find the end of the current expanded macro line.  */
+                 for (s = input_line_pointer-1; *s ; ++s)
+                   if (is_end_of_line[(unsigned char) *s])
+                     break;
+
+                 /* Copy it for safe keeping.  Also give an indication of
+                    how much macro nesting is involved at this point.  */
+                 len = s - (input_line_pointer-1);
+                 copy = (char *) xmalloc (len + macro_nest + 2);
+                 memset (copy, '>', macro_nest);
+                 copy[macro_nest] = ' ';
+                 memcpy (copy + macro_nest + 1, input_line_pointer-1, len);
+                 copy[macro_nest+1+len] = '\0';
+
+                 /* Install the line with the listing facility.  */
+                 listing_newline (copy);
+               }
+             else
+               listing_newline (NULL);
+           }
+#endif
+
          /*
           * C is the 1st significant character.
           * Input_line_pointer points after that character.
@@ -1286,7 +1318,7 @@ s_align_bytes (arg)
   s_align (arg, 1);
 }
 
-/* Handle the .align pseud-op on machines where ".align 4" means align
+/* Handle the .align pseudo-op on machines where ".align 4" means align
    to a 2**4 boundary.  */
 
 void 
@@ -1519,7 +1551,8 @@ s_app_file (appfile)
       /* If this is a fake .appfile, a fake newline was inserted into
         the buffer.  Passing -2 to new_logical_line tells it to
         account for it.  */
-      new_logical_line (s, appfile ? -2 : -1);
+      int may_omit
+       = (! new_logical_line (s, appfile ? -2 : -1) && appfile);
 
       /* In MRI mode, the preprocessor may have inserted an extraneous
          backquote.  */
@@ -1529,15 +1562,18 @@ s_app_file (appfile)
        ++input_line_pointer;
 
       demand_empty_rest_of_line ();
+      if (! may_omit)
+       {
 #ifdef LISTING
-      if (listing)
-       listing_source_file (s);
+         if (listing)
+           listing_source_file (s);
 #endif
-      register_dependency (s);
-    }
+         register_dependency (s);
 #ifdef obj_app_file
-  obj_app_file (s);
+         obj_app_file (s);
 #endif
+       }
+    }
 }
 
 /* Handle the .appline pseudo-op.  This is automatically generated by
@@ -1834,11 +1870,14 @@ s_linkonce (ignore)
   demand_empty_rest_of_line ();
 }
 
-void 
-s_lcomm (needs_align)
+static void 
+s_lcomm_internal (needs_align, bytes_p)
      /* 1 if this was a ".bss" directive, which may require a 3rd argument
        (alignment); 0 if it was an ".lcomm" (2 args only)  */
      int needs_align;
+     /* 1 if the alignment value should be interpreted as the byte boundary,
+       rather than the power of 2. */
+     int bytes_p;
 {
   register char *name;
   register char c;
@@ -1933,6 +1972,20 @@ s_lcomm (needs_align)
          return;
        }
       align = get_absolute_expression ();
+      if (bytes_p)
+       {
+         /* Convert to a power of 2.  */
+         if (align != 0)
+           {
+             unsigned int i;
+
+             for (i = 0; (align & 1) == 0; align >>= 1, ++i)
+               ;
+             if (align != 1)
+               as_bad ("Alignment not a power of 2");
+             align = i;
+           }
+       }
       if (align > max_alignment)
        {
          align = max_alignment;
@@ -2008,7 +2061,20 @@ s_lcomm (needs_align)
   subseg_set (current_seg, current_subseg);
 
   demand_empty_rest_of_line ();
-}                              /* s_lcomm() */
+}                              /* s_lcomm_internal() */
+
+void
+s_lcomm (needs_align)
+     int needs_align;
+{
+  s_lcomm_internal (needs_align, 0);
+}
+
+void s_lcomm_bytes (needs_align)
+     int needs_align;
+{
+  s_lcomm_internal (needs_align, 1);
+}
 
 void 
 s_lsym (ignore)
@@ -2119,7 +2185,8 @@ get_line_sb (line)
        }
       sb_add_char (line, *input_line_pointer++);
     }
-  while (input_line_pointer < buffer_limit && *input_line_pointer == '\n')
+  while (input_line_pointer < buffer_limit
+        && is_end_of_line[(unsigned char) *input_line_pointer])
     {
       if (input_line_pointer[-1] == '\n')
        bump_line_counters ();
@@ -3174,6 +3241,31 @@ emit_expr (exp, nbytes)
   if (need_pass_2)
     return;
 
+#ifndef NO_LISTING
+#ifdef OBJ_ELF
+  /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
+     appear as a four byte positive constant in the .line section,
+     followed by a 2 byte 0xffff.  Look for that case here.  */
+  {
+    static int dwarf_line = -1;
+
+    if (strcmp (segment_name (now_seg), ".line") != 0)
+      dwarf_line = -1;
+    else if (dwarf_line >= 0
+            && nbytes == 2
+            && exp->X_op == O_constant
+            && (exp->X_add_number == -1 || exp->X_add_number == 0xffff))
+      listing_source_line ((unsigned int) dwarf_line);
+    else if (nbytes == 4
+            && exp->X_op == O_constant
+            && exp->X_add_number >= 0)
+      dwarf_line = exp->X_add_number;
+    else
+      dwarf_line = -1;
+  }
+#endif
+#endif
+
   op = exp->X_op;
 
   /* Allow `.word 0' in the absolute section.  */
@@ -4192,6 +4284,7 @@ stringer (append_zero)            /* Worker to do .ascii etc statements. */
      register int append_zero; /* 0: don't append '\0', else 1 */
 {
   register unsigned int c;
+  char *start;
 
 #ifdef md_flush_pending_output
   md_flush_pending_output ();
@@ -4221,6 +4314,7 @@ stringer (append_zero)            /* Worker to do .ascii etc statements. */
        {
        case '\"':
          ++input_line_pointer; /*->1st char of string. */
+         start = input_line_pointer;
          while (is_a_char (c = next_char_of_string ()))
            {
              FRAG_APPEND_1_CHAR (c);
@@ -4230,6 +4324,24 @@ stringer (append_zero)           /* Worker to do .ascii etc statements. */
              FRAG_APPEND_1_CHAR (0);
            }
          know (input_line_pointer[-1] == '\"');
+
+#ifndef NO_LISTING
+#ifdef OBJ_ELF
+         /* In ELF, when gcc is emitting DWARF 1 debugging output, it
+             will emit .string with a filename in the .debug_sfnames
+             section to indicate a file name.  I don't know if this
+             will work for compilers other than gcc, and I don't know
+             if it will work for DWARF 2.  */
+         if (strcmp (segment_name (now_seg), ".debug_sfnames") == 0)
+           {
+             c = input_line_pointer[-1];
+             input_line_pointer[-1] = '\0';
+             listing_source_file (start);
+             input_line_pointer[-1] = c;
+           }
+#endif
+#endif
+
          break;
        case '<':
          input_line_pointer++;
This page took 0.025602 seconds and 4 git commands to generate.