[PATCH] D61586: [mips] fix segment fault for plt on mips64.

Qiao Pengcheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 6 01:30:45 PDT 2019


QiaoPengcheng created this revision.
Herald added subscribers: llvm-commits, atanasyan, MaskRay, jrtc27, arichardson, sdardis, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
QiaoPengcheng added a project: lld.

fix segment fault for plt on mips64.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61586

Files:
  lld/ELF/Arch/Mips.cpp


Index: lld/ELF/Arch/Mips.cpp
===================================================================
--- lld/ELF/Arch/Mips.cpp
+++ lld/ELF/Arch/Mips.cpp
@@ -331,9 +331,15 @@
                                : (Config->ZHazardplt ? 0x03200408 : 0x03200008);
 
   write32<E>(Buf, 0x3c0f0000);     // lui   $15, %hi(.got.plt entry)
-  write32<E>(Buf + 4, 0x8df90000); // l[wd] $25, %lo(.got.plt entry)($15)
+  if (ELFT::Is64Bits) {
+    write32<E>(Buf + 4, 0xddf90000); // ld $25, %lo(.got.plt entry)($15)
+  } else
+    write32<E>(Buf + 4, 0x8df90000); // lw $25, %lo(.got.plt entry)($15)
   write32<E>(Buf + 8, JrInst);     // jr  $25 / jr.hb $25
-  write32<E>(Buf + 12, 0x25f80000); // addiu $24, $15, %lo(.got.plt entry)
+  if (ELFT::Is64Bits) {
+    write32<E>(Buf + 12, 0x65f80000); // daddiu $24, $15, %lo(.got.plt entry)
+  } else
+    write32<E>(Buf + 12, 0x25f80000); // addiu $24, $15, %lo(.got.plt entry)
   writeValue<E>(Buf, GotPltEntryAddr + 0x8000, 16, 16);
   writeValue<E>(Buf + 4, GotPltEntryAddr, 16, 0);
   writeValue<E>(Buf + 12, GotPltEntryAddr, 16, 0);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61586.198234.patch
Type: text/x-patch
Size: 1069 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190506/5788e46b/attachment.bin>


More information about the llvm-commits mailing list