aboutsummaryrefslogtreecommitdiff
path: root/ld/emultempl/ppc64elf.em
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-09-09 23:07:35 +0930
committerAlan Modra <amodra@gmail.com>2019-09-11 13:44:22 +0930
commitd871d478061f10b0879c688e2fa941407e9137aa (patch)
tree4f564ccc452de8255f2eecfecfb931de03ad2093 /ld/emultempl/ppc64elf.em
parentcb7f4b298e5e0a3ab4fb6b13aa89e970478597bc (diff)
downloadgdb-d871d478061f10b0879c688e2fa941407e9137aa.zip
gdb-d871d478061f10b0879c688e2fa941407e9137aa.tar.gz
gdb-d871d478061f10b0879c688e2fa941407e9137aa.tar.bz2
Move elf32.em and elf-generic.em functions
Many ELF linker targets support multiple "emulations" and thus have multiple copies of elf32.em being compiled and linked into ld. This patch moves much of elf32.em and elf-generic.em into files which will be compiled just once, resulting in a 20% decrease in ld size for --enable-targets=all. * Makefile.am (ALL_EMUL_EXTRA_OFILES): Add ldelf and ldelfgen. (CFILES, HFILES, EXTRA_ld_new_SOURCES): Likewise. * configure.tgt: Formatting. (targ_extra_ofiles): Init to ldelf.o ldelfgen.o, reset to just ldelfgen.o for generic ELF targets, and empty for non-ELF. * emultempl/aarch64elf.em (gldaarch64_layout_sections_again): Use ldelf_map_segments. (gld${EMULATION_NAME}_after_allocation): Likewise. (real_func, aarch64_for_each_input_file_wrapper), (aarch64_lang_for_each_input_file): Delete. (lang_for_each_input_file): Don't define. * emultempl/alphaelf.em (alpha_after_parse): Use ldelf_map_segments. * emultempl/armelf.em (gldarm_layout_sections_again): Likewise. (gld${EMULATION_NAME}_after_allocation): Likewise. (real_func, arm_for_each_input_file_wrapper), (arm_lang_for_each_input_file): Delete. (lang_for_each_input_file): Don't define. * emultempl/cr16elf.em (cr16elf_after_parse): Use ldelf_map_segments. * emultempl/crxelf.em (crxelf_after_parse): Likewise. Delete declaration. * emultempl/cskyelf.em (gldcsky_layout_sections_again): Use ldelf_map_segments. (gld${EMULATION_NAME}_after_allocation): Likewise. (real_func, csky_for_each_input_file_wrapper), (csky_lang_for_each_input_file): Delete. (lang_for_each_input_file): Don't define. * emultempl/genelf.em: Include ldelfgen.h. (gld${EMULATION_NAME}_before_allocation): Use ldelf_map_segments. * emultempl/hppaelf.em (hppaelf_after_parse): Likewise. (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_after_allocation): Likewise. (real_func, hppa_for_each_input_file_wrapper), (hppa_lang_for_each_input_file): Delete. (lang_for_each_input_file): Don't define. * emultempl/ia64elf.em (ia64elf_after_parse): Use ldelf_map_segments. * emultempl/m68hc1xelf.em (real_func), (m68hc11_for_each_input_file_wrapper), (m68hc11_lang_for_each_input_file): Delete. (lang_for_each_input_file): Don't define. * emultempl/metagelf.em (metagelf_layout_sections_again): Use ldelf_map_segments. (gld${EMULATION_NAME}_after_allocation): Likewise. (real_func, metag_for_each_input_file_wrapper), (metag_lang_for_each_input_file): Delete. (lang_for_each_input_file): Don't define. * emultempl/mipself.em (real_func), (mips_for_each_input_file_wrapper), (mips_lang_for_each_input_file): Delete. (lang_for_each_input_file): Don't define. * emultempl/mmo.em: Don't include elf-bfd.h, do include ldelfgen.h. (gld${EMULATION_NAME}_after_allocation): Use ldelf_map_segments. * emultempl/nds32elf.em (nds32_elf_after_parse): Use ldelf_after_parse. (nds32_elf_after_allocation): Comment fix. * emultempl/nios2elf.em (nios2elf_layout_sections_again): Use ldelf_map_segments. (gld${EMULATION_NAME}_after_allocation): Likewise. (real_func, nios2_for_each_input_file_wrapper), (nios2_lang_for_each_input_file): Delete. (lang_for_each_input_file): Don't define. * emultempl/ppc32elf.em (gld${EMULATION_NAME}_load_symbols): Delete declaration. (ppc_recognized_file): Call ldelf_load_symbols. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_after_allocation): Likewise. (real_func, ppc_for_each_input_file_wrapper), (ppc_lang_for_each_input_file): Delete. (lang_for_each_input_file): Don't define. (gld${EMULATION_NAME}_load_symbols): Don't declare. (ppc64_recognized_file): Call ldelf_load_symbols. * emultempl/riscvelf.em (gld${EMULATION_NAME}_after_allocation): Use ldelf_map_segments. * emultempl/spuelf.em (spu_place_special_section): Use ldelf_place_orphan. * emultempl/tic6xdsbt.em (gld${EMULATION_NAME}_after_allocation): Use ldelf_map_segments. * emultempl/vms.em: Include ldelfgen.h. (gld${EMULATION_NAME}_after_allocation): Use ldelf_map_segments. * emultempl/elf32.em: Remove unnecessary headers, include ldelf.h and ldelfgen.h. Move much of file content to.. * ldelf.c: ..here. New file. * ldelf.h: New file. * emultempl/elf-generic.em: Move gld${EMULATION_NAME}_map_segments.. * ldelfgen.c: ..to here. * ldelfgen.h: New file. * ldlang.c (lang_for_each_input_file): Adjust to only call func on real files. (lang_for_each_file): Likewise. * po/SRC-POTFILES.in: Regenerate. * Makefile.in: Regenerate.
Diffstat (limited to 'ld/emultempl/ppc64elf.em')
-rw-r--r--ld/emultempl/ppc64elf.em28
1 files changed, 3 insertions, 25 deletions
diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em
index 2a354ba..ef1fd0e 100644
--- a/ld/emultempl/ppc64elf.em
+++ b/ld/emultempl/ppc64elf.em
@@ -456,7 +456,7 @@ ppc_layout_sections_again (void)
/* If we have changed sizes of the stub sections, then we need
to recalculate all the section offsets. This may mean we need to
add even more stubs. */
- gld${EMULATION_NAME}_map_segments (TRUE);
+ ldelf_map_segments (TRUE);
if (!bfd_link_relocatable (&link_info))
ppc64_elf_set_toc (&link_info, link_info.output_bfd);
@@ -565,7 +565,7 @@ gld${EMULATION_NAME}_after_allocation (void)
unneeded, after ppc_layout_sections_again. Another call removes
these sections from the segment map. Their presence is
innocuous except for confusing ELF_SECTION_IN_SEGMENT. */
- gld${EMULATION_NAME}_map_segments (need_laying_out > 0);
+ ldelf_map_segments (need_laying_out > 0);
if (need_laying_out != -1 && !bfd_link_relocatable (&link_info))
ppc64_elf_set_toc (&link_info, link_info.output_bfd);
@@ -652,34 +652,12 @@ gld${EMULATION_NAME}_new_vers_pattern (struct bfd_elf_version_expr *entry)
return dot_entry;
}
-
-/* Avoid processing the fake stub_file in vercheck, stat_needed and
- check_needed routines. */
-
-static void (*real_func) (lang_input_statement_type *);
-
-static void ppc_for_each_input_file_wrapper (lang_input_statement_type *l)
-{
- if (l != stub_file)
- (*real_func) (l);
-}
-
-static void
-ppc_lang_for_each_input_file (void (*func) (lang_input_statement_type *))
-{
- real_func = func;
- lang_for_each_input_file (&ppc_for_each_input_file_wrapper);
-}
-
-#define lang_for_each_input_file ppc_lang_for_each_input_file
-
EOF
if grep -q 'ld_elf32_spu_emulation' ldemul-list.h; then
fragment <<EOF
/* Special handling for embedded SPU executables. */
extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
-static bfd_boolean gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *);
static bfd_boolean
ppc64_recognized_file (lang_input_statement_type *entry)
@@ -687,7 +665,7 @@ ppc64_recognized_file (lang_input_statement_type *entry)
if (embedded_spu_file (entry, "-m64"))
return TRUE;
- return gld${EMULATION_NAME}_load_symbols (entry);
+ return ldelf_load_symbols (entry);
}
EOF
LDEMUL_RECOGNIZED_FILE=ppc64_recognized_file