Hello, On Tue, 16 Mar 2021, Gabriel F. T. Gomes wrote:
You could also link a live patchable library against libpulp (and so make any process using that library also be live patchable). But that has some interesting consequences about entry tracking: it starts globally for a process only when libpulp is loaded, so anything loaded before libpulp is loaded isn't tracked.
Hmm, perhaps this changed in the past, but since I joined the project, entrance tracking happens regardless of libpulp.so.0 being loaded or not.
Oh right. God, I really need to read the code again :-) The ulp_entry still does check if __ulp_global_universe is there or not (which is what indicates the presence or absence of libpulp), but it always does the tracking unconditionally. Hmm. I'm not sure we want to change this right now, or at all. But initially the idea was to only take the big cost hit for processes where libpulp is loaded. That still would need one memory access per entry point (to check for the weak symbol), but at least not go through the whole TLS-address business and memory writes for the counter updates.
Entrance tracking is enabled on any library that has been made live-patchable, because the .dynsym section in them is tweaked (by ulp_post (formerly known as dynsym_gate)) so that the addresses of actual functions are replaced with the address of trampolines (added by ulp_post). Just for the sake of completeness, each function has its own trampoline, which stores the address of the actual target function on the stack, then jumps to the entrance tracking routine.
By the way, this is the main source of overhead, so having a live-patchable library installed in default locations (or preferred by ld.so.cache) has an effect on the whole system. Perhaps this needs changing (in .spec files, that is).
Ciao, Michael.