Skip to content

Commit 7ea79cb

Browse files
committed
Provide string description of definition, visibility and resolution in LTO plug-in.
ld/ChangeLog: 2019-02-26 Martin Liska <[email protected]> * plugin.c (get_symbols): Add lto_kind_str, lto_resolution_str, lto_visibility_str and use then to inform about plugin-symbols. * testsuite/ld-plugin/plugin-12.d: Adjust expected pattern.
1 parent 5fb812f commit 7ea79cb

3 files changed

Lines changed: 81 additions & 6 deletions

File tree

ld/ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2019-03-26 Martin Liska <[email protected]>
2+
3+
* plugin.c (get_symbols): Add lto_kind_str, lto_resolution_str,
4+
lto_visibility_str and use then to inform about plugin-symbols.
5+
* testsuite/ld-plugin/plugin-12.d: Adjust expected pattern.
6+
17
2019-03-25 Tamar Christina <[email protected]>
28

39
* testsuite/ld-arm/jump-reloc-veneers-cond-long.d: Update disassembly.

ld/plugin.c

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,73 @@ is_visible_from_outside (struct ld_plugin_symbol *lsym,
659659
return FALSE;
660660
}
661661

662+
/* Return LTO kind string name that corresponds to INDEX enum value. */
663+
static const char *
664+
get_lto_kind (unsigned int index)
665+
{
666+
static char buffer[64];
667+
const char *lto_kind_str[5] =
668+
{
669+
"DEF",
670+
"WEAKDEF",
671+
"UNDEF",
672+
"WEAKUNDEF",
673+
"COMMON"
674+
};
675+
676+
if (index < ARRAY_SIZE (lto_kind_str))
677+
return lto_kind_str [index];
678+
679+
sprintf (buffer, _("unknown LTO kind value %x"), index);
680+
return buffer;
681+
}
682+
683+
/* Return LTO resolution string name that corresponds to INDEX enum value. */
684+
static const char *
685+
get_lto_resolution (unsigned int index)
686+
{
687+
static char buffer[64];
688+
static const char *lto_resolution_str[10] =
689+
{
690+
"UNKNOWN",
691+
"UNDEF",
692+
"PREVAILING_DEF",
693+
"PREVAILING_DEF_IRONLY",
694+
"PREEMPTED_REG",
695+
"PREEMPTED_IR",
696+
"RESOLVED_IR",
697+
"RESOLVED_EXEC",
698+
"RESOLVED_DYN",
699+
"PREVAILING_DEF_IRONLY_EXP",
700+
};
701+
702+
if (index < ARRAY_SIZE (lto_resolution_str))
703+
return lto_resolution_str [index];
704+
705+
sprintf (buffer, _("unknown LTO resolution value %x"), index);
706+
return buffer;
707+
}
708+
709+
/* Return LTO visibility string name that corresponds to INDEX enum value. */
710+
static const char *
711+
get_lto_visibility (unsigned int index)
712+
{
713+
static char buffer[64];
714+
const char *lto_visibility_str[4] =
715+
{
716+
"DEFAULT",
717+
"PROTECTED",
718+
"INTERNAL",
719+
"HIDDEN"
720+
};
721+
722+
if (index < ARRAY_SIZE (lto_visibility_str))
723+
return lto_visibility_str [index];
724+
725+
sprintf (buffer, _("unknown LTO visibility value %x"), index);
726+
return buffer;
727+
}
728+
662729
/* Get the symbol resolution info for a plugin-claimed input file. */
663730
static enum ld_plugin_status
664731
get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
@@ -777,9 +844,11 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
777844
syms[n].resolution = res;
778845
if (report_plugin_symbols)
779846
einfo (_("%P: %pB: symbol `%s' "
780-
"definition: %d, visibility: %d, resolution: %d\n"),
847+
"definition: %s, visibility: %s, resolution: %s\n"),
781848
abfd, syms[n].name,
782-
syms[n].def, syms[n].visibility, res);
849+
get_lto_kind (syms[n].def),
850+
get_lto_visibility (syms[n].visibility),
851+
get_lto_resolution (res));
783852
}
784853
return LDPS_OK;
785854
}

ld/testsuite/ld-plugin/plugin-12.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#...
2-
.*: symbol `func' definition: 0, visibility: 0, resolution: 2
3-
.*: symbol `func1' definition: 0, visibility: 1, resolution: 3
4-
.*: symbol `func2' definition: 0, visibility: 2, resolution: 3
5-
.*: symbol `func3' definition: 0, visibility: 3, resolution: 3
2+
.*: symbol `func' definition: DEF, visibility: DEFAULT, resolution: PREVAILING_DEF
3+
.*: symbol `func1' definition: DEF, visibility: PROTECTED, resolution: PREVAILING_DEF_IRONLY
4+
.*: symbol `func2' definition: DEF, visibility: INTERNAL, resolution: PREVAILING_DEF_IRONLY
5+
.*: symbol `func3' definition: DEF, visibility: HIDDEN, resolution: PREVAILING_DEF_IRONLY
66
#pass

0 commit comments

Comments
 (0)