diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-11-02 20:23:32 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-11-02 20:23:32 +0000 |
commit | 21ca5604689b35171671ce1ed04c5faccc82e0cd (patch) | |
tree | fecccf88d2c1cd815887b6c39d76a22688e234ca /gnu/usr.bin/binutils/ld/emultempl | |
parent | d4035bbe9de0a0eff2e5cae2ebc0a34f9227901b (diff) |
Binutils 2.15, with testsuites removed, and without gdb and libiberty.
Diffstat (limited to 'gnu/usr.bin/binutils/ld/emultempl')
21 files changed, 661 insertions, 844 deletions
diff --git a/gnu/usr.bin/binutils/ld/emultempl/alphaelf.em b/gnu/usr.bin/binutils/ld/emultempl/alphaelf.em index 4ff83cb76f2..7e643231f41 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/alphaelf.em +++ b/gnu/usr.bin/binutils/ld/emultempl/alphaelf.em @@ -27,18 +27,15 @@ cat >>e${EMULATION_NAME}.c <<EOF #include "elf/alpha.h" #include "elf-bfd.h" -static void alpha_after_parse PARAMS ((void)); -static void alpha_finish PARAMS ((void)); - static int elf64alpha_32bit = 0; /* Set the start address as in the Tru64 ld. */ #define ALPHA_TEXT_START_32BIT 0x12000000 static void -alpha_after_parse () +alpha_after_parse (void) { - if (elf64alpha_32bit && !link_info.shared && !link_info.relocateable) + if (elf64alpha_32bit && !link_info.shared && !link_info.relocatable) lang_section_start (".interp", exp_binop ('+', exp_intop (ALPHA_TEXT_START_32BIT), @@ -46,7 +43,7 @@ alpha_after_parse () } static void -alpha_finish () +alpha_finish (void) { if (elf64alpha_32bit) elf_elfheader (output_bfd)->e_flags |= EF_ALPHA_32BIT; diff --git a/gnu/usr.bin/binutils/ld/emultempl/armcoff.em b/gnu/usr.bin/binutils/ld/emultempl/armcoff.em index 11566581e03..468c3b08beb 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/armcoff.em +++ b/gnu/usr.bin/binutils/ld/emultempl/armcoff.em @@ -4,8 +4,8 @@ cat >e${EMULATION_NAME}.c <<EOF /* This file is is generated by a shell script. DO NOT EDIT! */ /* emulate the original gld for the given ${EMULATION_NAME} - Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, + 2004 Free Software Foundation, Inc. Written by Steve Chamberlain steve@cygnus.com This file is part of GLD, the Gnu Linker. @@ -40,18 +40,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "ldfile.h" #include "ldemul.h" -static void gld${EMULATION_NAME}_before_parse PARAMS ((void)); -static void gld${EMULATION_NAME}_before_allocation PARAMS ((void)); -static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile)); -static void gld${EMULATION_NAME}_add_options - PARAMS ((int, char **, int, struct option **, int, struct option **)); -static void gld${EMULATION_NAME}_list_options PARAMS ((FILE *)); -static bfd_boolean gld${EMULATION_NAME}_handle_option PARAMS ((int)); -static void gld${EMULATION_NAME}_finish PARAMS ((void)); -static void gld${EMULATION_NAME}_after_open PARAMS ((void)); - -/* If TRUE, then interworking stubs which support calls to old, non-interworking - aware ARM code should be generated. */ +/* If TRUE, then interworking stubs which support calls to old, + non-interworking aware ARM code should be generated. */ static int support_old_code = 0; static char * thumb_entry_symbol = NULL; @@ -60,13 +50,10 @@ static char * thumb_entry_symbol = NULL; #define OPTION_THUMB_ENTRY 301 static void -gld${EMULATION_NAME}_add_options (ns, shortopts, nl, longopts, nrl, really_longopts) - int ns ATTRIBUTE_UNUSED; - char **shortopts ATTRIBUTE_UNUSED; - int nl; - struct option **longopts; - int nrl ATTRIBUTE_UNUSED; - struct option **really_longopts ATTRIBUTE_UNUSED; +gld${EMULATION_NAME}_add_options + (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl, + struct option **longopts, int nrl ATTRIBUTE_UNUSED, + struct option **really_longopts ATTRIBUTE_UNUSED) { static const struct option xtra_long[] = { {"support-old-code", no_argument, NULL, OPTION_SUPPORT_OLD_CODE}, @@ -74,22 +61,20 @@ gld${EMULATION_NAME}_add_options (ns, shortopts, nl, longopts, nrl, really_longo {NULL, no_argument, NULL, 0} }; - *longopts = (struct option *) - xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long)); + *longopts = xrealloc (*longopts, + nl * sizeof (struct option) + sizeof (xtra_long)); memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long)); } static void -gld${EMULATION_NAME}_list_options (file) - FILE * file; +gld${EMULATION_NAME}_list_options (FILE *file) { fprintf (file, _(" --support-old-code Support interworking with old code\n")); fprintf (file, _(" --thumb-entry=<sym> Set the entry point to be Thumb symbol <sym>\n")); } static bfd_boolean -gld${EMULATION_NAME}_handle_option (optc) - int optc; +gld${EMULATION_NAME}_handle_option (int optc) { switch (optc) { @@ -104,15 +89,15 @@ gld${EMULATION_NAME}_handle_option (optc) thumb_entry_symbol = optarg; break; } - + return TRUE; } static void -gld${EMULATION_NAME}_before_parse () +gld${EMULATION_NAME}_before_parse (void) { #ifndef TARGET_ /* I.e., if not generic. */ - ldfile_set_output_arch ("`echo ${ARCH}`"); + ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); #endif /* not TARGET_ */ } @@ -120,7 +105,7 @@ gld${EMULATION_NAME}_before_parse () sections, but before any sizes or addresses have been set. */ static void -gld${EMULATION_NAME}_before_allocation () +gld${EMULATION_NAME}_before_allocation (void) { /* we should be able to set the size of the interworking stub section */ @@ -143,7 +128,7 @@ gld${EMULATION_NAME}_before_allocation () } static void -gld${EMULATION_NAME}_after_open () +gld${EMULATION_NAME}_after_open (void) { if (strstr (bfd_get_target (output_bfd), "arm") == NULL) { @@ -154,7 +139,7 @@ gld${EMULATION_NAME}_after_open () einfo ("%F%X%P: error: cannot change output format whilst linking ARM binaries\n"); return; } - + { LANG_FOR_EACH_INPUT_STATEMENT (is) { @@ -165,13 +150,13 @@ gld${EMULATION_NAME}_after_open () } static void -gld${EMULATION_NAME}_finish PARAMS((void)) +gld${EMULATION_NAME}_finish (void) { struct bfd_link_hash_entry * h; if (thumb_entry_symbol == NULL) return; - + h = bfd_link_hash_lookup (link_info.hash, thumb_entry_symbol, FALSE, FALSE, TRUE); @@ -182,21 +167,21 @@ gld${EMULATION_NAME}_finish PARAMS((void)) { static char buffer[32]; bfd_vma val; - + /* Special procesing is required for a Thumb entry symbol. The bottom bit of its address must be set. */ val = (h->u.def.value + bfd_get_section_vma (output_bfd, h->u.def.section->output_section) + h->u.def.section->output_offset); - + val |= 1; /* Now convert this value into a string and store it in entry_symbol - where the lang_finish() function will pick it up. */ + where the lang_finish() function will pick it up. */ buffer[0] = '0'; buffer[1] = 'x'; - + sprintf_vma (buffer + 2, val); if (entry_symbol.name != NULL && entry_from_cmdline) @@ -209,8 +194,7 @@ gld${EMULATION_NAME}_finish PARAMS((void)) } static char * -gld${EMULATION_NAME}_get_script (isfile) - int *isfile; +gld${EMULATION_NAME}_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -221,14 +205,14 @@ then sc="-f stringify.sed" cat >>e${EMULATION_NAME}.c <<EOF -{ +{ *isfile = 0; - if (link_info.relocateable && config.build_constructors) + if (link_info.relocatable && config.build_constructors) return EOF sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c -echo ' ; else if (link_info.relocateable) return' >> e${EMULATION_NAME}.c +echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c @@ -242,12 +226,12 @@ else # Scripts read from the filesystem. cat >>e${EMULATION_NAME}.c <<EOF -{ +{ *isfile = 1; - if (link_info.relocateable && config.build_constructors) + if (link_info.relocatable && config.build_constructors) return "ldscripts/${EMULATION_NAME}.xu"; - else if (link_info.relocateable) + else if (link_info.relocatable) return "ldscripts/${EMULATION_NAME}.xr"; else if (!config.text_read_only) return "ldscripts/${EMULATION_NAME}.xbn"; @@ -262,7 +246,7 @@ fi cat >>e${EMULATION_NAME}.c <<EOF -struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = +struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = { gld${EMULATION_NAME}_before_parse, syslib_default, diff --git a/gnu/usr.bin/binutils/ld/emultempl/armelf.em b/gnu/usr.bin/binutils/ld/emultempl/armelf.em index b125c579eff..0c051ad62b8 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/armelf.em +++ b/gnu/usr.bin/binutils/ld/emultempl/armelf.em @@ -1,5 +1,5 @@ # This shell script emits a C file. -*- C -*- -# Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2002, 2003 +# Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004 # Free Software Foundation, Inc. # # This file is part of GLD, the Gnu Linker. @@ -28,21 +28,18 @@ static int no_pipeline_knowledge = 0; static char *thumb_entry_symbol = NULL; static bfd *bfd_for_interwork; - static void -gld${EMULATION_NAME}_before_parse () +gld${EMULATION_NAME}_before_parse (void) { #ifndef TARGET_ /* I.e., if not generic. */ - ldfile_set_output_arch ("`echo ${ARCH}`"); + ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); #endif /* not TARGET_ */ config.dynamic_link = ${DYNAMIC_LINK-TRUE}; config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`; } -static void arm_elf_after_open PARAMS ((void)); - static void -arm_elf_after_open () +arm_elf_after_open (void) { if (strstr (bfd_get_target (output_bfd), "arm") == NULL) { @@ -65,12 +62,8 @@ arm_elf_after_open () gld${EMULATION_NAME}_after_open (); } -static void arm_elf_set_bfd_for_interworking - PARAMS ((lang_statement_union_type *)); - static void -arm_elf_set_bfd_for_interworking (statement) - lang_statement_union_type *statement; +arm_elf_set_bfd_for_interworking (lang_statement_union_type *statement) { if (statement->header.type == lang_input_section_enum && !statement->input_section.ifile->just_syms_flag) @@ -90,10 +83,8 @@ arm_elf_set_bfd_for_interworking (statement) } } -static void arm_elf_before_allocation PARAMS ((void)); - static void -arm_elf_before_allocation () +arm_elf_before_allocation (void) { bfd *tem; @@ -138,10 +129,8 @@ arm_elf_before_allocation () bfd_elf32_arm_allocate_interworking_sections (& link_info); } -static void arm_elf_finish PARAMS ((void)); - static void -arm_elf_finish () +arm_elf_finish (void) { struct bfd_link_hash_entry * h; @@ -150,7 +139,7 @@ arm_elf_finish () if (thumb_entry_symbol == NULL) return; - + h = bfd_link_hash_lookup (link_info.hash, thumb_entry_symbol, FALSE, FALSE, TRUE); @@ -161,21 +150,21 @@ arm_elf_finish () { static char buffer[32]; bfd_vma val; - + /* Special procesing is required for a Thumb entry symbol. The bottom bit of its address must be set. */ val = (h->u.def.value + bfd_get_section_vma (output_bfd, h->u.def.section->output_section) + h->u.def.section->output_offset); - + val |= 1; /* Now convert this value into a string and store it in entry_symbol - where the lang_finish() function will pick it up. */ + where the lang_finish() function will pick it up. */ buffer[0] = '0'; buffer[1] = 'x'; - + sprintf_vma (buffer + 2, val); if (entry_symbol.name != NULL && entry_from_cmdline) diff --git a/gnu/usr.bin/binutils/ld/emultempl/armelf_oabi.em b/gnu/usr.bin/binutils/ld/emultempl/armelf_oabi.em index 555b947e383..d75c6586330 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/armelf_oabi.em +++ b/gnu/usr.bin/binutils/ld/emultempl/armelf_oabi.em @@ -4,8 +4,8 @@ cat >e${EMULATION_NAME}.c <<EOF /* This file is is generated by a shell script. DO NOT EDIT! */ /* emulate the original gld for the given ${EMULATION_NAME} - Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 - Free Software Foundation, Inc. + Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, + 2004 Free Software Foundation, Inc. Written by Steve Chamberlain steve@cygnus.com This file is part of GLD, the Gnu Linker. @@ -47,16 +47,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "ldfile.h" #include "ldemul.h" -static void gld${EMULATION_NAME}_before_parse PARAMS ((void)); -static void gld${EMULATION_NAME}_before_allocation PARAMS ((void)); -static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile)); -static void gld${EMULATION_NAME}_after_open PARAMS ((void)); - static void -gld${EMULATION_NAME}_before_parse () +gld${EMULATION_NAME}_before_parse (void) { #ifndef TARGET_ /* I.e., if not generic. */ - ldfile_set_output_arch ("`echo ${ARCH}`"); + ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); #endif /* not TARGET_ */ } @@ -64,7 +59,7 @@ gld${EMULATION_NAME}_before_parse () sections, but before any sizes or addresses have been set. */ static void -gld${EMULATION_NAME}_before_allocation () +gld${EMULATION_NAME}_before_allocation (void) { /* we should be able to set the size of the interworking stub section */ @@ -86,7 +81,7 @@ gld${EMULATION_NAME}_before_allocation () } static void -gld${EMULATION_NAME}_after_open () +gld${EMULATION_NAME}_after_open (void) { LANG_FOR_EACH_INPUT_STATEMENT (is) @@ -98,8 +93,7 @@ gld${EMULATION_NAME}_after_open () } static char * -gld${EMULATION_NAME}_get_script (isfile) - int *isfile; +gld${EMULATION_NAME}_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -110,14 +104,14 @@ then sc="-f stringify.sed" cat >>e${EMULATION_NAME}.c <<EOF -{ +{ *isfile = 0; - if (link_info.relocateable && config.build_constructors) + if (link_info.relocatable && config.build_constructors) return EOF sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c -echo ' ; else if (link_info.relocateable) return' >> e${EMULATION_NAME}.c +echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c @@ -131,12 +125,12 @@ else # Scripts read from the filesystem. cat >>e${EMULATION_NAME}.c <<EOF -{ +{ *isfile = 1; - if (link_info.relocateable && config.build_constructors) + if (link_info.relocatable && config.build_constructors) return "ldscripts/${EMULATION_NAME}.xu"; - else if (link_info.relocateable) + else if (link_info.relocatable) return "ldscripts/${EMULATION_NAME}.xr"; else if (!config.text_read_only) return "ldscripts/${EMULATION_NAME}.xbn"; @@ -151,7 +145,7 @@ fi cat >>e${EMULATION_NAME}.c <<EOF -struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = +struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = { gld${EMULATION_NAME}_before_parse, syslib_default, diff --git a/gnu/usr.bin/binutils/ld/emultempl/beos.em b/gnu/usr.bin/binutils/ld/emultempl/beos.em index 3b84280f971..0431baf7cca 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/beos.em +++ b/gnu/usr.bin/binutils/ld/emultempl/beos.em @@ -7,7 +7,7 @@ else fi cat >e${EMULATION_NAME}.c <<EOF /* This file is part of GLD, the Gnu Linker. - Copyright 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003 + Copyright 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -51,43 +51,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define TARGET_IS_${EMULATION_NAME} -static void gld_${EMULATION_NAME}_set_symbols PARAMS ((void)); -static void gld_${EMULATION_NAME}_after_open PARAMS ((void)); -static void gld_${EMULATION_NAME}_before_parse PARAMS ((void)); -static void gld_${EMULATION_NAME}_before_allocation PARAMS ((void)); -static bfd_boolean gld${EMULATION_NAME}_place_orphan - PARAMS ((lang_input_statement_type *, asection *)); -static char *gld_${EMULATION_NAME}_get_script PARAMS ((int *)); - -static int sort_by_file_name PARAMS ((const PTR, const PTR)); -static int sort_by_section_name PARAMS ((const PTR, const PTR)); -static lang_statement_union_type **sort_sections_1 - PARAMS ((lang_statement_union_type **, lang_statement_union_type *, int, - int (*) PARAMS((const PTR, const PTR)))); -static void sort_sections PARAMS ((lang_statement_union_type *)); - -static void set_pe_name PARAMS ((char *, long int)); -static void set_pe_subsystem PARAMS ((void)); -static void set_pe_value PARAMS ((char *)); -static void set_pe_stack_heap PARAMS ((char *, char *)); - static struct internal_extra_pe_aouthdr pe; static int dll; extern const char *output_filename; static void -gld_${EMULATION_NAME}_before_parse() +gld_${EMULATION_NAME}_before_parse (void) { - const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}"); - if (arch) - { - ldfile_output_architecture = arch->arch; - ldfile_output_machine = arch->mach; - ldfile_output_machine_name = arch->printable_name; - } - else - ldfile_output_architecture = bfd_arch_${ARCH}; + ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`); output_filename = "a.exe"; } @@ -109,17 +81,11 @@ gld_${EMULATION_NAME}_before_parse() #define OPTION_SUBSYSTEM (OPTION_STACK + 1) #define OPTION_HEAP (OPTION_SUBSYSTEM + 1) -static void gld${EMULATION_NAME}_add_options - PARAMS ((int, char **, int, struct option **, int, struct option **)); - static void -gld${EMULATION_NAME}_add_options (ns, shortopts, nl, longopts, nrl, really_longopts) - int ns ATTRIBUTE_UNUSED; - char **shortopts ATTRIBUTE_UNUSED; - int nl; - struct option **longopts; - int nrl ATTRIBUTE_UNUSED; - struct option **really_longopts ATTRIBUTE_UNUSED; +gld${EMULATION_NAME}_add_options + (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl, + struct option **longopts, int nrl ATTRIBUTE_UNUSED, + struct option **really_longopts ATTRIBUTE_UNUSED) { static const struct option xtra_long[] = { /* PE options */ @@ -185,9 +151,7 @@ static definfo init[] = static void -set_pe_name (name, val) - char *name; - long val; +set_pe_name (char *name, long val) { int i; /* Find the name and set it. */ @@ -205,7 +169,7 @@ set_pe_name (name, val) static void -set_pe_subsystem () +set_pe_subsystem (void) { const char *sver; int len; @@ -281,11 +245,8 @@ set_pe_subsystem () } - static void -set_pe_value (name) - char *name; - +set_pe_value (char *name) { char *end; set_pe_name (name, strtoul (optarg, &end, 0)); @@ -298,9 +259,7 @@ set_pe_value (name) } static void -set_pe_stack_heap (resname, comname) - char *resname; - char *comname; +set_pe_stack_heap (char *resname, char *comname) { set_pe_value (resname); if (*optarg == ',') @@ -315,12 +274,8 @@ set_pe_stack_heap (resname, comname) } -static bfd_boolean gld${EMULATION_NAME}_handle_option - PARAMS ((int)); - static bfd_boolean -gld${EMULATION_NAME}_handle_option (optc) - int optc; +gld${EMULATION_NAME}_handle_option (int optc) { switch (optc) { @@ -328,7 +283,7 @@ gld${EMULATION_NAME}_handle_option (optc) return FALSE; case OPTION_BASE_FILE: - link_info.base_file = (PTR) fopen (optarg, FOPEN_WB); + link_info.base_file = fopen (optarg, FOPEN_WB); if (link_info.base_file == NULL) { fprintf (stderr, "%s: Can't open base file %s\n", @@ -385,7 +340,7 @@ gld${EMULATION_NAME}_handle_option (optc) read. */ static void -gld_${EMULATION_NAME}_set_symbols() +gld_${EMULATION_NAME}_set_symbols (void) { /* Run through and invent symbols for all the names and insert the defaults. */ @@ -394,7 +349,7 @@ gld_${EMULATION_NAME}_set_symbols() if (!init[IMAGEBASEOFF].inited) { - if (link_info.relocateable) + if (link_info.relocatable) init[IMAGEBASEOFF].value = 0; else if (init[DLLOFF].value) init[IMAGEBASEOFF].value = BEOS_DLL_IMAGE_BASE; @@ -402,8 +357,8 @@ gld_${EMULATION_NAME}_set_symbols() init[IMAGEBASEOFF].value = BEOS_EXE_IMAGE_BASE; } - /* Don't do any symbol assignments if this is a relocateable link. */ - if (link_info.relocateable) + /* Don't do any symbol assignments if this is a relocatable link. */ + if (link_info.relocatable) return; /* Glue the assignments into the abs section */ @@ -437,7 +392,7 @@ gld_${EMULATION_NAME}_set_symbols() } static void -gld_${EMULATION_NAME}_after_open() +gld_${EMULATION_NAME}_after_open (void) { /* Pass the wacky PE command line options into the output bfd. FIXME: This should be done via a function, rather than by @@ -455,9 +410,7 @@ gld_${EMULATION_NAME}_after_open() /* Callback functions for qsort in sort_sections. */ static int -sort_by_file_name (a, b) - const PTR a; - const PTR b; +sort_by_file_name (const void *a, const void *b) { const lang_statement_union_type *const *ra = a; const lang_statement_union_type *const *rb = b; @@ -512,9 +465,7 @@ return 0; } static int -sort_by_section_name (a, b) - const PTR a; - const PTR b; +sort_by_section_name (const void *a, const void *b) { const lang_statement_union_type *const *ra = a; const lang_statement_union_type *const *rb = b; @@ -539,10 +490,10 @@ sort_by_section_name (a, b) The result is a pointer to the last element's "next" pointer. */ static lang_statement_union_type ** -sort_sections_1 (startptr, next_after, count, sort_func) - lang_statement_union_type **startptr,*next_after; - int count; - int (*sort_func) PARAMS ((const PTR, const PTR)); +sort_sections_1 (lang_statement_union_type **startptr, + lang_statement_union_type *next_after, + int count, + int (*sort_func) (const void *, const void *)) { lang_statement_union_type **vec; lang_statement_union_type *p; @@ -585,8 +536,7 @@ sort_sections_1 (startptr, next_after, count, sort_func) place_orphans routine to implement grouped sections. */ static void -sort_sections (s) - lang_statement_union_type *s; +sort_sections (lang_statement_union_type *s) { for (; s ; s = s->header.next) switch (s->header.type) @@ -673,7 +623,7 @@ sort_sections (s) } static void -gld_${EMULATION_NAME}_before_allocation() +gld_${EMULATION_NAME}_before_allocation (void) { extern lang_statement_list_type *stat_ptr; @@ -728,11 +678,8 @@ gld_${EMULATION_NAME}_before_allocation() but I'm leaving this here in case we want to enable it for sections which are not mentioned in the linker script. */ -/*ARGSUSED*/ static bfd_boolean -gld${EMULATION_NAME}_place_orphan (file, s) - lang_input_statement_type *file; - asection *s; +gld${EMULATION_NAME}_place_orphan (lang_input_statement_type *file, asection *s) { const char *secname; char *output_secname, *ps; @@ -746,7 +693,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) If they're marked as COMDAT sections, we don't want .text\$foo to end up in .text and then have .text disappear because it's marked link-once-discard. */ - if (link_info.relocateable) + if (link_info.relocatable) return FALSE; secname = bfd_get_section_name (s->owner, s); @@ -821,8 +768,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) } static char * -gld_${EMULATION_NAME}_get_script(isfile) - int *isfile; +gld_${EMULATION_NAME}_get_script (int *isfile) EOF # Scripts compiled in. # sed commands to quote an ld script as a C string. @@ -832,11 +778,11 @@ cat >>e${EMULATION_NAME}.c <<EOF { *isfile = 0; - if (link_info.relocateable && config.build_constructors) + if (link_info.relocatable && config.build_constructors) return EOF sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c -echo ' ; else if (link_info.relocateable) return' >> e${EMULATION_NAME}.c +echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c diff --git a/gnu/usr.bin/binutils/ld/emultempl/ia64elf.em b/gnu/usr.bin/binutils/ld/emultempl/ia64elf.em new file mode 100644 index 00000000000..eee467b0809 --- /dev/null +++ b/gnu/usr.bin/binutils/ld/emultempl/ia64elf.em @@ -0,0 +1,62 @@ +# This shell script emits a C file. -*- C -*- +# Copyright 2003 Free Software Foundation, Inc. +# +# This file is part of GLD, the Gnu Linker. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +# This file is sourced from elf32.em, and defines extra ia64-elf +# specific routines. +# +# Define some shell vars to insert bits of code into the standard elf +# parse_args and list_options functions. +# +cat >>e${EMULATION_NAME}.c <<EOF + +/* None zero if generating binary for Intel Itanium processor. */ +static int itanium = 0; + +static void +gld${EMULATION_NAME}_after_parse (void) +{ + link_info.need_relax_finalize = TRUE; + bfd_elf${ELFSIZE}_ia64_after_parse (itanium); +} + +EOF + +PARSE_AND_LIST_PROLOGUE=' +#define OPTION_ITANIUM 300 +' + +PARSE_AND_LIST_LONGOPTS=' + { "itanium", no_argument, NULL, OPTION_ITANIUM}, +' + +PARSE_AND_LIST_OPTIONS=' + fprintf (file, _("\ + --itanium Generate code for Intel Itanium processor\n" + )); +' + +PARSE_AND_LIST_ARGS_CASES=' + case OPTION_ITANIUM: + itanium = 1; + break; +' + +LDEMUL_AFTER_PARSE=gld${EMULATION_NAME}_after_parse +. ${srcdir}/emultempl/needrelax.em diff --git a/gnu/usr.bin/binutils/ld/emultempl/irix.em b/gnu/usr.bin/binutils/ld/emultempl/irix.em new file mode 100644 index 00000000000..19511dd31ac --- /dev/null +++ b/gnu/usr.bin/binutils/ld/emultempl/irix.em @@ -0,0 +1,41 @@ +# This shell script emits a C file. -*- C -*- +# Copyright 2004 Free Software Foundation, Inc. +# +# This file is part of GLD, the Gnu Linker. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +cat >>e${EMULATION_NAME}.c <<EOF + +#include "ld.h" +#include "ldmain.h" +#include "libiberty.h" + +/* The native IRIX linker will always create a DT_SONAME for shared objects. + While this shouldn't really be necessary for ABI conformance, some versions + of the native linker will segfault if the tag is missing. */ + +static void +irix_after_open (void) +{ + if (link_info.shared && command_line.soname == 0) + command_line.soname = basename (bfd_get_filename (output_bfd)); + + gld${EMULATION_NAME}_after_open (); +} +EOF + +LDEMUL_AFTER_OPEN=irix_after_open diff --git a/gnu/usr.bin/binutils/ld/emultempl/m68hc1xelf.em b/gnu/usr.bin/binutils/ld/emultempl/m68hc1xelf.em index 5e5dc102434..ecae4c08b47 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/m68hc1xelf.em +++ b/gnu/usr.bin/binutils/ld/emultempl/m68hc1xelf.em @@ -44,12 +44,7 @@ cat >>e${EMULATION_NAME}.c <<EOF #include "ldctor.h" #include "elf32-m68hc1x.h" -static void m68hc11elf_create_output_section_statements PARAMS ((void)); -static asection *m68hc11elf_add_stub_section - PARAMS ((const char *, asection *)); -static void gld${EMULATION_NAME}_finish PARAMS ((void)); -static void m68hc11_elf_${EMULATION_NAME}_before_allocation PARAMS ((void)); - +static asection *m68hc11elf_add_stub_section (const char *, asection *); /* Fake input file for stubs. */ static lang_input_statement_type *stub_file; @@ -64,7 +59,7 @@ static int no_trampoline = 0; static const char* bank_window_name = 0; static void -m68hc11_elf_${EMULATION_NAME}_before_allocation () +m68hc11_elf_${EMULATION_NAME}_before_allocation (void) { lang_memory_region_type* region; int ret; @@ -73,7 +68,7 @@ m68hc11_elf_${EMULATION_NAME}_before_allocation () /* If generating a relocatable output file, then we don't have to generate the trampolines. */ - if (link_info.relocateable) + if (link_info.relocatable) return; ret = elf32_m68hc11_setup_section_lists (output_bfd, &link_info); @@ -87,9 +82,9 @@ m68hc11_elf_${EMULATION_NAME}_before_allocation () /* Call into the BFD backend to do the real work. */ if (!elf32_m68hc11_size_stubs (output_bfd, - stub_file->the_bfd, - &link_info, - &m68hc11elf_add_stub_section)) + stub_file->the_bfd, + &link_info, + &m68hc11elf_add_stub_section)) { einfo ("%X%P: can not size stub section: %E\n"); return; @@ -107,7 +102,7 @@ m68hc11_elf_${EMULATION_NAME}_before_allocation () But for 68HC11 this is board specific. The definition of such memory region allows to control how this paged memory is accessed. */ - region = lang_memory_region_lookup (bank_window_name); + region = lang_memory_region_lookup (bank_window_name, FALSE); /* Check the length to see if it was defined in the script. */ if (region->length != 0) @@ -123,7 +118,7 @@ m68hc11_elf_${EMULATION_NAME}_before_allocation () pinfo->bank_size = region->length; pinfo->bank_shift = 0; for (i = pinfo->bank_size; i != 0; i >>= 1) - pinfo->bank_shift++; + pinfo->bank_shift++; pinfo->bank_shift--; pinfo->bank_size = 1L << pinfo->bank_shift; pinfo->bank_mask = (1 << pinfo->bank_shift) - 1; @@ -131,12 +126,12 @@ m68hc11_elf_${EMULATION_NAME}_before_allocation () pinfo->bank_physical_end = region->origin + pinfo->bank_size; if (pinfo->bank_size != region->length) - { - einfo (_("warning: the size of the 'window' memory region " - "is not a power of 2\n")); - einfo (_("warning: its size %d is truncated to %d\n"), - region->length, pinfo->bank_size); - } + { + einfo (_("warning: the size of the 'window' memory region " + "is not a power of 2\n")); + einfo (_("warning: its size %d is truncated to %d\n"), + region->length, pinfo->bank_size); + } } } @@ -144,7 +139,7 @@ m68hc11_elf_${EMULATION_NAME}_before_allocation () fake input file to hold the stub sections. */ static void -m68hc11elf_create_output_section_statements () +m68hc11elf_create_output_section_statements (void) { stub_file = lang_add_input_file ("linker stubs", lang_input_file_is_fake_enum, @@ -152,8 +147,8 @@ m68hc11elf_create_output_section_statements () stub_file->the_bfd = bfd_create ("linker stubs", output_bfd); if (stub_file->the_bfd == NULL || !bfd_set_arch_mach (stub_file->the_bfd, - bfd_get_arch (output_bfd), - bfd_get_mach (output_bfd))) + bfd_get_arch (output_bfd), + bfd_get_mach (output_bfd))) { einfo ("%X%P: can not create BFD %E\n"); return; @@ -171,13 +166,8 @@ struct hook_stub_info /* Traverse the linker tree to find the spot where the stub goes. */ -static bfd_boolean hook_in_stub - PARAMS ((struct hook_stub_info *, lang_statement_union_type **)); - static bfd_boolean -hook_in_stub (info, lp) - struct hook_stub_info *info; - lang_statement_union_type **lp; +hook_in_stub (struct hook_stub_info *info, lang_statement_union_type **lp) { lang_statement_union_type *l; bfd_boolean ret; @@ -213,10 +203,10 @@ hook_in_stub (info, lp) case lang_input_section_enum: if (l->input_section.section == info->input_section - || strcmp (bfd_get_section_name (output_section, - l->input_section.section), - bfd_get_section_name (output_section, - info->input_section)) == 0) + || strcmp (bfd_get_section_name (output_section, + l->input_section.section), + bfd_get_section_name (output_section, + info->input_section)) == 0) { /* We've found our section. Insert the stub immediately before its associated input section. */ @@ -253,9 +243,8 @@ hook_in_stub (info, lp) immediately before INPUT_SECTION. */ static asection * -m68hc11elf_add_stub_section (stub_sec_name, tramp_section) - const char *stub_sec_name; - asection *tramp_section; +m68hc11elf_add_stub_section (const char *stub_sec_name, + asection *tramp_section) { asection *stub_sec; flagword flags; @@ -263,7 +252,7 @@ m68hc11elf_add_stub_section (stub_sec_name, tramp_section) const char *secname; lang_output_section_statement_type *os; struct hook_stub_info info; - + stub_sec = bfd_make_section_anyway (stub_file->the_bfd, stub_sec_name); if (stub_sec == NULL) goto err_ret; @@ -300,18 +289,18 @@ m68hc11elf_add_stub_section (stub_sec_name, tramp_section) to build linker stubs. */ static void -gld${EMULATION_NAME}_finish () +gld${EMULATION_NAME}_finish (void) { /* Now build the linker stubs. */ if (stub_file->the_bfd->sections != NULL) { /* Call again the trampoline analyzer to initialize the trampoline - stubs with the correct symbol addresses. Since there could have - been relaxation, the symbol addresses that were found during - first call may no longer be correct. */ + stubs with the correct symbol addresses. Since there could have + been relaxation, the symbol addresses that were found during + first call may no longer be correct. */ if (!elf32_m68hc11_size_stubs (output_bfd, - stub_file->the_bfd, - &link_info, 0)) + stub_file->the_bfd, + &link_info, 0)) { einfo ("%X%P: can not size stub section: %E\n"); return; @@ -325,23 +314,16 @@ gld${EMULATION_NAME}_finish () /* Avoid processing the fake stub_file in vercheck, stat_needed and check_needed routines. */ -static void m68hc11_for_each_input_file_wrapper - PARAMS ((lang_input_statement_type *)); -static void m68hc11_lang_for_each_input_file - PARAMS ((void (*) (lang_input_statement_type *))); - -static void (*real_func) PARAMS ((lang_input_statement_type *)); +static void (*real_func) (lang_input_statement_type *); -static void m68hc11_for_each_input_file_wrapper (l) - lang_input_statement_type *l; +static void m68hc11_for_each_input_file_wrapper (lang_input_statement_type *l) { if (l != stub_file) (*real_func) (l); } static void -m68hc11_lang_for_each_input_file (func) - void (*func) PARAMS ((lang_input_statement_type *)); +m68hc11_lang_for_each_input_file (void (*func) (lang_input_statement_type *)) { real_func = func; lang_for_each_input_file (&m68hc11_for_each_input_file_wrapper); @@ -355,8 +337,8 @@ EOF # parse_args and list_options functions. # PARSE_AND_LIST_PROLOGUE=' -#define OPTION_NO_TRAMPOLINE 300 -#define OPTION_BANK_WINDOW 301 +#define OPTION_NO_TRAMPOLINE 300 +#define OPTION_BANK_WINDOW 301 ' # The options are repeated below so that no abbreviations are allowed. diff --git a/gnu/usr.bin/binutils/ld/emultempl/m68kcoff.em b/gnu/usr.bin/binutils/ld/emultempl/m68kcoff.em index 765447a258b..162dcf7ed7a 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/m68kcoff.em +++ b/gnu/usr.bin/binutils/ld/emultempl/m68kcoff.em @@ -4,7 +4,7 @@ cat >e${EMULATION_NAME}.c <<EOF /* This file is is generated by a shell script. DO NOT EDIT! */ /* Handle embedded relocs for m68k. - Copyright 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright 2000, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Michael Sokolov <msokolov@ivan.Harhan.ORG>, based on generic.em by Steve Chamberlain <steve@cygnus.com>, embedded relocs code based on mipsecoff.em by Ian Lance Taylor <ian@cygnus.com>. @@ -37,17 +37,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "ldemul.h" #include "ldmisc.h" -static void gld${EMULATION_NAME}_before_parse PARAMS ((void)); -static void gld${EMULATION_NAME}_after_open PARAMS ((void)); -static void check_sections PARAMS ((bfd *, asection *, PTR)); -static void gld${EMULATION_NAME}_after_allocation PARAMS ((void)); -static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile)); +static void check_sections (bfd *, asection *, void *); static void -gld${EMULATION_NAME}_before_parse () +gld${EMULATION_NAME}_before_parse (void) { #ifndef TARGET_ /* I.e., if not generic. */ - ldfile_set_output_arch ("`echo ${ARCH}`"); + ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); #endif /* not TARGET_ */ } @@ -58,12 +54,12 @@ gld${EMULATION_NAME}_before_parse () time. */ static void -gld${EMULATION_NAME}_after_open () +gld${EMULATION_NAME}_after_open (void) { bfd *abfd; if (! command_line.embedded_relocs - || link_info.relocateable) + || link_info.relocatable) return; for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next) @@ -103,7 +99,7 @@ gld${EMULATION_NAME}_after_open () /* Double check that all other data sections are empty, as is required for embedded PIC code. */ - bfd_map_over_sections (abfd, check_sections, (PTR) datasec); + bfd_map_over_sections (abfd, check_sections, datasec); } } @@ -111,13 +107,10 @@ gld${EMULATION_NAME}_after_open () relocs. This is called via bfd_map_over_sections. */ static void -check_sections (abfd, sec, datasec) - bfd *abfd; - asection *sec; - PTR datasec; +check_sections (bfd *abfd, asection *sec, void *datasec) { if ((bfd_get_section_flags (abfd, sec) & SEC_DATA) - && sec != (asection *) datasec + && sec != datasec && sec->reloc_count != 0) einfo ("%B%X: section %s has relocs; can not use --embedded-relocs\n", abfd, bfd_get_section_name (abfd, sec)); @@ -128,12 +121,12 @@ check_sections (abfd, sec, datasec) BFD backend routine to do the work. */ static void -gld${EMULATION_NAME}_after_allocation () +gld${EMULATION_NAME}_after_allocation (void) { bfd *abfd; if (! command_line.embedded_relocs - || link_info.relocateable) + || link_info.relocatable) return; for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next) @@ -164,8 +157,7 @@ gld${EMULATION_NAME}_after_allocation () } static char * -gld${EMULATION_NAME}_get_script(isfile) - int *isfile; +gld${EMULATION_NAME}_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -176,14 +168,14 @@ then sc="-f stringify.sed" cat >>e${EMULATION_NAME}.c <<EOF -{ +{ *isfile = 0; - if (link_info.relocateable && config.build_constructors) + if (link_info.relocatable && config.build_constructors) return EOF sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c -echo ' ; else if (link_info.relocateable) return' >> e${EMULATION_NAME}.c +echo ' ; else if (link_info.relocatable) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xr >> e${EMULATION_NAME}.c echo ' ; else if (!config.text_read_only) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xbn >> e${EMULATION_NAME}.c @@ -197,12 +189,12 @@ else # Scripts read from the filesystem. cat >>e${EMULATION_NAME}.c <<EOF -{ +{ *isfile = 1; - if (link_info.relocateable && config.build_constructors) + if (link_info.relocatable && config.build_constructors) return "ldscripts/${EMULATION_NAME}.xu"; - else if (link_info.relocateable) + else if (link_info.relocatable) return "ldscripts/${EMULATION_NAME}.xr"; else if (!config.text_read_only) return "ldscripts/${EMULATION_NAME}.xbn"; @@ -217,7 +209,7 @@ fi cat >>e${EMULATION_NAME}.c <<EOF -struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = +struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = { gld${EMULATION_NAME}_before_parse, syslib_default, diff --git a/gnu/usr.bin/binutils/ld/emultempl/m68kelf.em b/gnu/usr.bin/binutils/ld/emultempl/m68kelf.em index cb3b86bbfef..31db20bcafe 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/m68kelf.em +++ b/gnu/usr.bin/binutils/ld/emultempl/m68kelf.em @@ -1,5 +1,5 @@ # This shell script emits a C file. -*- C -*- -# Copyright 2000, 2001 Free Software Foundation, Inc. +# Copyright 2000, 2001, 2003 Free Software Foundation, Inc. # Written by Michael Sokolov <msokolov@ivan.Harhan.ORG>, based on armelf.em # # This file is part of GLD, the Gnu Linker. @@ -31,23 +31,21 @@ esac cat >>e${EMULATION_NAME}.c <<EOF -static void m68k_elf_after_open PARAMS ((void)); #ifdef SUPPORT_EMBEDDED_RELOCS -static void check_sections PARAMS ((bfd *, asection *, PTR)); +static void check_sections (bfd *, asection *, void *); #endif -static void m68k_elf_after_allocation PARAMS ((void)); /* This function is run after all the input files have been opened. */ static void -m68k_elf_after_open () +m68k_elf_after_open (void) { /* Call the standard elf routine. */ gld${EMULATION_NAME}_after_open (); #ifdef SUPPORT_EMBEDDED_RELOCS if (command_line.embedded_relocs - && (! link_info.relocateable)) + && (! link_info.relocatable)) { bfd *abfd; @@ -95,7 +93,7 @@ m68k_elf_after_open () /* Double check that all other data sections are empty, as is required for embedded PIC code. */ - bfd_map_over_sections (abfd, check_sections, (PTR) datasec); + bfd_map_over_sections (abfd, check_sections, datasec); } } #endif /* SUPPORT_EMBEDDED_RELOCS */ @@ -106,13 +104,10 @@ m68k_elf_after_open () relocs. This is called via bfd_map_over_sections. */ static void -check_sections (abfd, sec, datasec) - bfd *abfd; - asection *sec; - PTR datasec; +check_sections (bfd *abfd, asection *sec, void *datasec) { if ((bfd_get_section_flags (abfd, sec) & SEC_DATA) - && sec != (asection *) datasec + && sec != datasec && sec->reloc_count != 0) einfo ("%B%X: section %s has relocs; can not use --embedded-relocs\n", abfd, bfd_get_section_name (abfd, sec)); @@ -124,14 +119,14 @@ check_sections (abfd, sec, datasec) been set. */ static void -m68k_elf_after_allocation () +m68k_elf_after_allocation (void) { /* Call the standard elf routine. */ after_allocation_default (); #ifdef SUPPORT_EMBEDDED_RELOCS if (command_line.embedded_relocs - && (! link_info.relocateable)) + && (! link_info.relocatable)) { bfd *abfd; diff --git a/gnu/usr.bin/binutils/ld/emultempl/mipself.em b/gnu/usr.bin/binutils/ld/emultempl/mipself.em index 62a53e0a57f..a950fb11d4b 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/mipself.em +++ b/gnu/usr.bin/binutils/ld/emultempl/mipself.em @@ -1,4 +1,5 @@ -# Copyright 2002 Free Software Foundation, Inc. +# This shell script emits a C file. -*- C -*- +# Copyright 2002, 2003 Free Software Foundation, Inc. # Written by Mitch Lichtenberg <mpl@broadcom.com> and # Chris Demetriou <cgd@broadcom.com> based on m68kelf.em and mipsecoff.em. # @@ -17,7 +18,6 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# This shell script emits a C file. -*- C -*- # This file is sourced from elf32.em, and defines some extra routines for m68k @@ -33,23 +33,20 @@ esac cat >>e${EMULATION_NAME}.c <<EOF -static void mips_elf${ELFSIZE}_after_open PARAMS ((void)); #ifdef SUPPORT_EMBEDDED_RELOCS -static void mips_elf${ELFSIZE}_check_sections PARAMS ((bfd *, asection *, - PTR)); +static void mips_elf${ELFSIZE}_check_sections (bfd *, asection *, void *); #endif -static void mips_elf${ELFSIZE}_after_allocation PARAMS ((void)); /* This function is run after all the input files have been opened. */ static void -mips_elf${ELFSIZE}_after_open() +mips_elf${ELFSIZE}_after_open (void) { /* Call the standard elf routine. */ gld${EMULATION_NAME}_after_open (); #ifdef SUPPORT_EMBEDDED_RELOCS - if (command_line.embedded_relocs && (! link_info.relocateable)) + if (command_line.embedded_relocs && (! link_info.relocatable)) { bfd *abfd; @@ -105,7 +102,7 @@ mips_elf${ELFSIZE}_after_open() /* Double check that all other data sections have no relocs, as is required for embedded PIC code. */ bfd_map_over_sections (abfd, mips_elf${ELFSIZE}_check_sections, - (PTR) datasec); + datasec); } } #endif /* SUPPORT_EMBEDDED_RELOCS */ @@ -116,13 +113,10 @@ mips_elf${ELFSIZE}_after_open() relocs. This is called via bfd_map_over_sections. */ static void -mips_elf${ELFSIZE}_check_sections (abfd, sec, sdatasec) - bfd *abfd; - asection *sec; - PTR sdatasec; +mips_elf${ELFSIZE}_check_sections (bfd *abfd, asection *sec, void *sdatasec) { if ((bfd_get_section_flags (abfd, sec) & SEC_DATA) - && sec != (asection *) sdatasec + && sec != sdatasec && sec->reloc_count != 0) einfo ("%B%X: section %s has relocs; cannot use --embedded-relocs\n", abfd, bfd_get_section_name (abfd, sec)); @@ -134,13 +128,13 @@ mips_elf${ELFSIZE}_check_sections (abfd, sec, sdatasec) BFD backend routine to do the work. */ static void -mips_elf${ELFSIZE}_after_allocation () +mips_elf${ELFSIZE}_after_allocation (void) { /* Call the standard elf routine. */ after_allocation_default (); #ifdef SUPPORT_EMBEDDED_RELOCS - if (command_line.embedded_relocs && (! link_info.relocateable)) + if (command_line.embedded_relocs && (! link_info.relocatable)) { bfd *abfd; diff --git a/gnu/usr.bin/binutils/ld/emultempl/mmix-elfnmmo.em b/gnu/usr.bin/binutils/ld/emultempl/mmix-elfnmmo.em index 8ec604f6e36..9777fa307ba 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/mmix-elfnmmo.em +++ b/gnu/usr.bin/binutils/ld/emultempl/mmix-elfnmmo.em @@ -1,5 +1,5 @@ # This shell script emits a C file. -*- C -*- -# Copyright 2001, 2002 Free Software Foundation, Inc. +# Copyright 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GLD, the Gnu Linker. # @@ -24,13 +24,10 @@ cat >>e${EMULATION_NAME}.c <<EOF #include "elf/mmix.h" -static void mmix_before_allocation PARAMS ((void)); -static void mmix_after_allocation PARAMS ((void)); - /* Set up handling of linker-allocated global registers. */ static void -mmix_before_allocation () +mmix_before_allocation (void) { /* Call the default first. */ gld${EMULATION_NAME}_before_allocation (); @@ -41,11 +38,11 @@ mmix_before_allocation () maintenance burden to keep them in sync. (Of course we lose the maintenance burden of checking that it still does what we need.) */ - /* Force -relax on if not doing a relocatable link. */ - if (! link_info.relocateable) - command_line.relax = TRUE; + /* Force -relax on (regardless of whether we're doing a relocatable + link). */ + command_line.relax = TRUE; - if (!_bfd_mmix_prepare_linker_allocated_gregs (output_bfd, &link_info)) + if (!_bfd_mmix_before_linker_allocation (output_bfd, &link_info)) einfo ("%X%P: Internal problems setting up section %s", MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME); } @@ -55,7 +52,7 @@ mmix_before_allocation () GREGs. */ static void -mmix_after_allocation () +mmix_after_allocation (void) { asection *sec = bfd_get_section_by_name (output_bfd, MMIX_REG_CONTENTS_SECTION_NAME); @@ -112,7 +109,7 @@ mmix_after_allocation () if (sec != NULL) bfd_set_section_vma (abfd, sec, 0); - if (!_bfd_mmix_finalize_linker_allocated_gregs (output_bfd, &link_info)) + if (!_bfd_mmix_after_linker_allocation (output_bfd, &link_info)) { /* This is a fatal error; make einfo call not return. */ einfo ("%F%P: Can't finalize linker-allocated global registers\n"); diff --git a/gnu/usr.bin/binutils/ld/emultempl/mmixelf.em b/gnu/usr.bin/binutils/ld/emultempl/mmixelf.em index 80d2d94830c..7cdae552c41 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/mmixelf.em +++ b/gnu/usr.bin/binutils/ld/emultempl/mmixelf.em @@ -1,5 +1,5 @@ # This shell script emits a C file. -*- C -*- -# Copyright 2001, 2002 Free Software Foundation, Inc. +# Copyright 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GLD, the Gnu Linker. # @@ -26,10 +26,8 @@ cat >>e${EMULATION_NAME}.c <<EOF #line 29 "${srcdir}/emultempl/elfmmix.em" -static void elfmmix_before_parse PARAMS ((void)); - static void -elfmmix_before_parse () +elfmmix_before_parse (void) { gld${EMULATION_NAME}_before_parse (); diff --git a/gnu/usr.bin/binutils/ld/emultempl/mmo.em b/gnu/usr.bin/binutils/ld/emultempl/mmo.em index e65e89bc5d9..38f1dbf78ef 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/mmo.em +++ b/gnu/usr.bin/binutils/ld/emultempl/mmo.em @@ -1,5 +1,5 @@ # This shell script emits a C file. -*- C -*- -# Copyright 2001, 2002 Free Software Foundation, Inc. +# Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. # # This file is part of GLD, the Gnu Linker. # @@ -32,22 +32,13 @@ EOF cat >>e${EMULATION_NAME}.c <<EOF -static bfd_boolean mmo_place_orphan - PARAMS ((lang_input_statement_type *, asection *)); -static asection *output_prev_sec_find - PARAMS ((lang_output_section_statement_type *)); -static void mmo_finish PARAMS ((void)); -static void mmo_wipe_sec_reloc_flag PARAMS ((bfd *, asection *, PTR)); -static void mmo_after_open PARAMS ((void)); - /* Find the last output section before given output statement. Used by place_orphan. */ static asection * -output_prev_sec_find (os) - lang_output_section_statement_type *os; +output_prev_sec_find (lang_output_section_statement_type *os) { - asection *s = (asection *) NULL; + asection *s = NULL; lang_statement_union_type *u; lang_output_section_statement_type *lookup; @@ -85,9 +76,7 @@ struct orphan_save { from elf32.em. */ static bfd_boolean -mmo_place_orphan (file, s) - lang_input_statement_type *file; - asection *s; +mmo_place_orphan (lang_input_statement_type *file, asection *s) { static struct orphan_save hold_text; struct orphan_save *place; @@ -97,7 +86,7 @@ mmo_place_orphan (file, s) asection *snew, **pps, *bfd_section; /* We have nothing to say for anything other than a final link. */ - if (link_info.relocateable + if (link_info.relocatable || (bfd_get_section_flags (s->owner, s) & (SEC_EXCLUDE | SEC_LOAD)) != SEC_LOAD) return FALSE; @@ -138,7 +127,6 @@ mmo_place_orphan (file, s) os = lang_enter_output_section_statement (bfd_get_section_name (s->owner, s), NULL, 0, - (bfd_vma) 0, (etree_type *) NULL, (etree_type *) NULL, (etree_type *) NULL); @@ -227,10 +215,7 @@ mmo_place_orphan (file, s) paper over the bug similarly. */ static void -mmo_wipe_sec_reloc_flag (abfd, sec, ptr) - bfd *abfd; - asection *sec; - PTR ptr ATTRIBUTE_UNUSED; +mmo_wipe_sec_reloc_flag (bfd *abfd, asection *sec, void *ptr ATTRIBUTE_UNUSED) { bfd_set_section_flags (abfd, sec, bfd_get_section_flags (abfd, sec) & ~SEC_RELOC); @@ -239,7 +224,7 @@ mmo_wipe_sec_reloc_flag (abfd, sec, ptr) /* Iterate with bfd_map_over_sections over mmo_wipe_sec_reloc_flag... */ static void -mmo_finish () +mmo_finish (void) { bfd_map_over_sections (output_bfd, mmo_wipe_sec_reloc_flag, NULL); } @@ -251,7 +236,7 @@ mmo_finish () when all input files are seen, which is equivalent. */ static void -mmo_after_open () +mmo_after_open (void) { /* When there's a mismatch between the output format and the emulation (using weird combinations like "-m mmo --oformat elf64-mmix" for diff --git a/gnu/usr.bin/binutils/ld/emultempl/needrelax.em b/gnu/usr.bin/binutils/ld/emultempl/needrelax.em index 242b7787435..65e622bee74 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/needrelax.em +++ b/gnu/usr.bin/binutils/ld/emultempl/needrelax.em @@ -1,5 +1,5 @@ # This shell script emits a C file. -*- C -*- -# Copyright 2001, 2002 Free Software Foundation, Inc. +# Copyright 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of GLD, the Gnu Linker. # @@ -25,16 +25,14 @@ LDEMUL_BEFORE_ALLOCATION=need_relax_${EMULATION_NAME}_before_allocation cat >>e${EMULATION_NAME}.c <<EOF -static void need_relax_${EMULATION_NAME}_before_allocation PARAMS ((void)); - static void -need_relax_${EMULATION_NAME}_before_allocation () +need_relax_${EMULATION_NAME}_before_allocation (void) { /* Call main function; we're just extending it. */ gld${EMULATION_NAME}_before_allocation (); /* Force -relax on if not doing a relocatable link. */ - if (! link_info.relocateable) + if (! link_info.relocatable) command_line.relax = TRUE; } EOF diff --git a/gnu/usr.bin/binutils/ld/emultempl/netbsd.em b/gnu/usr.bin/binutils/ld/emultempl/netbsd.em index 891a87941fc..43715e40462 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/netbsd.em +++ b/gnu/usr.bin/binutils/ld/emultempl/netbsd.em @@ -1,9 +1,11 @@ LDEMUL_BEFORE_PARSE=gldnetbsd_before_parse + cat >>e${EMULATION_NAME}.c <<EOF -static void gldnetbsd_before_parse PARAMS ((void)); +static void +gld${EMULATION_NAME}_before_parse (void); static void -gldnetbsd_before_parse () +gldnetbsd_before_parse (void) { gld${EMULATION_NAME}_before_parse (); link_info.common_skip_ar_aymbols = bfd_link_common_skip_text; diff --git a/gnu/usr.bin/binutils/ld/emultempl/ppc32elf.em b/gnu/usr.bin/binutils/ld/emultempl/ppc32elf.em index fbe1782aa1d..46145932c3d 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/ppc32elf.em +++ b/gnu/usr.bin/binutils/ld/emultempl/ppc32elf.em @@ -29,10 +29,8 @@ cat >>e${EMULATION_NAME}.c <<EOF /* Whether to run tls optimization. */ static int notlsopt = 0; -static void ppc_before_allocation PARAMS ((void)); - static void -ppc_before_allocation () +ppc_before_allocation (void) { extern const bfd_target bfd_elf32_powerpc_vec; extern const bfd_target bfd_elf32_powerpcle_vec; diff --git a/gnu/usr.bin/binutils/ld/emultempl/ppc64elf.em b/gnu/usr.bin/binutils/ld/emultempl/ppc64elf.em index 9f688a3d06a..4f408a9fa29 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/ppc64elf.em +++ b/gnu/usr.bin/binutils/ld/emultempl/ppc64elf.em @@ -1,5 +1,5 @@ # This shell script emits a C file. -*- C -*- -# Copyright 2002, 2003 Free Software Foundation, Inc. +# Copyright 2002, 2003, 2004 Free Software Foundation, Inc. # # This file is part of GLD, the Gnu Linker. # @@ -25,10 +25,12 @@ cat >>e${EMULATION_NAME}.c <<EOF #include "ldctor.h" #include "libbfd.h" +#include "elf-bfd.h" #include "elf64-ppc.h" /* Fake input file for stubs. */ static lang_input_statement_type *stub_file; +static int stub_added = 0; /* Whether we need to call ppc_layout_sections_again. */ static int need_laying_out = 0; @@ -44,28 +46,17 @@ static int dotsyms = 1; /* Whether to run tls optimization. */ static int notlsopt = 0; -static void ppc_create_output_section_statements - PARAMS ((void)); -static void ppc_after_open - PARAMS ((void)); -static void ppc_before_allocation - PARAMS ((void)); -static asection *ppc_add_stub_section - PARAMS ((const char *, asection *)); -static void ppc_layout_sections_again - PARAMS ((void)); -static void gld${EMULATION_NAME}_after_allocation - PARAMS ((void)); -static void build_section_lists - PARAMS ((lang_statement_union_type *)); -static struct bfd_elf_version_expr *gld${EMULATION_NAME}_new_vers_pattern - PARAMS ((struct bfd_elf_version_expr *)); +/* Whether to emit symbols for stubs. */ +static int emit_stub_syms = 0; + +static asection *toc_section = 0; + /* This is called before the input files are opened. We create a new fake input file to hold the stub sections. */ static void -ppc_create_output_section_statements () +ppc_create_output_section_statements (void) { extern const bfd_target bfd_elf64_powerpc_vec; extern const bfd_target bfd_elf64_powerpcle_vec; @@ -74,6 +65,8 @@ ppc_create_output_section_statements () && link_info.hash->creator != &bfd_elf64_powerpcle_vec) return; + link_info.wrap_char = '.'; + stub_file = lang_add_input_file ("linker stubs", lang_input_file_is_fake_enum, NULL); @@ -88,10 +81,11 @@ ppc_create_output_section_statements () } ldlang_add_file (stub_file); + ppc64_elf_init_stub_bfd (stub_file->the_bfd, &link_info); } static void -ppc_after_open () +ppc_after_open (void) { if (!ppc64_elf_mark_entry_syms (&link_info)) { @@ -103,7 +97,7 @@ ppc_after_open () } static void -ppc_before_allocation () +ppc_before_allocation (void) { if (stub_file != NULL) { @@ -118,7 +112,7 @@ ppc_before_allocation () /* Size the sections. This is premature, but we want to know the TLS segment layout so that certain optimizations can be done. */ lang_size_sections (stat_ptr->head, abs_output_section, - &stat_ptr->head, 0, (bfd_vma) 0, NULL, TRUE); + &stat_ptr->head, 0, 0, NULL, TRUE); if (!ppc64_elf_tls_optimize (output_bfd, &link_info)) { @@ -126,6 +120,8 @@ ppc_before_allocation () return; } + /* We must not cache anything from the preliminary sizing. */ + elf_tdata (output_bfd)->program_header_size = 0; lang_reset_memory_regions (); } } @@ -141,13 +137,8 @@ struct hook_stub_info /* Traverse the linker tree to find the spot where the stub goes. */ -static bfd_boolean hook_in_stub - PARAMS ((struct hook_stub_info *, lang_statement_union_type **)); - static bfd_boolean -hook_in_stub (info, lp) - struct hook_stub_info *info; - lang_statement_union_type **lp; +hook_in_stub (struct hook_stub_info *info, lang_statement_union_type **lp) { lang_statement_union_type *l; bfd_boolean ret; @@ -219,9 +210,7 @@ hook_in_stub (info, lp) immediately before INPUT_SECTION. */ static asection * -ppc_add_stub_section (stub_sec_name, input_section) - const char *stub_sec_name; - asection *input_section; +ppc_add_stub_section (const char *stub_sec_name, asection *input_section) { asection *stub_sec; flagword flags; @@ -250,6 +239,7 @@ ppc_add_stub_section (stub_sec_name, input_section) if (info.add.head == NULL) goto err_ret; + stub_added = 1; if (hook_in_stub (&info, &os->children.head)) return stub_sec; @@ -262,7 +252,7 @@ ppc_add_stub_section (stub_sec_name, input_section) /* Another call-back for ppc64_elf_size_stubs. */ static void -ppc_layout_sections_again () +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 @@ -273,38 +263,47 @@ ppc_layout_sections_again () /* Resize the sections. */ lang_size_sections (stat_ptr->head, abs_output_section, - &stat_ptr->head, 0, (bfd_vma) 0, NULL, TRUE); + &stat_ptr->head, 0, 0, NULL, TRUE); /* Recalculate TOC base. */ ldemul_after_allocation (); /* Do the assignments again. */ - lang_do_assignments (stat_ptr->head, abs_output_section, - (fill_type *) 0, (bfd_vma) 0); + lang_do_assignments (stat_ptr->head, abs_output_section, NULL, 0); } /* Call the back-end function to set TOC base after we have placed all the sections. */ static void -gld${EMULATION_NAME}_after_allocation () +gld${EMULATION_NAME}_after_allocation (void) { - if (!link_info.relocateable) + if (!link_info.relocatable) _bfd_set_gp_value (output_bfd, ppc64_elf_toc (output_bfd)); } static void -build_section_lists (statement) - lang_statement_union_type *statement; +build_toc_list (lang_statement_union_type *statement) +{ + if (statement->header.type == lang_input_section_enum + && !statement->input_section.ifile->just_syms_flag + && statement->input_section.section->output_section == toc_section) + ppc64_elf_next_toc_section (&link_info, statement->input_section.section); +} + + +static void +build_section_lists (lang_statement_union_type *statement) { if (statement->header.type == lang_input_section_enum && !statement->input_section.ifile->just_syms_flag && statement->input_section.section->output_section != NULL && statement->input_section.section->output_section->owner == output_bfd) { - ppc64_elf_next_input_section (&link_info, - statement->input_section.section); + if (!ppc64_elf_next_input_section (&link_info, + statement->input_section.section)) + einfo ("%X%P: can not size stub section: %E\n"); } } @@ -312,23 +311,23 @@ build_section_lists (statement) /* Final emulation specific call. */ static void -gld${EMULATION_NAME}_finish () +gld${EMULATION_NAME}_finish (void) { /* 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"; - /* bfd_elf64_discard_info just plays with debugging sections, + /* bfd_elf_discard_info just plays with debugging sections, ie. doesn't affect any code, so we can delay resizing the sections. It's likely we'll resize everything in the process of adding stubs. */ - if (bfd_elf${ELFSIZE}_discard_info (output_bfd, &link_info)) + if (bfd_elf_discard_info (output_bfd, &link_info)) need_laying_out = 1; /* If generating a relocatable output file, then we don't have any stubs. */ - if (stub_file != NULL && !link_info.relocateable) + if (stub_file != NULL && !link_info.relocatable) { int ret = ppc64_elf_setup_section_lists (output_bfd, &link_info); if (ret != 0) @@ -339,11 +338,16 @@ gld${EMULATION_NAME}_finish () return; } + toc_section = bfd_get_section_by_name (output_bfd, ".got"); + if (toc_section != NULL) + lang_for_each_statement (build_toc_list); + + ppc64_elf_reinit_toc (output_bfd, &link_info); + lang_for_each_statement (build_section_lists); /* Call into the BFD backend to do the real work. */ if (!ppc64_elf_size_stubs (output_bfd, - stub_file->the_bfd, &link_info, group_size, &ppc_add_stub_section, @@ -358,10 +362,24 @@ gld${EMULATION_NAME}_finish () if (need_laying_out) ppc_layout_sections_again (); - if (stub_file != NULL && stub_file->the_bfd->sections != NULL) + if (stub_added) { - if (!ppc64_elf_build_stubs (&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); } } @@ -384,55 +402,24 @@ gld${EMULATION_NAME}_finish () exported. Lack of an exported function code sym may cause a definition to be pulled in from a static library. */ -struct bfd_elf_version_expr * -gld${EMULATION_NAME}_new_vers_pattern (entry) - struct bfd_elf_version_expr *entry; +static struct bfd_elf_version_expr * +gld${EMULATION_NAME}_new_vers_pattern (struct bfd_elf_version_expr *entry) { struct bfd_elf_version_expr *dot_entry; - struct bfd_elf_version_expr *next; unsigned int len; char *dot_pat; - if (!dotsyms || entry->pattern[0] == '*') + if (!dotsyms || entry->pattern[0] == '*' || entry->pattern[0] == '.') return entry; - /* Is the script adding ".foo" explicitly? */ - if (entry->pattern[0] == '.') - { - /* We may have added this pattern automatically. Don't add it - again. Quadratic behaviour here is acceptable as the list - may be traversed for each input bfd symbol. */ - for (next = entry->next; next != NULL; next = next->next) - { - if (strcmp (next->pattern, entry->pattern) == 0 - && next->match == entry->match) - { - next = entry->next; - free ((char *) entry->pattern); - free (entry); - return next; - } - } - return entry; - } - - /* Don't add ".foo" if the script has already done so. */ - for (next = entry->next; next != NULL; next = next->next) - { - if (next->pattern[0] == '.' - && strcmp (next->pattern + 1, entry->pattern) == 0 - && next->match == entry->match) - return entry; - } - - dot_entry = (struct bfd_elf_version_expr *) xmalloc (sizeof *dot_entry); + dot_entry = xmalloc (sizeof *dot_entry); + *dot_entry = *entry; dot_entry->next = entry; len = strlen (entry->pattern) + 2; dot_pat = xmalloc (len); dot_pat[0] = '.'; memcpy (dot_pat + 1, entry->pattern, len - 1); dot_entry->pattern = dot_pat; - dot_entry->match = entry->match; return dot_entry; } @@ -440,23 +427,16 @@ gld${EMULATION_NAME}_new_vers_pattern (entry) /* Avoid processing the fake stub_file in vercheck, stat_needed and check_needed routines. */ -static void ppc_for_each_input_file_wrapper - PARAMS ((lang_input_statement_type *)); -static void ppc_lang_for_each_input_file - PARAMS ((void (*) (lang_input_statement_type *))); - -static void (*real_func) PARAMS ((lang_input_statement_type *)); +static void (*real_func) (lang_input_statement_type *); -static void ppc_for_each_input_file_wrapper (l) - lang_input_statement_type *l; +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 (func) - void (*func) PARAMS ((lang_input_statement_type *)); +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); @@ -471,13 +451,15 @@ EOF # PARSE_AND_LIST_PROLOGUE=' #define OPTION_STUBGROUP_SIZE 301 -#define OPTION_DOTSYMS (OPTION_STUBGROUP_SIZE + 1) +#define OPTION_STUBSYMS (OPTION_STUBGROUP_SIZE + 1) +#define OPTION_DOTSYMS (OPTION_STUBSYMS + 1) #define OPTION_NO_DOTSYMS (OPTION_DOTSYMS + 1) #define OPTION_NO_TLS_OPT (OPTION_NO_DOTSYMS + 1) ' PARSE_AND_LIST_LONGOPTS=' { "stub-group-size", required_argument, NULL, OPTION_STUBGROUP_SIZE }, + { "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS }, { "dotsyms", no_argument, NULL, OPTION_DOTSYMS }, { "no-dotsyms", no_argument, NULL, OPTION_NO_DOTSYMS }, { "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT }, @@ -494,6 +476,9 @@ PARSE_AND_LIST_OPTIONS=' the linker should choose suitable defaults.\n" )); fprintf (file, _("\ + --emit-stub-syms Label linker stubs with a symbol.\n" + )); + fprintf (file, _("\ --dotsyms For every version pattern \"foo\" in a version script,\n\ add \".foo\" so that function code symbols are\n\ treated the same as function descriptor symbols.\n\ @@ -517,6 +502,10 @@ PARSE_AND_LIST_ARGS_CASES=' } break; + case OPTION_STUBSYMS: + emit_stub_syms = 1; + break; + case OPTION_DOTSYMS: dotsyms = 1; break; diff --git a/gnu/usr.bin/binutils/ld/emultempl/sh64elf.em b/gnu/usr.bin/binutils/ld/emultempl/sh64elf.em index 066cab86d8b..83bfe676bb1 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/sh64elf.em +++ b/gnu/usr.bin/binutils/ld/emultempl/sh64elf.em @@ -33,9 +33,6 @@ cat >>e${EMULATION_NAME}.c <<EOF #include "elf/sh.h" #include "elf32-sh64.h" -static void sh64_elf_${EMULATION_NAME}_before_allocation PARAMS ((void)); -static void sh64_elf_${EMULATION_NAME}_after_allocation PARAMS ((void)); - /* Check if we need a .cranges section and create it if it's not in any input file. It might seem better to always create it and if unneeded, discard it, but I don't find a simple way to discard it totally from @@ -47,7 +44,7 @@ static void sh64_elf_${EMULATION_NAME}_after_allocation PARAMS ((void)); they will be linked. */ static void -sh64_elf_${EMULATION_NAME}_before_allocation () +sh64_elf_${EMULATION_NAME}_before_allocation (void) { asection *cranges; asection *osec; @@ -240,7 +237,7 @@ sh64_elf_${EMULATION_NAME}_before_allocation () /* Size up and extend the .cranges section, merging generated entries. */ static void -sh64_elf_${EMULATION_NAME}_after_allocation () +sh64_elf_${EMULATION_NAME}_after_allocation (void) { bfd_vma new_cranges = 0; bfd_vma cranges_growth = 0; @@ -378,14 +375,20 @@ sh64_elf_${EMULATION_NAME}_after_allocation () } } - BFD_ASSERT (cranges->contents == NULL); + /* ldemul_after_allocation may be called twice. First directly from + lang_process, and the second time when lang_process calls ldemul_finish, + which calls gld${EMULATION_NAME}_finish, e.g. gldshelf32_finish, which + is defined in emultempl/elf32.em and calls ldemul_after_allocation, + if bfd_elf_discard_info returned true. */ + if (cranges->contents != NULL) + free (cranges->contents); + BFD_ASSERT (sh64_elf_section_data (cranges)->sh64_info != NULL); /* Make sure we have .cranges in memory even if there were only assembler-generated .cranges. */ cranges_growth = new_cranges * SH64_CRANGE_SIZE; - cranges->contents - = (bfd_byte *) xcalloc (cranges->_raw_size + cranges_growth, 1); + cranges->contents = xcalloc (cranges->_raw_size + cranges_growth, 1); bfd_set_section_flags (cranges->owner, cranges, bfd_get_section_flags (cranges->owner, cranges) | SEC_IN_MEMORY); @@ -483,9 +486,9 @@ sh64_elf_${EMULATION_NAME}_after_allocation () continue; } - /* If we emit relocateable contents, we need a + /* If we emit relocatable contents, we need a relocation for the start address. */ - if (link_info.relocateable || link_info.emitrelocations) + if (link_info.relocatable || link_info.emitrelocations) { /* FIXME: We could perhaps use lang_add_reloc and friends here, but I'm not really sure that @@ -507,8 +510,7 @@ sh64_elf_${EMULATION_NAME}_after_allocation () - cranges->contents); cr_addr_order->size = 4; cr_addr_order->u.reloc.p - = ((struct bfd_link_order_reloc *) - xmalloc (sizeof (struct bfd_link_order_reloc))); + = xmalloc (sizeof (struct bfd_link_order_reloc)); cr_addr_order->u.reloc.p->reloc = BFD_RELOC_32; cr_addr_order->u.reloc.p->u.section = osec; @@ -540,7 +542,7 @@ sh64_elf_${EMULATION_NAME}_after_allocation () bfd_put_32 (output_bfd, cr_size, crangesp + SH64_CRANGE_CR_SIZE_OFFSET); - bfd_put_16 (output_bfd, (bfd_vma) cr_type, + bfd_put_16 (output_bfd, cr_type, crangesp + SH64_CRANGE_CR_TYPE_OFFSET); last_cr_type = cr_type; @@ -555,7 +557,7 @@ sh64_elf_${EMULATION_NAME}_after_allocation () } /* The .cranges section will have this size, no larger or smaller. - Since relocs (if relocateable linking) will be emitted into the + Since relocs (if relocatable linking) will be emitted into the "extended" size, we must set the raw size to the total. We have to keep track of the number of new .cranges entries. diff --git a/gnu/usr.bin/binutils/ld/emultempl/ticoff.em b/gnu/usr.bin/binutils/ld/emultempl/ticoff.em index 90c940e4976..8f86b04f0c7 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/ticoff.em +++ b/gnu/usr.bin/binutils/ld/emultempl/ticoff.em @@ -3,7 +3,7 @@ (echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-) cat >>e${EMULATION_NAME}.c <<EOF /* This file is part of GLD, the Gnu Linker. - Copyright 1999, 2000, 2002, 2003 Free Software Foundation, Inc. + Copyright 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,8 +20,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* For TI COFF */ -/* Need to determine load and run pages for output sections */ - +/* Need to determine load and run pages for output sections */ + #define TARGET_IS_${EMULATION_NAME} #include "bfd.h" @@ -39,24 +39,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ static int coff_version; -static void gld_${EMULATION_NAME}_before_parse PARAMS ((void)); -static char *gld_${EMULATION_NAME}_get_script PARAMS ((int *)); -static void gld${EMULATION_NAME}_add_options - PARAMS ((int, char **, int, struct option **, int, struct option **)); -static bfd_boolean gld${EMULATION_NAME}_handle_option PARAMS ((int)); -static void gld_${EMULATION_NAME}_list_options PARAMS ((FILE *)); - /* TI COFF extra command line options */ #define OPTION_COFF_FORMAT (300 + 1) static void -gld${EMULATION_NAME}_add_options (ns, shortopts, nl, longopts, nrl, really_longopts) - int ns ATTRIBUTE_UNUSED; - char **shortopts ATTRIBUTE_UNUSED; - int nl; - struct option **longopts; - int nrl ATTRIBUTE_UNUSED; - struct option **really_longopts ATTRIBUTE_UNUSED; +gld${EMULATION_NAME}_add_options + (int ns ATTRIBUTE_UNUSED, char **shortopts ATTRIBUTE_UNUSED, int nl, + struct option **longopts, int nrl ATTRIBUTE_UNUSED, + struct option **really_longopts ATTRIBUTE_UNUSED) { static const struct option xtra_long[] = { /* TI COFF options */ @@ -70,15 +60,13 @@ gld${EMULATION_NAME}_add_options (ns, shortopts, nl, longopts, nrl, really_longo } static void -gld_${EMULATION_NAME}_list_options (file) - FILE * file; +gld_${EMULATION_NAME}_list_options (FILE * file) { - fprintf (file, _(" --format 0|1|2 Specify which COFF version to use")); -} + fprintf (file, _(" --format 0|1|2 Specify which COFF version to use\n")); +} static bfd_boolean -gld${EMULATION_NAME}_handle_option (optc) - int optc; +gld${EMULATION_NAME}_handle_option (int optc) { switch (optc) { @@ -89,12 +77,10 @@ gld${EMULATION_NAME}_handle_option (optc) if ((*optarg == '0' || *optarg == '1' || *optarg == '2') && optarg[1] == '\0') { - extern void lang_add_output_format - PARAMS ((const char *, const char *, const char *, int)); static char buf[] = "coffX-${OUTPUT_FORMAT_TEMPLATE}"; coff_version = *optarg - '0'; buf[4] = *optarg; - lang_add_output_format (buf, NULL, NULL, 0); + lang_add_output_format (buf, NULL, NULL, 0); } else { @@ -106,16 +92,15 @@ gld${EMULATION_NAME}_handle_option (optc) } static void -gld_${EMULATION_NAME}_before_parse() +gld_${EMULATION_NAME}_before_parse(void) { #ifndef TARGET_ /* I.e., if not generic. */ - ldfile_set_output_arch ("`echo ${ARCH}`"); + ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); #endif /* not TARGET_ */ } static char * -gld_${EMULATION_NAME}_get_script (isfile) - int *isfile; +gld_${EMULATION_NAME}_get_script (int *isfile) EOF if test -n "$COMPILE_IN" then @@ -128,11 +113,11 @@ s/$/\\n\\/ $s/$/n"/ ' cat >>e${EMULATION_NAME}.c <<EOF -{ +{ *isfile = 0; - if (link_info.relocateable && config.build_constructors) + if (link_info.relocatable && config.build_constructors) return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`; - else if (link_info.relocateable) + else if (link_info.relocatable) return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`; else if (!config.text_read_only) return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`; @@ -147,12 +132,12 @@ else # Scripts read from the filesystem. cat >>e${EMULATION_NAME}.c <<EOF -{ +{ *isfile = 1; - if (link_info.relocateable && config.build_constructors) + if (link_info.relocatable && config.build_constructors) return "ldscripts/${EMULATION_NAME}.xu"; - else if (link_info.relocateable) + else if (link_info.relocatable) return "ldscripts/${EMULATION_NAME}.xr"; else if (!config.text_read_only) return "ldscripts/${EMULATION_NAME}.xbn"; @@ -166,7 +151,7 @@ EOF fi cat >>e${EMULATION_NAME}.c <<EOF -struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = +struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = { gld_${EMULATION_NAME}_before_parse, syslib_default, diff --git a/gnu/usr.bin/binutils/ld/emultempl/xtensaelf.em b/gnu/usr.bin/binutils/ld/emultempl/xtensaelf.em index b0700758f69..87629200f65 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/xtensaelf.em +++ b/gnu/usr.bin/binutils/ld/emultempl/xtensaelf.em @@ -26,22 +26,8 @@ cat >>e${EMULATION_NAME}.c <<EOF #include <xtensa-config.h> -static char *elf_xtensa_choose_target - PARAMS ((int, char **)); -static bfd_boolean elf_xtensa_place_orphan - PARAMS ((lang_input_statement_type *, asection *)); -static void elf_xtensa_before_parse - PARAMS ((void)); -static void elf_xtensa_before_allocation - PARAMS ((void)); -static void xtensa_wild_group_interleave - PARAMS ((lang_statement_union_type *)); -static void xtensa_wild_group_interleave_callback - PARAMS ((lang_statement_union_type *)); -static void xtensa_colocate_output_literals - PARAMS ((lang_statement_union_type *)); -static void xtensa_colocate_output_literals_callback - PARAMS ((lang_statement_union_type *)); +static void xtensa_wild_group_interleave (lang_statement_union_type *); +static void xtensa_colocate_output_literals (lang_statement_union_type *); /* Flag for the emulation-specific "--no-relax" option. */ @@ -58,9 +44,8 @@ static bfd_boolean xtensa_use_literal_pages = FALSE; static char * -elf_xtensa_choose_target (argc, argv) - int argc ATTRIBUTE_UNUSED; - char **argv ATTRIBUTE_UNUSED; +elf_xtensa_choose_target (int argc ATTRIBUTE_UNUSED, + char **argv ATTRIBUTE_UNUSED) { if (XCHAL_HAVE_BE) return "${BIG_OUTPUT_FORMAT}"; @@ -70,12 +55,10 @@ elf_xtensa_choose_target (argc, argv) static bfd_boolean -elf_xtensa_place_orphan (file, s) - lang_input_statement_type *file; - asection *s; +elf_xtensa_place_orphan (lang_input_statement_type *file, asection *s) { /* Early exit for relocatable links. */ - if (link_info.relocateable) + if (link_info.relocatable) return FALSE; return gld${EMULATION_NAME}_place_orphan (file, s); @@ -83,7 +66,7 @@ elf_xtensa_place_orphan (file, s) static void -elf_xtensa_before_parse () +elf_xtensa_before_parse (void) { /* Just call the default hook.... Tensilica's version of this function does some other work that isn't relevant here. */ @@ -94,8 +77,8 @@ elf_xtensa_before_parse () /* This is called after the sections have been attached to output sections, but before any sizes or addresses have been set. */ -void -elf_xtensa_before_allocation () +static void +elf_xtensa_before_allocation (void) { bfd *in_bfd; bfd_boolean is_big_endian = XCHAL_HAVE_BE; @@ -143,12 +126,12 @@ elf_xtensa_before_allocation () gld${EMULATION_NAME}_before_allocation (); xtensa_wild_group_interleave (stat_ptr->head); - if (command_line.relax) + if (command_line.relax) xtensa_colocate_output_literals (stat_ptr->head); /* TBD: We need to force the page alignments to here and only do them as needed for the entire output section. Finally, if this - is a relocateable link then we need to add alignment notes so + is a relocatable link then we need to add alignment notes so that the literals can be separated later. */ } @@ -184,64 +167,29 @@ struct reloc_deps_graph_t }; static void xtensa_layout_wild - PARAMS ((const reloc_deps_graph *, lang_wild_statement_type *)); + (const reloc_deps_graph *, lang_wild_statement_type *); -typedef void (*deps_callback_t) - PARAMS ((asection *, /* src_sec */ - bfd_vma, /* src_offset */ - asection *, /* target_sec */ - bfd_vma, /* target_offset */ - PTR)); /* closure */ +typedef void (*deps_callback_t) (asection *, /* src_sec */ + bfd_vma, /* src_offset */ + asection *, /* target_sec */ + bfd_vma, /* target_offset */ + void *); /* closure */ -static void build_deps_graph_callback - PARAMS ((asection *, bfd_vma, asection *, bfd_vma, PTR)); extern bfd_boolean xtensa_callback_required_dependence - PARAMS ((bfd *, asection *, struct bfd_link_info *, - deps_callback_t, PTR)); + (bfd *, asection *, struct bfd_link_info *, deps_callback_t, void *); static void xtensa_ldlang_clear_addresses - PARAMS ((lang_statement_union_type *)); + (lang_statement_union_type *); static bfd_boolean ld_local_file_relocations_fit - PARAMS ((lang_statement_union_type *, const reloc_deps_graph *)); + (lang_statement_union_type *, const reloc_deps_graph *); static bfd_vma ld_assign_relative_paged_dot - PARAMS ((bfd_vma, lang_statement_union_type *, - const reloc_deps_graph *, bfd_boolean)); + (bfd_vma, lang_statement_union_type *, const reloc_deps_graph *, + bfd_boolean); static bfd_vma ld_xtensa_insert_page_offsets - PARAMS ((bfd_vma, lang_statement_union_type *, reloc_deps_graph *, - bfd_boolean)); -static void lang_for_each_statement_worker - PARAMS ((void (*) (lang_statement_union_type *), - lang_statement_union_type *)); -static void xtensa_move_dependencies_to_front - PARAMS ((reloc_deps_graph *, lang_wild_statement_type *)); -static reloc_deps_graph *ld_build_required_section_dependence - PARAMS ((lang_statement_union_type *)); -static bfd_boolean section_is_source - PARAMS ((const reloc_deps_graph *, lang_statement_union_type *)); -static bfd_boolean section_is_target - PARAMS ((const reloc_deps_graph *, lang_statement_union_type *)); -static bfd_boolean section_is_source_or_target - PARAMS ((const reloc_deps_graph *, lang_statement_union_type *)); -static bfd_boolean deps_has_sec_edge - PARAMS ((const reloc_deps_graph *, asection *, asection *)); -static bfd_boolean deps_has_edge - PARAMS ((const reloc_deps_graph *, lang_statement_union_type *, - lang_statement_union_type *)); -static void add_deps_edge - PARAMS ((reloc_deps_graph *, asection *, asection *)); + (bfd_vma, lang_statement_union_type *, reloc_deps_graph *, bfd_boolean); #if EXTRA_VALIDATION static size_t ld_count_children - PARAMS ((lang_statement_union_type *)); + (lang_statement_union_type *); #endif -static void free_reloc_deps_graph - PARAMS ((reloc_deps_graph *)); -static void xtensa_colocate_literals - PARAMS ((reloc_deps_graph *, lang_statement_union_type *)); -static reloc_deps_section *xtensa_get_section_deps - PARAMS ((const reloc_deps_graph *, asection *)); -static void xtensa_set_section_deps - PARAMS ((const reloc_deps_graph *, asection *, reloc_deps_section *)); -static void xtensa_append_section_deps - PARAMS ((reloc_deps_graph *, asection *)); extern lang_statement_list_type constructor_list; @@ -250,99 +198,94 @@ extern lang_statement_list_type constructor_list; there statically. */ static void -lang_for_each_statement_worker (func, s) - void (*func) PARAMS ((lang_statement_union_type *)); - lang_statement_union_type *s; +lang_for_each_statement_worker (void (*func) (lang_statement_union_type *), + lang_statement_union_type *s) { for (; s != (lang_statement_union_type *) NULL; s = s->header.next) { func (s); switch (s->header.type) - { - case lang_constructors_statement_enum: - lang_for_each_statement_worker (func, constructor_list.head); - break; - case lang_output_section_statement_enum: - lang_for_each_statement_worker - (func, - s->output_section_statement.children.head); - break; - case lang_wild_statement_enum: - lang_for_each_statement_worker - (func, - s->wild_statement.children.head); - break; - case lang_group_statement_enum: - lang_for_each_statement_worker (func, - s->group_statement.children.head); - break; - case lang_data_statement_enum: - case lang_reloc_statement_enum: - case lang_object_symbols_statement_enum: - case lang_output_statement_enum: - case lang_target_statement_enum: - case lang_input_section_enum: - case lang_input_statement_enum: - case lang_assignment_statement_enum: - case lang_padding_statement_enum: - case lang_address_statement_enum: - case lang_fill_statement_enum: - break; - default: - FAIL (); - break; - } + { + case lang_constructors_statement_enum: + lang_for_each_statement_worker (func, constructor_list.head); + break; + case lang_output_section_statement_enum: + lang_for_each_statement_worker + (func, + s->output_section_statement.children.head); + break; + case lang_wild_statement_enum: + lang_for_each_statement_worker + (func, + s->wild_statement.children.head); + break; + case lang_group_statement_enum: + lang_for_each_statement_worker (func, + s->group_statement.children.head); + break; + case lang_data_statement_enum: + case lang_reloc_statement_enum: + case lang_object_symbols_statement_enum: + case lang_output_statement_enum: + case lang_target_statement_enum: + case lang_input_section_enum: + case lang_input_statement_enum: + case lang_assignment_statement_enum: + case lang_padding_statement_enum: + case lang_address_statement_enum: + case lang_fill_statement_enum: + break; + default: + FAIL (); + break; + } } } /* End of verbatim code from ldlang.c. */ -reloc_deps_section * -xtensa_get_section_deps (deps, sec) - const reloc_deps_graph *deps ATTRIBUTE_UNUSED; - asection *sec; +static reloc_deps_section * +xtensa_get_section_deps (const reloc_deps_graph *deps ATTRIBUTE_UNUSED, + asection *sec) { /* We have a separate function for this so that we could in the future keep a completely independent structure that maps a section to its dependence edges. For now, we place these in the sec->userdata field. */ - reloc_deps_section *sec_deps = (reloc_deps_section *) sec->userdata; + reloc_deps_section *sec_deps = sec->userdata; return sec_deps; } -void -xtensa_set_section_deps (deps, sec, deps_section) - const reloc_deps_graph *deps ATTRIBUTE_UNUSED; - asection *sec; - reloc_deps_section *deps_section; +static void +xtensa_set_section_deps (const reloc_deps_graph *deps ATTRIBUTE_UNUSED, + asection *sec, + reloc_deps_section *deps_section) { - sec->userdata = (void *) deps_section; + sec->userdata = deps_section; } /* This is used to keep a list of all of the sections participating in the graph so we can clean them up quickly. */ -static void -xtensa_append_section_deps (deps, sec) - reloc_deps_graph *deps; - asection *sec; +static void +xtensa_append_section_deps (reloc_deps_graph *deps, asection *sec) { if (deps->size <= deps->count) { asection **new_sections; size_t i; size_t new_size; - + new_size = deps->size * 2; if (new_size == 0) new_size = 20; - - new_sections = (asection**) xmalloc (sizeof (asection*) * new_size); - memset (new_sections, 0, sizeof (asection*) * new_size); - for (i = 0; i < deps->count; i++) + + new_sections = xmalloc (sizeof (asection *) * new_size); + memset (new_sections, 0, sizeof (asection *) * new_size); + for (i = 0; i < deps->count; i++) { new_sections[i] = deps->sections[i]; } @@ -356,9 +299,8 @@ xtensa_append_section_deps (deps, sec) } -static void -free_reloc_deps_graph (deps) - reloc_deps_graph *deps; +static void +free_reloc_deps_graph (reloc_deps_graph *deps) { size_t i; for (i = 0; i < deps->count; i++) @@ -366,7 +308,7 @@ free_reloc_deps_graph (deps) asection *sec = deps->sections[i]; reloc_deps_section *sec_deps; sec_deps = xtensa_get_section_deps (deps, sec); - if (sec_deps) + if (sec_deps) { reloc_deps_e *next; while (sec_deps->succs != NULL) @@ -375,7 +317,7 @@ free_reloc_deps_graph (deps) free (sec_deps->succs); sec_deps->succs = next; } - + while (sec_deps->preds != NULL) { next = sec_deps->preds->next; @@ -393,10 +335,9 @@ free_reloc_deps_graph (deps) } -bfd_boolean -section_is_source (deps, s) - const reloc_deps_graph *deps ATTRIBUTE_UNUSED; - lang_statement_union_type *s; +static bfd_boolean +section_is_source (const reloc_deps_graph *deps ATTRIBUTE_UNUSED, + lang_statement_union_type *s) { asection *sec; const reloc_deps_section *sec_deps; @@ -406,14 +347,13 @@ section_is_source (deps, s) sec = s->input_section.section; sec_deps = xtensa_get_section_deps (deps, sec); - return (sec_deps && sec_deps->succs != NULL); + return sec_deps && sec_deps->succs != NULL; } -bfd_boolean -section_is_target (deps, s) - const reloc_deps_graph *deps ATTRIBUTE_UNUSED; - lang_statement_union_type *s; +static bfd_boolean +section_is_target (const reloc_deps_graph *deps ATTRIBUTE_UNUSED, + lang_statement_union_type *s) { asection *sec; const reloc_deps_section *sec_deps; @@ -423,13 +363,12 @@ section_is_target (deps, s) sec = s->input_section.section; sec_deps = xtensa_get_section_deps (deps, sec); - return (sec_deps && sec_deps->preds != NULL); + return sec_deps && sec_deps->preds != NULL; } -bfd_boolean -section_is_source_or_target (deps, s) - const reloc_deps_graph *deps ATTRIBUTE_UNUSED; - lang_statement_union_type *s; +static bfd_boolean +section_is_source_or_target (const reloc_deps_graph *deps ATTRIBUTE_UNUSED, + lang_statement_union_type *s) { return (section_is_source (deps, s) || section_is_target (deps, s)); @@ -449,19 +388,14 @@ struct xtensa_ld_iter_t struct xtensa_ld_iter_stack_t { xtensa_ld_iter iterloc; /* List that hold it. */ - + xtensa_ld_iter_stack *next; /* Next in the stack. */ xtensa_ld_iter_stack *prev; /* Back pointer for stack. */ }; -static void ld_xtensa_move_section_after - PARAMS ((xtensa_ld_iter *, xtensa_ld_iter *)); - -void -ld_xtensa_move_section_after (to, current) - xtensa_ld_iter *to; - xtensa_ld_iter *current; +static void +ld_xtensa_move_section_after (xtensa_ld_iter *to, xtensa_ld_iter *current) { lang_statement_union_type *to_next; lang_statement_union_type *current_next; @@ -474,7 +408,7 @@ ld_xtensa_move_section_after (to, current) if (to == current) return; - + #if EXTRA_VALIDATION old_to_count = ld_count_children (to->parent); old_current_count = ld_count_children (current->parent); @@ -482,9 +416,9 @@ ld_xtensa_move_section_after (to, current) to_next = *(to->loc); current_next = (*current->loc)->header.next; - + *(to->loc) = *(current->loc); - + *(current->loc) = current_next; (*(to->loc))->header.next = to_next; @@ -502,7 +436,7 @@ ld_xtensa_move_section_after (to, current) new_to_count = ld_count_children (to->parent); new_current_count = ld_count_children (current->parent); - ASSERT ((old_to_count + old_current_count) + ASSERT ((old_to_count + old_current_count) == (new_to_count + new_current_count)); #endif } @@ -511,41 +445,21 @@ ld_xtensa_move_section_after (to, current) /* Can only be called with lang_statements that have lists. Returns false if the list is empty. */ -static bfd_boolean iter_stack_empty - PARAMS ((xtensa_ld_iter_stack **)); -static bfd_boolean iter_stack_push - PARAMS ((xtensa_ld_iter_stack **, lang_statement_union_type *)); -static void iter_stack_pop - PARAMS ((xtensa_ld_iter_stack **)); -static void iter_stack_update - PARAMS ((xtensa_ld_iter_stack **)); -static void iter_stack_next - PARAMS ((xtensa_ld_iter_stack **)); -static lang_statement_union_type *iter_stack_current - PARAMS ((xtensa_ld_iter_stack **)); -static void iter_stack_create - PARAMS ((xtensa_ld_iter_stack **, lang_statement_union_type *)); -static void iter_stack_copy_current - PARAMS ((xtensa_ld_iter_stack **, xtensa_ld_iter *)); - - -static bfd_boolean -iter_stack_empty (stack_p) - xtensa_ld_iter_stack **stack_p; +static bfd_boolean +iter_stack_empty (xtensa_ld_iter_stack **stack_p) { - return (*stack_p == NULL); + return *stack_p == NULL; } static bfd_boolean -iter_stack_push (stack_p, parent) - xtensa_ld_iter_stack **stack_p; - lang_statement_union_type *parent; +iter_stack_push (xtensa_ld_iter_stack **stack_p, + lang_statement_union_type *parent) { xtensa_ld_iter_stack *stack; lang_statement_list_type *l = NULL; - switch (parent->header.type) + switch (parent->header.type) { case lang_output_section_statement_enum: l = &parent->output_section_statement.children; @@ -562,10 +476,10 @@ iter_stack_push (stack_p, parent) } /* Empty. do not push. */ - if (l->tail == &l->head) + if (l->tail == &l->head) return FALSE; - stack = (xtensa_ld_iter_stack *) xmalloc (sizeof (xtensa_ld_iter_stack)); + stack = xmalloc (sizeof (xtensa_ld_iter_stack)); memset (stack, 0, sizeof (xtensa_ld_iter_stack)); stack->iterloc.parent = parent; stack->iterloc.l = l; @@ -573,28 +487,27 @@ iter_stack_push (stack_p, parent) stack->next = *stack_p; stack->prev = NULL; - if (*stack_p != NULL) + if (*stack_p != NULL) (*stack_p)->prev = stack; *stack_p = stack; return TRUE; } -static void -iter_stack_pop (stack_p) - xtensa_ld_iter_stack **stack_p; +static void +iter_stack_pop (xtensa_ld_iter_stack **stack_p) { xtensa_ld_iter_stack *stack; stack = *stack_p; - if (stack == NULL) + if (stack == NULL) { ASSERT (stack != NULL); return; } - if (stack->next != NULL) + if (stack->next != NULL) stack->next->prev = NULL; *stack_p = stack->next; @@ -607,11 +520,10 @@ iter_stack_pop (stack_p) accordingly. */ static void -iter_stack_update (stack_p) - xtensa_ld_iter_stack **stack_p; +iter_stack_update (xtensa_ld_iter_stack **stack_p) { if (!iter_stack_empty (stack_p) - && (*(*stack_p)->iterloc.loc) == NULL) + && (*(*stack_p)->iterloc.loc) == NULL) { iter_stack_pop (stack_p); @@ -626,9 +538,8 @@ iter_stack_update (stack_p) } -static void -iter_stack_next (stack_p) - xtensa_ld_iter_stack **stack_p; +static void +iter_stack_next (xtensa_ld_iter_stack **stack_p) { xtensa_ld_iter_stack *stack; lang_statement_union_type *current; @@ -636,9 +547,9 @@ iter_stack_next (stack_p) current = *stack->iterloc.loc; /* If we are on the first element. */ - if (current != NULL) + if (current != NULL) { - switch (current->header.type) + switch (current->header.type) { case lang_output_section_statement_enum: case lang_wild_statement_enum: @@ -664,8 +575,7 @@ iter_stack_next (stack_p) static lang_statement_union_type * -iter_stack_current (stack_p) - xtensa_ld_iter_stack **stack_p; +iter_stack_current (xtensa_ld_iter_stack **stack_p) { return *((*stack_p)->iterloc.loc); } @@ -673,28 +583,25 @@ iter_stack_current (stack_p) /* The iter stack is a preorder. */ -static void -iter_stack_create (stack_p, parent) - xtensa_ld_iter_stack **stack_p; - lang_statement_union_type *parent; +static void +iter_stack_create (xtensa_ld_iter_stack **stack_p, + lang_statement_union_type *parent) { iter_stack_push (stack_p, parent); } -static void -iter_stack_copy_current (stack_p, front) - xtensa_ld_iter_stack **stack_p; - xtensa_ld_iter *front; +static void +iter_stack_copy_current (xtensa_ld_iter_stack **stack_p, + xtensa_ld_iter *front) { *front = (*stack_p)->iterloc; } -void -xtensa_colocate_literals (deps, statement) - reloc_deps_graph *deps; - lang_statement_union_type *statement; +static void +xtensa_colocate_literals (reloc_deps_graph *deps, + lang_statement_union_type *statement) { /* Keep a stack of pointers to control iteration through the contours. */ xtensa_ld_iter_stack *stack = NULL; @@ -719,15 +626,15 @@ xtensa_colocate_literals (deps, statement) lang_for_each_statement_worker (xtensa_ldlang_clear_addresses, statement); #endif - + iter_stack_create (stack_p, statement); - while (!iter_stack_empty (stack_p)) + while (!iter_stack_empty (stack_p)) { bfd_boolean skip_increment = FALSE; lang_statement_union_type *l = iter_stack_current (stack_p); - - switch (l->header.type) + + switch (l->header.type) { case lang_assignment_statement_enum: /* Any assignment statement should block reordering across it. */ @@ -740,12 +647,12 @@ xtensa_colocate_literals (deps, statement) { in_literals = (section_is_target (deps, l) && !section_is_source (deps, l)); - if (in_literals) + if (in_literals) { front_p = &front; iter_stack_copy_current (stack_p, front_p); } - } + } else { bfd_boolean is_target; @@ -762,15 +669,15 @@ xtensa_colocate_literals (deps, statement) } else { - if (is_target) + if (is_target) { /* Try to insert in place. */ ld_xtensa_move_section_after (front_p, current_p); - ld_assign_relative_paged_dot (0x100000, + ld_assign_relative_paged_dot (0x100000, statement, deps, xtensa_use_literal_pages); - + /* We use this code because it's already written. */ if (!ld_local_file_relocations_fit (statement, deps)) { @@ -779,7 +686,7 @@ xtensa_colocate_literals (deps, statement) /* Reset the literal placement. */ iter_stack_copy_current (stack_p, front_p); } - else + else { /* Move front pointer up by one. */ front_p->loc = &(*front_p->loc)->header.next; @@ -801,15 +708,14 @@ xtensa_colocate_literals (deps, statement) /* Be careful to update the stack_p if it now is a null. */ iter_stack_update (stack_p); } - + lang_for_each_statement_worker (xtensa_ldlang_clear_addresses, statement); } -void -xtensa_move_dependencies_to_front (deps, w) - reloc_deps_graph *deps; - lang_wild_statement_type *w; +static void +xtensa_move_dependencies_to_front (reloc_deps_graph *deps, + lang_wild_statement_type *w) { /* Keep a front pointer and a current pointer. */ lang_statement_union_type **front; @@ -825,7 +731,7 @@ xtensa_move_dependencies_to_front (deps, w) return; current = &(*front)->header.next; - while (*current != NULL) + while (*current != NULL) { if (section_is_source_or_target (deps, *current)) { @@ -853,10 +759,9 @@ xtensa_move_dependencies_to_front (deps, w) static bfd_boolean -deps_has_sec_edge (deps, src, tgt) - const reloc_deps_graph *deps; - asection *src; - asection *tgt; +deps_has_sec_edge (const reloc_deps_graph *deps, + asection *src, + asection *tgt) { const reloc_deps_section *sec_deps; const reloc_deps_e *sec_deps_e; @@ -864,13 +769,13 @@ deps_has_sec_edge (deps, src, tgt) sec_deps = xtensa_get_section_deps (deps, src); if (sec_deps == NULL) return FALSE; - + for (sec_deps_e = sec_deps->succs; - sec_deps_e != NULL; + sec_deps_e != NULL; sec_deps_e = sec_deps_e->next) { ASSERT (sec_deps_e->src == src); - if (sec_deps_e->tgt == tgt) + if (sec_deps_e->tgt == tgt) return TRUE; } return FALSE; @@ -878,10 +783,9 @@ deps_has_sec_edge (deps, src, tgt) static bfd_boolean -deps_has_edge (deps, src, tgt) - const reloc_deps_graph *deps; - lang_statement_union_type *src; - lang_statement_union_type *tgt; +deps_has_edge (const reloc_deps_graph *deps, + lang_statement_union_type *src, + lang_statement_union_type *tgt) { if (!section_is_source (deps, src)) return FALSE; @@ -892,17 +796,16 @@ deps_has_edge (deps, src, tgt) return FALSE; if (tgt->header.type != lang_input_section_enum) return FALSE; - + return deps_has_sec_edge (deps, src->input_section.section, tgt->input_section.section); } static void -add_deps_edge (deps, src_sec, tgt_sec) - reloc_deps_graph *deps; - asection *src_sec; - asection *tgt_sec; +add_deps_edge (reloc_deps_graph *deps, + asection *src_sec, + asection *tgt_sec) { reloc_deps_section *src_sec_deps; reloc_deps_section *tgt_sec_deps; @@ -912,13 +815,12 @@ add_deps_edge (deps, src_sec, tgt_sec) if (deps_has_sec_edge (deps, src_sec, tgt_sec)) return; - + src_sec_deps = xtensa_get_section_deps (deps, src_sec); if (src_sec_deps == NULL) { /* Add a section. */ - src_sec_deps = (reloc_deps_section *) - xmalloc (sizeof (reloc_deps_section)); + src_sec_deps = xmalloc (sizeof (reloc_deps_section)); memset (src_sec_deps, 0, sizeof (reloc_deps_section)); src_sec_deps->is_only_literal = 0; src_sec_deps->preds = NULL; @@ -931,8 +833,7 @@ add_deps_edge (deps, src_sec, tgt_sec) if (tgt_sec_deps == NULL) { /* Add a section. */ - tgt_sec_deps = (reloc_deps_section *) - xmalloc (sizeof (reloc_deps_section)); + tgt_sec_deps = xmalloc (sizeof (reloc_deps_section)); memset (tgt_sec_deps, 0, sizeof (reloc_deps_section)); tgt_sec_deps->is_only_literal = 0; tgt_sec_deps->preds = NULL; @@ -942,14 +843,14 @@ add_deps_edge (deps, src_sec, tgt_sec) } /* Add the edges. */ - src_edge = (reloc_deps_e *) xmalloc (sizeof (reloc_deps_e)); + src_edge = xmalloc (sizeof (reloc_deps_e)); memset (src_edge, 0, sizeof (reloc_deps_e)); src_edge->src = src_sec; src_edge->tgt = tgt_sec; src_edge->next = src_sec_deps->succs; src_sec_deps->succs = src_edge; - tgt_edge = (reloc_deps_e *) xmalloc (sizeof (reloc_deps_e)); + tgt_edge = xmalloc (sizeof (reloc_deps_e)); memset (tgt_edge, 0, sizeof (reloc_deps_e)); tgt_edge->src = src_sec; tgt_edge->tgt = tgt_sec; @@ -958,17 +859,14 @@ add_deps_edge (deps, src_sec, tgt_sec) } -void -build_deps_graph_callback (src_sec, src_offset, - target_sec, target_offset, closure) - asection *src_sec; - bfd_vma src_offset ATTRIBUTE_UNUSED; - asection *target_sec; - bfd_vma target_offset ATTRIBUTE_UNUSED; - PTR closure; +static void +build_deps_graph_callback (asection *src_sec, + bfd_vma src_offset ATTRIBUTE_UNUSED, + asection *target_sec, + bfd_vma target_offset ATTRIBUTE_UNUSED, + void *closure) { - reloc_deps_graph *deps; - deps = (reloc_deps_graph*) closure; + reloc_deps_graph *deps = closure; /* If the target is defined. */ if (target_sec != NULL) @@ -976,21 +874,20 @@ build_deps_graph_callback (src_sec, src_offset, } -reloc_deps_graph * -ld_build_required_section_dependence (s) - lang_statement_union_type *s; +static reloc_deps_graph * +ld_build_required_section_dependence (lang_statement_union_type *s) { reloc_deps_graph *deps; xtensa_ld_iter_stack *stack = NULL; - deps = (reloc_deps_graph*) xmalloc (sizeof (reloc_deps_graph)); + deps = xmalloc (sizeof (reloc_deps_graph)); deps->sections = NULL; deps->count = 0; deps->size = 0; - + for (iter_stack_create (&stack, s); !iter_stack_empty (&stack); - iter_stack_next (&stack)) + iter_stack_next (&stack)) { lang_statement_union_type *l = iter_stack_current (&stack); @@ -1003,7 +900,7 @@ ld_build_required_section_dependence (s) &link_info, /* Use the same closure. */ build_deps_graph_callback, - (PTR) deps); + deps); } } return deps; @@ -1011,15 +908,14 @@ ld_build_required_section_dependence (s) #if EXTRA_VALIDATION -size_t -ld_count_children (s) - lang_statement_union_type *s; +static size_t +ld_count_children (lang_statement_union_type *s) { size_t count = 0; xtensa_ld_iter_stack *stack = NULL; for (iter_stack_create (&stack, s); !iter_stack_empty (&stack); - iter_stack_next (&stack)) + iter_stack_next (&stack)) { lang_statement_union_type *l = iter_stack_current (&stack); ASSERT (l != NULL); @@ -1030,9 +926,8 @@ ld_count_children (s) #endif /* EXTRA_VALIDATION */ -void -xtensa_wild_group_interleave_callback (statement) - lang_statement_union_type * statement; +static void +xtensa_wild_group_interleave_callback (lang_statement_union_type *statement) { lang_wild_statement_type *w; reloc_deps_graph *deps; @@ -1069,13 +964,13 @@ xtensa_wild_group_interleave_callback (statement) break; } } - } + } /* Special case until the NOREORDER linker directive is supported: - *(.init) output sections and *(.fini) specs may NOT be reordered. */ + *(.init) output sections and *(.fini) specs may NOT be reordered. */ /* Check for sorting in a section list wildcard spec as well. */ - if (!no_reorder) + if (!no_reorder) { struct wildcard_list *l; for (l = w->section_list; l != NULL; l = l->next) @@ -1095,7 +990,7 @@ xtensa_wild_group_interleave_callback (statement) #endif /* It is now officially a target. Build the graph of source - section -> target section (kept as a list of edges). */ + section -> target section (kept as a list of edges). */ deps = ld_build_required_section_dependence (statement); /* If this wildcard does not reorder.... */ @@ -1124,18 +1019,16 @@ xtensa_wild_group_interleave_callback (statement) } -void -xtensa_wild_group_interleave (s) - lang_statement_union_type *s; +static void +xtensa_wild_group_interleave (lang_statement_union_type *s) { lang_for_each_statement_worker (xtensa_wild_group_interleave_callback, s); } -void -xtensa_layout_wild (deps, w) - const reloc_deps_graph *deps; - lang_wild_statement_type *w; +static void +xtensa_layout_wild (const reloc_deps_graph *deps, + lang_wild_statement_type *w) { /* If it does not fit initially, we need to do this step. Move all of the wild literal sections to a new list, then move each of @@ -1145,7 +1038,7 @@ xtensa_layout_wild (deps, w) size_t old_count, new_count; size_t ct1, ct2; #endif - + lang_wild_statement_type literal_wild; literal_wild.header.next = NULL; literal_wild.header.type = lang_wild_statement_enum; @@ -1167,7 +1060,7 @@ xtensa_layout_wild (deps, w) if (l->header.type == lang_input_section_enum) { if (section_is_target (deps, l) - && ! section_is_source (deps, l)) + && ! section_is_source (deps, l)) { /* Detach. */ *s_p = l->header.next; @@ -1179,7 +1072,7 @@ xtensa_layout_wild (deps, w) *literal_wild.children.tail = l; literal_wild.children.tail = &l->header.next; continue; - } + } } s_p = &(*s_p)->header.next; } @@ -1187,10 +1080,10 @@ xtensa_layout_wild (deps, w) #if EXTRA_VALIDATION ct1 = ld_count_children ((lang_statement_union_type*) w); ct2 = ld_count_children ((lang_statement_union_type*) &literal_wild); - + ASSERT (old_count == (ct1 + ct2)); #endif - + /* Now place them back in front of their dependent sections. */ while (literal_wild.children.head != NULL) @@ -1205,12 +1098,12 @@ xtensa_layout_wild (deps, w) /* Detach. */ literal_wild.children.head = lit->header.next; - if (literal_wild.children.head == NULL) + if (literal_wild.children.head == NULL) literal_wild.children.tail = &literal_wild.children.head; lit->header.next = NULL; /* Find a spot to place it. */ - for (s_p = &w->children.head; *s_p != NULL; s_p = &(*s_p)->header.next) + for (s_p = &w->children.head; *s_p != NULL; s_p = &(*s_p)->header.next) { lang_statement_union_type *src = *s_p; if (deps_has_edge (deps, src, lit)) @@ -1222,7 +1115,7 @@ xtensa_layout_wild (deps, w) break; } } - + if (!placed) { /* Put it at the end. */ @@ -1238,9 +1131,8 @@ xtensa_layout_wild (deps, w) } -void -xtensa_colocate_output_literals_callback (statement) - lang_statement_union_type * statement; +static void +xtensa_colocate_output_literals_callback (lang_statement_union_type *statement) { lang_output_section_statement_type *os; reloc_deps_graph *deps; @@ -1271,7 +1163,7 @@ xtensa_colocate_output_literals_callback (statement) #endif /* It is now officially a target. Build the graph of source - section -> target section (kept as a list of edges). */ + section -> target section (kept as a list of edges). */ deps = ld_build_required_section_dependence (statement); @@ -1290,7 +1182,7 @@ xtensa_colocate_output_literals_callback (statement) /* Insert align/offset assignment statement. */ if (xtensa_use_literal_pages) { - ld_xtensa_insert_page_offsets ((bfd_vma) 0, statement, deps, + ld_xtensa_insert_page_offsets (0, statement, deps, xtensa_use_literal_pages); lang_for_each_statement_worker (xtensa_ldlang_clear_addresses, statement); @@ -1302,21 +1194,19 @@ xtensa_colocate_output_literals_callback (statement) } -void -xtensa_colocate_output_literals (s) - lang_statement_union_type *s; +static void +xtensa_colocate_output_literals (lang_statement_union_type *s) { lang_for_each_statement_worker (xtensa_colocate_output_literals_callback, s); } -void -xtensa_ldlang_clear_addresses (statement) - lang_statement_union_type * statement; +static void +xtensa_ldlang_clear_addresses (lang_statement_union_type *statement) { switch (statement->header.type) { - case lang_input_section_enum: + case lang_input_section_enum: { asection *bfd_section = statement->input_section.section; bfd_section->output_offset = 0; @@ -1328,16 +1218,15 @@ xtensa_ldlang_clear_addresses (statement) } -bfd_vma -ld_assign_relative_paged_dot (dot, s, deps, lit_align) - bfd_vma dot; - lang_statement_union_type *s; - const reloc_deps_graph *deps ATTRIBUTE_UNUSED; - bfd_boolean lit_align; +static bfd_vma +ld_assign_relative_paged_dot (bfd_vma dot, + lang_statement_union_type *s, + const reloc_deps_graph *deps ATTRIBUTE_UNUSED, + bfd_boolean lit_align) { /* Walk through all of the input statements in this wild statement assign dot to all of them. */ - + xtensa_ld_iter_stack *stack = NULL; xtensa_ld_iter_stack **stack_p = &stack; @@ -1346,18 +1235,18 @@ ld_assign_relative_paged_dot (dot, s, deps, lit_align) for (iter_stack_create (stack_p, s); !iter_stack_empty (stack_p); - iter_stack_next (stack_p)) + iter_stack_next (stack_p)) { lang_statement_union_type *l = iter_stack_current (stack_p); - - switch (l->header.type) + + switch (l->header.type) { case lang_input_section_enum: { asection *section = l->input_section.section; size_t align_pow = section->alignment_power; bfd_boolean do_xtensa_alignment = FALSE; - + if (lit_align) { bfd_boolean sec_is_target = section_is_target (deps, l); @@ -1371,7 +1260,7 @@ ld_assign_relative_paged_dot (dot, s, deps, lit_align) do_xtensa_alignment = TRUE; } first_section = FALSE; - if (section->_raw_size != 0) + if (section->_raw_size != 0) in_literals = (sec_is_target && !sec_is_source); } @@ -1397,18 +1286,17 @@ ld_assign_relative_paged_dot (dot, s, deps, lit_align) } -bfd_boolean -ld_local_file_relocations_fit (statement, deps) - lang_statement_union_type *statement; - const reloc_deps_graph *deps ATTRIBUTE_UNUSED; +static bfd_boolean +ld_local_file_relocations_fit (lang_statement_union_type *statement, + const reloc_deps_graph *deps ATTRIBUTE_UNUSED) { /* Walk over all of the dependencies that we identified and make sure that IF the source and target are here (addr != 0): 1) target addr < source addr - 2) (roundup(source + source_size, 4) - rounddown(target, 4)) + 2) (roundup(source + source_size, 4) - rounddown(target, 4)) < (256K - (1 << bad align)) Need a worst-case proof.... */ - + xtensa_ld_iter_stack *stack = NULL; xtensa_ld_iter_stack **stack_p = &stack; size_t max_align_power = 0; @@ -1419,10 +1307,10 @@ ld_local_file_relocations_fit (statement, deps) /* Find the worst-case alignment requirement for this set of statements. */ for (iter_stack_create (stack_p, statement); !iter_stack_empty (stack_p); - iter_stack_next (stack_p)) + iter_stack_next (stack_p)) { lang_statement_union_type *l = iter_stack_current (stack_p); - if (l->header.type == lang_input_section_enum) + if (l->header.type == lang_input_section_enum) { lang_input_section_type *input = &l->input_section; asection *section = input->section; @@ -1435,21 +1323,21 @@ ld_local_file_relocations_fit (statement, deps) for (i = 0; i < deps->count; i++) { asection *sec = deps->sections[i]; - const reloc_deps_section *deps_section = + const reloc_deps_section *deps_section = xtensa_get_section_deps (deps, sec); if (deps_section) { /* We choose to walk through the successors. */ for (e = deps_section->succs; e != NULL; e = e->next) { - if ((e->src != e->tgt) + if (e->src != e->tgt && e->src->output_section == e->tgt->output_section && e->src->output_offset != 0 && e->tgt->output_offset != 0) { - bfd_vma l32r_addr = + bfd_vma l32r_addr = align_power (e->src->output_offset + e->src->_raw_size, 2); - bfd_vma target_addr = e->tgt->output_offset & (~3); + bfd_vma target_addr = e->tgt->output_offset & ~3; if (l32r_addr < target_addr) { fprintf (stderr, "Warning: " @@ -1457,7 +1345,7 @@ ld_local_file_relocations_fit (statement, deps) return FALSE; } - if ((l32r_addr - target_addr) > (256*1024 - align_penalty)) + if (l32r_addr - target_addr > 256 * 1024 - align_penalty) return FALSE; } } @@ -1468,35 +1356,34 @@ ld_local_file_relocations_fit (statement, deps) } -bfd_vma -ld_xtensa_insert_page_offsets (dot, s, deps, lit_align) - bfd_vma dot; - lang_statement_union_type *s; - reloc_deps_graph *deps; - bfd_boolean lit_align; +static bfd_vma +ld_xtensa_insert_page_offsets (bfd_vma dot, + lang_statement_union_type *s, + reloc_deps_graph *deps, + bfd_boolean lit_align) { xtensa_ld_iter_stack *stack = NULL; xtensa_ld_iter_stack **stack_p = &stack; bfd_boolean first_section = FALSE; bfd_boolean in_literals = FALSE; - + if (!lit_align) return FALSE; for (iter_stack_create (stack_p, s); !iter_stack_empty (stack_p); - iter_stack_next (stack_p)) + iter_stack_next (stack_p)) { lang_statement_union_type *l = iter_stack_current (stack_p); - switch (l->header.type) - { + switch (l->header.type) + { case lang_input_section_enum: { asection *section = l->input_section.section; bfd_boolean do_xtensa_alignment = FALSE; - + if (lit_align) { if (section->_raw_size != 0 @@ -1507,7 +1394,7 @@ ld_xtensa_insert_page_offsets (dot, s, deps, lit_align) do_xtensa_alignment = TRUE; } first_section = FALSE; - if (section->_raw_size != 0) + if (section->_raw_size != 0) { in_literals = (section_is_target (deps, l) && !section_is_source (deps, l)); @@ -1527,7 +1414,7 @@ ld_xtensa_insert_page_offsets (dot, s, deps, lit_align) lang_statement_union_type *assign_union; lang_statement_list_type tmplist; lang_statement_list_type *old_stat_ptr = stat_ptr; - + /* There is hidden state in "lang_add_assignment". It appends the new assignment statement to the stat_ptr list. Thus, we swap it before and after the call. */ @@ -1544,12 +1431,12 @@ ld_xtensa_insert_page_offsets (dot, s, deps, lit_align) assign_union->header.next = l; *(*stack_p)->iterloc.loc = assign_union; iter_stack_next (stack_p); - } - } - break; - default: - break; - } + } + } + break; + default: + break; + } } return dot; } |