Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lld/ELF/Arch/Hexagon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void Hexagon::relocate(uint8_t *loc, const Relocation &rel,
case R_HEX_B22_PCREL:
case R_HEX_GD_PLT_B22_PCREL:
case R_HEX_PLT_B22_PCREL:
checkInt(ctx, loc, val, 22, rel);
checkInt(ctx, loc, val, 24, rel);
or32le(loc, applyMask(0x1ff3ffe, val >> 2));
break;
case R_HEX_B22_PCREL_X:
Expand Down
2 changes: 1 addition & 1 deletion lld/test/ELF/hexagon-jump-error.s
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (p0) jump #1f
.section b15, "ax"
1:

# CHECK: relocation R_HEX_B22_PCREL out of range: 8388612 is not in [-2097152, 2097151]
# CHECK: relocation R_HEX_B22_PCREL out of range: 8388612 is not in [-8388608, 8388607]
jump #1f
.space (1<<23)
.section b22, "ax"
Expand Down
45 changes: 45 additions & 0 deletions lld/test/ELF/hexagon-jump.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# REQUIRES: hexagon
# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o

## Make sure we got the right relocations.
# RUN: llvm-readelf -r %t.o | FileCheck %s --check-prefix=REL
# REL: R_HEX_B9_PCREL 00000000 b9
# REL: R_HEX_B13_PCREL 00000000 b13
# REL: R_HEX_B15_PCREL 00000000 b15
# REL: R_HEX_B22_PCREL 00000000 b22

# RUN: ld.lld %t.o -o %t.out --section-start=.text=0x1000000 \
# RUN: --section-start=b9=0x1000400 --section-start=b13=0x1004000 \
# RUN: --section-start=b15=0x1010000 --section-start=b22=0x1800000 \
# RUN: --threads=1
# RUN: llvm-objdump -d --no-show-raw-insn %t.out | FileCheck %s

# CHECK-NOT: trampoline
# CHECK: 01000000 <_start>:
# CHECK-NEXT: 1000000: { nop }
# CHECK-NEXT: 1000004: { r0 = #0x0 ; jump 0x1000400 }
# CHECK-NEXT: 1000008: { if (r0==#0) jump:t 0x1004000 }
# CHECK-NEXT: 100000c: { if (p0) jump:nt 0x1010000 }
# CHECK-NEXT: 1000010: { jump 0x1800000 }

.globl _start
.type _start, @function
_start:
## Make sure the first jump is within range
nop
{ r0 = #0; jump #b9 }
if (r0==#0) jump:t #b13
if (p0) jump #b15
jump #b22

.section b9, "ax"
nop

.section b13, "ax"
nop

.section b15, "ax"
nop

.section b22, "ax"
nop
Loading