[llvm-branch-commits] [llvm] 43327ba - [Object] Fix LFFile<ELFT>::getEntry on sizeof(size_t)==4 platforms

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Dec 20 10:47:07 PST 2020


Author: Fangrui Song
Date: 2020-12-20T10:39:59-08:00
New Revision: 43327ba98da138d9d87e13f65675a0b600dae018

URL: https://github.com/llvm/llvm-project/commit/43327ba98da138d9d87e13f65675a0b600dae018
DIFF: https://github.com/llvm/llvm-project/commit/43327ba98da138d9d87e13f65675a0b600dae018.diff

LOG: [Object] Fix LFFile<ELFT>::getEntry on sizeof(size_t)==4 platforms

This should fix:

Failed Tests (2):
  LLVM-Unit :: Object/./ObjectTests/ELFObjectFileTest.InvalidSymbolTest
  LLVM :: tools/llvm-readobj/ELF/relocation-errors.test

Added: 
    

Modified: 
    llvm/include/llvm/Object/ELF.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h
index 25f2df47781b..a5233bd3ac10 100644
--- a/llvm/include/llvm/Object/ELF.h
+++ b/llvm/include/llvm/Object/ELF.h
@@ -625,10 +625,11 @@ Expected<const T *> ELFFile<ELFT>::getEntry(const Elf_Shdr &Section,
 
   ArrayRef<T> Arr = *EntriesOrErr;
   if (Entry >= Arr.size())
-    return createError("can't read an entry at 0x" +
-                       Twine::utohexstr(Entry * sizeof(T)) +
-                       ": it goes past the end of the section (0x" +
-                       Twine::utohexstr(Section.sh_size) + ")");
+    return createError(
+        "can't read an entry at 0x" +
+        Twine::utohexstr(Entry * static_cast<uint64_t>(sizeof(T))) +
+        ": it goes past the end of the section (0x" +
+        Twine::utohexstr(Section.sh_size) + ")");
   return &Arr[Entry];
 }
 


        


More information about the llvm-branch-commits mailing list