[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:20 PST 2024


================
@@ -801,7 +801,7 @@ uint64_t MipsGotSection::getGlobalDynOffset(const InputFile *f,
                                             const Symbol &s) const {
   const FileGot &g = gots[f->mipsGotIndex];
   Symbol *sym = const_cast<Symbol *>(&s);
-  return g.dynTlsSymbols.lookup(sym) * config->wordsize;
+  return g.dynTlsSymbols.lookup(sym) * (uint64_t)config->wordsize;
----------------
jsji wrote:

1468948 [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::​GotSection::​getGlobalDynOffset(lld::​elf::​Symbol const &): 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