[llvm-readobj] - A third attempt to fix BB.

http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/15718/steps/build%20stage%201/logs/stdio:

FAILED: /usr/bin/c++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/llvm-readobj -I/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj -Iinclude -I/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/include -march=broadwell -fPIC -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -O3     -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/ELFDumper.cpp.o -MF tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/ELFDumper.cpp.o.d -o tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/ELFDumper.cpp.o -c /home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp: In function ‘llvm::Expected<const llvm::object::Elf_Mips_Options<ELFT>*> readMipsOptions(const uint8_t*, llvm::ArrayRef<unsigned char>&, bool&)’:
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/llvm/tools/llvm-readobj/ELFDumper.cpp:3374:12: error: parse error in template argument list
     if (O->size < ExpectedSize)

Note: I played with godbolt.org and was able to catch the similar "error in template argument list" error when used gcc 4.9.0 with this code.
Fix: try to introduce a variable to store `O->size`, it helped to me in godbolt.
This commit is contained in:
Georgii Rymar 2020-08-04 12:40:10 +03:00
parent 3c7e7d40a9
commit 4e4243848e
1 changed files with 6 additions and 5 deletions

View File

@ -3356,10 +3356,11 @@ readMipsOptions(const uint8_t *SecBegin, ArrayRef<uint8_t> &SecData,
const Elf_Mips_Options<ELFT> *O =
reinterpret_cast<const Elf_Mips_Options<ELFT> *>(SecData.data());
if (O->size > SecData.size()) {
const uint8_t Size = O->size;
if (Size > SecData.size()) {
const uint64_t Offset = SecData.data() - SecBegin;
const uint64_t SecSize = Offset + SecData.size();
return createError("a descriptor of size 0x" + Twine::utohexstr(O->size) +
return createError("a descriptor of size 0x" + Twine::utohexstr(Size) +
" at offset 0x" + Twine::utohexstr(Offset) +
" goes past the end of the .MIPS.options "
"section of size 0x" +
@ -3371,14 +3372,14 @@ readMipsOptions(const uint8_t *SecBegin, ArrayRef<uint8_t> &SecData,
sizeof(Elf_Mips_Options<ELFT>) + sizeof(Elf_Mips_RegInfo<ELFT>);
if (IsSupported)
if (O->size < ExpectedSize)
if (Size < ExpectedSize)
return createError(
"a .MIPS.options entry of kind " +
Twine(getElfMipsOptionsOdkType(O->kind)) +
" has an invalid size (0x" + Twine::utohexstr(O->size) +
" has an invalid size (0x" + Twine::utohexstr(Size) +
"), the expected size is 0x" + Twine::utohexstr(ExpectedSize));
SecData = SecData.drop_front(O->size);
SecData = SecData.drop_front(Size);
return O;
}