From edc45954721e8fb27537319dc276f0b2dddf2863 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Tue, 29 Apr 2014 13:42:02 +0000 Subject: [PATCH] Parse and create GOT_PREL relocations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207526 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCExpr.cpp | 2 ++ lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp | 6 ++++++ test/MC/ARM/symbol-variants.s | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 5a45c652660..60b14ad53ee 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -285,6 +285,8 @@ MCSymbolRefExpr::getVariantKindForName(StringRef Name) { .Case("gotoff", VK_GOTOFF) .Case("GOTPCREL", VK_GOTPCREL) .Case("gotpcrel", VK_GOTPCREL) + .Case("GOT_PREL", VK_GOTPCREL) + .Case("got_prel", VK_GOTPCREL) .Case("GOTTPOFF", VK_GOTTPOFF) .Case("gottpoff", VK_GOTTPOFF) .Case("INDNTPOFF", VK_INDNTPOFF) diff --git a/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp b/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp index a4661b1a4fb..a6f7258e651 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp @@ -91,6 +91,9 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target, case MCSymbolRefExpr::VK_GOTTPOFF: Type = ELF::R_ARM_TLS_IE32; break; + case MCSymbolRefExpr::VK_GOTPCREL: + Type = ELF::R_ARM_GOT_PREL; + break; } break; case ARM::fixup_arm_blx: @@ -167,6 +170,9 @@ unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target, case MCSymbolRefExpr::VK_GOTOFF: Type = ELF::R_ARM_GOTOFF32; break; + case MCSymbolRefExpr::VK_GOTPCREL: + Type = ELF::R_ARM_GOT_PREL; + break; case MCSymbolRefExpr::VK_ARM_TARGET1: Type = ELF::R_ARM_TARGET1; break; diff --git a/test/MC/ARM/symbol-variants.s b/test/MC/ARM/symbol-variants.s index e1036a33e31..a10fe5029e0 100644 --- a/test/MC/ARM/symbol-variants.s +++ b/test/MC/ARM/symbol-variants.s @@ -2,6 +2,7 @@ @ RUN: llvm-mc < %s -triple thumbv7-none-linux-gnueabi -filetype=obj | llvm-objdump -triple thumbv7-none-linux-gnueabi -r - | FileCheck %s --check-prefix=CHECK --check-prefix=THUMB @ CHECK-LABEL: RELOCATION RECORDS FOR [.rel.text] +.Lsym: @ empty .word f00 @@ -83,3 +84,8 @@ bl f05(plt) @ CHECK: 60 R_ARM_TLS_GOTDESC f24 @ CHECK: 64 R_ARM_TLS_GOTDESC f25 +@ 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