[lld] r289527 - [ELF] Add R_ARM_RELATIVE to relocations that can be applied to GotSection

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 13 02:42:06 PST 2016


Author: psmith
Date: Tue Dec 13 04:42:05 2016
New Revision: 289527

URL: http://llvm.org/viewvc/llvm-project?rev=289527&view=rev
Log:
[ELF] Add R_ARM_RELATIVE to relocations that can be applied to GotSection
    
When compiling -fpie and linking with the --pie option the R_ARM_GOTBREL
relocation to D is resolved by writing the value of D into the .got slot
and emitting an R_ARM_RELATIVE relocation for it.
    
This changes adds the R_ARM_RELATIVE relocation to the switch in
relocateOne() so we can process the GotSection relocation to write the
value of the variable as well as emitting the dynamic relocation.

Differential revision: https://reviews.llvm.org/D27678


Added:
    lld/trunk/test/ELF/arm-pie-relative.s   (with props)
Modified:
    lld/trunk/ELF/Target.cpp

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=289527&r1=289526&r2=289527&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Dec 13 04:42:05 2016
@@ -1739,6 +1739,7 @@ void ARMTargetInfo::relocateOne(uint8_t
   case R_ARM_GOT_BREL:
   case R_ARM_GOT_PREL:
   case R_ARM_REL32:
+  case R_ARM_RELATIVE:
   case R_ARM_TARGET1:
   case R_ARM_TARGET2:
   case R_ARM_TLS_GD32:

Added: lld/trunk/test/ELF/arm-pie-relative.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/arm-pie-relative.s?rev=289527&view=auto
==============================================================================
--- lld/trunk/test/ELF/arm-pie-relative.s (added)
+++ lld/trunk/test/ELF/arm-pie-relative.s Tue Dec 13 04:42:05 2016
@@ -0,0 +1,25 @@
+// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
+// RUN: ld.lld %t --pie -o %t2
+// RUN: llvm-readobj -r %t2 | FileCheck %s
+// RUN: llvm-objdump -s %t2 | FileCheck %s --check-prefix=GOT
+// REQUIRES: arm
+
+// Test that a R_ARM_GOT_BREL relocation with PIE results in a R_ARM_RELATIVE
+// dynamic relocation
+ .syntax unified
+ .text
+ .global _start
+_start:
+ .word sym(GOT)
+
+ .data
+ .global sym
+sym:
+ .word 0
+
+// CHECK:      Relocations [
+// CHECK-NEXT:   Section (4) .rel.dyn {
+// CHECK-NEXT:     0x2058 R_ARM_RELATIVE
+
+// GOT: Contents of section .got:
+// GOT-NEXT:  2058 00300000

Propchange: lld/trunk/test/ELF/arm-pie-relative.s
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lld/trunk/test/ELF/arm-pie-relative.s
------------------------------------------------------------------------------
    svn:keywords = Rev Date Author URL Id




More information about the llvm-commits mailing list