This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] ld.so: command argument "--preload"
- From: Carlos O'Donell <carlos at redhat dot com>
- To: David Newall <glibc at davidnewall dot com>, Florian Weimer <fweimer at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 5 Nov 2018 21:10:41 -0500
- Subject: Re: [PATCH] ld.so: command argument "--preload"
- References: <322fb70a-9c0e-100b-4366-dfa7e5134aa5@davidnewall.com> <265bec63-9875-7268-2199-c7e133b2298e@davidnewall.com> <874ldb7gxp.fsf@oldenburg.str.redhat.com> <5f79f366-d687-583f-940c-36c169bd34a9@davidnewall.com>
On 11/5/18 4:16 AM, David Newall wrote:
> On 24/10/18 9:24 pm, Florian Weimer wrote:
>> For some reason, the [--preload] patch as posted does not apply to
>> master.
>>
>> I think the general approach of the patch is fine. Could you write
>> a test case for it?
>
> I hate to say this, but I can't work out how to write a test case.
> Normally I'd crib from something similar, but I can't find any test
> cases for any of rtld's arguments. (In all cases where I can find
> arguments for rtld, it's not rtld that's being tested, but something
> else.)
Is elf/tst-rtld-load-self.sh a useful template?
You will need:
* 3 parts in elf/Makefile, a binary you're going to build for the
test, and two shared objects that provide the same function, the
default one exits with a non-zero exit code, and the preloading
one which exits with a zero exit code.
* The test itself e.g. tst-rtld-args.sh, with a dependency on the
DSOs and binary so they get built. It will be tests-special and
have it's own rule to run the test, and pass in the right
arguments along with an additional argument of the path to the
binary to run.
* The script tst-rtld-args.sh will run the loader with --preload
and try to load the new DSO, and run the test. It return 0 if
it was able to successfully preload the DSO and interpose the
function and you can catch that in your script and exit with
a zero also to indicate the test passed e.g. just passing along
the return code and printing some information.
--
Cheers,
Carlos.