C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Interceptor Function

From: Thiago Macieira <thiago_at_[hidden]>
Date: Tue, 14 Apr 2026 09:57:45 -0700
On Tuesday, 14 April 2026 06:56:59 Pacific Daylight Time Sebastian Wittmeier
via Std-Proposals wrote:
> Those are now 4 different approaches:
>
> - Linker: Redirecting symbols at link time
>
> - Compiler: Adding code to function calls (callsite)
>
> - Compiler: Redirecting functions to a wrapper at compile time
>
> - Compiler: Adding code to the beginning and end of functions themselves
> (each return, each exception or those not)

One more:
- Dynamic linker: using (DY)LD_PRELOAD to intercept a symbol

There are also some adventurous souls that change the memory protection of a
function and patch it at runtime with code jumping elsewhere.
 
> Some of those approaches work with compiled caller, some not.
>
> Some of those approaches work with compiled callee, some not.
>
> Some of those approaches work with inlined functions some not.

Some of those approaches work with some lib builds, some not.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-04-14 16:57:57