Index: lld/trunk/ELF/Config.h =================================================================== --- lld/trunk/ELF/Config.h +++ lld/trunk/ELF/Config.h @@ -103,6 +103,7 @@ bool StripAll; bool StripDebug; bool SysvHash = true; + bool Target1Rel; bool Threads; bool Trace; bool Verbose; Index: lld/trunk/ELF/Driver.cpp =================================================================== --- lld/trunk/ELF/Driver.cpp +++ lld/trunk/ELF/Driver.cpp @@ -364,6 +364,7 @@ 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); Index: lld/trunk/ELF/Options.td =================================================================== --- lld/trunk/ELF/Options.td +++ lld/trunk/ELF/Options.td @@ -146,6 +146,10 @@ 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">; Index: lld/trunk/ELF/Target.cpp =================================================================== --- lld/trunk/ELF/Target.cpp +++ lld/trunk/ELF/Target.cpp @@ -1526,6 +1526,8 @@ 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 @@ } 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 @@ 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 @@ 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: Index: lld/trunk/test/ELF/arm-target1.s =================================================================== --- lld/trunk/test/ELF/arm-target1.s +++ lld/trunk/test/ELF/arm-target1.s @@ -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