[PATCH] D157365: [lld][PPC64] Fix location of the least significant byte when fixing up R_PPC64_ADDR14 for little-endian target

Kai Luo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 8 18:55:08 PDT 2023


lkail added inline comments.


================
Comment at: lld/ELF/Arch/PPC64.cpp:1224
+    uint8_t aalk = loc[config->isLE ? 0 : 3];
+    write16(config->isLE ? loc : loc + 2, (aalk & 3) | (val & 0xfffc));
     break;
----------------
nemanjai wrote:
> Is this backwards? Shouldn't it be offset by 2 bytes for LE?
We should agree with `aalk` is at `loc[0]` for LE. Then we should also agree with `loc[1]` contains the most significant 8-bits of the intermediate number. `write16(loc, ...)` writes `loc[0]` and `loc[1]` while `write(loc + 2, ...)` writes `loc[2]` and `loc[3]`. IIUC, when it's LE, where we want to write at should be `loc[0]` and `loc[1]`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157365/new/

https://reviews.llvm.org/D157365



More information about the llvm-commits mailing list