On 14.08.2023 17:34, Andrew Cooper wrote: > On 14/08/2023 4:21 pm, Jan Beulich wrote: >> Question therefore is whether we can find a way of effecting the needed >> overrides (including for compiler generated calls) without resorting to >> emitting .equ (or alike), and hence without doing it fully behind the >> compiler's back. > > --wrap= each symbol, except when compiling wrappers.c ? > > This seems to be the normal way to mock out functions including malloc() > and friends.
What is --wrap= ? I was thinking along the lines of void*memcpy(void*, const void*, size_t) __asm__("emul_memcpy"); void*memset(void*, int, size_t) __asm__("emul_memset"); This looks to work at least for explicit __builtin_mem*() invocations, without LTO. Inspecting the LTO object, though, doesn't show any sign of "memcpy" in any of the strings it embeds (custom functions are recorded with strings one can recognize), so I fear this wouldn't work there either. (But if indeed so, I'd wonder if this wasn't a compiler bug, as then we don't do things behind the compiler's back anymore.) Jan