From 1079403cc002be65ea1c318160efc18c19965389 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 11 Mar 2015 17:45:37 +1030 Subject: Fix ppc32 synthetic symbols when __tls_get_addr_opt stub is generated Also update the 32-bit tls testcases to be secure plt. bfd/ * elf32-ppc.c (ppc_elf_get_synthetic_symtab): Examine stubs in reverse order. Account for larger size of __tls_get_addr_opt stub. ld/testsuite/ * ld-powerpc/tls32.s: Add GOT pointer setup. * ld-powerpc/tls32.d: Update. * ld-powerpc/tls32.g: Update. * ld-powerpc/tls32.t: Update. * ld-powerpc/tlsexe.d: Update. * ld-powerpc/tlsexe32.d: Update. * ld-powerpc/tlsexe32.g: Update. * ld-powerpc/tlsexe32.r: Update. * ld-powerpc/tlsexetoc.d: Update. * ld-powerpc/tlsso32.d: Update. * ld-powerpc/tlsso32.g: Update. * ld-powerpc/tlsso32.r: Update. --- bfd/elf32-ppc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'bfd/elf32-ppc.c') diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index cc16b0d..d61d75e 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -2925,7 +2925,6 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms, } count = relplt->size / sizeof (Elf32_External_Rela); - stub_vma = glink_vma - (bfd_vma) count * 16; /* If the stubs are those for -shared/-pie then we might have multiple stubs for each plt entry. If that is the case then there is no way to associate stubs with their plt entries short @@ -2956,9 +2955,10 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms, if (s == NULL) return -1; + stub_vma = glink_vma; names = (char *) (s + count + 1 + (resolv_vma != 0)); - p = relplt->relocation; - for (i = 0; i < count; i++, p++) + p = relplt->relocation + count - 1; + for (i = 0; i < count; i++) { size_t len; @@ -2969,6 +2969,9 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms, s->flags |= BSF_GLOBAL; s->flags |= BSF_SYNTHETIC; s->section = glink; + stub_vma -= 16; + if (strcmp ((*p->sym_ptr_ptr)->name, "__tls_get_addr_opt") == 0) + stub_vma -= 32; s->value = stub_vma - glink->vma; s->name = names; s->udata.p = NULL; @@ -2985,7 +2988,7 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms, memcpy (names, "@plt", sizeof ("@plt")); names += sizeof ("@plt"); ++s; - stub_vma += 16; + --p; } /* Add a symbol at the start of the glink branch table. */ -- cgit v1.1