[lld] r277369 - [ELF/ARM] Add support for R_ARM_TARGET1 relocation.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 1 12:28:13 PDT 2016
Author: davide
Date: Mon Aug 1 14:28:13 2016
New Revision: 277369
URL: http://llvm.org/viewvc/llvm-project?rev=277369&view=rev
Log:
[ELF/ARM] Add support for R_ARM_TARGET1 relocation.
Differential Revision: https://reviews.llvm.org/D22990
Added:
lld/trunk/test/ELF/arm-target1.s
Modified:
lld/trunk/ELF/Config.h
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Options.td
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=277369&r1=277368&r2=277369&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Mon Aug 1 14:28:13 2016
@@ -103,6 +103,7 @@ struct Configuration {
bool StripAll;
bool StripDebug;
bool SysvHash = true;
+ bool Target1Rel;
bool Threads;
bool Trace;
bool Verbose;
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=277369&r1=277368&r2=277369&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon Aug 1 14:28:13 2016
@@ -364,6 +364,7 @@ void LinkerDriver::readConfigs(opt::Inpu
Config->Shared = Args.hasArg(OPT_shared);
Config->StripAll = Args.hasArg(OPT_strip_all);
Config->StripDebug = Args.hasArg(OPT_strip_debug);
+ Config->Target1Rel = Args.hasArg(OPT_target1_rel);
Config->Threads = Args.hasArg(OPT_threads);
Config->Trace = Args.hasArg(OPT_trace);
Config->Verbose = Args.hasArg(OPT_verbose);
Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=277369&r1=277368&r2=277369&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Mon Aug 1 14:28:13 2016
@@ -146,6 +146,10 @@ def strip_debug: F<"strip-debug">, HelpT
def sysroot: J<"sysroot=">, HelpText<"Set the system root">;
+def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">;
+
+def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32">;
+
def threads: F<"threads">, HelpText<"Enable use of threads">;
def trace: F<"trace">, HelpText<"Print the names of the input files">;
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=277369&r1=277368&r2=277369&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Mon Aug 1 14:28:13 2016
@@ -1526,6 +1526,8 @@ RelExpr ARMTargetInfo::getRelExpr(uint32
case R_ARM_TLS_IE32:
// GOT(S) + A - P
return R_GOT_PC;
+ case R_ARM_TARGET1:
+ return Config->Target1Rel ? R_PC : R_ABS;
case R_ARM_TLS_GD32:
return R_TLSGD_PC;
case R_ARM_TLS_LDM32:
@@ -1548,6 +1550,8 @@ RelExpr ARMTargetInfo::getRelExpr(uint32
}
uint32_t ARMTargetInfo::getDynRel(uint32_t Type) const {
+ if (Type == R_ARM_TARGET1 && !Config->Target1Rel)
+ return R_ARM_ABS32;
if (Type == R_ARM_ABS32)
return Type;
// Keep it going with a dummy value so that we can find more reloc errors.
@@ -1629,6 +1633,7 @@ void ARMTargetInfo::relocateOne(uint8_t
case R_ARM_GOT_BREL:
case R_ARM_GOT_PREL:
case R_ARM_REL32:
+ case R_ARM_TARGET1:
case R_ARM_TLS_GD32:
case R_ARM_TLS_IE32:
case R_ARM_TLS_LDM32:
@@ -1757,6 +1762,7 @@ uint64_t ARMTargetInfo::getImplicitAdden
case R_ARM_GOT_BREL:
case R_ARM_GOT_PREL:
case R_ARM_REL32:
+ case R_ARM_TARGET1:
case R_ARM_TLS_GD32:
case R_ARM_TLS_LDM32:
case R_ARM_TLS_LDO32:
Added: lld/trunk/test/ELF/arm-target1.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/arm-target1.s?rev=277369&view=auto
==============================================================================
--- lld/trunk/test/ELF/arm-target1.s (added)
+++ lld/trunk/test/ELF/arm-target1.s Mon Aug 1 14:28:13 2016
@@ -0,0 +1,26 @@
+// REQUIRES: arm
+// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
+// RUN: llvm-readobj -r %t.o | FileCheck %s --check-prefix=RELOC
+// RUN: ld.lld -shared %t.o -o %t2.so --target1-rel
+// RUN: llvm-objdump -t -d %t2.so | FileCheck %s \
+// RUN: --check-prefix=RELATIVE
+// RUN: not ld.lld -shared %t.o -o %t3.so 2>&1 | FileCheck %s \
+// RUN: --check-prefix=ABS
+
+// RELOC: Relocations [
+// RELOC: .rel.text {
+// RELOC: 0x0 R_ARM_TARGET1 patatino 0x0
+// RELOC: }
+// RELOC: ]
+
+.text
+ .word patatino(target1)
+ patatino:
+
+// RELATIVE: Disassembly of section .text:
+// RELATIVE: $d.0:
+// RELATIVE: 1000: 04 00 00 00 andeq r0, r0, r4
+// RELATIVE: SYMBOL TABLE:
+// RELATIVE: 00001004 .text 00000000 patatino
+
+// ABS: can't create dynamic relocation R_ARM_TARGET1 against readonly segment
More information about the llvm-commits
mailing list