mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-09 04:21:49 +08:00
Riscv ld-elf/stab failure and fake label cleanup.
* 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.
This commit is contained in:
parent
2ca23e65f5
commit
2469b3c584
@ -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.
|
||||
|
||||
|
5
gas/as.c
5
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
|
||||
|
@ -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)
|
||||
|
10
gas/ecoff.c
10
gas/ecoff.c
@ -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,
|
||||
|
@ -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++;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 (".");
|
||||
|
3
gas/testsuite/gas/all/err-fakelabel.s
Normal file
3
gas/testsuite/gas/all/err-fakelabel.s
Normal file
@ -0,0 +1,3 @@
|
||||
;# Test that fake labels aren't accepted.
|
||||
;# { dg-do assemble }
|
||||
label: ;# { dg-error "Error: " }
|
@ -27,6 +27,12 @@
|
||||
#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"
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user