Discussion:
[PATCH] gold: Provide more failed archive member info in error message
H.J. Lu
2018-12-02 14:44:57 UTC
Permalink
When gold fails to get an archive member, its error message doesn't
have information for

1. The failed archive member name.
2. The cause of failure: non-ELF object vs non-IR object.

This patch adds the failed archive member name and non-ELF/non-IR info
to gold error message.

* archive.cc (Archive::get_elf_object_for_member): Also print
archive member and non-ELF/non-IR info on error.
---
gold/archive.cc | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/gold/archive.cc b/gold/archive.cc
index 4df9e74b07..181aef723f 100644
--- a/gold/archive.cc
+++ b/gold/archive.cc
@@ -690,6 +690,7 @@ Archive::get_elf_object_for_member(off_t off, bool* punconfigured)
int read_size;
Object *obj = NULL;
bool is_elf_obj = false;
+ bool plugin_failed = false;

if (is_elf_object(input_file, memoff, &ehdr, &read_size))
{
@@ -716,12 +717,20 @@ Archive::get_elf_object_for_member(off_t off, bool* punconfigured)
delete obj;
return plugin_obj;
}
+
+ plugin_failed = true;
}

if (!is_elf_obj)
{
- gold_error(_("%s: member at %zu is not an ELF object"),
- this->name().c_str(), static_cast<size_t>(off));
+ if (plugin_failed)
+ gold_error(_("%s: plugin failed to claim member %s at %zu"),
+ this->name().c_str(), member_name.c_str(),
+ static_cast<size_t>(off));
+ else
+ gold_error(_("%s: member %s at %zu is not an ELF object"),
+ this->name().c_str(), member_name.c_str(),
+ static_cast<size_t>(off));
return NULL;
}
--
2.19.2
Cary Coutant
2018-12-04 08:00:38 UTC
Permalink
Post by H.J. Lu
+ bool plugin_failed = false;
if (is_elf_object(input_file, memoff, &ehdr, &read_size))
{
@@ -716,12 +717,20 @@ Archive::get_elf_object_for_member(off_t off, bool* punconfigured)
delete obj;
return plugin_obj;
}
+
+ plugin_failed = true;
An unclaimed file is not a plugin "failure". I'd prefer to name this
variable "unclaimed".

-cary
H.J. Lu
2018-12-04 13:35:55 UTC
Permalink
Post by Cary Coutant
Post by H.J. Lu
+ bool plugin_failed = false;
if (is_elf_object(input_file, memoff, &ehdr, &read_size))
{
@@ -716,12 +717,20 @@ Archive::get_elf_object_for_member(off_t off, bool* punconfigured)
delete obj;
return plugin_obj;
}
+
+ plugin_failed = true;
An unclaimed file is not a plugin "failure". I'd prefer to name this
variable "unclaimed".
Like this?
--
H.J.
H.J. Lu
2018-12-06 14:07:49 UTC
Permalink
Post by H.J. Lu
Post by Cary Coutant
Post by H.J. Lu
+ bool plugin_failed = false;
if (is_elf_object(input_file, memoff, &ehdr, &read_size))
{
@@ -716,12 +717,20 @@ Archive::get_elf_object_for_member(off_t off, bool* punconfigured)
delete obj;
return plugin_obj;
}
+
+ plugin_failed = true;
An unclaimed file is not a plugin "failure". I'd prefer to name this
variable "unclaimed".
Like this?
I will check it in.
--
H.J.
Cary Coutant
2018-12-06 20:59:02 UTC
Permalink
Post by H.J. Lu
Post by Cary Coutant
An unclaimed file is not a plugin "failure". I'd prefer to name this
variable "unclaimed".
Like this?
This is OK. Thanks!

-cary

Loading...