This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Provide string description of definition, visibility and resolution in LTO plug-in.


Hi.

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.

Patch survives tests on x86_64-linux-gnu.

ld/ChangeLog:

2019-02-26  Martin Liska  <mliska@suse.cz>

	* 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.
---
 ld/plugin.c                        | 37 ++++++++++++++++++++++++++++--
 ld/testsuite/ld-plugin/plugin-12.d |  8 +++----
 2 files changed, 39 insertions(+), 6 deletions(-)


diff --git a/ld/plugin.c b/ld/plugin.c
index ea1a7f7064..e86d22d432 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -165,6 +165,37 @@ static const enum ld_plugin_tag tv_header_tags[] =
   LDPT_SET_EXTRA_LIBRARY_PATH
 };
 
+static const char *lto_kind_str[5] =
+{
+  "DEF",
+  "WEAKDEF",
+  "UNDEF",
+  "WEAKUNDEF",
+  "COMMON"
+};
+
+static const char *lto_resolution_str[10] =
+{
+  "UNKNOWN",
+  "UNDEF",
+  "PREVAILING_DEF",
+  "PREVAILING_DEF_IRONLY",
+  "PREEMPTED_REG",
+  "PREEMPTED_IR",
+  "RESOLVED_IR",
+  "RESOLVED_EXEC",
+  "RESOLVED_DYN",
+  "PREVAILING_DEF_IRONLY_EXP",
+};
+
+const char *lto_visibility_str[4] =
+{
+  "DEFAULT",
+  "PROTECTED",
+  "INTERNAL",
+  "HIDDEN"
+};
+
 /* How many entries in the constant leading part of the tv array.  */
 static const size_t tv_header_size = ARRAY_SIZE (tv_header_tags);
 
@@ -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]);
     }
   return LDPS_OK;
 }
diff --git a/ld/testsuite/ld-plugin/plugin-12.d b/ld/testsuite/ld-plugin/plugin-12.d
index 10d772553d..35eae1e00a 100644
--- a/ld/testsuite/ld-plugin/plugin-12.d
+++ b/ld/testsuite/ld-plugin/plugin-12.d
@@ -1,6 +1,6 @@
 #...
-.*: symbol `func' definition: 0, visibility: 0, resolution: 2
-.*: symbol `func1' definition: 0, visibility: 1, resolution: 3
-.*: symbol `func2' definition: 0, visibility: 2, resolution: 3
-.*: symbol `func3' definition: 0, visibility: 3, resolution: 3
+.*: symbol `func' definition: DEF, visibility: DEFAULT, resolution: PREVAILING_DEF
+.*: symbol `func1' definition: DEF, visibility: PROTECTED, resolution: PREVAILING_DEF_IRONLY
+.*: symbol `func2' definition: DEF, visibility: INTERNAL, resolution: PREVAILING_DEF_IRONLY
+.*: symbol `func3' definition: DEF, visibility: HIDDEN, resolution: PREVAILING_DEF_IRONLY
 #pass


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]