[PATCH] D156953: PowerPC 32bit: Emit relocation type R_PPC_DTPREL32 for tls variablels.
Aaron Ballman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 9 11:29:19 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd00f03dd6fc7: [PPC32] Emit relocation type R_PPC_DTPREL32 for tls variables (authored by varunkumare99, committed by aaron.ballman).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156953/new/
https://reviews.llvm.org/D156953
Files:
llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
llvm/test/MC/PowerPC/ppc32-R_PPC_DTPREL32-reloc.s
Index: llvm/test/MC/PowerPC/ppc32-R_PPC_DTPREL32-reloc.s
===================================================================
--- /dev/null
+++ llvm/test/MC/PowerPC/ppc32-R_PPC_DTPREL32-reloc.s
@@ -0,0 +1,50 @@
+# RUN: llvm-mc -filetype=obj -triple=ppc %s -o %t
+# RUN: llvm-readelf -r %t | FileCheck %s
+
+# CHECK: Relocation section '.rela.debug_info' at offset 0xf8 contains 1 entries:
+# CHECK-NEXT: Offset Info Type Sym. Value Symbol's Name + Addend
+# CHECK-NEXT: 00000000 0000024e R_PPC_DTPREL32 00000000 tls_rtp_var + 8000
+
+ .text
+ .globl foo # -- Begin function foo
+ .p2align 2
+ .type foo, at function
+foo: # @foo
+# %bb.0: # %entry
+ stwu 1, -16(1)
+ stw 31, 12(1)
+ mr 31, 1
+ addis 3, 2, tls_rtp_var at tprel@ha
+ addi 4, 3, tls_rtp_var at tprel@l
+ lwz 3, 0(4)
+ addi 3, 3, 1
+ stw 3, 0(4)
+ lis 4, my_global_var at ha
+ lwz 3, my_global_var at l(4)
+ addi 3, 3, 1
+ stw 3, my_global_var at l(4)
+ lwz 31, 12(1)
+ addi 1, 1, 16
+ blr
+
+ .type tls_rtp_var, at object # @tls_rtp_var
+ .section .tdata,"awT", at progbits
+ .globl tls_rtp_var
+ .p2align 2, 0x0
+tls_rtp_var:
+ .long 5 # 0x5
+ .size tls_rtp_var, 4
+
+ .type my_global_var, at object # @my_global_var
+ .data
+ .globl my_global_var
+ .p2align 2, 0x0
+my_global_var:
+ .long 7 # 0x7
+ .size my_global_var, 4
+
+ .section .debug_info,"", at progbits
+.Lcu_begin0:
+.Ldebug_info_start0:
+ .long tls_rtp_var at DTPREL+32768
+.Ldebug_info_end0:
Index: llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
===================================================================
--- llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
+++ llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
@@ -456,7 +456,13 @@
}
break;
case FK_Data_4:
- Type = ELF::R_PPC_ADDR32;
+ switch (Modifier) {
+ case MCSymbolRefExpr::VK_DTPREL:
+ Type = ELF::R_PPC_DTPREL32;
+ break;
+ default:
+ Type = ELF::R_PPC_ADDR32;
+ }
break;
case FK_Data_2:
Type = ELF::R_PPC_ADDR16;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156953.548697.patch
Type: text/x-patch
Size: 2207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230809/e877b87f/attachment.bin>
More information about the llvm-commits
mailing list