From 7341d5e22f1061016411734ba162d362ac5928db Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 1 Jul 2014 19:32:25 +0930 Subject: Add symbols for global entry stub, and report stats The undefined function symbols (with non-zero value) on global entry stubs are discarded by objdump when disassembling, so give objdump another symbol to mark the stubs. Also fixes a couple of bugs: - entry_section was set to .opd for ELFv2, which meant a hard error rather than a warning when _start wasn't defined. - global entry stubs were not built if they were the only type of stub in an executable. bfd/ * elf64-ppc.c (ppc_stub_type): Add ppc_stub_global_entry. (struct ppc_link_hash_table): Increase size of stub_count array. (build_global_entry_stubs): Emit symbol on global entry stub. (ppc64_elf_build_stubs): NULL check htab->brlt. Add global entry stub stats. ld/ * emultempl/ppc64elf.em (stub_added): Delete. (gld${EMULATION_NAME}_finish): Call ppc64_elf_build_stubs even when none of the usual stubs have been added. Only change entry_section for ELFv1. --- ld/ChangeLog | 7 +++++++ ld/emultempl/ppc64elf.em | 47 +++++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 24 deletions(-) (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index fd14305..bfddd80 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,5 +1,12 @@ 2014-07-01 Alan Modra + * emultempl/ppc64elf.em (stub_added): Delete. + (gld${EMULATION_NAME}_finish): Call ppc64_elf_build_stubs even when + none of the usual stubs have been added. Only change entry_section + for ELFv1. + +2014-07-01 Alan Modra + * sysdep.h: Don't include limits.h and sys/param.h. Don't include unistd.h twice. (LD_PATHMAX): Don't define. diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em index 78faf68..d45fdac 100644 --- a/ld/emultempl/ppc64elf.em +++ b/ld/emultempl/ppc64elf.em @@ -29,6 +29,7 @@ fragment <children.head)) return stub_sec; @@ -518,33 +517,33 @@ gld${EMULATION_NAME}_after_allocation (void) static void gld${EMULATION_NAME}_finish (void) { + char *msg = NULL; + char *line, *endline; + /* e_entry on PowerPC64 points to the function descriptor for _start. If _start is missing, default to the first function descriptor in the .opd section. */ - entry_section = ".opd"; - - if (stub_added) + if ((elf_elfheader (link_info.output_bfd)->e_flags & EF_PPC64_ABI) == 1) + entry_section = ".opd"; + + if (params.emit_stub_syms < 0) + params.emit_stub_syms = 1; + if (stub_file != NULL + && !link_info.relocatable + && !ppc64_elf_build_stubs (&link_info, config.stats ? &msg : NULL)) + einfo ("%X%P: can not build stubs: %E\n"); + + fflush (stdout); + for (line = msg; line != NULL; line = endline) { - char *msg = NULL; - char *line, *endline; - - if (params.emit_stub_syms < 0) - params.emit_stub_syms = 1; - if (!ppc64_elf_build_stubs (&link_info, config.stats ? &msg : NULL)) - einfo ("%X%P: can not build stubs: %E\n"); - - fflush (stdout); - for (line = msg; line != NULL; line = endline) - { - endline = strchr (line, '\n'); - if (endline != NULL) - *endline++ = '\0'; - fprintf (stderr, "%s: %s\n", program_name, line); - } - fflush (stderr); - if (msg != NULL) - free (msg); + endline = strchr (line, '\n'); + if (endline != NULL) + *endline++ = '\0'; + fprintf (stderr, "%s: %s\n", program_name, line); } + fflush (stderr); + if (msg != NULL) + free (msg); ppc64_elf_restore_symbols (&link_info); finish_default (); -- cgit v1.1