]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Riscv ld-elf/stab failure and fake label cleanup.
authorJim Wilson <jimw@sifive.com>
Wed, 22 Nov 2017 19:20:48 +0000 (11:20 -0800)
committerJim Wilson <jimw@sifive.com>
Wed, 22 Nov 2017 19:20:48 +0000 (11:20 -0800)
* as.c: Include write.h.
(common_emul_init): Use FAKE_LABEL_NAME.
* ecoff.c (add_file, ecoff_directive_end, ecoff_directive_loc):
Likewise.
(ecoff_build_symbols): Use FAKE_LABEL_CHAR.
* expr.c (get_symbol_name): Use FAKE_LABEL_CHAR.  Accept only if
input_from_string is TRUE.
* read.c (input_from_string): New.
(read_symbol_name): Use FAKE_LABEL_CHAR.  Accept only if
input_from_string is TRUE.
(temp_ilp): Set input_from_string to TRUE.
(restore_ilp): Set input_from_string to FALSE.
* read.h (input_from_string): Declare.
* symbols.c: Include write.h
(S_IS_LOCAL): Check for FAKE_LABEL_CHAR.
(symbol_relc_make_sym): Fix comment refering to default fake label
string.
* write.h (FAKE_LABEL_CHAR): New.
* config/tc-riscv.h (FAKE_LABEL_CHAR): Define.
* testsuite/gas/all/err-fakelabel.s: New.

gas/ChangeLog
gas/as.c
gas/config/tc-riscv.h
gas/ecoff.c
gas/expr.c
gas/read.c
gas/read.h
gas/symbols.c
gas/testsuite/gas/all/err-fakelabel.s [new file with mode: 0644]
gas/write.h

index 0206977006a77d32d3ce05485d4cd45962f5f478..d77e7ef6f6a736599a9ca5694a6278e3a8e2eee9 100644 (file)
@@ -1,5 +1,26 @@
 2017-11-22  Jim Wilson  <jimw@sifive.com>
 
+       * as.c: Include write.h.
+       (common_emul_init): Use FAKE_LABEL_NAME.
+       * ecoff.c (add_file, ecoff_directive_end, ecoff_directive_loc):
+       Likewise.
+       (ecoff_build_symbols): Use FAKE_LABEL_CHAR.
+       * expr.c (get_symbol_name): Use FAKE_LABEL_CHAR.  Accept only if
+       input_from_string is TRUE.
+       * read.c (input_from_string): New.
+       (read_symbol_name): Use FAKE_LABEL_CHAR.  Accept only if
+       input_from_string is TRUE.
+       (temp_ilp): Set input_from_string to TRUE.
+       (restore_ilp): Set input_from_string to FALSE.
+       * read.h (input_from_string): Declare.
+       * symbols.c: Include write.h
+       (S_IS_LOCAL): Check for FAKE_LABEL_CHAR.
+       (symbol_relc_make_sym): Fix comment refering to default fake label
+       string.
+       * write.h (FAKE_LABEL_CHAR): New.
+       * config/tc-riscv.h (FAKE_LABEL_CHAR): Define.
+       * testsuite/gas/all/err-fakelabel.s: New.
+
        * doc/as.texinfo (.align): Change some to most for text nop fill.
        (.balign, .p2align): Likewise.
 
index 31e62805af611dfed306cc90349ccdd4973bf709..fbf3257fbbf3eb2751887dc9275cfc4ca3a5b1ea 100644 (file)
--- a/gas/as.c
+++ b/gas/as.c
@@ -39,6 +39,7 @@
 #include "dwarf2dbg.h"
 #include "dw2gencfi.h"
 #include "bfdver.h"
+#include "write.h"
 
 #ifdef HAVE_ITBL_CPU
 #include "itbl-ops.h"
@@ -199,10 +200,10 @@ common_emul_init (void)
   if (this_emulation->fake_label_name == 0)
     {
       if (this_emulation->leading_underscore)
-       this_emulation->fake_label_name = "L0\001";
+       this_emulation->fake_label_name = FAKE_LABEL_NAME;
       else
        /* What other parameters should we test?  */
-       this_emulation->fake_label_name = ".L0\001";
+       this_emulation->fake_label_name = "." FAKE_LABEL_NAME;
     }
 }
 #endif
index d79d30564cac4515be834f9bfaa722a9a80120af..04ef467b148b660983268064fabef41b871c1c20 100644 (file)
@@ -39,6 +39,9 @@ struct expressionS;
    sure FAKE_LABEL_NAME is printable.  It still must be distinct from any
    real label name.  So, append a space, which other labels can't contain.  */
 #define FAKE_LABEL_NAME ".L0 "
+/* Changing the special character in FAKE_LABEL_NAME requires changing
+   FAKE_LABEL_CHAR too.  */
+#define FAKE_LABEL_CHAR ' '
 
 #define md_relax_frag(segment, fragp, stretch) \
   riscv_relax_frag (segment, fragp, stretch)
index 325c3de362168d970cde1194d8cda9bb0b786053..2ec40764071a5bc87aad8f5c0aa9762587f0719a 100644 (file)
@@ -2227,7 +2227,7 @@ add_file (const char *file_name, int indx ATTRIBUTE_UNUSED, int fake)
   if (stabs_seen)
     {
       (void) add_ecoff_symbol (file_name, st_Nil, sc_Nil,
-                              symbol_new ("L0\001", now_seg,
+                              symbol_new (FAKE_LABEL_NAME, now_seg,
                                           (valueT) frag_now_fix (),
                                           frag_now),
                               (bfd_vma) 0, 0, ECOFF_MARK_STAB (N_SOL));
@@ -3020,7 +3020,7 @@ ecoff_directive_end (int ignore ATTRIBUTE_UNUSED)
     as_warn (_(".end directive names unknown symbol"));
   else
     (void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text,
-                            symbol_new ("L0\001", now_seg,
+                            symbol_new (FAKE_LABEL_NAME, now_seg,
                                         (valueT) frag_now_fix (),
                                         frag_now),
                             (bfd_vma) 0, (symint_t) 0, (symint_t) 0);
@@ -3264,7 +3264,7 @@ ecoff_directive_loc (int ignore ATTRIBUTE_UNUSED)
   if (stabs_seen)
     {
       (void) add_ecoff_symbol ((char *) NULL, st_Label, sc_Text,
-                              symbol_new ("L0\001", now_seg,
+                              symbol_new (FAKE_LABEL_NAME, now_seg,
                                           (valueT) frag_now_fix (),
                                           frag_now),
                               (bfd_vma) 0, 0, lineno);
@@ -4104,10 +4104,10 @@ ecoff_build_symbols (const struct ecoff_debug_swap *backend,
                      /* If an st_end symbol has an associated gas
                         symbol, then it is a local label created for
                         a .bend or .end directive.  Stabs line
-                        numbers will have \001 in the names.  */
+                        numbers will have FAKE_LABEL_CHAR in the names.  */
                      if (local
                          && sym_ptr->ecoff_sym.asym.st != st_End
-                         && strchr (sym_ptr->name, '\001') == 0)
+                         && strchr (sym_ptr->name, FAKE_LABEL_CHAR) == 0)
                        sym_ptr->ecoff_sym.asym.iss =
                          add_string (&fil_ptr->strings,
                                      fil_ptr->str_hash,
index 6fc707b8a593eea0441568cf46e6cf7c14d71932..fffb7f16ff90bdb4e7665f5f4746e0bbdabf3029 100644 (file)
@@ -2369,12 +2369,13 @@ get_symbol_name (char ** ilp_return)
   char c;
 
   * ilp_return = input_line_pointer;
-  /* We accept \001 in a name in case this is being called with a
+  /* We accept FAKE_LABEL_CHAR in a name in case this is being called with a
      constructed string.  */
-  if (is_name_beginner (c = *input_line_pointer++) || c == '\001')
+  if (is_name_beginner (c = *input_line_pointer++)
+      || (input_from_string && c == FAKE_LABEL_CHAR))
     {
       while (is_part_of_name (c = *input_line_pointer++)
-            || c == '\001')
+            || (input_from_string && c == FAKE_LABEL_CHAR))
        ;
       if (is_name_ender (c))
        c = *input_line_pointer++;
index afa1a168a65469a112f1ffdc7941a74bddc590c9..6247b3ff58e1cf15b99dac0f9cfd247507762c8f 100644 (file)
@@ -62,6 +62,7 @@
 #endif
 
 char *input_line_pointer;      /*->next char of source file to parse.  */
+bfd_boolean input_from_string = FALSE;
 
 #if BITS_PER_CHAR != 8
 /*  The following table is indexed by[(char)] and will break if
@@ -1684,16 +1685,16 @@ read_symbol_name (void)
       if (mbstowcs (NULL, name, len) == (size_t) -1)
        as_warn (_("symbol name not recognised in the current locale"));
     }
-  else if (is_name_beginner (c) || c == '\001')
+  else if (is_name_beginner (c) || (input_from_string && c == FAKE_LABEL_CHAR))
     {
       ptrdiff_t len;
 
       name = input_line_pointer - 1;
 
-      /* We accept \001 in a name in case this is
+      /* We accept FAKE_LABEL_CHAR in a name in case this is
         being called with a constructed string.  */
       while (is_part_of_name (c = *input_line_pointer++)
-            || c == '\001')
+            || (input_from_string && c == FAKE_LABEL_CHAR))
        ;
 
       len = (input_line_pointer - name) - 1;
@@ -6385,6 +6386,7 @@ temp_ilp (char *buf)
 
   input_line_pointer = buf;
   buffer_limit = buf + strlen (buf);
+  input_from_string = TRUE;
 }
 
 /* Restore a saved input line pointer.  */
@@ -6396,6 +6398,7 @@ restore_ilp (void)
 
   input_line_pointer = saved_ilp;
   buffer_limit = saved_limit;
+  input_from_string = FALSE;
 
   saved_ilp = NULL;
 }
index f16455d428863de58990882a6820e9c40084be0e..5bc7475484b03f6cc59a96e1acbd676420815104 100644 (file)
@@ -19,6 +19,7 @@
    02110-1301, USA.  */
 
 extern char *input_line_pointer;       /* -> char we are parsing now.  */
+extern bfd_boolean input_from_string;
 
 /* Define to make whitespace be allowed in many syntactically
    unnecessary places.  Normally undefined.  For compatibility with
index 19a1fa57283f1f97e759db85655121d0d58e4f6f..19b3dbc667eb50cf5ad9442eaffe46667d94da5d 100644 (file)
@@ -25,6 +25,7 @@
 #include "obstack.h"           /* For "symbols.h" */
 #include "subsegs.h"
 #include "struc-symbol.h"
+#include "write.h"
 
 /* This is non-zero if symbols are case sensitive, which is the
    default.  */
@@ -2161,6 +2162,9 @@ S_IS_LOCAL (symbolS *s)
          && ! S_IS_DEBUG (s)
          && (strchr (name, DOLLAR_LABEL_CHAR)
              || strchr (name, LOCAL_LABEL_CHAR)
+#if FAKE_LABEL_CHAR != DOLLAR_LABEL_CHAR
+             || strchr (name, FAKE_LABEL_CHAR)
+#endif
              || TC_LABEL_IS_LOCAL (name)
              || (! flag_keep_locals
                  && (bfd_is_local_label (stdoutput, s->bsym)
@@ -3087,7 +3091,7 @@ symbol_relc_make_sym (symbolS * sym)
       || S_GET_SEGMENT (sym) == absolute_section)
     return symbol_relc_make_expr (& sym->sy_value);
 
-  /* This may be a "fake symbol" L0\001, referring to ".".
+  /* This may be a "fake symbol", referring to ".".
      Write out a special null symbol to refer to this position.  */
   if (! strcmp (S_GET_NAME (sym), FAKE_LABEL_NAME))
     return xstrdup (".");
diff --git a/gas/testsuite/gas/all/err-fakelabel.s b/gas/testsuite/gas/all/err-fakelabel.s
new file mode 100644 (file)
index 0000000..1e87f2e
--- /dev/null
@@ -0,0 +1,3 @@
+;# Test that fake labels aren't accepted.
+;# { dg-do assemble }
+label\ 1:                        ;# { dg-error "Error: " }
index a238320d4e295c5b727eac4c69096344163bee0c..4157bc971cb06b941164299e1b711d5eb1faed7e 100644 (file)
 #define FAKE_LABEL_NAME "L0\001"
 #endif
 
+/* This is the special character used to indicate a fake symbol.  Must be
+   present in FAKE_LABEL_NAME.  */
+#ifndef FAKE_LABEL_CHAR
+#define FAKE_LABEL_CHAR '\001'
+#endif
+
 #include "bit_fix.h"
 
 /*