Fix a 32-bit overflow issue when reading LTO-generated bitcode files whose strtab...
authorJianzhou Zhao <jianzhouzh@google.com>
Tue, 25 Aug 2020 00:36:24 +0000 (00:36 +0000)
committerJianzhou Zhao <jianzhouzh@google.com>
Wed, 26 Aug 2020 05:47:22 +0000 (05:47 +0000)
commit47849870278ce05cde03d41f03fd3a1e65ee22a6
treebb305bdedad45e3e326b8371253da84ab06cd360
parenta3ef1054fd5ba3177e2fe33d45e40de00b79f1f0
Fix a 32-bit overflow issue when reading LTO-generated bitcode files whose strtab are of size > 2^29

This happens when using -flto and -Wl,--plugin-opt=emit-llvm to create a linked LTO bitcode file, and the bitcode file has a strtab with size > 2^29.

All the issues relate to a pattern like this
  size_t x64 = y64 + z32 * C
  When z32 is >= (2^32)/C, z32 * C overflows.

Reviewed-by: MaskRay
Differential Revision: https://reviews.llvm.org/D86500
llvm/lib/Bitstream/Reader/BitstreamReader.cpp