From: Peter Collingbourne Date: Sat, 15 Dec 2018 00:20:17 +0000 (+0000) Subject: ELF: Handle R_ARM_V4BX correctly in PIC output files. X-Git-Tag: llvmorg-8.0.0-rc1~2045 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ae15e7232a4c12a2691c94c6585692ff6d1421e9;p=platform%2Fupstream%2Fllvm.git ELF: Handle R_ARM_V4BX correctly in PIC output files. Previously we considered R_ARM_V4BX to be an absolute relocation, which meant that we rejected it in read-only sections in PIC output files. Instead, treat it as a hint relocation so that relocation processing ignores it entirely. Also fix a problem with the test case where it was never being run because it has a .yaml extension and we don't run tests with that extension. Differential Revision: https://reviews.llvm.org/D55728 llvm-svn: 349216 --- diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp index 1d1dd31..5f1485f 100644 --- a/lld/ELF/Arch/ARM.cpp +++ b/lld/ELF/Arch/ARM.cpp @@ -134,6 +134,12 @@ RelExpr ARM::getRelExpr(RelType Type, const Symbol &S, return R_NONE; case R_ARM_TLS_LE32: return R_TLS; + case R_ARM_V4BX: + // V4BX is just a marker to indicate there's a "bx rN" instruction at the + // given address. It can be used to implement a special linker mode which + // rewrites ARMv4T inputs to ARMv4. Since we support only ARMv4 input and + // not ARMv4 output, we can just ignore it. + return R_HINT; default: return R_ABS; } @@ -514,12 +520,6 @@ void ARM::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const { ((Val << 4) & 0x7000) | // imm3 (Val & 0x00ff)); // imm8 break; - case R_ARM_V4BX: - // V4BX is just a marker to indicate there's a "bx rN" instruction at the - // given address. It can be used to implement a special linker mode which - // rewrites ARMv4T inputs to ARMv4. Since we support only ARMv4 input and - // not ARMv4 output, we can just ignore it. - break; default: error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type)); } diff --git a/lld/test/ELF/v4bx.yaml b/lld/test/ELF/arm-v4bx.test similarity index 92% rename from lld/test/ELF/v4bx.yaml rename to lld/test/ELF/arm-v4bx.test index 8dd619f..1b39a43 100644 --- a/lld/test/ELF/v4bx.yaml +++ b/lld/test/ELF/arm-v4bx.test @@ -2,6 +2,8 @@ # RUN: yaml2obj %s -o %t.o # RUN: ld.lld %t.o -o %t # RUN: llvm-readelf -sections %t | FileCheck %s +# RUN: ld.lld -shared %t.o -o %t +# RUN: llvm-readelf -sections %t | FileCheck %s # CHECK: .text