[PATCH] D134715: [LoongArch] Produce a R_LARCH_32_PCREL relocation
Ray Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 27 01:12:09 PDT 2022
wangleiat created this revision.
wangleiat added reviewers: SixWeining, xen0n, xry111, gonglingqin, MaskRay.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
wangleiat requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
LoongArchELFObjectWriter::getRelocType check IsPCRel for FK_Data_4
(which we produce a R_LARCH_32_PCREL relocation for if IsPCRel).
R_LARCH_32_PCREL is required for FDE relocation.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134715
Files:
llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFObjectWriter.cpp
llvm/test/MC/LoongArch/Relocations/fde-reloc.s
Index: llvm/test/MC/LoongArch/Relocations/fde-reloc.s
===================================================================
--- /dev/null
+++ llvm/test/MC/LoongArch/Relocations/fde-reloc.s
@@ -0,0 +1,14 @@
+# RUN: llvm-mc --filetype=obj --triple=loongarch64 < %s \
+# RUN: | llvm-readobj -r - | FileCheck %s
+
+## Ensure that the eh_frame records the symbolic difference with
+## the R_LARCH_32_PCREL relocation.
+
+func:
+ .cfi_startproc
+ ret
+ .cfi_endproc
+
+# CHECK: Section (4) .rela.eh_frame {
+# CHECK-NEXT: 0x1C R_LARCH_32_PCREL - 0x0
+# CHECK-NEXT: }
Index: llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFObjectWriter.cpp
===================================================================
--- llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFObjectWriter.cpp
+++ llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFObjectWriter.cpp
@@ -64,7 +64,7 @@
Ctx.reportError(Fixup.getLoc(), "2-byte data relocations not supported");
return ELF::R_LARCH_NONE;
case FK_Data_4:
- return ELF::R_LARCH_32;
+ return IsPCRel ? ELF::R_LARCH_32_PCREL : ELF::R_LARCH_32;
case FK_Data_8:
return ELF::R_LARCH_64;
case LoongArch::fixup_loongarch_b16:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134715.463139.patch
Type: text/x-patch
Size: 1182 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220927/93cc310e/attachment.bin>
More information about the llvm-commits
mailing list