[PATCH] D153872: [LoongArch] Emit R_LARCH_64_PCREL relocation for FK_Data_8 when IsPCRel is true
Lu Weining via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 28 20:17:18 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG42cb3c6346fc: [LoongArch] Emit R_LARCH_64_PCREL relocation for FK_Data_8 when IsPCRel is true (authored by SixWeining).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153872/new/
https://reviews.llvm.org/D153872
Files:
llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFObjectWriter.cpp
llvm/test/MC/LoongArch/Relocations/sub-expr.s
Index: llvm/test/MC/LoongArch/Relocations/sub-expr.s
===================================================================
--- /dev/null
+++ llvm/test/MC/LoongArch/Relocations/sub-expr.s
@@ -0,0 +1,28 @@
+# RUN: llvm-mc --filetype=obj --triple=loongarch64 %s -o %t
+# RUN: llvm-readobj -r %t | FileCheck %s
+
+## Check that subtraction expressions emit R_LARCH_32_PCREL and R_LARCH_64_PCREL relocations.
+
+## TODO: 1- or 2-byte data relocations are not supported for now.
+
+# CHECK: Relocations [
+# CHECK-NEXT: Section ({{.*}}) .rela.data {
+# CHECK-NEXT: 0x0 R_LARCH_64_PCREL sx 0x0
+# CHECK-NEXT: 0x8 R_LARCH_64_PCREL sy 0x0
+# CHECK-NEXT: 0x10 R_LARCH_32_PCREL sx 0x0
+# CHECK-NEXT: 0x14 R_LARCH_32_PCREL sy 0x0
+# CHECK-NEXT: }
+
+.section sx,"a"
+x:
+nop
+
+.data
+.8byte x-.
+.8byte y-.
+.4byte x-.
+.4byte y-.
+
+.section sy,"a"
+y:
+nop
Index: llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFObjectWriter.cpp
===================================================================
--- llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFObjectWriter.cpp
+++ llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFObjectWriter.cpp
@@ -59,7 +59,7 @@
case FK_Data_4:
return IsPCRel ? ELF::R_LARCH_32_PCREL : ELF::R_LARCH_32;
case FK_Data_8:
- return ELF::R_LARCH_64;
+ return IsPCRel ? ELF::R_LARCH_64_PCREL : ELF::R_LARCH_64;
case LoongArch::fixup_loongarch_b16:
return ELF::R_LARCH_B16;
case LoongArch::fixup_loongarch_b21:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153872.535610.patch
Type: text/x-patch
Size: 1479 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230629/a102acdc/attachment.bin>
More information about the llvm-commits
mailing list