From a3e00a8704fee31d815aeb5983a881eed490969e Mon Sep 17 00:00:00 2001 From: James Clarke Date: Tue, 20 Jun 2017 18:01:52 +0930 Subject: [GOLD] Avoid duplicate PLT stub symbols on ppc32 If two objects are compiled with -fPIC or -fPIE and call the same function, two different PLT entries are created, one for each object, but the same stub symbol name is used for both. * powerpc.cc (Stub_table::define_stub_syms): Always include object's uniq_ value. --- gold/ChangeLog | 5 +++++ gold/powerpc.cc | 18 ++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index f6a0836..98adcbb 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,8 @@ +2017-06-20 James Clarke + + * powerpc.cc (Stub_table::define_stub_syms): Always include object's + uniq_ value. + 2017-06-03 Alan Modra Apply from master diff --git a/gold/powerpc.cc b/gold/powerpc.cc index 1f2bc9e..a448efb 100644 --- a/gold/powerpc.cc +++ b/gold/powerpc.cc @@ -4656,19 +4656,25 @@ Stub_table::define_stub_syms(Symbol_table* symtab) add[0] = 0; if (cs->first.addend_ != 0) sprintf(add, "+%x", static_cast(cs->first.addend_)); - char localname[18]; - const char *symname; - if (cs->first.sym_ == NULL) + char obj[10]; + obj[0] = 0; + if (cs->first.object_) { const Powerpc_relobj* ppcobj = static_cast *>(cs->first.object_); - sprintf(localname, "%x:%x", ppcobj->uniq(), cs->first.locsym_); + sprintf(obj, "%x:", ppcobj->uniq()); + } + char localname[9]; + const char *symname; + if (cs->first.sym_ == NULL) + { + sprintf(localname, "%x", cs->first.locsym_); symname = localname; } else symname = cs->first.sym_->name(); - char* name = new char[8 + 10 + strlen(symname) + strlen(add) + 1]; - sprintf(name, "%08x.plt_call.%s%s", this->uniq_, symname, add); + char* name = new char[8 + 10 + strlen(obj) + strlen(symname) + strlen(add) + 1]; + sprintf(name, "%08x.plt_call.%s%s%s", this->uniq_, obj, symname, add); Address value = this->stub_address() - this->address() + cs->second; unsigned int stub_size = this->plt_call_size(cs); this->targ_->define_local(symtab, name, this, value, stub_size); -- cgit v1.1