Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -1286,6 +1286,12 @@ or32le(Loc, (X & 0x0FFFFFFC) >> 2); break; } + case R_AARCH64_CONDBR19: { + uint64_t X = SA - P; + checkInt<21>(X, Type); + or32le(Loc, (X & 0x1FFFFC) << 3); + break; + } case R_AARCH64_LD64_GOT_LO12_NC: checkAlignment<8>(SA, Type); or32le(Loc, (SA & 0xFF8) << 7); Index: test/ELF/Inputs/aarch64-condb-reloc.s =================================================================== --- test/ELF/Inputs/aarch64-condb-reloc.s +++ test/ELF/Inputs/aarch64-condb-reloc.s @@ -0,0 +1,17 @@ +.globl _foo +_foo: + nop + nop + nop + nop + +.globl _bar +_bar: + nop + nop + nop + +.globl _dah +_dah: + nop + nop Index: test/ELF/aarch64-condb-reloc.s =================================================================== --- test/ELF/aarch64-condb-reloc.s +++ test/ELF/aarch64-condb-reloc.s @@ -0,0 +1,32 @@ +# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %p/Inputs/aarch64-condb-reloc.s -o %t1 +# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %t2 +# RUN: ld.lld %t1 %t2 -o %t +# RUN: llvm-objdump -d %t | FileCheck %s +# REQUIRES: aarch64 + +# 0x11024 - 36 = 0x11000 +# 0x11028 - 24 = 0x11010 +# 0x1102c - 16 = 0x1101c +# CHECK: Disassembly of section .text: +# CHECK-NEXT: _foo: +# CHECK-NEXT: 11000: {{.*}} nop +# CHECK-NEXT: 11004: {{.*}} nop +# CHECK-NEXT: 11008: {{.*}} nop +# CHECK-NEXT: 1100c: {{.*}} nop +# CHECK: _bar: +# CHECK-NEXT: 11010: {{.*}} nop +# CHECK-NEXT: 11014: {{.*}} nop +# CHECK-NEXT: 11018: {{.*}} nop +# CHECK: _dah: +# CHECK-NEXT: 1101c: {{.*}} nop +# CHECK-NEXT: 11020: {{.*}} nop +# CHECK: _start: +# CHECK-NEXT: 11024: {{.*}} b.eq #-36 +# CHECK-NEXT: 11028: {{.*}} b.eq #-24 +# CHECK-NEXT: 1102c: {{.*}} b.eq #-16 + +.globl _start +_start: + b.eq _foo + b.eq _bar + b.eq _dah