Sujet : Re: (interposers): How to workaround the "strong symbols" problem?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.unix.programmerDate : 18. Jan 2025, 02:22:51
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250117172121.963@kylheku.com>
References : 1 2
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-01-17, Kenny McCormack <
gazelle@shell.xmission.com> wrote:
In article <vmeibp$33sam$1@news.xmission.com>,
Kenny McCormack <gazelle@shell.xmission.com> wrote:
Context is Linux (and only Linux).
>
Over the years, I have written many "interposers" - that is, a shared
library loaded with LD_PRELOAD that hooks some system or library call
(e.g., "read"). The interposer usually ends up calling the "real"
function, then doing something special either before or after the call.
>
Also, wanted to state that the function I am trying to hook is "openat".
>
"open" I can hook, but "openat" doesn't work. I think most programs just
call "open", which eventually ends up calling "openat", so that (hooking
"open") works. But some programs call "openat" directly, and that doesn't
work.
>
And, also, just to clarify, the whole point of this is to modify the
behavior of a program without the bother of re-compiling it.
In one installation where glibc is 2.31 from 2021, I get this:
$ nm /lib64/libc.so.6 | grep '1444b0'
00000000001444b0 t __GI___openat
00000000001444b0 t __GI___openat64
00000000001444b0 t __libc_openat64
00000000001444b0 t __openat
00000000001444b0 W openat
00000000001444b0 t __openat64
00000000001444b0 W openat64
Where 1444b0 is the address I discovered by another grep, and
then used it to see what all the aliases are. The openat and
openat64 symbols are W (weak).
If you do the same exercise, what do you see?
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca