From aba16fca5de0aeb61d35c4e9261fa8feec639d94 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 10 Mar 2016 19:30:18 +0000 Subject: [PATCH] ARM: Support relative references using the PREL31 symbol variant. Differential Revision: http://reviews.llvm.org/D17937 llvm-svn: 263156 --- .../Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp | 3 +++ llvm/test/MC/ARM/symbol-variants.s | 14 ++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp index 388ce799b6ad..9001ad33b58b 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp @@ -98,6 +98,9 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target, case MCSymbolRefExpr::VK_ARM_GOT_PREL: Type = ELF::R_ARM_GOT_PREL; break; + case MCSymbolRefExpr::VK_ARM_PREL31: + Type = ELF::R_ARM_PREL31; + break; } break; case ARM::fixup_arm_blx: diff --git a/llvm/test/MC/ARM/symbol-variants.s b/llvm/test/MC/ARM/symbol-variants.s index af1bc07b5e1a..c54190587a27 100644 --- a/llvm/test/MC/ARM/symbol-variants.s +++ b/llvm/test/MC/ARM/symbol-variants.s @@ -84,8 +84,14 @@ bl f05(plt) @ CHECK: 60 R_ARM_TLS_GOTDESC f24 @ CHECK: 64 R_ARM_TLS_GOTDESC f25 +@ prel31 (relative) +.word f26(PREL31)-. +.word f27(prel31)-. +@CHECK: 68 R_ARM_PREL31 f26 +@CHECK: 6c R_ARM_PREL31 f27 + @ got_prel -.word f26(GOT_PREL) + (. - .Lsym) - ldr r3, =f27(GOT_PREL) -@ CHECK: 68 R_ARM_GOT_PREL f26 -@ CHECK: 70 R_ARM_GOT_PREL f27 +.word f28(GOT_PREL) + (. - .Lsym) + ldr r3, =f29(GOT_PREL) +@ CHECK: 70 R_ARM_GOT_PREL f28 +@ CHECK: 78 R_ARM_GOT_PREL f29