* [binutils-gdb] PR31120, ld-scripts/fill2 fails when bfd_vma is 32 bits
@ 2024-01-05 2:31 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2024-01-05 2:31 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c217aed574216e6af34188ac8a9bf019539e415d
commit c217aed574216e6af34188ac8a9bf019539e415d
Author: Alan Modra <amodra@gmail.com>
Date: Sun Dec 31 14:09:10 2023 +1030
PR31120, ld-scripts/fill2 fails when bfd_vma is 32 bits
The ld lexer converts strings to integers without overflow checking,
so I don't think there is any problem in truncating an integer that
exceeds the size of a bfd_vma rather than using (bfd_vma) -1.
PR 31120
* ldlex.l: Don't use bfd_scan_vma for integer conversion, use
strtoull.
Diff:
---
ld/ldlex.l | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/ld/ldlex.l b/ld/ldlex.l
index 5a771b481cc..e113c90812b 100644
--- a/ld/ldlex.l
+++ b/ld/ldlex.l
@@ -133,7 +133,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
comment (); }
<MRI,EXPRESSION>"$"([0-9A-Fa-f])+ {
- yylval.integer = bfd_scan_vma (yytext + 1, 0, 16);
+ yylval.integer = strtoull (yytext + 1, 0, 16);
yylval.bigint.str = NULL;
return INT;
}
@@ -158,8 +158,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
default:
ibase = 10;
}
- yylval.integer = bfd_scan_vma (yytext, 0,
- ibase);
+ yylval.integer = strtoull (yytext, 0, ibase);
yylval.bigint.str = NULL;
return INT;
}
@@ -172,7 +171,7 @@ V_IDENTIFIER [*?.$_a-zA-Z\[\]\-\!\^\\]([*?.$_a-zA-Z0-9\[\]\-\!\^\\]|::)*
++s;
ibase = 16;
}
- yylval.integer = bfd_scan_vma (s, 0, ibase);
+ yylval.integer = strtoull (s, 0, ibase);
yylval.bigint.str = NULL;
if (yytext[yyleng - 1] == 'M'
|| yytext[yyleng - 1] == 'm')
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-01-05 2:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-05 2:31 [binutils-gdb] PR31120, ld-scripts/fill2 fails when bfd_vma is 32 bits Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).