[llvm] e258ad5 - [Object/ELF] - Fix a position calculation expression in ELFFile<ELFT>::getEntry().
Georgii Rymar via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 5 01:49:50 PST 2020
Author: Georgii Rymar
Date: 2020-03-05T12:49:31+03:00
New Revision: e258ad51293f9c363aee8f9b990c6502dd4d14ac
URL: https://github.com/llvm/llvm-project/commit/e258ad51293f9c363aee8f9b990c6502dd4d14ac
DIFF: https://github.com/llvm/llvm-project/commit/e258ad51293f9c363aee8f9b990c6502dd4d14ac.diff
LOG: [Object/ELF] - Fix a position calculation expression in ELFFile<ELFT>::getEntry().
It fixes now what 1c991f907a43d7a56e82dd67a76514843841ed9a tried to fix.
(A test case failture on 32-bit Arch Linux)
On 32-bit hosts it still fails (because it truncates the `Pos` value to 32 bits).
It seems happens because of `sizeof` that returns `size_t`, which has a
different size on 32/64 bits hosts.
I've tested on a 32-bit host and verified that relocation-errors.test test and
other LLVM tools tests pass now.
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 eb670c3e7560..18cc7abe1cd6 100644
--- a/llvm/include/llvm/Object/ELF.h
+++ b/llvm/include/llvm/Object/ELF.h
@@ -573,7 +573,7 @@ Expected<const T *> ELFFile<ELFT>::getEntry(const Elf_Shdr *Section,
return createError("section " + getSecIndexForError(this, Section) +
" has invalid sh_entsize: expected " + Twine(sizeof(T)) +
", but got " + Twine(Section->sh_entsize));
- uint64_t Pos = Section->sh_offset + Entry * sizeof(T);
+ uint64_t Pos = Section->sh_offset + (uint64_t)Entry * sizeof(T);
if (Pos + sizeof(T) > Buf.size())
return createError("unable to access section " +
getSecIndexForError(this, Section) + " data at 0x" +
More information about the llvm-commits
mailing list