[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
Mon Aug 7 23:48:05 PDT 2023


lkail created this revision.
lkail added reviewers: PowerPC, MaskRay.
Herald added subscribers: shchenz, kbarton, arichardson, nemanjai, emaste.
Herald added a project: All.
lkail requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157365

Files:
  lld/ELF/Arch/PPC64.cpp


Index: lld/ELF/Arch/PPC64.cpp
===================================================================
--- lld/ELF/Arch/PPC64.cpp
+++ lld/ELF/Arch/PPC64.cpp
@@ -1220,8 +1220,8 @@
   case R_PPC64_ADDR14: {
     checkAlignment(loc, val, 4, rel);
     // Preserve the AA/LK bits in the branch instruction
-    uint8_t aalk = loc[3];
-    write16(loc + 2, (aalk & 3) | (val & 0xfffc));
+    uint8_t aalk = loc[config->isLE ? 0 : 3];
+    write16(config->isLE ? loc : loc + 2, (aalk & 3) | (val & 0xfffc));
     break;
   }
   case R_PPC64_ADDR16:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157365.548076.patch
Type: text/x-patch
Size: 538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230808/82da43c6/attachment.bin>


More information about the llvm-commits mailing list