[PATCH] D46586: [ELF][PPC64] Fix getRelExpr for R_PPC64_REL32

Zaara Syeda via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 14 08:33:01 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD332252: [ELF][PPC64] Fix getRelExpr for R_PPC64_REL32 (authored by syzaara, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D46586?vs=145713&id=146620#toc

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D46586

Files:
  ELF/Arch/PPC64.cpp
  test/ELF/ppc64-relocs.s


Index: test/ELF/ppc64-relocs.s
===================================================================
--- test/ELF/ppc64-relocs.s
+++ test/ELF/ppc64-relocs.s
@@ -2,11 +2,13 @@
 
 # RUN: llvm-mc -filetype=obj -triple=powerpc64le-unknown-linux %s -o %t
 # RUN: ld.lld %t -o %t2
-# RUN: llvm-objdump -d %t2 | FileCheck %s
+# RUN: llvm-objdump -D %t2 | FileCheck %s --check-prefix=rodataLE
+# RUN: llvm-objdump -D %t2 | FileCheck %s
 
 # RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-linux %s -o %t
 # RUN: ld.lld %t -o %t2
-# RUN: llvm-objdump -d %t2 | FileCheck %s
+# RUN: llvm-objdump -D %t2 | FileCheck %s --check-prefix=rodataBE
+# RUN: llvm-objdump -D %t2 | FileCheck %s
 
 .text
 .global _start
@@ -16,9 +18,16 @@
 	li      3,42
 	sc
 
-.section        ".toc","aw"
+.section        .rodata,"a", at progbits
+        .p2align        2
+.LJTI0_0:
+        .long   .LBB0_2-.LJTI0_0
+
+.section        .toc,"aw", at progbits
 .L1:
 .quad           22, 37, 89, 47
+.LC0:
+        .tc .LJTI0_0[TC],.LJTI0_0
 
 .section .R_PPC64_TOC16_LO_DS,"ax", at progbits
 .globl .FR_PPC64_TOC16_LO_DS
@@ -130,3 +139,27 @@
 # CHECK: .FR_PPC64_ADDR16_HIGHESTA:
 # CHECK: 10010038: {{.*}} li 1, 0
 
+.section  .R_PPC64_REL32, "ax", at progbits
+.globl .FR_PPC64_REL32
+.FR_PPC64_REL32:
+  addis 5, 2, .LC0 at toc@ha
+  ld 5, .LC0 at toc@l(5)
+.LBB0_2:
+  add 3, 3, 4
+
+# rodataLE: Disassembly of section .rodata:
+# rodataLE: .rodata:
+# rodataLE: 10000190: b4 fe 00 00
+
+# rodataBE: Disassembly of section .rodata:
+# rodataBE: .rodata:
+# rodataBE: 10000190: 00 00 fe b4
+
+# Address of rodata + value stored at rodata entry
+# should equal address of LBB0_2.
+# 0x10000190 + 0xfeb4 = 0x10010044
+# CHECK: Disassembly of section .R_PPC64_REL32:
+# CHECK: .FR_PPC64_REL32:
+# CHECK: 1001003c: {{.*}} addis 5, 2, -1
+# CHECK: 10010040: {{.*}} ld 5, -32736(5)
+# CHECK: 10010044: {{.*}} add 3, 3, 4
Index: ELF/Arch/PPC64.cpp
===================================================================
--- ELF/Arch/PPC64.cpp
+++ ELF/Arch/PPC64.cpp
@@ -163,6 +163,7 @@
     return R_PPC_CALL_PLT;
   case R_PPC64_REL16_LO:
   case R_PPC64_REL16_HA:
+  case R_PPC64_REL32:
     return R_PC;
   default:
     return R_ABS;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46586.146620.patch
Type: text/x-patch
Size: 2179 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180514/7cd9eba7/attachment.bin>


More information about the llvm-commits mailing list