__static_call(name)
is a macro that expands to (name inlined): ({ \
__ADDRESSABLE(__SCK__x86_pmu_add); \
&__SCT__x86_pmu_add_tramp; \
})
It is used in this context #define static_call(name) __static_call(name)
Which is used in this context static_call(name)(args...);
But... this (expanding the last version) isn't valid syntax? ({ \
__ADDRESSABLE(__SCK__x86_pmu_add); \
&__SCT__x86_pmu_add_tramp; \
})(args...)
A block isn't callable in C?---
It might help if I understood what the final product (assembly) is supposed to look like, but I don't. For instance, at the end of the article the final assembly produced is discussed, but it's not clear to me what code is producing that assembly/what the surrounding assembly is supposed to look like. Taking the last example
call __SCK__x86_pmu_add
; in call + "trampoline"
ret ; "trampoline" returns, completing the call
Is this code generated inside a trampoline function (so that last ret is actually a ret)? Is this code called inside the caller, and someone played with the return address? Something else?