[llvm] c4a250e - [AMDGPU][MC] Generate relative relocations for allocatable (more particularly, eh_frame) sections
Juan Manuel MARTINEZ CAAMAÑO via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 10 06:57:44 PST 2023
Author: Juan Manuel MARTINEZ CAAMAÑO
Date: 2023-02-10T15:54:43+01:00
New Revision: c4a250ecea14fda4920ddf035318b32b18bca5e5
URL: https://github.com/llvm/llvm-project/commit/c4a250ecea14fda4920ddf035318b32b18bca5e5
DIFF: https://github.com/llvm/llvm-project/commit/c4a250ecea14fda4920ddf035318b32b18bca5e5.diff
LOG: [AMDGPU][MC] Generate relative relocations for allocatable (more particularly, eh_frame) sections
Reviewed By: scott.linder
Differential Revision: https://reviews.llvm.org/D142453
Added:
llvm/test/MC/AMDGPU/cfi_reloc.s
Modified:
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
index 066b36622a16b..3f188478ca8bc 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUELFObjectWriter.cpp
@@ -74,9 +74,9 @@ unsigned AMDGPUELFObjectWriter::getRelocType(MCContext &Ctx,
return ELF::R_AMDGPU_REL32;
case FK_Data_4:
case FK_SecRel_4:
- return ELF::R_AMDGPU_ABS32;
+ return IsPCRel ? ELF::R_AMDGPU_REL32 : ELF::R_AMDGPU_ABS32;
case FK_Data_8:
- return ELF::R_AMDGPU_ABS64;
+ return IsPCRel ? ELF::R_AMDGPU_REL64 : ELF::R_AMDGPU_ABS64;
}
if (Fixup.getTargetKind() == AMDGPU::fixup_si_sopp_br) {
diff --git a/llvm/test/MC/AMDGPU/cfi_reloc.s b/llvm/test/MC/AMDGPU/cfi_reloc.s
new file mode 100644
index 0000000000000..add81a88931c8
--- /dev/null
+++ b/llvm/test/MC/AMDGPU/cfi_reloc.s
@@ -0,0 +1,16 @@
+// RUN: llvm-mc -filetype=obj -triple amdgcn-- -mcpu=kaveri -show-encoding %s | llvm-readobj -r - | FileCheck %s
+
+// CHECK: Relocations [
+// CHECK: .rel.eh_frame {
+// CHECK: R_AMDGPU_REL32 .text
+// CHECK: }
+// CHECK: .rel.debug_frame {
+// CHECK: R_AMDGPU_ABS64 .text
+// CHECK: }
+// CHECK: ]
+
+kernel:
+ .cfi_startproc
+ .cfi_sections .debug_frame, .eh_frame
+ s_endpgm
+ .cfi_endproc
\ No newline at end of file
More information about the llvm-commits
mailing list