From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 245C23857C74; Wed, 31 Mar 2021 19:27:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 245C23857C74 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/99490] [11 Regression] -gdwarf-5 -gsplit-dwarf puts .debug_rnglists to main file, not .dwo file Date: Wed, 31 Mar 2021 19:27:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: wrong-debug X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Mar 2021 19:27:27 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99490 --- Comment #19 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:4b33c5aaab9e863da162942ab8bcd54070b705af commit r11-7938-g4b33c5aaab9e863da162942ab8bcd54070b705af Author: Jakub Jelinek Date: Wed Mar 31 21:25:58 2021 +0200 dwarf2out: Fix up ranges for -gdwarf-5 -gsplit-dwarf [PR99490] For -gdwarf-4 -gsplit-dwarf we used to emit .debug_ranges section (so in the binaries/shared libraries) with DW_AT_ranges from skeleton units as well as .debug_info.dwo pointing to it through DW_FORM_sec_off= set (and DW_AT_GNU_ranges_base pointing into section, not sure for what reason exactly). When DWARF5 support was being added, we've started using .debug_rnglists section, added DW_AT_rnglists_base to the DW_TAG_skeleton_unit, kept DW_AT_ranges with DW_FORM_sec_offset in the skeleton and switched over to DW_FORM_rnglistx for DW_AT_ranges in .debug_info.dwo. But the DWARF5 spec actually means for the ranges section (at least everything for those DW_AT_ranges in .debug_info.dwo) to sit in .debug_rnglists.dwo section next to the .debug_info.dwo, rather than having consumers look it up in the binary/shared library instead. Based on some discussions in the DWARF discuss mailing list: =20=20=20 http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/2021-March/t= hread.html#4765 this patch mostly follows what LLVM emits for that right now: 1) small .debug_rnglists section (when needed) just to cover the skeleton DW_AT_ranges (if present); the content of the section uses the Split DWARFy DW_RLE_* codes with addrx encodings where possible 2) DW_AT_ranges in the skeleton uses DW_FORM_sec_offset (difference from LLVM which uses DW_FORM_rnglistx, which makes it larger and ambiguous) 3) DW_AT_rnglists_base attribute is gone from the skeleton (again, unlike LLVM where it is just confusing what exactly it means because it is inherited; it would make sense if we emitted DW_FORM_rnglistx in non-split DWARF, but unless ranges are shared, I'm afraid we'd make DWARF larger with fewer relocations by that) 4) usually big .debug_rnglists.dwo section again with using DW_RLE_*x* where possible 5) DW_AT_ranges with DW_FORM_rnglistx from .debug_info.dwo referring to that .debug_rnglists.dwo ranges 2021-03-31 Jakub Jelinek PR debug/99490 * dwarf2out.c (debug_ranges_dwo_section): New variable. (DW_RANGES_IDX_SKELETON): Define. (struct dw_ranges): Add begin_entry and end_entry members. (DEBUG_DWO_RNGLISTS_SECTION): Define. (add_ranges_num): Adjust r initializer for addition of *_entry members. (add_ranges_by_labels): For -gsplit-dwarf and force_direct, set idx to DW_RANGES_IDX_SKELETON. (use_distinct_base_address_for_range): New function. (index_rnglists): Don't set r->idx if it is equal to DW_RANGES_IDX_SKELETON. Initialize r->begin_entry and r->end_entry for -gsplit-dwarf if those will be needed by output_rnglists. (output_rnglists): Add DWO argument. If true, switch to debug_ranges_dwo_section rather than debug_ranges_section. Adjust l1/l2 label indexes. Only output the offset table when dwo is true and don't include in there the skeleton range entry if present. For -gsplit-dwarf, skip ranges that belong to the other rnglists section. Change return type from void to bool and return true if there are any range entries for the other section. For dwarf_split_debug_info use DW_RLE_startx_endx, DW_RLE_startx_length and DW_RLE_base_addres= sx entries instead of DW_RLE_start_end, DW_RLE_start_length and DW_RLE_base_address. Use use_distinct_base_address_for_range. (init_sections_and_labels): Initialize debug_ranges_dwo_section if -gsplit-dwarf and DWARF >=3D 5. Adjust ranges_section_label and range_base_label indexes. (dwarf2out_finish): Call index_rnglists earlier before finalizi= ng .debug_addr. Never emit DW_AT_rnglists_base attribute. For -gsplit-dwarf and DWARF >=3D 5 call output_rnglists up to twice with different dwo arguments. (dwarf2out_c_finalize): Clear debug_ranges_dwo_section.=