diff options
author | Nick Clifton <nickc@redhat.com> | 2021-11-18 16:48:19 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2021-11-18 16:48:19 +0000 |
commit | 578c64a45a0e47fd0af53c77339ec0c26ef4874a (patch) | |
tree | b95f61afc34286ad08556eb14848e9ba2d0123a1 /gas/symbols.c | |
parent | 76eb8ef1ce470ca71b10fae721e32d49998d87b9 (diff) | |
download | gdb-578c64a45a0e47fd0af53c77339ec0c26ef4874a.zip gdb-578c64a45a0e47fd0af53c77339ec0c26ef4874a.tar.gz gdb-578c64a45a0e47fd0af53c77339ec0c26ef4874a.tar.bz2 |
Add multibyte character warning option to the assembler.
* as.c (parse_args): Add support for --multibyte-handling.
* as.h (multibyte_handling): Declare.
* app.c (scan_for_multibyte_characters): New function.
(do_scrub_chars): Call the new function if multibyte warning is
enabled.
* input-scrub,c (input_scrub_next_buffer): Call the multibyte
scanning function if multibyte warnings are enabled.
* symbols.c (struct symbol_flags): Add multibyte_warned bit.
(symbol_init): Call the multibyte scanning function if multibyte
symbol warnings are enabled.
(S_SET_SEGMENT): Likewise.
* NEWS: Mention the new feature.
* doc/as.texi: Document the new feature.
* testsuite/gas/all/multibyte.s: New test source file.
* testsuite/gas/all/multibyte1.d: New test driver file.
* testsuite/gas/all/multibyte1.l: New test expected output.
* testsuite/gas/all/multibyte2.d: New test driver file.
* testsuite/gas/all/multibyte2.l: New test expected output.
* testsuite/gas/all/gas.exp: Run the new tests.
Diffstat (limited to 'gas/symbols.c')
-rw-r--r-- | gas/symbols.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/gas/symbols.c b/gas/symbols.c index 3cb9425..889ec66 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -82,6 +82,10 @@ struct symbol_flags /* Whether the symbol has been marked to be removed by a .symver directive. */ unsigned int removed : 1; + + /* Set when a warning about the symbol containing multibyte characters + is generated. */ + unsigned int multibyte_warned : 1; }; /* A pointer in the symbol may point to either a complete symbol @@ -198,7 +202,7 @@ static void * symbol_entry_find (htab_t table, const char *name) { hashval_t hash = htab_hash_string (name); - symbol_entry_t needle = { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + symbol_entry_t needle = { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, hash, name, 0, 0, 0 } }; return htab_find_with_hash (table, &needle, hash); } @@ -309,6 +313,18 @@ symbol_init (symbolS *symbolP, const char *name, asection *sec, symbolP->bsym->name = name; symbolP->bsym->section = sec; + if (multibyte_handling == multibyte_warn_syms + && ! symbolP->flags.local_symbol + && sec != undefined_section + && ! symbolP->flags.multibyte_warned + && scan_for_multibyte_characters ((const unsigned char *) name, + (const unsigned char *) name + strlen (name), + false /* Do not warn. */)) + { + as_warn (_("symbol '%s' contains multibyte characters"), name); + symbolP->flags.multibyte_warned = 1; + } + S_SET_VALUE (symbolP, valu); symbol_clear_list_pointers (symbolP); @@ -2427,7 +2443,21 @@ S_SET_SEGMENT (symbolS *s, segT seg) abort (); } else - s->bsym->section = seg; + { + if (multibyte_handling == multibyte_warn_syms + && ! s->flags.local_symbol + && seg != undefined_section + && ! s->flags.multibyte_warned + && scan_for_multibyte_characters ((const unsigned char *) s->name, + (const unsigned char *) s->name + strlen (s->name), + false)) + { + as_warn (_("symbol '%s' contains multibyte characters"), s->name); + s->flags.multibyte_warned = 1; + } + + s->bsym->section = seg; + } } void |