From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82916 invoked by alias); 23 Apr 2019 07:42:01 -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 82864 invoked by uid 48); 23 Apr 2019 07:41:57 -0000 From: "vries at gcc dot gnu.org" To: dwz@sourceware.org Subject: [Bug default/24477] New: multifile optimization fails if single-file optimization not beneficial Date: Tue, 01 Jan 2019 00:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: dwz X-Bugzilla-Component: default X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: nobody at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2019-q2/txt/msg00028.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D24477 Bug ID: 24477 Summary: multifile optimization fails if single-file optimization not beneficial Product: dwz Version: unspecified Status: NEW Severity: normal Priority: P2 Component: default Assignee: nobody at sourceware dot org Reporter: vries at gcc dot gnu.org CC: dwz at sourceware dot org Target Milestone: --- Say we multifile-optimize hello: ... $ rm -f 3 $ cp hello 1 $ cp 1 2 $ dwz -m 3 1 2 ... We find that the multifile is created, and linked to: ... $ ls 3 3 $ readelf -S 1 | grep alt [32] .gnu_debugaltlink PROGBITS 0000000000000000 00001182 ... What happens in dwz for -m, is that first 1 and 2 are optimized in single-f= ile mode, and then multifile-mode optimization is done. However, if we try to factor out the single-file mode optimization in a separate dwz invocation, we get instead: ... $ rm -f 3 $ cp hello 1 $ dwz 1 $ cp 1 2 $ ./dwz -m 3 1 2 ./dwz: 1: DWARF compression not beneficial - old size 436 new size 436 ./dwz: 2: DWARF compression not beneficial - old size 436 new size 436 $ ls 3 ls: cannot access '3': No such file or directory $ readelf -S 1 | grep alt $ ... In the "DWARF compression not beneficial" code in dwz () we still make an effort to do the multifile optimization: ... if (multifile && !fi_multifile && !low_mem) write_multifile (dso); ... and we count the dwz() invocation in successcount in main (used to determine whether there are sufficient files for multifile optimization). But multifile optimization fails because this triggers (on the first part) = in optimize_multifile: ... if (multi_ehdr.e_ident[0] =3D=3D '\0' || multi_ptr_size =3D=3D 0 || multi_endian =3D=3D 0) return -1; ... And multi_ehdr.e_ident[0] is only set in write_dso, which is not triggered. Tentative fix: ... diff --git a/dwz.c b/dwz.c index 2ea7c27..acec90a 100644 --- a/dwz.c +++ b/dwz.c @@ -10262,8 +10262,6 @@ write_dso (DSO *dso, const char *file, struct stat = *st) memset (remove_sections, '\0', sizeof (remove_sections)); ehdr =3D dso->ehdr; - if (multi_ehdr.e_ident[0] =3D=3D '\0') - multi_ehdr =3D ehdr; sort_section_numbers (dso, sorted_section_numbers); if (calculate_section_distance (dso, sorted_section_numbers, distance)) @@ -11001,6 +10999,9 @@ write_multifile (DSO *dso) unsigned int i; int ret =3D 0; + if (multi_ehdr.e_ident[0] =3D=3D '\0') + multi_ehdr =3D dso->ehdr; + if ((multi_ptr_size && ptr_size !=3D multi_ptr_size) || (multi_endian && multi_endian !=3D (do_read_32 =3D=3D buf_read_ule32 ... with which we get: ... $ rm -f 3 $ cp hello 1 $ dwz 1 $ cp 1 2 $ dwz -m 3 1 2 ./dwz: 1: DWARF compression not beneficial - old size 436 new size 436 ./dwz: 2: DWARF compression not beneficial - old size 436 new size 436 $ ls 3 3 $ readelf -S 1 | grep alt [32] .gnu_debugaltlink PROGBITS 0000000000000000 00001182 ... --=20 You are receiving this mail because: You are on the CC list for the bug.