Index: ELF/InputSection.cpp =================================================================== --- ELF/InputSection.cpp +++ ELF/InputSection.cpp @@ -248,6 +248,7 @@ typename ELFT::uint P, const SymbolBody &Body, RelExpr Expr) { switch (Expr) { + case R_NONE: case R_HINT: llvm_unreachable("cannot relocate hint relocs"); case R_TLSLD: Index: ELF/Relocations.h =================================================================== --- ELF/Relocations.h +++ ELF/Relocations.h @@ -36,6 +36,7 @@ R_MIPS_TLSGD, R_MIPS_TLSLD, R_NEG_TLS, + R_NONE, R_PAGE_PC, R_PC, R_PLT, Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -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_NONE || + 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) return true; // These never do, except if the entire file is position dependent or if @@ -620,8 +621,9 @@ continue; } - // Ignore "hint" relocation because it is for optional code optimization. - if (Expr == R_HINT) + // Ignore "hint" relocation because it is for optional code optimization, + // and the "none" relocation as it has no effect on the section contents. + if (Expr == R_HINT || Expr == R_NONE) continue; if (needsPlt(Expr) || Expr == R_THUNK_ABS || Expr == R_THUNK_PC || Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -1538,6 +1538,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: @@ -1565,11 +1566,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_NONE; case R_ARM_TLS_LE32: return R_TLS; } Index: test/ELF/arm-exidx-shared.s =================================================================== --- /dev/null +++ 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