From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51157 invoked by alias); 28 Jun 2019 14:37:44 -0000 Mailing-List: contact dwz-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: dwz-owner@sourceware.org Received: (qmail 51145 invoked by uid 89); 28 Jun 2019 14:37:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-Spam-Status: No, score=-24.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) 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: [committed] Fix handling of empty .data section Message-ID: <20190628143737.GA16633@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-q2/txt/msg00091.txt.bz2 Hi, When running tests using make check CC="gcc -fuse-ld=gold", we run into: ... Running /data/dwz/build/../src/testsuite/dwz.tests/dwz-tests.exp ... dwz: Allocatable section in 1 after non-allocatable ones dwz: Allocatable section in 2 after non-allocatable ones dwz: Too few files for multifile optimization child process exited abnormally FAIL: /data/dwz/build/../src/testsuite/dwz.tests/pr24542.sh ... The trigger is that the .data section has the same offset as .debug_info: ... Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align ... [ 5] .data PROGBITS 0000000000401000 00001000 0000000000000000 0000000000000000 WA 0 0 1 [ 6] .bss NOBITS 0000000000401000 00001000 0000000000000000 0000000000000000 WA 0 0 1 [ 7] .debug_info PROGBITS 0000000000000000 00001000 0000000000000047 0000000000000000 0 0 1 ... The problem is here in write_dso: ... else if (dso->shdr[j].sh_offset < min_shoff && !last_shoff) continue; else if ((dso->shdr[j].sh_flags & SHF_ALLOC) != 0) { error (0, 0, "Allocatable section in %s after " "non-allocatable ones", dso->filename); return 1; } ... For the empty .data section, "dso->shdr[j].sh_offset == min_shoff" holds, so it won't get skipped by the '<' test. Fix this by skipping an empty section that starts at min_shoff. Committed to trunk. Thanks, - Tom Fix handling of empty .data section 2019-06-28 Tom de Vries PR dwz/24747 * Makefile (TEST_EXECS): Add start-gold. (start-gold): New target. * dwz.c (write_dso): Handle empty allocatable section. * testsuite/dwz.tests/dwz-tests.exp: Require start-gold for pr24747.sh. * testsuite/dwz.tests/pr24747.sh: New test. --- Makefile | 6 +++++- dwz.c | 5 ++++- testsuite/dwz.tests/dwz-tests.exp | 3 +++ testsuite/dwz.tests/pr24747.sh | 7 +++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9b02cc1..b2a1fb1 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,8 @@ PWD:=$(shell pwd -P) TEST_SRC = $(srcdir)/testsuite/dwz.tests TEST_EXECS = hello dw2-restrict py-section-script dwz-for-test min two-typedef \ - dw2-skip-prologue start implptr-64bit-d2o4a8r8t0 hello-gold-gdb-index + dw2-skip-prologue start implptr-64bit-d2o4a8r8t0 hello-gold-gdb-index \ + start-gold hello: $(CC) $(TEST_SRC)/hello.c -o $@ -g @@ -58,6 +59,9 @@ two-typedef: start: $(CC) $(TEST_SRC)/start.c -o $@ -g -nostdlib +start-gold: + $(CC) $(TEST_SRC)/start.c -fuse-ld=gold -o $@ -g -nostdlib || touch $@ + implptr-64bit-d2o4a8r8t0: $(CC) $(TEST_SRC)/implptr-64bit-d2o4a8r8t0.S $(TEST_SRC)/main.c -o $@ \ -g || touch $@ diff --git a/dwz.c b/dwz.c index 342a742..19e8f10 100644 --- a/dwz.c +++ b/dwz.c @@ -10673,7 +10673,10 @@ write_dso (DSO *dso, const char *file, struct stat *st) j = sorted_section_numbers[l]; if (j == dso->ehdr.e_shnum) continue; - else if (dso->shdr[j].sh_offset < min_shoff && !last_shoff) + else if (!last_shoff + && (dso->shdr[j].sh_offset < min_shoff + || (dso->shdr[j].sh_offset == min_shoff + && dso->shdr[j].sh_size == 0))) continue; else if ((dso->shdr[j].sh_flags & SHF_ALLOC) != 0) { diff --git a/testsuite/dwz.tests/dwz-tests.exp b/testsuite/dwz.tests/dwz-tests.exp index e974e7d..ad1ac47 100644 --- a/testsuite/dwz.tests/dwz-tests.exp +++ b/testsuite/dwz.tests/dwz-tests.exp @@ -49,6 +49,9 @@ foreach test $tests { if { $basename == "gold-gdb-index.sh" } { lappend required_execs "hello-gold-gdb-index" } + if { $basename == "pr24747.sh" } { + lappend required_execs "start-gold" + } if { ![istarget x86_64-*-*] } { if { $basename == "pr24468.sh" } { unsupported "$test" diff --git a/testsuite/dwz.tests/pr24747.sh b/testsuite/dwz.tests/pr24747.sh new file mode 100644 index 0000000..1e555ce --- /dev/null +++ b/testsuite/dwz.tests/pr24747.sh @@ -0,0 +1,7 @@ +cp $execs/start-gold 1 + +dwz 1 + +smaller-than.sh 1 $execs/hello + +rm -f 1