diff --git a/lld/test/ELF/riscv-relax-wrap.s b/lld/test/ELF/riscv-relax-wrap.s new file mode 100644 --- /dev/null +++ b/lld/test/ELF/riscv-relax-wrap.s @@ -0,0 +1,26 @@ +## Check that relaxation doesn't break when using --wrap. See D150220 + +# REQUIRES: riscv +# RUN: rm -rf %t && split-file %s %t +# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax %t/main.s -o %t/main.o +# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax %t/wrap.s -o %t/wrap.o +# RUN: ld.lld %t/main.o %t/wrap.o --wrap bar -o %t1 +# RUN: llvm-objdump -t %t1 | FileCheck %s + +# CHECK-DAG: 0000000000011120 g .text 0000000000000000 _start +# CHECK-DAG: 0000000000011124 g .text 0000000000000000 bar +# CHECK-DAG: 0000000000011128 g .text 0000000000000000 __wrap_bar + +#--- main.s +.globl _start +_start: + call bar + +#--- wrap.s +.globl bar, __wrap_bar +bar: +## Note that this can be any instruction that gets relaxed. The goal is to force +## the value of __wrap_bar to change. + call __wrap_bar +__wrap_bar: + call __real_bar