I’ve written a shared object that modifies the arguments to FreeType’s FT_Load_Glyph
and FT_Render_Glyph
functions, currently by interposing it with LD_PRELOAD
and dlsym
.
This works fine, but I’m curious to know whether or not there’s a way to make these changes:
- to all programs that use FreeType on a given host (running e.g. Debian);
- without clobbering any programs that aren’t actually linked to FreeType;
- without simply applying an
LD_PRELOAD
to all programs on the host; - without requiring any maintenance unless FreeType’s soname is changed; and
- without modifying any of FreeType’s files, nor those of any programs on the host.
The only two “solutions” that I’ve been able to come up with are ugly hacks:
- to
LD_PRELOAD
all programs, all of the time, which seems slow and fragile; or - to copy e.g.
libfreetype.so.6.12.3
tolibxxxxtype.so.6.12.3
; then- patch the soname in
libxxxxtype.so.6.12.3
tolibxxxxtype.so.6
; - link the interposing shared object against
libxxxxtype.so.6
; and - install the shared object as e.g.
libfreetype.so.6.999
.
- patch the soname in
I’d essentially like to transparently patch a couple of functions in a shared object, while letting the remaining functions through, without necessarily having access to the source of the shared object or the programs that use it, but if I make a fake shared object with the soname libfreetype.so.6
, I can’t see a clean way to link it to (or dlopen
) the real libfreetype.so.6
.
This is my first real experiment with shared libraries, so please bear with me if this question makes some incorrect assumptions, or just makes no sense.
libfreetype.so.x.y.z
seems to be the right way of doing this. Why do you describe it as ugly? – Gonicklibfreetype.so
that had a patched soname, especially keeping it up to date when a new (or the same) version of thelibfreetype6
package is installed, and (b) I would be polluting the global “sonamespace” with alibxxxxtype.so
, which is at least theoretically fragile because it would be impossible to come up with a name that absolutely no library author would ever use. (a) is mitigated by glorpen’s answer (in exchange for relying on an absolute path), and (b) can be mitigated to the point where it’s only theoretical. – Ced