[PATCH] Provide string description of definition, visibility and resolution in LTO plug-in.
Martin Liška
mliska@suse.cz
Thu Mar 14 09:09:00 GMT 2019
On 3/13/19 1:28 PM, Nick Clifton wrote:
> Hi Martin,
>
> Sorry for the delay in reviewing.
Hi.
That's fine.
>
>> 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
>
Good point, I reworked that.
Patch survives tests on x86_64-linux-gnu.
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Provide-string-description-of-definition-visibility-.patch
Type: text/x-patch
Size: 3988 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20190314/bcf18168/attachment.bin>
More information about the Binutils
mailing list