This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 1/1] gold: Avoid duplicate PLT stub symbols on PowerPC
- From: James Clarke <jrtc27 at jrtc27 dot com>
- To: binutils at sourceware dot org
- Cc: James Clarke <jrtc27 at jrtc27 dot com>
- Date: Sun, 18 Jun 2017 22:58:03 +0100
- Subject: [PATCH 1/1] gold: Avoid duplicate PLT stub symbols on PowerPC
- Authentication-results: sourceware.org; auth=none
- References: <20170618215803.21349-1-jrtc27@jrtc27.com>
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. Therefore let's make
the names unique by incorporating the object's uniq_ value where
necessary.
gold/
* (Stub_table::define_stub_syms): Include object's uniq_ value
when set for non-local symbols as well.
---
gold/powerpc.cc | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/gold/powerpc.cc b/gold/powerpc.cc
index 1f2bc9ede7..a448efbc94 100644
--- a/gold/powerpc.cc
+++ b/gold/powerpc.cc
@@ -4656,19 +4656,25 @@ Stub_table<size, big_endian>::define_stub_syms(Symbol_table* symtab)
add[0] = 0;
if (cs->first.addend_ != 0)
sprintf(add, "+%x", static_cast<uint32_t>(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<size, big_endian>* ppcobj = static_cast
<const Powerpc_relobj<size, big_endian>*>(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);
--
2.13.1