From f073a3e8c6735bd8fc24d35a957d8944087ea367 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Fri, 28 Jun 2019 10:17:45 +0930 Subject: [GOLD] PowerPC linkage table error This fixes a segfault when attempring to output a "linkage table error". "object" is only non-NULL in the local symbol case. * powerpc.cc (Stub_table::plt_error): New function. (Stub_table::do_write): Use it. (Output_data_glink::do_write): Don't segfault emitting linkage table error. --- gold/ChangeLog | 7 +++++++ gold/powerpc.cc | 23 ++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'gold') diff --git a/gold/ChangeLog b/gold/ChangeLog index 955e556..225a85c 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,5 +1,12 @@ 2019-06-28 Alan Modra + * powerpc.cc (Stub_table::plt_error): New function. + (Stub_table::do_write): Use it. + (Output_data_glink::do_write): Don't segfault emitting linkage + table error. + +2019-06-28 Alan Modra + * powerpc.cc (Target_powerpc::Scan::get_reference_flags): Handle REL16_HIGH* relocs. (Target_powerpc::Scan::local): Likewise. diff --git a/gold/powerpc.cc b/gold/powerpc.cc index 1f24071..43010b8 100644 --- a/gold/powerpc.cc +++ b/gold/powerpc.cc @@ -4733,6 +4733,9 @@ class Stub_table : public Output_relaxed_input_section return bytes; } + void + plt_error(const Plt_stub_key& p); + // Write out stubs. void do_write(Output_file*); @@ -5384,6 +5387,19 @@ Stub_table::define_stub_syms(Symbol_table* symtab) } } +template +void +Stub_table::plt_error(const Plt_stub_key& p) +{ + if (p.sym_) + gold_error(_("linkage table error against `%s'"), + p.sym_->demangled_name().c_str()); + else + gold_error(_("linkage table error against `%s:[local %u]'"), + p.object_->name().c_str(), + p.locsym_); +} + // Write out plt and long branch stub code. template @@ -5424,9 +5440,7 @@ Stub_table::do_write(Output_file* of) Address off = plt_addr - got_addr; if (off + 0x80008000 > 0xffffffff || (off & 7) != 0) - gold_error(_("%s: linkage table error against `%s'"), - cs->first.object_->name().c_str(), - cs->first.sym_->demangled_name().c_str()); + this->plt_error(cs->first); bool plt_load_toc = this->targ_->abiversion() < 2; bool static_chain @@ -5871,8 +5885,7 @@ Output_data_glink::do_write(Output_file* of) Address off = plt_addr - my_addr; if (off + 0x80008000 > 0xffffffff || (off & 3) != 0) - gold_error(_("%s: linkage table error against `%s'"), - ge->first->object()->name().c_str(), + gold_error(_("linkage table error against `%s'"), ge->first->demangled_name().c_str()); write_insn(p, addis_12_12 + ha(off)), p += 4; -- cgit v1.1