[PATCH] gold: fix crash for empty file
Cary Coutant
ccoutant@gmail.com
Wed Jan 5 17:35:36 GMT 2022
> >> @@ -701,6 +701,8 @@ Symbol_table::resolve_forwards(const Symbol* from) const
> >> Symbol*
> >> Symbol_table::lookup(const char* name, const char* version) const
> >> {
> >> + if (name == NULL)
> >> + return NULL;
I'm more concerned with why a NULL name got passed to lookup in the
first place. In this test case, it's because parameters->entry() is
returning NULL, which in turn is because no (valid) object files have
been named, so a target hasn't been determined. I'd be more
comfortable with maintaining the requirement of passing a non-null
name to Symbol_table::lookup() (perhaps even adding an assert to that
effect), and then fixing Plugin_hook::run() to check for NULL before
calling lookup.
-cary
More information about the Binutils
mailing list