From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101113 invoked by alias); 1 Mar 2019 18:49:10 -0000 Mailing-List: contact dwz-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: dwz-owner@sourceware.org Received: (qmail 101054 invoked by uid 89); 1 Mar 2019 18:49:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=ap, Hx-languages-length:3971, showing X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: mx1.suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Date: Tue, 01 Jan 2019 00:00:00 -0000 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com Subject: [PATCH] Don't process low-mem files in multifile mode Message-ID: <20190301184820.GA21919@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2019-q1/txt/msg00058.txt.bz2 Hi, Consider three executables, a.out and b.out with n DIEs, and c.out with n + m DIEs. When running in multifile mode, with a low-mem limit of n + m - 1 DIEs: ... $ dwz -m common.out -l$(($n + $m - 1)) a.out b.out c.out ... the expectation is that c.out is not used in multifile processing, because it exceeds the low-mem limit. However, all three files turn out to have the .gnu_debugaltlink section, showing that in fact c.out was used in multifile processing. Fix this by adding a low_mem_p field to struct file_result, setting it in function dwz and using it in main. OK for trunk? Thanks, - Tom Don't process low-mem files in multifile mode 2019-03-01 Tom de Vries PR dwz/24274 * Makefile (TEST_EXECS): Add hello2. * dwz.c (struct file_result): Add low_mem_p field. (dwz): Set low_mem_p field. Remove non-functional low_mem test. (main): Don't use low_mem_p files in multifile loop. * hello.c [HAVE_STRUCT] (struct a): New struct. [HAVE_STRUCT] (a): New var. (main) [HAVE_STRUCT]: Use a. * testsuite/dwz.tests/multifile-low-mem.sh: New test. --- Makefile | 5 ++++- dwz.c | 8 ++++++-- hello.c | 14 ++++++++++++++ testsuite/dwz.tests/multifile-low-mem.sh | 26 ++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bc51ca2..b8dd9ca 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..ffa8e08 100644 --- a/dwz.c +++ b/dwz.c @@ -10954,6 +10954,7 @@ struct file_result dev_t dev; ino_t ino; nlink_t nlink; + bool low_mem_p; }; /* Handle compression of a single file FILE. If OUTFILE is @@ -10970,6 +10971,7 @@ dwz (const char *file, const char *outfile, struct file_result *res, struct stat st; res->res = -1; + res->low_mem_p = low_mem ? true : false; fd = open (file, O_RDONLY); if (fd < 0) { @@ -10999,6 +11001,7 @@ dwz (const char *file, const char *outfile, struct file_result *res, break; if (&resa[n] != res) { + res->low_mem_p = resa[n].low_mem_p; /* If a hardlink to this has been processed before and we didn't change it, just assume the same state. */ @@ -11224,7 +11227,7 @@ dwz (const char *file, const char *outfile, struct file_result *res, close (fd); free (dso); - if (ret == 0 && !low_mem) + if (ret == 0) res->res = 0; return ret; } @@ -11968,7 +11971,8 @@ main (int argc, char *argv[]) /* Don't process again files that couldn't be processed successfully. */ if (resa[i - optind].res == -1 - || resa[i - optind].res == 1) + || resa[i - optind].res == 1 + || resa[i - optind].low_mem_p) continue; for (cu = alt_first_cu; cu; cu = cu->cu_next) alt_clear_dups (cu->cu_die); 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/multifile-low-mem.sh b/testsuite/dwz.tests/multifile-low-mem.sh new file mode 100755 index 0000000..435dfa3 --- /dev/null +++ b/testsuite/dwz.tests/multifile-low-mem.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +cp ../hello 1 +cp ../hello 2 +cp ../hello2 3 + +low_mem_limit=$(readelf -w 3 | grep '(DW_TAG' | wc -l) +low_mem_limit=$((low_mem_limit - 1)) + +dwz -l$low_mem_limit -m 4 1 2 3 + +smaller-than.sh 1 ../hello +smaller-than.sh 2 ../hello +smaller-than.sh 3 ../hello2 + +ls=$(ls) +ls=$(echo $ls) +[ "$ls" = "1 2 3 4" ] + +[ $(gnu-debugaltlink-name.sh 1) = "4" ] +[ $(gnu-debugaltlink-name.sh 2) = "4" ] +[ "$(gnu-debugaltlink-name.sh 3)" = "" ] + +rm -f 1 2 3 4