From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 2F66839484B7 for ; Tue, 10 Mar 2020 14:55:14 +0000 (GMT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4D39BAC61; Tue, 10 Mar 2020 14:55:13 +0000 (UTC) Date: Tue, 10 Mar 2020 15:55:13 +0100 (CET) From: Richard Biener To: H dot J dot Lu cc: Alan Modra , binutils@sourceware.org Subject: Re: [PATCH] Use GCC LTO wrapper to get real symbols from LTO IR objects In-Reply-To: Message-ID: References: <20200210142435.397899-1-hjl.tools@gmail.com> <20200210230156.GR5669@bubble.grove.modra.org> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Mar 2020 14:55:14 -0000 On Mon, 10 Feb 2020, H dot J dot Lu wrote: > On Mon, Feb 10, 2020 at 3:02 PM Alan Modra wrote: > > > > Wow, that's a lot of work to get proper symbol type. What happens if > > Very true. I couldn't come up with a better solution without changing plugin > API. > > > you run nm on a system where gcc isn't installed? Or where the lto > > version doesn't match? > > I assume standard GCC installation directory layout like > > PREFIX/libexec/gcc/TARGET/VERSION/liblto_plugin.so > PREFIX/libexec/gcc/TARGET/VERSION/lto-wrapper > > and > > PREFIX/bin/TARGET-gcc > > or > > PREFIX/bin/gcc > > If there is no gcc nor lto-wrapper at expected location, no real > symbols will be used. If LTO version doesn't match, it is a > GCC installation problem. GCC installation problem? Uh. The attempt to find the approprate GCC driver to do code generation is bound to fail in interesting ways. Not sure if the cases that are fixed with this approach are better than the know shortcomings of the symbol table part of the plugin API and the resulting impreciseness of nm output. For better heuristics you should probably parse the .comment section of the object file which contains GCC version information: > readelf -x 13 x.o Hex dump of section '.comment': 0x00000000 00474343 3a202847 4e552920 31302e30 .GCC: (GNU) 10.0 0x00000010 2e312032 30323030 33303520 28657870 .1 20200305 (exp 0x00000020 6572696d 656e7461 6c2900 erimental). which might help to disambiguate the choice between multiple installed compiler candidates. For SUSE installed systems it's common to have an "old" lto-plugin but also newer compilers installed so using solely the lto-plugin location is misleading. As said, there's technically no way to get at the correct lto-wrapper or compiler driver (for COLLECT_GCC) for an LTO object. The only solution is to extend the plugin API (and the LTO bytecode symbol table). Richard.