From 4e4243848ece311d982d3fe5550b555e26709f9a Mon Sep 17 00:00:00 2001 From: Georgii Rymar Date: Tue, 4 Aug 2020 12:40:10 +0300 Subject: [PATCH] [llvm-readobj] - A third attempt to fix BB. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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*> readMipsOptions(const uint8_t*, llvm::ArrayRef&, 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. --- llvm/tools/llvm-readobj/ELFDumper.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp index 19aae413acec..53ebfd5663c9 100644 --- a/llvm/tools/llvm-readobj/ELFDumper.cpp +++ b/llvm/tools/llvm-readobj/ELFDumper.cpp @@ -3356,10 +3356,11 @@ readMipsOptions(const uint8_t *SecBegin, ArrayRef &SecData, const Elf_Mips_Options *O = reinterpret_cast *>(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 &SecData, sizeof(Elf_Mips_Options) + sizeof(Elf_Mips_RegInfo); 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; }