Commit e258ad51 authored by Georgii Rymar's avatar Georgii Rymar
Browse files

[Object/ELF] - Fix a position calculation expression in ELFFile<ELFT>::getEntry().

It fixes now what 1c991f90 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.
parent aafd65ad
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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" +