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

Georgii Rymar via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 4 02:44:50 PDT 2020


Author: Georgii Rymar
Date: 2020-08-04T12:44:26+03:00
New Revision: 4e4243848ece311d982d3fe5550b555e26709f9a

URL: https://github.com/llvm/llvm-project/commit/4e4243848ece311d982d3fe5550b555e26709f9a
DIFF: https://github.com/llvm/llvm-project/commit/4e4243848ece311d982d3fe5550b555e26709f9a.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/tools/llvm-readobj/ELFDumper.cpp

Removed: 
    


################################################################################
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<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;
 }
 


        


More information about the llvm-commits mailing list