Honour errors when processing more than one file When using dwz -L0 on a hello world a.out, it fails: ... $ dwz -L0 a.out $ echo $? 1 ... But when we do the same for a.out and a copy b.out, it passes: ... $ cp a.out b.out $ dwz -L0 a.out b.out $ echo $? 0 ... Fix this by honouring dwz return codes when processing more than one file. 2019-03-04 Tom de Vries PR dwz/24301 * dwz.c (main): Handle dwz returning 1 if processing more than one file. * testsuite/dwz.tests/two-files-too-many-dies.sh: New test. --- Makefile | 5 ++++- dwz.c | 2 ++ hello.c | 14 ++++++++++++++ testsuite/dwz.tests/two-files-too-many-dies.sh | 22 ++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b318fd7..4b37732 100644 --- a/Makefile +++ b/Makefile @@ -17,11 +17,14 @@ clean: PWD:=$(shell pwd -P) -TEST_EXECS = hello +TEST_EXECS = hello hello2 hello: $(CC) hello.c -o $@ -g +hello2: + $(CC) hello.c -o $@ -DWITH_STRUCT -g + check: dwz $(TEST_EXECS) mkdir -p testsuite-bin cd testsuite-bin; ln -sf $(PWD)/dwz . diff --git a/dwz.c b/dwz.c index d348418..e82d6a7 100644 --- a/dwz.c +++ b/dwz.c @@ -11940,6 +11940,8 @@ main (int argc, char *argv[]) } else if (resa[i - optind].res == 0) successcount++; + else if (thisret == 1) + ret = 1; if (hardlink && resa[i - optind].res >= 0 && resa[i - optind].nlink > 1) diff --git a/hello.c b/hello.c index 82d070e..ee65515 100644 --- a/hello.c +++ b/hello.c @@ -1,8 +1,22 @@ #include +#ifdef WITH_STRUCT +struct a { + int a; + char *p; +}; + +struct a a; +#endif + int main (void) { +#ifdef WITH_STRUCT + a.p = "hello"; + printf ("%s\n", a.p); +#else printf ("hello\n"); +#endif return 0; } diff --git a/testsuite/dwz.tests/two-files-too-many-dies.sh b/testsuite/dwz.tests/two-files-too-many-dies.sh new file mode 100755 index 0000000..da86d23 --- /dev/null +++ b/testsuite/dwz.tests/two-files-too-many-dies.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +set -e + +cp ../hello 1 +cp ../hello2 2 + +limit=$(readelf -w 2 | grep '(DW_TAG' | wc -l) +limit=$((limit - 1)) + +if dwz -L$limit 2 1 2>/dev/null; then + exit 1 +fi + +smaller-than.sh 1 ../hello +cmp 2 ../hello2 + +ls=$(ls) +ls=$(echo $ls) +[ "$ls" = "1 2" ] + +rm -f 1 2