This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: powerpc64 multiple toc refinement
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: binutils at sources dot redhat dot com
- Date: Thu, 19 Jun 2003 23:23:37 +0930
- Subject: Re: powerpc64 multiple toc refinement
- References: <20030619114808.GL12458@bubble.sa.bigpond.net.au>
Some code to support generation of stub statistics sneaked into the
last patch. This one prints out the info.
* elf64-ppc.c (ppc64_elf_reloc_type_lookup): Tidy prototype.
(ppc64_elf_info_to_howto): Likewise.
(ppc64_elf_build_stubs): Add "stats" param, and print statistics.
* elf64-ppc.h (ppc64_elf_build_stubs): Adjust prototype.
* emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Dump out
statistics from ppc64_elf_build_stubs.
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.110
diff -u -p -r1.110 elf64-ppc.c
--- bfd/elf64-ppc.c 19 Jun 2003 11:49:01 -0000 1.110
+++ bfd/elf64-ppc.c 19 Jun 2003 13:38:17 -0000
@@ -33,9 +33,9 @@
static void ppc_howto_init
PARAMS ((void));
static reloc_howto_type *ppc64_elf_reloc_type_lookup
- PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+ PARAMS ((bfd *, bfd_reloc_code_real_type));
static void ppc64_elf_info_to_howto
- PARAMS ((bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst));
+ PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
static bfd_reloc_status_type ppc64_elf_ha_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_reloc_status_type ppc64_elf_brtaken_reloc
@@ -7114,9 +7114,10 @@ ppc64_elf_toc (obfd)
hash table. This function is called via gldelf64ppc_finish. */
bfd_boolean
-ppc64_elf_build_stubs (emit_stub_syms, info)
+ppc64_elf_build_stubs (emit_stub_syms, info, stats)
bfd_boolean emit_stub_syms;
struct bfd_link_info *info;
+ char **stats;
{
struct ppc_link_hash_table *htab = ppc_hash_table (info);
asection *stub_sec;
@@ -7242,7 +7243,29 @@ ppc64_elf_build_stubs (emit_stub_syms, i
(*_bfd_error_handler) (_("stubs don't match calculated size"));
}
- return !htab->stub_error;
+ if (htab->stub_error)
+ return FALSE;
+
+ if (stats != NULL)
+ {
+ *stats = bfd_malloc (500);
+ if (*stats == NULL)
+ return FALSE;
+
+ sprintf (*stats, _("linker stubs in %u groups\n"
+ " branch %lu\n"
+ " toc adjust %lu\n"
+ " long branch %lu\n"
+ " long toc adj %lu\n"
+ " plt call %lu"),
+ htab->stub_bfd->section_count,
+ htab->stub_count[(int) ppc_stub_long_branch - 1],
+ htab->stub_count[(int) ppc_stub_long_branch_r2off - 1],
+ htab->stub_count[(int) ppc_stub_plt_branch - 1],
+ htab->stub_count[(int) ppc_stub_plt_branch_r2off - 1],
+ htab->stub_count[(int) ppc_stub_plt_call - 1]);
+ }
+ return TRUE;
}
/* The RELOCATE_SECTION function is called by the ELF backend linker
Index: bfd/elf64-ppc.h
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.h,v
retrieving revision 1.10
diff -u -p -r1.10 elf64-ppc.h
--- bfd/elf64-ppc.h 19 Jun 2003 11:49:02 -0000 1.10
+++ bfd/elf64-ppc.h 19 Jun 2003 13:04:04 -0000
@@ -39,4 +39,4 @@ bfd_boolean ppc64_elf_size_stubs
PARAMS ((bfd *, bfd *, struct bfd_link_info *, bfd_signed_vma,
asection *(*) (const char *, asection *), void (*) (void)));
bfd_boolean ppc64_elf_build_stubs
- PARAMS ((bfd_boolean, struct bfd_link_info *));
+ PARAMS ((bfd_boolean, struct bfd_link_info *, char **));
Index: ld/emultempl/ppc64elf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ppc64elf.em,v
retrieving revision 1.18
diff -u -p -r1.18 ppc64elf.em
--- ld/emultempl/ppc64elf.em 19 Jun 2003 11:51:55 -0000 1.18
+++ ld/emultempl/ppc64elf.em 19 Jun 2003 13:04:04 -0000
@@ -387,8 +387,22 @@ gld${EMULATION_NAME}_finish ()
if (stub_file != NULL && stub_file->the_bfd->sections != NULL)
{
- if (!ppc64_elf_build_stubs (emit_stub_syms, &link_info))
+ char *msg = NULL;
+ char *line, *endline;
+
+ if (!ppc64_elf_build_stubs (emit_stub_syms, &link_info,
+ config.stats ? &msg : NULL))
einfo ("%X%P: can not build stubs: %E\n");
+
+ for (line = msg; line != NULL; line = endline)
+ {
+ endline = strchr (line, '\n');
+ if (endline != NULL)
+ *endline++ = '\0';
+ fprintf (stderr, "%s: %s\n", program_name, line);
+ }
+ if (msg != NULL)
+ free (msg);
}
}
--
Alan Modra
IBM OzLabs - Linux Technology Centre