1# RUN: %cheri128_llvm-mc -filetype=obj %s -o %t.o 2# RUN: ld.lld -pie %t.o -o %t.exe 3# RUsN: llvm-readobj --cap-relocs --dynamic-table %t.exe | FileCheck %s 4# RUN: %cheri128_llvm-mc -filetype=obj -defsym=EMPTY_CAP_TABLE=1 %s -o %t2.o 5# This used to crash: 6# RUN: not ld.lld -pie %t2.o -o %t.exe 2>&1 | FileCheck %s -check-prefix=EMPTY-TABLE 7 8// EMPTY-TABLE: ld.lld: error: cannot compute difference between non-existent CheriCapabilityTable and symbol foo 9// EMPTY-TABLE: ld.lld: error: cannot compute difference between non-existent CheriCapabilityTable and symbol foo 10 11 12.text 13 14 15# CHECK-LABEL: Disassembly of section .text: 16.global __start 17.ent __start 18__start: 19# CHECK-LABEL: __start: 20.set noat 21.set noreorder 22.ifdef _USE_CHERI_CAPABILITY_TABLE_ 23# referencing _CHERI_CAPABILITY_TABLE_ fixes the crash: 24lui $1, %hi(%neg(%captab_rel(_CHERI_CAPABILITY_TABLE_))) 25daddiu $1, $1, %lo(%neg(%captab_rel(_CHERI_CAPABILITY_TABLE_))) 26.endif 27lui $1, %hi(%neg(%captab_rel(foo))) 28daddiu $1, $1, %lo(%neg(%captab_rel(foo))) 29nop 30 31# Just to ensure we have something in the captable: 32.ifdef EMPTY_CAP_TABLE 33nop 34.else 35clcbi $c1, %captab20(bar)($c1) 36.endif 37cjr $c17 38cld $2, $zero, 0($c1) 39 40 41.end __start 42 43.data 44.space 32 45foo: 46.8byte 9 47.size foo, 8 48bar: 49.8byte 10 50.size bar, 8 51