From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10367 invoked by alias); 10 Feb 2020 23:02:04 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 10359 invoked by uid 89); 10 Feb 2020 23:02:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=H*i:sk:CAMe9rO X-HELO: mail-pf1-f193.google.com Received: from mail-pf1-f193.google.com (HELO mail-pf1-f193.google.com) (209.85.210.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Feb 2020 23:02:02 +0000 Received: by mail-pf1-f193.google.com with SMTP id i6so4456584pfc.1 for ; Mon, 10 Feb 2020 15:02:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=cwHOlNBkUaUJ+qLiFdzGSggSxYSX6Xei5om+9AZ1tv0=; b=Genl43CkvB3VDKQJr9O/dIuQ0NYyO2IbNWnLlMW3P3ihnl2DyUECFEowwRbOW5b+69 zMrxH+U4YmnD2uOc//8ZN6n9AlT8T8giCjxO4ebcKvMr6y9CtYAQhsJAwveXDaCc9IPs Lka9KC7hQzpR0WZeiWdvkN1aez2TNuMO+9qS3olX9bgNhqawuEuixGUKZGAuxLVtasAW L4bP9TJPR4P37ePfR/zeQ+ykfecv4NCtJOrtMg39vOW4foXvEhcoBuxu/5dmSFjthi5h uc07/ZbQ4/Zw7XXrH5IO3iJpp3jFoOITtfmsAVTP49DoA0C+xCf44XvNKIX47bdc86PN h1vg== Return-Path: Received: from bubble.grove.modra.org ([2406:3400:51d:8cc0:d5a4:7e63:5182:cf65]) by smtp.gmail.com with ESMTPSA id j21sm450376pji.13.2020.02.10.15.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 15:02:00 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id F2388807F6; Tue, 11 Feb 2020 09:31:56 +1030 (ACDT) Date: Mon, 10 Feb 2020 23:02:00 -0000 From: Alan Modra To: "H.J. Lu" Cc: Binutils Subject: Re: [PATCH] Use GCC LTO wrapper to get real symbols from LTO IR objects Message-ID: <20200210230156.GR5669@bubble.grove.modra.org> References: <20200210142435.397899-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00160.txt.bz2 Wow, that's a lot of work to get proper symbol type. What happens if you run nm on a system where gcc isn't installed? Or where the lto version doesn't match? On Mon, Feb 10, 2020 at 01:31:16PM -0800, H.J. Lu wrote: > + gcc_name = bfd_malloc (length + target_length + sizeof ("gcc")); > + memcpy (gcc_name, real_name, length); No check of bfd_malloc return value before use. > + wrapper_name = bfd_malloc (length + sizeof ("lto-wrapper")); > + memcpy (wrapper_name, real_name, length); Again. > + real_syms = (asymbol **) xmalloc (real_symsize); xmalloc shouldn't be used in libbfd. > struct plugin_data_struct *plugin_data = > bfd_alloc (abfd, sizeof (plugin_data_struct)); This also doesn't check for NULL, preexisting bug. > + int i; > + > + /* NB: LTO symbols are owned by LTO plugin. Create a copy so that we > + can use it in bfd_plugin_canonicalize_symtab. */ > + copy_of_syms = bfd_alloc (abfd, nsyms * sizeof (*syms)); > + memcpy (copy_of_syms, syms, nsyms * sizeof (*syms)); > + for (i = 0; i < nsyms; i++) > + copy_of_syms[i].name = xstrdup (syms[i].name); xstrdup shouldn't be used in libbfd. -- Alan Modra Australia Development Lab, IBM