================ @@ -0,0 +1,41 @@ +# RUN: rm -rf %t && split-file %s %t +# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/use.s -o %t/use-le.o +# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/def.s -o %t/def-le.o + +## Deactivation symbol used without being defined: instruction emitted as usual. +# RUN: ld.lld -o %t/undef-le %t/use-le.o +# RUN: llvm-objdump -d %t/undef-le | FileCheck --check-prefix=UNDEF %s + +## Deactivation symbol defined: instructions overwritten with NOPs. +# RUN: ld.lld -o %t/def-le %t/use-le.o %t/def-le.o +# RUN: llvm-objdump -d %t/def-le | FileCheck --check-prefix=DEF %s + +## Behavior unchanged by endianness: relocation always written as little endian. +# RUN: llvm-mc -filetype=obj -triple=aarch64_be %t/use.s -o %t/use-be.o +# RUN: llvm-mc -filetype=obj -triple=aarch64_be %t/def.s -o %t/def-be.o +# RUN: ld.lld -o %t/undef-be %t/use-be.o +# RUN: llvm-objdump -d %t/undef-be | FileCheck --check-prefix=UNDEF %s +# RUN: ld.lld -o %t/def-be %t/use-be.o %t/def-be.o +# RUN: llvm-objdump -d %t/def-be | FileCheck --check-prefix=DEF %s + +#--- use.s +.weak ds +# This instruction has a single relocation: the DS relocation. +# UNDEF: add x0, x1, x2 +# DEF: nop +.reloc ., R_AARCH64_PATCHINST, ds +add x0, x1, x2 +# This instruction has two relocations: the DS relocation and the JUMP26 to f1. +# Make sure that the DS relocation takes precedence. +.reloc ., R_AARCH64_PATCHINST, ds ---------------- smithp35 wrote:
Could be worth a test with emit-relocs to show both relocations coming out. Thinking of Bolt, which relies on emit-relocs, I expect that it would just ignore the R_AARCH_PATCHINST relocations on their own as it wouldn't know how to recreate the original value [1]. It would have to discard any relocation at the same location. We're hoping to create a binary analysis ABI supplement soon to document conventions that binary analysis tools are using. First step https://github.com/ARM-software/abi-aa/pull/333 [1] In theory if we did want to let Bolt reverse a patch, the emit-relocs output could give the reverse patch. https://github.com/llvm/llvm-project/pull/133534 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits