Index: lld/trunk/ELF/InputSection.cpp =================================================================== --- lld/trunk/ELF/InputSection.cpp +++ lld/trunk/ELF/InputSection.cpp @@ -248,6 +248,7 @@ const SymbolBody &Body, RelExpr Expr) { switch (Expr) { case R_HINT: + case R_TLSDESC_CALL: llvm_unreachable("cannot relocate hint relocs"); case R_TLSLD: return Out::Got->getTlsIndexOff() + A - Out::Got->getSize(); Index: lld/trunk/ELF/Relocations.h =================================================================== --- lld/trunk/ELF/Relocations.h +++ lld/trunk/ELF/Relocations.h @@ -61,6 +61,7 @@ R_TLS, R_TLSDESC, R_TLSDESC_PAGE, + R_TLSDESC_CALL, R_TLSGD, R_TLSGD_PC, R_TLSLD, Index: lld/trunk/ELF/Relocations.cpp =================================================================== --- lld/trunk/ELF/Relocations.cpp +++ lld/trunk/ELF/Relocations.cpp @@ -143,14 +143,14 @@ return handleNoRelaxTlsRelocation(Type, Body, C, Offset, Addend, Expr); - if ((Expr == R_TLSDESC || Expr == R_TLSDESC_PAGE || Expr == R_HINT) && + if ((Expr == R_TLSDESC || Expr == R_TLSDESC_PAGE || Expr == R_TLSDESC_CALL) && Config->Shared) { if (Out::Got->addDynTlsEntry(Body)) { uintX_t Off = Out::Got->getGlobalDynOffset(Body); Out::RelaDyn->addReloc( {Target->TlsDescRel, Out::Got, Off, false, &Body, 0}); } - if (Expr != R_HINT) + if (Expr != R_TLSDESC_CALL) C.Relocations.push_back({Expr, Type, Offset, Addend, &Body}); return 1; } @@ -177,7 +177,7 @@ return 1; } - if (Expr == R_TLSDESC_PAGE || Expr == R_TLSDESC || Expr == R_HINT || + if (Expr == R_TLSDESC_PAGE || Expr == R_TLSDESC || Expr == R_TLSDESC_CALL || Target->isTlsGlobalDynamicRel(Type)) { if (Config->Shared) { if (Out::Got->addDynTlsEntry(Body)) { @@ -304,9 +304,10 @@ // These expressions always compute a constant if (E == R_SIZE || E == R_GOT_FROM_END || E == R_GOT_OFF || E == R_MIPS_GOT_LOCAL_PAGE || E == R_MIPS_GOT_OFF || E == R_MIPS_TLSGD || - E == R_GOT_PAGE_PC || E == R_GOT_PC || E == R_PLT_PC || E == R_TLSGD_PC || - E == R_TLSGD || E == R_PPC_PLT_OPD || E == R_TLSDESC_PAGE || - E == R_HINT || E == R_THUNK_PC || E == R_THUNK_PLT_PC) + E == R_GOT_PAGE_PC || E == R_GOT_PC || E == R_PLT_PC || + E == R_TLSGD_PC || E == R_TLSGD || E == R_PPC_PLT_OPD || + E == R_TLSDESC_CALL || E == R_TLSDESC_PAGE || E == R_HINT || + E == R_THUNK_PC || E == R_THUNK_PLT_PC) return true; // These never do, except if the entire file is position dependent or if @@ -621,8 +622,9 @@ continue; } - // Ignore "hint" relocation because it is for optional code optimization. - if (Expr == R_HINT) + // Ignore "hint" and TLS Descriptor call relocation because they are + // only markers for relaxation. + if (Expr == R_HINT || Expr == R_TLSDESC_CALL) continue; if (needsPlt(Expr) || Expr == R_THUNK_ABS || Expr == R_THUNK_PC || Index: lld/trunk/ELF/Target.cpp =================================================================== --- lld/trunk/ELF/Target.cpp +++ lld/trunk/ELF/Target.cpp @@ -1172,7 +1172,7 @@ case R_AARCH64_TLSDESC_ADD_LO12_NC: return R_TLSDESC; case R_AARCH64_TLSDESC_CALL: - return R_HINT; + return R_TLSDESC_CALL; case R_AARCH64_TLSLE_ADD_TPREL_HI12: case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC: return R_TLS; @@ -1541,6 +1541,7 @@ case R_ARM_JUMP24: case R_ARM_PC24: case R_ARM_PLT32: + case R_ARM_PREL31: case R_ARM_THM_JUMP19: case R_ARM_THM_JUMP24: case R_ARM_THM_CALL: @@ -1574,11 +1575,12 @@ return R_GOTONLY_PC; case R_ARM_MOVW_PREL_NC: case R_ARM_MOVT_PREL: - case R_ARM_PREL31: case R_ARM_REL32: case R_ARM_THM_MOVW_PREL_NC: case R_ARM_THM_MOVT_PREL: return R_PC; + case R_ARM_NONE: + return R_HINT; case R_ARM_TLS_LE32: return R_TLS; } @@ -1660,8 +1662,6 @@ void ARMTargetInfo::relocateOne(uint8_t *Loc, uint32_t Type, uint64_t Val) const { switch (Type) { - case R_ARM_NONE: - break; case R_ARM_ABS32: case R_ARM_BASE_PREL: case R_ARM_GOTOFF32: Index: lld/trunk/test/ELF/arm-exidx-shared.s =================================================================== --- lld/trunk/test/ELF/arm-exidx-shared.s +++ lld/trunk/test/ELF/arm-exidx-shared.s @@ -0,0 +1,44 @@ +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t --shared -o %t2 2>&1 +// RUN: llvm-readobj --relocations %t2 | FileCheck %s +// RUN: llvm-objdump -s -triple=armv7a-none-linux-gnueabi %t2 | FileCheck -check-prefix=CHECK-EXTAB %s + +// Check that the relative R_ARM_PREL31 relocation can access a PLT entry +// for when the personality routine is referenced from a shared library. +// Also check that the R_ARM_NONE no-op relocation can be used in a shared +// library. + .syntax unified +// Will produce an ARM.exidx entry with an R_ARM_NONE relocation to +// __aeabi_unwind_cpp_pr0 + .section .text.func1, "ax",%progbits + .global func1 +func1: + .fnstart + bx lr + .fnend + +// Will produce a R_ARM_PREL31 relocation with respect to the PLT entry of +// __gxx_personality_v0 + .section .text.func2, "ax",%progbits + .global func2 +func2: + .fnstart + bx lr + .personality __gxx_personality_v0 + .handlerdata + .long 0 + .section .text.func2 + .fnend + + .section .text.__aeabi_unwind_cpp_pr0, "ax", %progbits + .global __aeabi_unwind_cpp_pr0 +__aeabi_unwind_cpp_pr0: + bx lr + +// CHECK: Relocations [ +// CHECK-NEXT: Section (6) .rel.plt { +// CHECK-NEXT: 0x300C R_ARM_JUMP_SLOT __gxx_personality_v0 + +// CHECK-EXTAB: Contents of section .ARM.extab.text.func2: +// 0144 + 0ee0 = 0x1024 = __gxx_personality_v0(PLT) +// CHECK-EXTAB-NEXT: 0144 e00e0000 b0b0b000 00000000