[llvm] [BOLT] Gadget scanner: clarify MCPlusBuilder callbacks interface (PR #136147)

Anatoly Trosinenko via llvm-commits llvm-commits at lists.llvm.org
Mon May 26 04:33:10 PDT 2025


================
@@ -985,6 +985,26 @@ inst_pacnbibsppc:
         ret
         .size inst_pacnbibsppc, .-inst_pacnbibsppc
 
+// Test that write-back forms of LDRA(A|B) instructions are handled properly.
+
+        .globl  inst_ldraa_wb
+        .type   inst_ldraa_wb, at function
+inst_ldraa_wb:
+// CHECK-NOT: inst_ldraa_wb
+        ldraa   x2, [x0]!
+        pacda   x0, x1
+        ret
+        .size inst_ldraa_wb, .-inst_ldraa_wb
+
+        .globl  inst_ldrab_wb
+        .type   inst_ldrab_wb, at function
+inst_ldrab_wb:
+// CHECK-NOT: inst_ldrab_wb
+        ldraa   x2, [x0]!
+        pacda   x0, x1
+        ret
+        .size inst_ldrab_wb, .-inst_ldrab_wb
+
----------------
atrosinenko wrote:

> Maybe it'd be best to add a FIXME to the implementations of the isLDR* functions to help highlight these aren't fully correct?
> And maybe it's not too hard to add the PAC-related load instructions to the relevant `isLDR*` functions?

Added a FIXME in 51c779ace239c502a71d45988b163707a980e783. While it would be great to make `mayLoad` handle all possible load instructions, I don't think `LDRA*` instructions are more important here. At the first glance, from the gadget scanner point of view `LDRA*` instructions are even **less** important than other load instructions:
* they hardly fit as a single-instruction "pointer checker", as passing an already authenticated pointer to them seems meaningless and would most likely crash at run-time
* there are no rules for non-protected load instructions defined so far, but `LDRA*` instructions have built-in protection anyway :)

https://github.com/llvm/llvm-project/pull/136147


More information about the llvm-commits mailing list