From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E93613857013; Wed, 7 Oct 2020 06:53:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E93613857013 From: "marxin at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/97290] Segmentation fault in lto-wrapper Date: Wed, 07 Oct 2020 06:53:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 10.2.1 X-Bugzilla-Keywords: patch X-Bugzilla-Severity: normal X-Bugzilla-Who: marxin at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: marxin at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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, 07 Oct 2020 06:53:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97290 --- Comment #8 from Martin Li=C5=A1ka --- Fixed on master with g:190c04ba36d9c6c3dce41f12012aa97c6d7f22f5 commit 190c04ba36d9c6c3dce41f12012aa97c6d7f22f5 Author: Martin Liska Date: Mon Oct 5 18:03:08 2020 +0200 lto: fix LTO debug sections copying. readelf -S prints: There are 81999 section headers, starting at offset 0x1f488060: Section Headers: [Nr] Name Type Address Off Size = ES Flg Lk Inf Al [ 0] NULL 0000000000000000 000000 01404f= 00=20 81998 0 0 [ 1] .group GROUP 0000000000000000 000040 000008= 04=20 81995 105027 4 ... [81995] .symtab SYMTAB 0000000000000000 d5d9298 2d= b310 18 81997 105026 8 [81996] .symtab_shndx SYMTAB SECTION INDICES 0000000000000000 d8b= 45a8 079dd8 04 81995 0 4 [81997] .strtab STRTAB 0000000000000000 d92e380 80= 460c 00 0 0 1 ... Looking at the documentation: Table 7=E2=80=9315 ELF sh_link and sh_info Interpretation sh_type - sh_link SHT_SYMTAB - The section header index of the associated string table. SHT_SYMTAB_SHNDX - The section header index of the associated symbol ta= ble. As seen, sh_link of a SHT_SYMTAB always points to a .strtab and readelf confirms that. So we need to use reverse mapping taken from [81996] .symtab_shndx SYMTAB SECTION INDICES 0000000000000000 d8b= 45a8 079dd8 04 81995 0 4 where sh_link points to 81995. libiberty/ChangeLog: PR lto/97290 * simple-object-elf.c (simple_object_elf_copy_lto_debug_section= s): Use sh_link of a .symtab_shndx section.=