[GOLD] Avoid duplicate PLT stub symbols on ppc32
authorJames Clarke <jrtc27@jrtc27.com>
Tue, 20 Jun 2017 08:31:52 +0000 (18:01 +0930)
committerAlan Modra <amodra@gmail.com>
Tue, 20 Jun 2017 08:31:52 +0000 (18:01 +0930)
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
gold/powerpc.cc

index 0b751b571b788c887d236bca12b339a8cc46f3cf..2fd3038510f4f14cccbb949196a14d5de3e10506 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-20  James Clarke  <jrtc27@jrtc27.com>
+
+       * powerpc.cc (Stub_table::define_stub_syms): Always include object's
+       uniq_ value.
+
 2017-06-15  Eric Christopher  <echristo@gmail.com>
 
        * aarch64.cc: Fix a few typos and grammar-os.
index 1f2bc9ede798de03a647c91cd8b10e6268c0a0b6..a448efbc9440608aa847ae03a9c0f89944f1a3f9 100644 (file)
@@ -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);
This page took 0.030646 seconds and 4 git commands to generate.