This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Provide string description of definition, visibility and resolution in LTO plug-in.
- From: Nick Clifton <nickc at redhat dot com>
- To: Martin Liška <mliska at suse dot cz>, binutils at sourceware dot org
- Date: Wed, 13 Mar 2019 12:28:51 +0000
- Subject: Re: [PATCH] Provide string description of definition, visibility and resolution in LTO plug-in.
- References: <c6183e18-1908-aaff-d2fb-ad30b09042a8@suse.cz>
Hi Martin,
Sorry for the delay in reviewing.
> I would like to enhance get_symbols function to report string
> representation of definition, visibility and resolution.
> It's easier for users to read it.
Agreed, but ...
@@ -777,9 +808,11 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
syms[n].resolution = res;
if (report_plugin_symbols)
einfo (_("%P: %pB: symbol `%s' "
- "definition: %d, visibility: %d, resolution: %d\n"),
+ "definition: %s, visibility: %s, resolution: %s\n"),
abfd, syms[n].name,
- syms[n].def, syms[n].visibility, res);
+ lto_kind_str[syms[n].def],
+ lto_visibility_str[syms[n].visibility],
+ lto_resolution_str[res]);
You need to be more paranoid. If one of the values is not in the
expected range, then you will have an illegal or unexpected memory
dereference via the array accesses.
My suggestion - create a set of small new functions which return
the name of a particular value, and which handle unknown values.
eg:
const char *
get_lto_kind (unsigned int index)
{
const char *lto_kind_str[5] =
{
"DEF",
"WEAKDEF",
"UNDEF",
"WEAKUNDEF",
"COMMON"
};
if (index < ARRAY_SIZE (lto_kind_str))
return lto_kind_str [index];
const char buf [1024];
sprintf (buf, _("unknown definition value %x"), index);
return buf;
}
Then use these new functions in the einfo() statement.
Cheers
Nick