This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] ld.so: command argument "--preload"


On 6/11/18 12:40 pm, Carlos O'Donell wrote:
On 11/5/18 4:16 AM, David Newall wrote:
... I can't work out how to write a test case ...
Is elf/tst-rtld-load-self.sh a useful template?

Thank you, yes, that helped.  I'll use the existing preloadtest program, so, for Makefile, something like this seems to work:

289c289,290
< tests-special += $(objpfx)tst-pathopt.out $(objpfx)tst-rtld-load-self.out
---
tests-special += $(objpfx)tst-pathopt.out $(objpfx)tst-rtld-load-self.out \
         $(objpfx)tst-rtld-preload.out
769a771,777

tst-rtld-preload-OBJS =  $(subst $(empty) ,:,$(strip $(preloadtest-preloads:=.so)))
$(objpfx)tst-rtld-preload.out: tst-rtld-preload.sh $(objpfx)ld.so \
                   $(objpfx)preloadtest
    $(SHELL) $^ '$(test-wrapper)' '$(test-wrapper-env)' \
            '$(rpath-link)' '$(tst-rtld-preload-OBJS)' > $@; \
    $(evaluate-test)

For the script:

set -e

rtld=$1
test_program=$2
test_wrapper=$3
test_wrapper_env=$4
library_path=$5
preload=$6

echo "# [${test_wrapper}] [$rtld] [--library-path] [$library_path] [--preload] [$preload] [$test_program]"
${test_wrapper} $rtld --library-path $library_path --preload $preload $test_program 2>&1 && rc=0 || rc=$?
echo "# exit status $rc"

exit $rc

Is this reasonable?

David


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]