[all-commits] [llvm/llvm-project] fb8ea8: [RuntimeDyld][ELF] Fix unwanted sign extension. (#...

Alastair Houghton via All-commits all-commits at lists.llvm.org
Wed Jun 5 18:32:48 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fb8ea85987470ad82b365fb1a78bb66754f927c6
      https://github.com/llvm/llvm-project/commit/fb8ea85987470ad82b365fb1a78bb66754f927c6
  Author: Alastair Houghton <ahoughton at apple.com>
  Date:   2024-06-06 (Thu, 06 Jun 2024)

  Changed paths:
    M llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

  Log Message:
  -----------
  [RuntimeDyld][ELF] Fix unwanted sign extension. (#94482)

Casting the result of `Section.getAddressWithOffset()` goes wrong if we
are on a 32-bit platform whose addresses are regarded as signed; in that
case, just doing
```
(uint64_t)Section.getAddressWithOffset(...)
```
or
```
reinterpret_cast<uint64_t>(Section.getAddressWithOffset(...))
```
will result in sign-extension.

We use these expressions when constructing branch stubs, which is before
we know the final load address, so we can just switch to the
`Section.getLoadAddressWithOffset(...)` method instead.

Doing that is also more consistent, since when calculating relative
offsets for relocations, we use the load address anyway, so the code
currently only works because `Section.Address` is equal to
`Section.LoadAddress` at this point.

Fixes #94478.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list