[lld] [LLD] Use uint64_t timestamp to overcome potential overflow (PR #81665)
Jinsong Ji via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 14:27:22 PST 2024
================
@@ -178,8 +178,9 @@ uint64_t Symbol::getGotPltVA() const {
uint64_t Symbol::getGotPltOffset() const {
if (isInIplt)
- return getPltIdx() * target->gotEntrySize;
- return (getPltIdx() + target->gotPltHeaderEntriesNum) * target->gotEntrySize;
+ return getPltIdx() * (uint64_t)target->gotEntrySize;
----------------
jsji wrote:
1468970 [Unintentional integer overflow](https://scan6.scan.coverity.com/doc/en/cov_checker_ref.html#static_checker_OVERFLOW_BEFORE_WIDEN)
The expression's value may not be what the programmer intended, because the expression is evaluated using a narrow (i.e. few bits) integer type.
In lld::elf::Symbol::getGotPltOffset(): An integer overflow occurs, with the result converted to a wider integer type ([CWE-190](http://cwe.mitre.org/data/definitions/190.html))
https://github.com/llvm/llvm-project/pull/81665
More information about the llvm-commits
mailing list