diff options
author | Alan Modra <amodra@gmail.com> | 2022-02-16 13:11:55 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-02-16 22:05:24 +1030 |
commit | 19f7966ede4658568e273c6786e2dad73c2223e1 (patch) | |
tree | 09632187cfc3a869120841aca97c52d7d962066b /gas/expr.c | |
parent | 969f6a63c0ae7779fd5eb10af25fd4ab810feef8 (diff) | |
download | binutils-gdb-19f7966ede4658568e273c6786e2dad73c2223e1.tar.gz |
gas local label and dollar label handling
Much of the gas source and older BFD source use "long" for function
parameters and variables, when other types would be more appropriate.
This patch fixes one of those cases. Dollar labels and numeric local
labels do not need large numbers. Small positive itegers are usually
all that is required. Due to allowing longs, it was possible for
fb_label_name and dollar_label_name to overflow their buffers.
* symbols.c: Delete unnecessary forward declarations.
(dollar_labels, dollar_label_instances): Use unsigned int.
(dollar_label_defined, dollar_label_instance): Likewise.
(define_dollar_label): Likewise.
(fb_low_counter, fb_labels, fb_label_instances): Likewise.
(fb_label_instance_inc, fb_label_instance): Likewise.
(fb_label_count, fb_label_max): Make them size_t.
(dollar_label_name, fb_label_name): Rewrite using sprintf.
* symbols.h (dollar_label_defined): Update prototype.
(define_dollar_label, dollar_label_name): Likewise.
(fb_label_instance_inc, fb_label_name): Likewise.
* config/bfin-lex.l (yylex): Remove unnecessary casts.
* expr.c (integer_constant): Likewise.
* read.c (read_a_source_file): Limit numeric label range to int.
Diffstat (limited to 'gas/expr.c')
-rw-r--r-- | gas/expr.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gas/expr.c b/gas/expr.c index 1e97a83f27b..bd5b9e70a4a 100644 --- a/gas/expr.c +++ b/gas/expr.c @@ -567,7 +567,7 @@ integer_constant (int radix, expressionS *expressionP) /* Backward ref to local label. Because it is backward, expect it to be defined. */ /* Construct a local label. */ - name = fb_label_name ((int) number, 0); + name = fb_label_name (number, 0); /* Seen before, or symbol is defined: OK. */ symbolP = symbol_find (name); @@ -601,7 +601,7 @@ integer_constant (int radix, expressionS *expressionP) Construct a local label name, then an undefined symbol. Don't create a xseg frag for it: caller may do that. Just return it as never seen before. */ - name = fb_label_name ((int) number, 1); + name = fb_label_name (number, 1); symbolP = symbol_find_or_make (name); /* We have no need to check symbol properties. */ #ifndef many_segments @@ -620,15 +620,15 @@ integer_constant (int radix, expressionS *expressionP) then this is a fresh instantiation of that number, so create it. */ - if (dollar_label_defined ((long) number)) + if (dollar_label_defined (number)) { - name = dollar_label_name ((long) number, 0); + name = dollar_label_name (number, 0); symbolP = symbol_find (name); know (symbolP != NULL); } else { - name = dollar_label_name ((long) number, 1); + name = dollar_label_name (number, 1); symbolP = symbol_find_or_make (name); } |