kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

callx_indirect.c (483B)


      1 /* Indirect call through a function pointer. The callee address is taken via a
      2  * volatile function-pointer local so codegen cannot devirtualize it to a direct
      3  * `bl`; it must load the address (GOT/ADRP+ADD reloc) and emit `blr <reg>`.
      4  * Exercises the indirect-call register form on the asm round-trip surface.
      5  * Exit code dbl(21) = 42. */
      6 __attribute__((noinline)) static int dbl(int x) { return x + x; }
      7 int test_main(void) {
      8   int (*volatile fp)(int) = dbl;
      9   return fp(21);
     10 }