From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: [PATCH] Use GCC LTO wrapper to get real symbols from LTO IR objects
Date: Mon, 10 Feb 2020 23:02:00 -0000 [thread overview]
Message-ID: <20200210230156.GR5669@bubble.grove.modra.org> (raw)
In-Reply-To: <CAMe9rOoSuEbOPxZ0jDgE9kWgQOEkS4fozOKCboQEXB-u6B19Qg@mail.gmail.com>
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
next prev parent reply other threads:[~2020-02-10 23:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-10 14:24 H.J. Lu
2020-02-10 21:31 ` H.J. Lu
2020-02-10 23:02 ` Alan Modra [this message]
2020-02-11 1:23 ` H.J. Lu
2020-02-11 2:31 ` Alan Modra
2020-02-11 12:21 ` H.J. Lu
2020-02-11 22:05 ` [PATCH] Plugin: Treat each object as independent H.J. Lu
2020-02-11 22:22 ` Alan Modra
2020-02-11 16:07 ` [PATCH] Use GCC LTO wrapper to get real symbols from LTO IR objects Michael Matz
2020-02-11 17:04 ` H.J. Lu
2020-02-13 8:15 ` Alan Modra
2020-03-10 14:55 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200210230156.GR5669@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=hjl.tools@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).