aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-ppc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2010-07-06 09:29:47 +0000
committerAlan Modra <amodra@gmail.com>2010-07-06 09:29:47 +0000
commit50248c890f1bc82c6e1751bd549da7580c60f098 (patch)
tree12000cf2317e8f8b826e64787d87d057b988d1b0 /bfd/elf32-ppc.c
parentd3dbc53042f0e29120fe037b1ebaca342fe71ad2 (diff)
downloadgdb-50248c890f1bc82c6e1751bd549da7580c60f098.zip
gdb-50248c890f1bc82c6e1751bd549da7580c60f098.tar.gz
gdb-50248c890f1bc82c6e1751bd549da7580c60f098.tar.bz2
bfd/
* elf32-ppc.c (ppc_elf_relax_section): Insert branch around trampolines only for .init and .fini sections. ld/testsuite/ * ld-powerpc/relax.s: Add branch back to _start. * ld-powerpc/relax.d: Update. * ld-powerpc/relaxr.d: Update.
Diffstat (limited to 'bfd/elf32-ppc.c')
-rw-r--r--bfd/elf32-ppc.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 60adae8..e3638cd 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -5967,6 +5967,7 @@ ppc_elf_relax_section (bfd *abfd,
struct ppc_elf_link_hash_table *htab;
bfd_size_type trampoff;
asection *got2;
+ bfd_boolean maybe_pasted;
*again = FALSE;
@@ -5985,8 +5986,11 @@ ppc_elf_relax_section (bfd *abfd,
return TRUE;
trampoff = (isec->size + 3) & (bfd_vma) -4;
+ maybe_pasted = (strcmp (isec->output_section->name, ".init") == 0
+ || strcmp (isec->output_section->name, ".fini") == 0);
/* Space for a branch around any trampolines. */
- trampoff += 4;
+ if (maybe_pasted)
+ trampoff += 4;
symtab_hdr = &elf_symtab_hdr (abfd);
@@ -6311,7 +6315,6 @@ ppc_elf_relax_section (bfd *abfd,
{
const int *stub;
bfd_byte *dest;
- bfd_vma val;
int i, size;
do
@@ -6327,12 +6330,15 @@ ppc_elf_relax_section (bfd *abfd,
goto error_return;
isec->size = (isec->size + 3) & (bfd_vma) -4;
- /* Branch around the trampolines. */
- val = B + trampoff - isec->size;
dest = contents + isec->size;
+ /* Branch around the trampolines. */
+ if (maybe_pasted)
+ {
+ bfd_vma val = B + trampoff - isec->size;
+ bfd_put_32 (abfd, val, dest);
+ dest += 4;
+ }
isec->size = trampoff;
- bfd_put_32 (abfd, val, dest);
- dest += 4;
if (link_info->shared)
{