diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-11-02 20:45:59 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-11-02 20:45:59 +0000 |
commit | 56301d46413bee335c617ed8e6e32080e4ffaba7 (patch) | |
tree | 6a4c4eeffd92f1d9f6394e2d5fa08301fa0b79b1 /gnu/usr.bin/binutils/ld/emultempl | |
parent | 21ca5604689b35171671ce1ed04c5faccc82e0cd (diff) |
Merge conflicts, bringing our changes back in:
- extra $(SHELL) and sugar for make (so that files not mode +x still work)
- safer temp file handling
- our W^X binary layout changes in ld
- OpenBSD policy for library file selection in ld
- arm and m88k changes which were not merged in time for official 2.15
- bfd core file handling
- a couple typos
New for 2.15:
- ld(1) and as(1) manpages now generated at build time
- binutils/stabs.c reverted to use our in-tree libiberty for now
- we still use our VIA C3 crypto code over stock binutils, as it recognizes
more instructions
- new emulations for OpenBSD on mips64 machines, to help OpenBSD/sgi
- relaxed %f# handling in gas on OpenBSD/sparc64 (same as was in 2.14)
Tested on all platforms by various people; special thanks to sturm@ and
otto@.
Diffstat (limited to 'gnu/usr.bin/binutils/ld/emultempl')
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/aix.em | 128 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/elf32.em | 359 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/generic.em | 26 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/gld960.em | 34 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/gld960c.em | 38 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/hppaelf.em | 62 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/linux.em | 50 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/lnk960.em | 74 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/mipsecoff.em | 56 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/pe.em | 251 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/sunos.em | 111 | ||||
-rw-r--r-- | gnu/usr.bin/binutils/ld/emultempl/vanilla.em | 14 |
12 files changed, 495 insertions, 708 deletions
diff --git a/gnu/usr.bin/binutils/ld/emultempl/aix.em b/gnu/usr.bin/binutils/ld/emultempl/aix.em index 910f831b897..513cd50d859 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/aix.em +++ b/gnu/usr.bin/binutils/ld/emultempl/aix.em @@ -9,7 +9,7 @@ cat >e${EMULATION_NAME}.c <<EOF /* This file is is generated by a shell script. DO NOT EDIT! */ /* AIX emulation code for ${EMULATION_NAME} - Copyright 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003 + Copyright 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Steve Chamberlain <sac@cygnus.com> AIX support by Ian Lance Taylor <ian@cygnus.com> @@ -56,40 +56,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "libcoff.h" #include "libxcoff.h" -static void gld${EMULATION_NAME}_before_parse - PARAMS ((void)); -static bfd_boolean gld${EMULATION_NAME}_parse_args - PARAMS ((int, char **)); -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}_after_open - PARAMS ((void)); -static char *gld${EMULATION_NAME}_choose_target - PARAMS ((int, char **)); -static void gld${EMULATION_NAME}_before_allocation - PARAMS ((void)); -static void gld${EMULATION_NAME}_read_file - PARAMS ((const char *, bfd_boolean)); -static void gld${EMULATION_NAME}_free - PARAMS ((PTR)); -static void gld${EMULATION_NAME}_find_relocs - PARAMS ((lang_statement_union_type *)); -static void gld${EMULATION_NAME}_find_exp_assignment - PARAMS ((etree_type *)); -static char *gld${EMULATION_NAME}_get_script - PARAMS ((int *isfile)); -static bfd_boolean gld${EMULATION_NAME}_unrecognized_file - PARAMS ((lang_input_statement_type *)); -static void gld${EMULATION_NAME}_create_output_section_statements - PARAMS ((void)); -static void gld${EMULATION_NAME}_set_output_arch - PARAMS ((void)); -static int is_syscall - PARAMS ((char *, unsigned int *)); -static int change_symbol_mode - PARAMS ((char *)); +static void gld${EMULATION_NAME}_read_file (const char *, bfd_boolean); +static void gld${EMULATION_NAME}_free (void *); +static void gld${EMULATION_NAME}_find_relocs (lang_statement_union_type *); +static void gld${EMULATION_NAME}_find_exp_assignment (etree_type *); + /* The file alignment required for each section. */ static unsigned long file_align; @@ -160,17 +131,9 @@ static char *command_line_blibpath = NULL; /* This routine is called before anything else is done. */ 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_`echo ${ARCH} | sed -e 's/:.*//'`; + ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`); config.has_shared = TRUE; @@ -210,13 +173,9 @@ enum }; static void -gld${EMULATION_NAME}_add_options (ns, shortopts, nl, longopts, nrl, really_longopts) - int ns; - char **shortopts; - int nl; - struct option **longopts; - int nrl ATTRIBUTE_UNUSED; - struct option **really_longopts ATTRIBUTE_UNUSED; +gld${EMULATION_NAME}_add_options + (int ns, char **shortopts, int nl, struct option **longopts, + int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED) { static const char xtra_short[] = "D:H:KT:z"; static const struct option xtra_long[] = { @@ -291,15 +250,13 @@ gld${EMULATION_NAME}_add_options (ns, shortopts, nl, longopts, nrl, really_longo *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short)); memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short)); - *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 bfd_boolean -gld${EMULATION_NAME}_parse_args (argc, argv) - int argc; - char **argv; +gld${EMULATION_NAME}_parse_args (int argc, char **argv) { int indx; @@ -327,8 +284,7 @@ gld${EMULATION_NAME}_parse_args (argc, argv) } static bfd_boolean -gld${EMULATION_NAME}_handle_option (optc) - int optc; +gld${EMULATION_NAME}_handle_option (int optc) { bfd_signed_vma val; const char *end; @@ -570,8 +526,7 @@ gld${EMULATION_NAME}_handle_option (optc) as an import file. This is for AIX compatibility. */ static bfd_boolean -gld${EMULATION_NAME}_unrecognized_file (entry) - lang_input_statement_type *entry; +gld${EMULATION_NAME}_unrecognized_file (lang_input_statement_type *entry) { FILE *e; bfd_boolean ret; @@ -607,21 +562,21 @@ gld${EMULATION_NAME}_unrecognized_file (entry) /* This is called after the input files have been opened. */ static void -gld${EMULATION_NAME}_after_open () +gld${EMULATION_NAME}_after_open (void) { bfd_boolean r; struct set_info *p; /* Call ldctor_build_sets, after pretending that this is a - relocateable link. We do this because AIX requires relocation + relocatable link. We do this because AIX requires relocation entries for all references to symbols, even in a final executable. Of course, we only want to do this if we are producing an XCOFF output file. */ - r = link_info.relocateable; + r = link_info.relocatable; if (strstr (bfd_get_target (output_bfd), "xcoff") != NULL) - link_info.relocateable = TRUE; + link_info.relocatable = TRUE; ldctor_build_sets (); - link_info.relocateable = r; + link_info.relocatable = r; /* For each set, record the size, so that the XCOFF backend can output the correct csect length. */ @@ -652,7 +607,7 @@ gld${EMULATION_NAME}_after_open () sections, but before any sizes or addresses have been set. */ static void -gld${EMULATION_NAME}_before_allocation () +gld${EMULATION_NAME}_before_allocation (void) { struct filelist *fl; struct export_symbol_list *el; @@ -834,9 +789,7 @@ gld${EMULATION_NAME}_before_allocation () } static char * -gld${EMULATION_NAME}_choose_target (argc, argv) - int argc; - char **argv; +gld${EMULATION_NAME}_choose_target (int argc, char **argv) { int i, j, jmax; static char *from_outside; @@ -871,8 +824,7 @@ gld${EMULATION_NAME}_choose_target (argc, argv) 1 : state changed 0 : no change */ static int -change_symbol_mode (input) - char *input; +change_symbol_mode (char *input) { char *symbol_mode_string[] = { "# 32", /* 0x01 */ @@ -906,9 +858,7 @@ change_symbol_mode (input) 0 : ignore -1 : error, try something else */ static int -is_syscall (input, flag) - char *input; - unsigned int *flag; +is_syscall (char *input, unsigned int *flag) { unsigned int bit; char *string; @@ -958,9 +908,7 @@ is_syscall (input, flag) this is called by the handle_option emulation routine. */ static void -gld${EMULATION_NAME}_read_file (filename, import) - const char *filename; - bfd_boolean import; +gld${EMULATION_NAME}_read_file (const char *filename, bfd_boolean import) { struct obstack *o; FILE *f; @@ -1201,8 +1149,7 @@ gld${EMULATION_NAME}_read_file (filename, import) /* This routine saves us from worrying about declaring free. */ static void -gld${EMULATION_NAME}_free (p) - PTR p; +gld${EMULATION_NAME}_free (void *p) { free (p); } @@ -1212,8 +1159,7 @@ gld${EMULATION_NAME}_free (p) to symbols. */ static void -gld${EMULATION_NAME}_find_relocs (s) - lang_statement_union_type *s; +gld${EMULATION_NAME}_find_relocs (lang_statement_union_type *s) { if (s->header.type == lang_reloc_statement_enum) { @@ -1233,8 +1179,7 @@ gld${EMULATION_NAME}_find_relocs (s) /* Look through an expression for an assignment statement. */ static void -gld${EMULATION_NAME}_find_exp_assignment (exp) - etree_type *exp; +gld${EMULATION_NAME}_find_exp_assignment (etree_type *exp) { struct bfd_link_hash_entry *h; @@ -1278,8 +1223,7 @@ gld${EMULATION_NAME}_find_exp_assignment (exp) } static char * -gld${EMULATION_NAME}_get_script (isfile) - int *isfile; +gld${EMULATION_NAME}_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -1293,11 +1237,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 @@ -1314,9 +1258,9 @@ 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"; @@ -1332,7 +1276,7 @@ fi cat >>e${EMULATION_NAME}.c <<EOF static void -gld${EMULATION_NAME}_create_output_section_statements () +gld${EMULATION_NAME}_create_output_section_statements (void) { /* __rtinit */ if ((bfd_get_flavour (output_bfd) == bfd_target_xcoff_flavour) @@ -1371,7 +1315,7 @@ gld${EMULATION_NAME}_create_output_section_statements () } static void -gld${EMULATION_NAME}_set_output_arch () +gld${EMULATION_NAME}_set_output_arch (void) { bfd_set_arch_mach (output_bfd, bfd_xcoff_architecture (output_bfd), diff --git a/gnu/usr.bin/binutils/ld/emultempl/elf32.em b/gnu/usr.bin/binutils/ld/emultempl/elf32.em index da553983441..b3e4639f072 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/elf32.em +++ b/gnu/usr.bin/binutils/ld/emultempl/elf32.em @@ -13,7 +13,7 @@ cat >e${EMULATION_NAME}.c <<EOF /* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME} Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003 Free Software Foundation, Inc. + 2002, 2003, 2004 Free Software Foundation, Inc. Written by Steve Chamberlain <sac@cygnus.com> ELF support by Ian Lance Taylor <ian@cygnus.com> @@ -53,38 +53,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <ldgram.h> #include "elf/common.h" -static void gld${EMULATION_NAME}_before_parse - PARAMS ((void)); -static void gld${EMULATION_NAME}_vercheck - PARAMS ((lang_input_statement_type *)); -static void gld${EMULATION_NAME}_stat_needed - PARAMS ((lang_input_statement_type *)); -static bfd_boolean gld${EMULATION_NAME}_try_needed - PARAMS ((const char *, int)); -static bfd_boolean gld${EMULATION_NAME}_search_needed - PARAMS ((const char *, const char *, int)); -static void gld${EMULATION_NAME}_check_needed - PARAMS ((lang_input_statement_type *)); -static void gld${EMULATION_NAME}_after_open - PARAMS ((void)); -static void gld${EMULATION_NAME}_find_exp_assignment - PARAMS ((etree_type *)); -static void gld${EMULATION_NAME}_find_statement_assignment - PARAMS ((lang_statement_union_type *)); -static void gld${EMULATION_NAME}_before_allocation - PARAMS ((void)); -static bfd_boolean gld${EMULATION_NAME}_open_dynamic_archive - PARAMS ((const char *, search_dirs_type *, lang_input_statement_type *)); -static lang_output_section_statement_type *output_rel_find - PARAMS ((asection *)); -static asection *output_prev_sec_find - PARAMS ((lang_output_section_statement_type *)); +/* Declare functions used by various EXTRA_EM_FILEs. */ +static void gld${EMULATION_NAME}_before_parse (void); +static void gld${EMULATION_NAME}_after_open (void); +static void gld${EMULATION_NAME}_before_allocation (void); static bfd_boolean gld${EMULATION_NAME}_place_orphan - PARAMS ((lang_input_statement_type *, asection *)); -static void gld${EMULATION_NAME}_finish - PARAMS ((void)); -static char *gld${EMULATION_NAME}_get_script - PARAMS ((int *isfile)); + (lang_input_statement_type *file, asection *s); +static void gld${EMULATION_NAME}_finish (void); EOF case ${target} in @@ -335,17 +310,9 @@ if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then cat >>e${EMULATION_NAME}.c <<EOF 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_`echo ${ARCH} | sed -e 's/:.*//'`; + ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`); config.dynamic_link = ${DYNAMIC_LINK-TRUE}; config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`; } @@ -353,6 +320,28 @@ gld${EMULATION_NAME}_before_parse () EOF fi +if test x"$LDEMUL_RECOGNIZED_FILE" != xgld"${EMULATION_NAME}"_load_symbols; then +cat >>e${EMULATION_NAME}.c <<EOF +/* Handle as_needed DT_NEEDED. */ + +static bfd_boolean +gld${EMULATION_NAME}_load_symbols (lang_input_statement_type *entry) +{ + if (!entry->as_needed + || (bfd_get_file_flags (entry->the_bfd) & DYNAMIC) == 0) + return FALSE; + + /* Tell the ELF linker that we don't want the output file to have a + DT_NEEDED entry for this file, unless it is used to resolve + references in a regular object. */ + bfd_elf_set_dyn_lib_class (entry->the_bfd, DYN_AS_NEEDED); + + /* Continue on with normal load_symbols processing. */ + return FALSE; +} +EOF +fi + cat >>e${EMULATION_NAME}.c <<EOF /* These variables are required to pass information back and forth @@ -383,8 +372,7 @@ static bfd_boolean global_vercheck_failed; a conflicting version. */ static void -gld${EMULATION_NAME}_vercheck (s) - lang_input_statement_type *s; +gld${EMULATION_NAME}_vercheck (lang_input_statement_type *s) { const char *soname; struct bfd_link_needed_list *l; @@ -421,10 +409,10 @@ gld${EMULATION_NAME}_vercheck (s) if (strncmp (soname, l->name, suffix - l->name) == 0) { /* Here we know that S is a dynamic object FOO.SO.VER1, and - the object we are considering needs a dynamic object - FOO.SO.VER2, and VER1 and VER2 are different. This - appears to be a version mismatch, so we tell the caller - to try a different version of this library. */ + the object we are considering needs a dynamic object + FOO.SO.VER2, and VER1 and VER2 are different. This + appears to be a version mismatch, so we tell the caller + to try a different version of this library. */ global_vercheck_failed = TRUE; return; } @@ -436,8 +424,7 @@ gld${EMULATION_NAME}_vercheck (s) the file. */ static void -gld${EMULATION_NAME}_stat_needed (s) - lang_input_statement_type *s; +gld${EMULATION_NAME}_stat_needed (lang_input_statement_type *s) { struct stat st; const char *suffix; @@ -492,9 +479,7 @@ gld${EMULATION_NAME}_stat_needed (s) to skip the check for a conflicting version. */ static bfd_boolean -gld${EMULATION_NAME}_try_needed (name, force) - const char *name; - int force; +gld${EMULATION_NAME}_try_needed (const char *name, int force) { bfd *abfd; char *soname; @@ -541,16 +526,16 @@ gld${EMULATION_NAME}_try_needed (name, force) { bfd_close (abfd); /* Return FALSE to force the caller to move on to try - another file on the search path. */ + another file on the search path. */ return FALSE; } /* But wait! It gets much worse. On Linux, if a shared - library does not use libc at all, we are supposed to skip - it the first time around in case we encounter a shared - library later on with the same name which does use the - version of libc that we want. This is much too horrible - to use on any system other than Linux. */ + library does not use libc at all, we are supposed to skip + it the first time around in case we encounter a shared + library later on with the same name which does use the + version of libc that we want. This is much too horrible + to use on any system other than Linux. */ EOF case ${target} in @@ -600,19 +585,18 @@ cat >>e${EMULATION_NAME}.c <<EOF if (global_found) { /* Return TRUE to indicate that we found the file, even though - we aren't going to do anything with it. */ - free(soname); + we aren't going to do anything with it. */ + free (soname); return TRUE; } - /* Tell the ELF backend that we don't want the output file to have a - DT_NEEDED entry for this file. */ - bfd_elf_set_dt_needed_name (abfd, ""); + /* Specify the soname to use. */ + bfd_elf_set_dt_needed_name (abfd, soname); - /* Tell the ELF backend that the output file needs a DT_NEEDED - entry for this file if it is used to resolve the reference in - a regular object. */ - bfd_elf_set_dt_needed_soname (abfd, soname); + /* Tell the ELF linker that we don't want the output file to have a + DT_NEEDED entry for this file, unless it is used to resolve + references in a regular object. */ + bfd_elf_set_dyn_lib_class (abfd, DYN_DT_NEEDED); /* Add this file into the symbol table. */ if (! bfd_link_add_symbols (abfd, &link_info)) @@ -625,10 +609,7 @@ cat >>e${EMULATION_NAME}.c <<EOF /* Search for a needed file in a path. */ static bfd_boolean -gld${EMULATION_NAME}_search_needed (path, name, force) - const char *path; - const char *name; - int force; +gld${EMULATION_NAME}_search_needed (const char *path, const char *name, int force) { const char *s; size_t len; @@ -696,11 +677,8 @@ if [ "x${USE_LIBPATH}" = xyes ] ; then /* Add the sysroot to every entry in a colon-separated path. */ -static char * gld${EMULATION_NAME}_add_sysroot PARAMS ((const char *)); - static char * -gld${EMULATION_NAME}_add_sysroot (path) - const char *path; +gld${EMULATION_NAME}_add_sysroot (const char *path) { int len, colons, i; char *ret, *p; @@ -723,7 +701,7 @@ gld${EMULATION_NAME}_add_sysroot (path) while (path[i]) if (path[i] == ':') { - *p++ = path[i++]; + *p++ = path[i++]; strcpy (p, ld_sysroot); p = p + strlen (p); } @@ -742,13 +720,8 @@ EOF in which we may find shared libraries. /etc/ld.so.conf is really only meaningful on Linux. */ -static bfd_boolean gld${EMULATION_NAME}_check_ld_so_conf - PARAMS ((const char *, int)); - static bfd_boolean -gld${EMULATION_NAME}_check_ld_so_conf (name, force) - const char *name; - int force; +gld${EMULATION_NAME}_check_ld_so_conf (const char *name, int force) { static bfd_boolean initialized; static char *ld_so_conf; @@ -839,8 +812,7 @@ cat >>e${EMULATION_NAME}.c <<EOF /* See if an input file matches a DT_NEEDED entry by name. */ static void -gld${EMULATION_NAME}_check_needed (s) - lang_input_statement_type *s; +gld${EMULATION_NAME}_check_needed (lang_input_statement_type *s) { if (global_found) return; @@ -889,12 +861,12 @@ cat >>e${EMULATION_NAME}.c <<EOF /* This is called after all the input files have been opened. */ static void -gld${EMULATION_NAME}_after_open () +gld${EMULATION_NAME}_after_open (void) { struct bfd_link_needed_list *needed, *l; /* We only need to worry about this when doing a final link. */ - if (link_info.relocateable || link_info.shared) + if (link_info.relocatable || !link_info.executable) return; /* Get the list of files which appear in DT_NEEDED entries in @@ -935,7 +907,7 @@ gld${EMULATION_NAME}_after_open () rpath_link, rpath, then the environment variable LD_LIBRARY_PATH (native only), then the DT_RPATH/DT_RUNPATH entries (native only), then the linker script LIB_SEARCH_DIRS. - We look at the -L arguments to build search path. + We look at the -L arguments to build the search path. We search twice. The first time, we skip objects which may introduce version mismatches. The second time, we force @@ -967,7 +939,7 @@ EOF fi if [ "x${NATIVE}" = xyes ] ; then cat >>e${EMULATION_NAME}.c <<EOF - if (getenv("LD_RUN_PATH") != NULL + if (getenv ("LD_RUN_PATH") != NULL && command_line.rpath_link == NULL && command_line.rpath == NULL) { @@ -977,29 +949,29 @@ cat >>e${EMULATION_NAME}.c <<EOF break; } - len = strlen(search_head->name); - lib_path = xstrdup(search_head->name); - for (search = search_head->next; search != NULL; - search = search->next) - { - size_t nlen; - - nlen = strlen(search->name); - lib_path = xrealloc(lib_path, len + nlen + 2); - lib_path[len] = ':'; - strcpy(lib_path + len + 1, search->name); - len += nlen + 1; - } + len = strlen(search_head->name); + lib_path = xstrdup(search_head->name); + for (search = search_head->next; search != NULL; + search = search->next) + { + size_t nlen; - if (gld${EMULATION_NAME}_search_needed (lib_path, l->name, force)) - { - free(lib_path); - break; - } - free(lib_path); + nlen = strlen(search->name); + lib_path = xrealloc(lib_path, len + nlen + 2); + lib_path[len] = ':'; + strcpy(lib_path + len + 1, search->name); + len += nlen + 1; + } - lib_path = getenv ("LD_LIBRARY_PATH"); if (gld${EMULATION_NAME}_search_needed (lib_path, l->name, force)) + { + free(lib_path); + break; + } + free(lib_path); + + lib_path = getenv ("LD_LIBRARY_PATH"); + if (gld${EMULATION_NAME}_search_needed (lib_path, l->name, force)) break; EOF fi @@ -1068,8 +1040,7 @@ cat >>e${EMULATION_NAME}.c <<EOF /* Look through an expression for an assignment statement. */ static void -gld${EMULATION_NAME}_find_exp_assignment (exp) - etree_type *exp; +gld${EMULATION_NAME}_find_exp_assignment (etree_type *exp) { struct bfd_link_hash_entry *h; @@ -1093,7 +1064,7 @@ gld${EMULATION_NAME}_find_exp_assignment (exp) case etree_assign: if (strcmp (exp->assign.dst, ".") != 0) { - if (! (bfd_elf${ELFSIZE}_record_link_assignment + if (! (bfd_elf_record_link_assignment (output_bfd, &link_info, exp->assign.dst, exp->type.node_class == etree_provide ? TRUE : FALSE))) einfo ("%P%F: failed to record assignment to %s: %E\n", @@ -1129,8 +1100,7 @@ gld${EMULATION_NAME}_find_exp_assignment (exp) symbols which are referred to by dynamic objects. */ static void -gld${EMULATION_NAME}_find_statement_assignment (s) - lang_statement_union_type *s; +gld${EMULATION_NAME}_find_statement_assignment (lang_statement_union_type *s) { if (s->header.type == lang_assignment_statement_enum) gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp); @@ -1157,11 +1127,14 @@ cat >>e${EMULATION_NAME}.c <<EOF sections, but before any sizes or addresses have been set. */ static void -gld${EMULATION_NAME}_before_allocation () +gld${EMULATION_NAME}_before_allocation (void) { const char *rpath; asection *sinterp; + if (link_info.hash->type == bfd_link_elf_hash_table) + _bfd_elf_tls_setup (output_bfd, &link_info); + /* If we are going to make any variable assignments, we need to let the ELF backend know about them in case the variables are referred to by dynamic objects. */ @@ -1172,8 +1145,8 @@ gld${EMULATION_NAME}_before_allocation () rpath = command_line.rpath; if (rpath == NULL) rpath = (const char *) getenv ("LD_RUN_PATH"); - if (! (bfd_elf${ELFSIZE}_size_dynamic_sections - (output_bfd, command_line.soname, rpath, + if (! (bfd_elf_size_dynamic_sections + (output_bfd, command_line.soname, rpath, command_line.filter_shlib, (const char * const *) command_line.auxiliary_filters, &link_info, &sinterp, lang_elf_version_info))) @@ -1197,8 +1170,10 @@ ${ELF_INTERPRETER_SET_DEFAULT} { asection *s; bfd_size_type sz; + bfd_size_type prefix_len; char *msg; bfd_boolean ret; + const char * gnu_warning_prefix = _("warning: "); if (is->just_syms_flag) continue; @@ -1208,11 +1183,14 @@ ${ELF_INTERPRETER_SET_DEFAULT} continue; sz = bfd_section_size (is->the_bfd, s); - msg = xmalloc ((size_t) sz + 1); - if (! bfd_get_section_contents (is->the_bfd, s, msg, (file_ptr) 0, sz)) + prefix_len = strlen (gnu_warning_prefix); + msg = xmalloc ((size_t) (prefix_len + sz + 1)); + strcpy (msg, gnu_warning_prefix); + if (! bfd_get_section_contents (is->the_bfd, s, msg + prefix_len, + (file_ptr) 0, sz)) einfo ("%F%B: Can't read contents of section .gnu.warning: %E\n", is->the_bfd); - msg[sz] = '\0'; + msg[prefix_len + sz] = '\0'; ret = link_info.callbacks->warning (&link_info, msg, (const char *) NULL, is->the_bfd, (asection *) NULL, @@ -1238,10 +1216,8 @@ cat >>e${EMULATION_NAME}.c <<EOF like hpux). */ static bfd_boolean -gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry) - const char *arch; - search_dirs_type *search; - lang_input_statement_type *entry; +gld${EMULATION_NAME}_open_dynamic_archive + (const char *arch, search_dirs_type *search, lang_input_statement_type *entry) { const char *filename; char *string; @@ -1331,12 +1307,12 @@ cat >>e${EMULATION_NAME}.c <<EOF /* A variant of lang_output_section_find. Used by place_orphan. */ static lang_output_section_statement_type * -output_rel_find (sec) - asection *sec; +output_rel_find (asection *sec, int isdyn) { lang_statement_union_type *u; lang_output_section_statement_type *lookup; lang_output_section_statement_type *last = NULL; + lang_output_section_statement_type *last_alloc = NULL; lang_output_section_statement_type *last_rel = NULL; lang_output_section_statement_type *last_rel_alloc = NULL; int rela = sec->name[4] == 'a'; @@ -1346,22 +1322,30 @@ output_rel_find (sec) lookup = &u->output_section_statement; if (strncmp (".rel", lookup->name, 4) == 0) { - /* Don't place after .rel.plt as doing so results in wrong - dynamic tags. Also, place allocated reloc sections before - non-allocated. */ int lookrela = lookup->name[4] == 'a'; - if (strcmp (".plt", lookup->name + 4 + lookrela) == 0 - || (lookup->bfd_section != NULL - && (lookup->bfd_section->flags & SEC_ALLOC) == 0)) + /* .rel.dyn must come before all other reloc sections, to suit + GNU ld.so. */ + if (isdyn) + break; + + /* Don't place after .rel.plt as doing so results in wrong + dynamic tags. */ + if (strcmp (".plt", lookup->name + 4 + lookrela) == 0) break; - last = lookup; - if (rela == lookrela) + + if (rela == lookrela || last_rel == NULL) last_rel = lookup; - if (lookup->bfd_section != NULL + if ((rela == lookrela || last_rel_alloc == NULL) + && lookup->bfd_section != NULL && (lookup->bfd_section->flags & SEC_ALLOC) != 0) last_rel_alloc = lookup; } + + last = lookup; + if (lookup->bfd_section != NULL + && (lookup->bfd_section->flags & SEC_ALLOC) != 0) + last_alloc = lookup; } if (last_rel_alloc) @@ -1370,6 +1354,9 @@ output_rel_find (sec) if (last_rel) return last_rel; + if (last_alloc) + return last_alloc; + return last; } @@ -1377,8 +1364,7 @@ output_rel_find (sec) 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; lang_statement_union_type *u; @@ -1410,9 +1396,7 @@ struct orphan_save { }; 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) { static struct orphan_save hold_text; static struct orphan_save hold_rodata; @@ -1434,7 +1418,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) int isdyn = 0; secname = bfd_get_section_name (s->owner, s); - if (! link_info.relocateable + if (! link_info.relocatable && link_info.combreloc && (s->flags & SEC_ALLOC) && strncmp (secname, ".rel", 4) == 0) @@ -1468,8 +1452,8 @@ gld${EMULATION_NAME}_place_orphan (file, s) /* If this is a final link, then always put .gnu.warning.SYMBOL sections into the .text section to get them out of the way. */ - if (! link_info.shared - && ! link_info.relocateable + if (link_info.executable + && ! link_info.relocatable && strncmp (secname, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0 && hold_text.os != NULL) { @@ -1485,7 +1469,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) #define HAVE_SECTION(hold, name) \ (hold.os != NULL || (hold.os = lang_output_section_find (name)) != NULL) - if ((s->flags & SEC_EXCLUDE) != 0 && !link_info.relocateable) + if ((s->flags & SEC_EXCLUDE) != 0 && !link_info.relocatable) { if (s->output_section == NULL) s->output_section = bfd_abs_section_ptr; @@ -1511,7 +1495,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) else if (strncmp (secname, ".rel", 4) == 0 && (s->flags & SEC_LOAD) != 0 && (hold_rel.os != NULL - || (hold_rel.os = output_rel_find (s)) != NULL)) + || (hold_rel.os = output_rel_find (s, isdyn)) != NULL)) place = &hold_rel; else if ((s->flags & (SEC_CODE | SEC_READONLY)) == SEC_READONLY && HAVE_SECTION (hold_rodata, ".rodata")) @@ -1566,7 +1550,7 @@ gld${EMULATION_NAME}_place_orphan (file, s) } address = NULL; - if (link_info.relocateable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0) + if (link_info.relocatable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0) address = exp_intop ((bfd_vma) 0); load_base = NULL; @@ -1581,7 +1565,6 @@ gld${EMULATION_NAME}_place_orphan (file, s) os_tail = lang_output_section_statement.tail; os = lang_enter_output_section_statement (secname, address, 0, - (bfd_vma) 0, (etree_type *) NULL, (etree_type *) NULL, load_base); @@ -1710,9 +1693,9 @@ if test x"$LDEMUL_FINISH" != xgld"$EMULATION_NAME"_finish; then cat >>e${EMULATION_NAME}.c <<EOF static void -gld${EMULATION_NAME}_finish () +gld${EMULATION_NAME}_finish (void) { - if (bfd_elf${ELFSIZE}_discard_info (output_bfd, &link_info)) + if (bfd_elf_discard_info (output_bfd, &link_info)) { lang_reset_memory_regions (); @@ -1735,8 +1718,7 @@ if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then cat >>e${EMULATION_NAME}.c <<EOF static char * -gld${EMULATION_NAME}_get_script (isfile) - int *isfile; +gld${EMULATION_NAME}_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -1750,11 +1732,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 @@ -1762,6 +1744,14 @@ if cmp -s ldscripts/${EMULATION_NAME}.x ldscripts/${EMULATION_NAME}.xn; then : ; echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c fi +if test -n "$GENERATE_PIE_SCRIPT" ; then +if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then +echo ' ; else if (link_info.pie && link_info.combreloc) return' >> e${EMULATION_NAME}.c +sed $sc ldscripts/${EMULATION_NAME}.xdc >> e${EMULATION_NAME}.c +fi +echo ' ; else if (link_info.pie) return' >> e${EMULATION_NAME}.c +sed $sc ldscripts/${EMULATION_NAME}.xd >> e${EMULATION_NAME}.c +fi if test -n "$GENERATE_SHLIB_SCRIPT" ; then if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then echo ' ; else if (link_info.shared && link_info.combreloc) return' >> e${EMULATION_NAME}.c @@ -1787,9 +1777,9 @@ 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"; @@ -1801,6 +1791,18 @@ cat >>e${EMULATION_NAME}.c <<EOF return "ldscripts/${EMULATION_NAME}.xn"; EOF fi +if test -n "$GENERATE_PIE_SCRIPT" ; then +if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then +cat >>e${EMULATION_NAME}.c <<EOF + else if (link_info.pie && link_info.combreloc) + return "ldscripts/${EMULATION_NAME}.xdc"; +EOF +fi +cat >>e${EMULATION_NAME}.c <<EOF + else if (link_info.pie) + return "ldscripts/${EMULATION_NAME}.xd"; +EOF +fi if test -n "$GENERATE_SHLIB_SCRIPT" ; then if test -n "$GENERATE_COMBRELOC_SCRIPT" ; then cat >>e${EMULATION_NAME}.c <<EOF @@ -1847,17 +1849,10 @@ cat >>e${EMULATION_NAME}.c <<EOF #define OPTION_GROUP (OPTION_ENABLE_NEW_DTAGS + 1) #define OPTION_EH_FRAME_HDR (OPTION_GROUP + 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; - char **shortopts; - int nl; - struct option **longopts; - int nrl ATTRIBUTE_UNUSED; - struct option **really_longopts ATTRIBUTE_UNUSED; +gld${EMULATION_NAME}_add_options + (int ns, char **shortopts, int nl, struct option **longopts, + int nrl ATTRIBUTE_UNUSED, struct option **really_longopts ATTRIBUTE_UNUSED) { static const char xtra_short[] = "${PARSE_AND_LIST_SHORTOPTS}z:"; static const struct option xtra_long[] = { @@ -1889,12 +1884,8 @@ cat >>e${EMULATION_NAME}.c <<EOF memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long)); } -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) { @@ -1920,7 +1911,8 @@ cat >>e${EMULATION_NAME}.c <<EOF case OPTION_GROUP: link_info.flags_1 |= (bfd_vma) DF_1_GROUP; /* Groups must be self-contained. */ - link_info.no_undefined = TRUE; + link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR; + link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR; break; case 'z': @@ -1949,7 +1941,7 @@ cat >>e${EMULATION_NAME}.c <<EOF link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN; } else if (strcmp (optarg, "defs") == 0) - link_info.no_undefined = TRUE; + link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR; else if (strcmp (optarg, "muldefs") == 0) link_info.allow_multiple_definition = TRUE; else if (strcmp (optarg, "combreloc") == 0) @@ -1957,7 +1949,17 @@ cat >>e${EMULATION_NAME}.c <<EOF else if (strcmp (optarg, "nocombreloc") == 0) link_info.combreloc = FALSE; else if (strcmp (optarg, "nocopyreloc") == 0) - link_info.nocopyreloc = TRUE; + link_info.nocopyreloc = TRUE; + else if (strcmp (optarg, "execstack") == 0) + { + link_info.execstack = TRUE; + link_info.noexecstack = FALSE; + } + else if (strcmp (optarg, "noexecstack") == 0) + { + link_info.noexecstack = TRUE; + link_info.execstack = FALSE; + } /* What about the other Solaris -z options? FIXME. */ break; EOF @@ -1980,11 +1982,8 @@ EOF if test x"$LDEMUL_LIST_OPTIONS" != xgld"$EMULATION_NAME"_list_options; then cat >>e${EMULATION_NAME}.c <<EOF -static void gld${EMULATION_NAME}_list_options PARAMS ((FILE * file)); - static void -gld${EMULATION_NAME}_list_options (file) - FILE * file; +gld${EMULATION_NAME}_list_options (FILE * file) { EOF @@ -1995,7 +1994,8 @@ cat >>e${EMULATION_NAME}.c <<EOF fprintf (file, _(" --enable-new-dtags\tEnable new dynamic tags\n")); fprintf (file, _(" --eh-frame-hdr\tCreate .eh_frame_hdr section\n")); fprintf (file, _(" -z combreloc\t\tMerge dynamic relocs into one section and sort\n")); - fprintf (file, _(" -z defs\t\tDisallows undefined symbols\n")); + fprintf (file, _(" -z defs\t\tReport unresolved symbols in object files.\n")); + fprintf (file, _(" -z execstack\t\tMark executable as requiring executable stack\n")); fprintf (file, _(" -z initfirst\t\tMark DSO to be initialized first at runtime\n")); fprintf (file, _(" -z interpose\t\tMark object to interpose all DSOs but executable\n")); fprintf (file, _(" -z loadfltr\t\tMark object requiring immediate process\n")); @@ -2006,6 +2006,7 @@ cat >>e${EMULATION_NAME}.c <<EOF fprintf (file, _(" -z nodelete\t\tMark DSO non-deletable at runtime\n")); fprintf (file, _(" -z nodlopen\t\tMark DSO not available to dlopen\n")); fprintf (file, _(" -z nodump\t\tMark DSO not available to dldump\n")); + fprintf (file, _(" -z noexecstack\tMark executable as not requiring executable stack\n")); fprintf (file, _(" -z now\t\tMark object non-lazy runtime binding\n")); fprintf (file, _(" -z origin\t\tMark object requiring immediate \$ORIGIN processing\n\t\t\t at runtime\n")); fprintf (file, _(" -z KEYWORD\t\tIgnored for Solaris compatibility\n")); @@ -2066,7 +2067,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = gld${EMULATION_NAME}_handle_option, ${LDEMUL_UNRECOGNIZED_FILE-NULL}, ${LDEMUL_LIST_OPTIONS-gld${EMULATION_NAME}_list_options}, - ${LDEMUL_RECOGNIZED_FILE-NULL}, + ${LDEMUL_RECOGNIZED_FILE-gld${EMULATION_NAME}_load_symbols}, ${LDEMUL_FIND_POTENTIAL_LIBRARIES-NULL}, ${LDEMUL_NEW_VERS_PATTERN-NULL} }; diff --git a/gnu/usr.bin/binutils/ld/emultempl/generic.em b/gnu/usr.bin/binutils/ld/emultempl/generic.em index 3a7d6115315..4d17ca261ab 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/generic.em +++ b/gnu/usr.bin/binutils/ld/emultempl/generic.em @@ -4,7 +4,7 @@ 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, 1992, 1994, 1996, 2000, 2001, 2002 + Copyright 1991, 1992, 1994, 1996, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Steve Chamberlain steve@cygnus.com @@ -39,9 +39,6 @@ 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 char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile)); - EOF # Import any needed special functions and/or overrides. @@ -54,10 +51,10 @@ if test x"$LDEMUL_BEFORE_PARSE" != xgld"$EMULATION_NAME"_before_parse; then cat >>e${EMULATION_NAME}.c <<EOF 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_ */ } @@ -68,8 +65,7 @@ if test x"$LDEMUL_GET_SCRIPT" != xgld"$EMULATION_NAME"_get_script; then cat >>e${EMULATION_NAME}.c <<EOF static char * -gld${EMULATION_NAME}_get_script(isfile) - int *isfile; +gld${EMULATION_NAME}_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -80,14 +76,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 @@ -101,12 +97,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"; @@ -121,7 +117,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 = { ${LDEMUL_BEFORE_PARSE-gld${EMULATION_NAME}_before_parse}, ${LDEMUL_SYSLIB-syslib_default}, diff --git a/gnu/usr.bin/binutils/ld/emultempl/gld960.em b/gnu/usr.bin/binutils/ld/emultempl/gld960.em index dd73e6b061e..9b93bac2db3 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/gld960.em +++ b/gnu/usr.bin/binutils/ld/emultempl/gld960.em @@ -20,7 +20,7 @@ You should have received a copy of the GNU General Public License along with GLD; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* +/* * emulate the Intels port of gld */ @@ -39,15 +39,10 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307 #include "ldfile.h" #include "ldemul.h" -static void gld960_before_parse PARAMS ((void)); -static char *gld960_choose_target PARAMS ((int, char **)); -static void gld960_set_output_arch PARAMS ((void)); -static char *gld960_get_script PARAMS ((int *)); - #ifdef GNU960 static void -gld960_before_parse() +gld960_before_parse (void) { static char *env_variables[] = { "G960LIB", "G960BASE", 0 }; char **p; @@ -67,7 +62,7 @@ gld960_before_parse() #else /* not GNU960 */ -static void gld960_before_parse() +static void gld960_before_parse (void) { char *env ; env = getenv("G960LIB"); @@ -84,15 +79,13 @@ static void gld960_before_parse() static void -gld960_set_output_arch() +gld960_set_output_arch (void) { bfd_set_arch_mach(output_bfd, ldfile_output_architecture, bfd_mach_i960_core); } static char * -gld960_choose_target (argc, argv) - int argc ATTRIBUTE_UNUSED; - char **argv ATTRIBUTE_UNUSED; +gld960_choose_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { #ifdef GNU960 @@ -113,8 +106,7 @@ gld960_choose_target (argc, argv) } static char * -gld960_get_script(isfile) - int *isfile; +gld960_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -125,14 +117,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 @@ -146,12 +138,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 +158,7 @@ fi cat >>e${EMULATION_NAME}.c <<EOF -struct ld_emulation_xfer_struct ld_gld960_emulation = +struct ld_emulation_xfer_struct ld_gld960_emulation = { gld960_before_parse, syslib_default, diff --git a/gnu/usr.bin/binutils/ld/emultempl/gld960c.em b/gnu/usr.bin/binutils/ld/emultempl/gld960c.em index 132afcb5c5e..ef2293e7806 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/gld960c.em +++ b/gnu/usr.bin/binutils/ld/emultempl/gld960c.em @@ -1,7 +1,7 @@ # This shell script emits a C file. -*- C -*- # It does some substitutions. cat >e${EMULATION_NAME}.c <<EOF -/* Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2003 +/* Copyright 1991, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GLD, the Gnu Linker. @@ -21,7 +21,7 @@ along with GLD; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* +/* * emulate the Intels port of gld */ @@ -41,15 +41,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "ldfile.h" #include "ldemul.h" -static void gld960_before_parse PARAMS ((void)); -static void gld960_set_output_arch PARAMS ((void)); -static char *gld960_choose_target PARAMS ((int, char **)); -static char *gld960_get_script PARAMS ((int *)); - #ifdef GNU960 static void -gld960_before_parse() +gld960_before_parse (void) { static char *env_variables[] = { "G960LIB", "G960BASE", 0 }; char **p; @@ -69,7 +64,7 @@ gld960_before_parse() #else /* not GNU960 */ -static void gld960_before_parse() +static void gld960_before_parse (void) { char *env ; env = getenv("G960LIB"); @@ -87,7 +82,7 @@ static void gld960_before_parse() static void -gld960_set_output_arch() +gld960_set_output_arch (void) { if (ldfile_output_machine_name != NULL && *ldfile_output_machine_name != '\0') @@ -97,7 +92,7 @@ gld960_set_output_arch() s = concat ("i960:", ldfile_output_machine_name, (char *) NULL); for (s1 = s; *s1 != '\0'; s1++) *s1 = TOLOWER (*s1); - ldfile_set_output_arch (s); + ldfile_set_output_arch (s, bfd_arch_unknown); free (s); } @@ -105,9 +100,7 @@ gld960_set_output_arch() } static char * -gld960_choose_target (argc, argv) - int argc ATTRIBUTE_UNUSED; - char **argv ATTRIBUTE_UNUSED; +gld960_choose_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { #ifdef GNU960 @@ -128,8 +121,7 @@ gld960_choose_target (argc, argv) } static char * -gld960_get_script(isfile) - int *isfile; +gld960_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -140,14 +132,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 @@ -161,12 +153,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"; @@ -181,7 +173,7 @@ fi cat >>e${EMULATION_NAME}.c <<EOF -struct ld_emulation_xfer_struct ld_gld960coff_emulation = +struct ld_emulation_xfer_struct ld_gld960coff_emulation = { gld960_before_parse, syslib_default, diff --git a/gnu/usr.bin/binutils/ld/emultempl/hppaelf.em b/gnu/usr.bin/binutils/ld/emultempl/hppaelf.em index 4e3b6b957f9..93e88ad655a 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/hppaelf.em +++ b/gnu/usr.bin/binutils/ld/emultempl/hppaelf.em @@ -27,14 +27,6 @@ cat >>e${EMULATION_NAME}.c <<EOF #include "ldctor.h" #include "elf32-hppa.h" -static void hppaelf_after_parse PARAMS ((void)); -static void hppaelf_create_output_section_statements PARAMS ((void)); -static asection *hppaelf_add_stub_section - PARAMS ((const char *, asection *)); -static void hppaelf_layout_sections_again PARAMS ((void)); -static void gld${EMULATION_NAME}_finish PARAMS ((void)); -static void build_section_lists PARAMS ((lang_statement_union_type *)); - /* Fake input file for stubs. */ static lang_input_statement_type *stub_file; @@ -56,9 +48,9 @@ static bfd_signed_vma group_size = 1; and adds millicode library to the list of input files. */ static void -hppaelf_after_parse () +hppaelf_after_parse (void) { - if (link_info.relocateable) + if (link_info.relocatable) lang_add_unique (".text"); #if 0 /* Enable this once we split millicode stuff from libgcc. */ else @@ -72,8 +64,15 @@ hppaelf_after_parse () fake input file to hold the stub sections. */ static void -hppaelf_create_output_section_statements () +hppaelf_create_output_section_statements (void) { + extern const bfd_target bfd_elf32_hppa_linux_vec; + extern const bfd_target bfd_elf32_hppa_vec; + + if (link_info.hash->creator != &bfd_elf32_hppa_linux_vec + && link_info.hash->creator != &bfd_elf32_hppa_vec) + return; + stub_file = lang_add_input_file ("linker stubs", lang_input_file_is_fake_enum, NULL); @@ -99,13 +98,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; @@ -177,9 +171,7 @@ hook_in_stub (info, lp) immediately before INPUT_SECTION. */ static asection * -hppaelf_add_stub_section (stub_sec_name, input_section) - const char *stub_sec_name; - asection *input_section; +hppaelf_add_stub_section (const char *stub_sec_name, asection *input_section) { asection *stub_sec; flagword flags; @@ -220,7 +212,7 @@ hppaelf_add_stub_section (stub_sec_name, input_section) /* Another call-back for elf32_hppa_size_stubs. */ static void -hppaelf_layout_sections_again () +hppaelf_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 @@ -243,8 +235,7 @@ hppaelf_layout_sections_again () static void -build_section_lists (statement) - lang_statement_union_type *statement; +build_section_lists (lang_statement_union_type *statement) { if (statement->header.type == lang_input_section_enum && !statement->input_section.ifile->just_syms_flag @@ -261,18 +252,18 @@ build_section_lists (statement) to build linker stubs. */ static void -gld${EMULATION_NAME}_finish () +gld${EMULATION_NAME}_finish (void) { - /* bfd_elf32_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 to examine the relocs. */ - if (! link_info.relocateable) + if (stub_file != NULL && !link_info.relocatable) { int ret = elf32_hppa_setup_section_lists (output_bfd, &link_info); @@ -304,7 +295,7 @@ gld${EMULATION_NAME}_finish () if (need_laying_out) hppaelf_layout_sections_again (); - if (! link_info.relocateable) + if (! link_info.relocatable) { /* Set the global data pointer. */ if (! elf32_hppa_set_gp (output_bfd, &link_info)) @@ -314,7 +305,7 @@ gld${EMULATION_NAME}_finish () } /* Now build the linker stubs. */ - if (stub_file->the_bfd->sections != NULL) + if (stub_file != NULL && stub_file->the_bfd->sections != NULL) { if (! elf32_hppa_build_stubs (&link_info)) einfo ("%X%P: can not build stubs: %E\n"); @@ -326,23 +317,16 @@ gld${EMULATION_NAME}_finish () /* Avoid processing the fake stub_file in vercheck, stat_needed and check_needed routines. */ -static void hppa_for_each_input_file_wrapper - PARAMS ((lang_input_statement_type *)); -static void hppa_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 hppa_for_each_input_file_wrapper (l) - lang_input_statement_type *l; +static void hppa_for_each_input_file_wrapper (lang_input_statement_type *l) { if (l != stub_file) (*real_func) (l); } static void -hppa_lang_for_each_input_file (func) - void (*func) PARAMS ((lang_input_statement_type *)); +hppa_lang_for_each_input_file (void (*func) (lang_input_statement_type *)) { real_func = func; lang_for_each_input_file (&hppa_for_each_input_file_wrapper); diff --git a/gnu/usr.bin/binutils/ld/emultempl/linux.em b/gnu/usr.bin/binutils/ld/emultempl/linux.em index fae1252ca60..d041b681df6 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/linux.em +++ b/gnu/usr.bin/binutils/ld/emultempl/linux.em @@ -9,7 +9,7 @@ cat >e${EMULATION_NAME}.c <<EOF /* This file is is generated by a shell script. DO NOT EDIT! */ /* Linux a.out emulation code for ${EMULATION_NAME} - Copyright 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002, 2003 + Copyright 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Steve Chamberlain <sac@cygnus.com> Linux support by Eric Youngdale <ericy@cais.cais.com> @@ -44,28 +44,10 @@ 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 bfd_boolean gld${EMULATION_NAME}_open_dynamic_archive - PARAMS ((const char *, search_dirs_type *, lang_input_statement_type *)); -static void gld${EMULATION_NAME}_find_address_statement - PARAMS ((lang_statement_union_type *)); -static void gld${EMULATION_NAME}_create_output_section_statements - 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}_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/:.*//'`); config.dynamic_link = TRUE; config.has_shared = TRUE; } @@ -74,10 +56,8 @@ gld${EMULATION_NAME}_before_parse() dynamic libraries have an extension of .sa. */ static bfd_boolean -gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry) - const char *arch; - search_dirs_type *search; - lang_input_statement_type *entry; +gld${EMULATION_NAME}_open_dynamic_archive + (const char *arch, search_dirs_type *search, lang_input_statement_type *entry) { char *string; @@ -110,8 +90,7 @@ gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry) Linux tools. */ static void -gld${EMULATION_NAME}_find_address_statement (s) - lang_statement_union_type *s; +gld${EMULATION_NAME}_find_address_statement (lang_statement_union_type *s) { if (s->header.type == lang_address_statement_enum && strcmp (s->address_statement.section_name, ".text") == 0) @@ -124,7 +103,7 @@ gld${EMULATION_NAME}_find_address_statement (s) /* This is called before opening the input BFD's. */ static void -gld${EMULATION_NAME}_create_output_section_statements () +gld${EMULATION_NAME}_create_output_section_statements (void) { lang_for_each_statement (gld${EMULATION_NAME}_find_address_statement); } @@ -133,9 +112,9 @@ gld${EMULATION_NAME}_create_output_section_statements () sections, but before any sizes or addresses have been set. */ static void -gld${EMULATION_NAME}_before_allocation () +gld${EMULATION_NAME}_before_allocation (void) { - if (link_info.relocateable) + if (link_info.relocatable) return; /* Let the backend work out the sizes of any sections required by @@ -145,8 +124,7 @@ gld${EMULATION_NAME}_before_allocation () } static char * -gld${EMULATION_NAME}_get_script(isfile) - int *isfile; +gld${EMULATION_NAME}_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -160,11 +138,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 @@ -181,9 +159,9 @@ 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"; diff --git a/gnu/usr.bin/binutils/ld/emultempl/lnk960.em b/gnu/usr.bin/binutils/ld/emultempl/lnk960.em index ba0fe93b6f6..2c294ec63b9 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/lnk960.em +++ b/gnu/usr.bin/binutils/ld/emultempl/lnk960.em @@ -47,23 +47,9 @@ static lib_list_type **hll_list_tail = &hll_list; static lib_list_type *syslib_list; static lib_list_type **syslib_list_tail = &syslib_list; -static void append PARAMS ((lib_list_type ***, char *)); -static void lnk960_hll PARAMS ((char *)); -static void lnk960_syslib PARAMS ((char *)); -static void lnk960_before_parse PARAMS ((void)); -static void add_on PARAMS ((lib_list_type *, lang_input_file_enum_type)); -static void lnk960_after_parse PARAMS ((void)); -static void lnk960_before_allocation PARAMS ((void)); -static void lnk960_after_allocation PARAMS ((void)); -static void lnk960_set_output_arch PARAMS ((void)); -static char *lnk960_choose_target PARAMS ((int, char **)); -static char *lnk960_get_script PARAMS ((int *)); - static void -append (list, name) - lib_list_type ***list; - char *name; +append (lib_list_type ***list, char *name) { lib_list_type *element = (lib_list_type *) xmalloc (sizeof (lib_list_type)); @@ -78,8 +64,7 @@ static bfd_boolean had_hll = FALSE; static bfd_boolean had_hll_name = FALSE; static void -lnk960_hll (name) - char *name; +lnk960_hll (char *name) { had_hll = TRUE; if (name != (char *) NULL) @@ -89,9 +74,8 @@ lnk960_hll (name) } } -static void -lnk960_syslib (name) - char *name; +static void +lnk960_syslib (char *name) { append (&syslib_list_tail, name); } @@ -99,8 +83,8 @@ lnk960_syslib (name) #ifdef GNU960 -static void -lnk960_before_parse () +static void +lnk960_before_parse (void) { static char *env_variables[] = { "G960LIB", "G960BASE", 0 }; char **p; @@ -123,8 +107,8 @@ lnk960_before_parse () #else /* not GNU960 */ -static void -lnk960_before_parse () +static void +lnk960_before_parse (void) { char *name = getenv ("I960BASE"); @@ -145,9 +129,7 @@ lnk960_before_parse () static void -add_on (list, search) - lib_list_type *list; - lang_input_file_enum_type search; +add_on (lib_list_type *list, lang_input_file_enum_type search) { while (list) { @@ -155,15 +137,16 @@ add_on (list, search) list = list->next; } } + static void -lnk960_after_parse () +lnk960_after_parse (void) { /* If there has been no arch, default to -KB */ if (ldfile_output_machine_name[0] == 0) ldfile_add_arch ("KB"); /* if there has been no hll list then add our own */ - + if (had_hll && !had_hll_name) { append (&hll_list_tail, "cg"); @@ -171,20 +154,20 @@ lnk960_after_parse () || ldfile_output_machine == bfd_mach_i960_ca) append (&hll_list_tail, "fpg"); } - + add_on (hll_list, lang_input_file_is_l_enum); add_on (syslib_list, lang_input_file_is_search_file_enum); } static void -lnk960_before_allocation () +lnk960_before_allocation (void) { } static void -lnk960_after_allocation () +lnk960_after_allocation (void) { - if (!link_info.relocateable) + if (!link_info.relocatable) { lang_abs_symbol_at_end_of (".text", "_etext"); lang_abs_symbol_at_end_of (".data", "_edata"); @@ -197,7 +180,7 @@ lnk960_after_allocation () static struct { unsigned long number; - char *name; + char *name; } machine_table[] = { @@ -227,7 +210,7 @@ machine_table[] = }; static void -lnk960_set_output_arch () +lnk960_set_output_arch (void) { /* Set the output architecture and machine if possible */ unsigned int i; @@ -245,9 +228,7 @@ lnk960_set_output_arch () } static char * -lnk960_choose_target (argc, argv) - int argc ATTRIBUTE_UNUSED; - char **argv ATTRIBUTE_UNUSED; +lnk960_choose_target (int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) { #ifdef GNU960 @@ -268,8 +249,7 @@ lnk960_choose_target (argc, argv) } static char * -lnk960_get_script (isfile) - int *isfile; +lnk960_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -280,14 +260,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 @@ -301,12 +281,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"; @@ -321,7 +301,7 @@ fi cat >>e${EMULATION_NAME}.c <<EOF -struct ld_emulation_xfer_struct ld_lnk960_emulation = +struct ld_emulation_xfer_struct ld_lnk960_emulation = { lnk960_before_parse, lnk960_syslib, diff --git a/gnu/usr.bin/binutils/ld/emultempl/mipsecoff.em b/gnu/usr.bin/binutils/ld/emultempl/mipsecoff.em index 6e417ed52c6..dde33c24be5 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/mipsecoff.em +++ b/gnu/usr.bin/binutils/ld/emultempl/mipsecoff.em @@ -1,6 +1,6 @@ # This shell script emits a C file. -*- C -*- # It does some substitutions. -if [ -z "$MACHINE" ]; then +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH} else OUTPUT_ARCH=${ARCH}:${MACHINE} @@ -9,7 +9,7 @@ cat >e${EMULATION_NAME}.c <<EOF /* This file is is generated by a shell script. DO NOT EDIT! */ /* Handle embedded relocs for MIPS. - Copyright 1994, 1995, 1997, 2000, 2002, 2003 + Copyright 1994, 1995, 1997, 2000, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Ian Lance Taylor <ian@cygnus.com> based on generic.em. @@ -44,25 +44,13 @@ 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}_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. */ - 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/:.*//'`); #endif /* not TARGET_ */ } @@ -74,12 +62,12 @@ gld${EMULATION_NAME}_before_parse() have been compiled using -membedded-pic. */ 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) @@ -119,7 +107,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); } } @@ -127,13 +115,10 @@ gld${EMULATION_NAME}_after_open () relocs. This is called via bfd_map_over_sections. */ static void -check_sections (abfd, sec, sdatasec) - bfd *abfd; - asection *sec; - PTR sdatasec; +check_sections (bfd *abfd, asection *sec, void *sdatasec) { if ((bfd_get_section_flags (abfd, sec) & SEC_CODE) == 0 - && sec != (asection *) sdatasec + && sec != sdatasec && sec->reloc_count != 0) einfo ("%B%X: section %s has relocs; can not use --embedded-relocs\n", abfd, bfd_get_section_name (abfd, sec)); @@ -144,12 +129,12 @@ check_sections (abfd, sec, sdatasec) 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) @@ -180,8 +165,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" @@ -192,14 +176,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 @@ -213,12 +197,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"; @@ -233,7 +217,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/pe.em b/gnu/usr.bin/binutils/ld/emultempl/pe.em index 10522d75759..7d6c2e8a6d1 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/pe.em +++ b/gnu/usr.bin/binutils/ld/emultempl/pe.em @@ -9,7 +9,7 @@ rm -f e${EMULATION_NAME}.c (echo;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 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 + Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -68,8 +68,7 @@ cat >>e${EMULATION_NAME}.c <<EOF #include "deffile.h" #include "pe-dll.h" - -#include <ctype.h> +#include "safe-ctype.h" /* Permit the emulation parameters to override the default section alignment by setting OVERRIDE_SECTION_ALIGNMENT. FIXME: This makes @@ -104,44 +103,6 @@ cat >>e${EMULATION_NAME}.c <<EOF #define PE_DEF_FILE_ALIGNMENT 0x00000200 #endif -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}_after_parse PARAMS ((void)); -static void gld_${EMULATION_NAME}_before_allocation PARAMS ((void)); -static asection *output_prev_sec_find - PARAMS ((lang_output_section_statement_type *)); -static bfd_boolean gld_${EMULATION_NAME}_place_orphan - PARAMS ((lang_input_statement_type *, asection *)); -static char *gld_${EMULATION_NAME}_get_script PARAMS ((int *)); -static void gld_${EMULATION_NAME}_finish PARAMS ((void)); -static bfd_boolean gld_${EMULATION_NAME}_open_dynamic_archive - PARAMS ((const char *, search_dirs_type *, lang_input_statement_type *)); -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 *)); -static void set_pe_name PARAMS ((char *, long)); -static void set_pe_subsystem PARAMS ((void)); -static void set_pe_value PARAMS ((char *)); -static void set_pe_stack_heap PARAMS ((char *, char *)); - -#ifdef DLL_SUPPORT -static bfd_boolean pe_undef_cdecl_match - PARAMS ((struct bfd_link_hash_entry *, PTR)); -static void pe_fixup_stdcalls PARAMS ((void)); -static int make_import_fixup PARAMS ((arelent *, asection *)); -static void pe_find_data_imports PARAMS ((void)); -#endif - -static bfd_boolean pr_sym PARAMS ((struct bfd_hash_entry *, PTR)); -static bfd_boolean gld_${EMULATION_NAME}_unrecognized_file - PARAMS ((lang_input_statement_type *)); -static bfd_boolean gld_${EMULATION_NAME}_recognized_file - PARAMS ((lang_input_statement_type *)); -static int gld_${EMULATION_NAME}_find_potential_libraries - PARAMS ((char *, lang_input_statement_type *)); - static struct internal_extra_pe_aouthdr pe; static int dll; @@ -160,17 +121,9 @@ static char *pe_dll_search_prefix = NULL; 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 = "${EXECUTABLE_NAME:-a.exe}"; #ifdef DLL_SUPPORT config.dynamic_link = TRUE; @@ -180,9 +133,9 @@ gld_${EMULATION_NAME}_before_parse() #if (PE_DEF_SUBSYSTEM == 9) || (PE_DEF_SUBSYSTEM == 2) #if defined TARGET_IS_mipspe || defined TARGET_IS_armpe - lang_add_entry ("WinMainCRTStartup", 1); + lang_add_entry ("WinMainCRTStartup", FALSE); #else - lang_add_entry ("_WinMainCRTStartup", 1); + lang_add_entry ("_WinMainCRTStartup", FALSE); #endif #endif #endif @@ -202,8 +155,8 @@ gld_${EMULATION_NAME}_before_parse() #define OPTION_MINOR_OS_VERSION (OPTION_MINOR_IMAGE_VERSION + 1) #define OPTION_MINOR_SUBSYSTEM_VERSION (OPTION_MINOR_OS_VERSION + 1) #define OPTION_SECTION_ALIGNMENT (OPTION_MINOR_SUBSYSTEM_VERSION + 1) -#define OPTION_STACK (OPTION_SECTION_ALIGNMENT + 1) -#define OPTION_SUBSYSTEM (OPTION_STACK + 1) +#define OPTION_STACK (OPTION_SECTION_ALIGNMENT + 1) +#define OPTION_SUBSYSTEM (OPTION_STACK + 1) #define OPTION_HEAP (OPTION_SUBSYSTEM + 1) #define OPTION_SUPPORT_OLD_CODE (OPTION_HEAP + 1) #define OPTION_OUT_DEF (OPTION_SUPPORT_OLD_CODE + 1) @@ -231,13 +184,10 @@ gld_${EMULATION_NAME}_before_parse() (OPTION_DLL_ENABLE_RUNTIME_PSEUDO_RELOC + 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[] = { /* PE options */ @@ -337,8 +287,7 @@ static definfo init[] = static void -gld_${EMULATION_NAME}_list_options (file) - FILE * file; +gld_${EMULATION_NAME}_list_options (FILE *file) { fprintf (file, _(" --base_file <basefile> Generate a base file for relocatable DLLs\n")); fprintf (file, _(" --dll Set image base to the default for DLLs\n")); @@ -390,9 +339,7 @@ gld_${EMULATION_NAME}_list_options (file) static void -set_pe_name (name, val) - char *name; - long val; +set_pe_name (char *name, long val) { int i; @@ -411,7 +358,7 @@ set_pe_name (name, val) static void -set_pe_subsystem () +set_pe_subsystem (void) { const char *sver; int len; @@ -484,7 +431,7 @@ set_pe_subsystem () entry = alc_entry; } - lang_add_entry (entry, 0); + lang_add_entry (entry, TRUE); return; } @@ -495,9 +442,7 @@ set_pe_subsystem () static void -set_pe_value (name) - char *name; - +set_pe_value (char *name) { char *end; @@ -511,9 +456,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); @@ -528,8 +471,7 @@ set_pe_stack_heap (resname, comname) static bfd_boolean -gld${EMULATION_NAME}_handle_option (optc) - int optc; +gld${EMULATION_NAME}_handle_option (int optc) { switch (optc) { @@ -537,7 +479,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) { /* xgettext:c-format */ @@ -698,7 +640,7 @@ compute_dll_image_base (const char *ofile) 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. */ @@ -707,7 +649,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 || link_info.shared) #ifdef DLL_SUPPORT @@ -720,8 +662,8 @@ gld_${EMULATION_NAME}_set_symbols () init[IMAGEBASEOFF].value = NT_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. */ @@ -762,7 +704,7 @@ gld_${EMULATION_NAME}_set_symbols () have been read. */ static void -gld_${EMULATION_NAME}_after_parse () +gld_${EMULATION_NAME}_after_parse (void) { /* The Windows libraries are designed for the linker to treat the entry point as an undefined symbol. Otherwise, the .obj that @@ -777,7 +719,7 @@ gld_${EMULATION_NAME}_after_parse () opened, so registering the symbol as undefined will make a difference. */ - if (! link_info.relocateable && entry_symbol.name != NULL) + if (! link_info.relocatable && entry_symbol.name != NULL) ldlang_add_undef (entry_symbol.name); } @@ -792,13 +734,12 @@ char * pe_data_import_dll; static struct bfd_link_hash_entry *pe_undef_found_sym; static bfd_boolean -pe_undef_cdecl_match (h, string) - struct bfd_link_hash_entry *h; - PTR string; +pe_undef_cdecl_match (struct bfd_link_hash_entry *h, void *inf) { int sl; + char *string = inf; - sl = strlen (string); /* Silence compiler warning. */ + sl = strlen (string); if (h->type == bfd_link_hash_defined && strncmp (h->root.string, string, sl) == 0 && h->root.string[sl] == '@') @@ -810,7 +751,7 @@ pe_undef_cdecl_match (h, string) } static void -pe_fixup_stdcalls () +pe_fixup_stdcalls (void) { static int gave_warning_message = 0; struct bfd_link_hash_entry *undef, *sym; @@ -818,7 +759,7 @@ pe_fixup_stdcalls () if (pe_dll_extra_pe_debug) printf ("%s\n", __FUNCTION__); - for (undef = link_info.hash->undefs; undef; undef=undef->next) + for (undef = link_info.hash->undefs; undef; undef=undef->und_next) if (undef->type == bfd_link_hash_undefined) { char* at = strchr (undef->root.string, '@'); @@ -859,7 +800,7 @@ pe_fixup_stdcalls () symbols - which means scanning the whole symbol table. */ pe_undef_found_sym = 0; bfd_link_hash_traverse (link_info.hash, pe_undef_cdecl_match, - (PTR) undef->root.string); + (char *) undef->root.string); sym = pe_undef_found_sym; if (sym) { @@ -884,11 +825,9 @@ pe_fixup_stdcalls () } static int -make_import_fixup (rel, s) - arelent *rel; - asection *s; +make_import_fixup (arelent *rel, asection *s) { - struct symbol_cache_entry *sym = *rel->sym_ptr_ptr; + struct bfd_symbol *sym = *rel->sym_ptr_ptr; int addend = 0; if (pe_dll_extra_pe_debug) @@ -905,14 +844,14 @@ make_import_fixup (rel, s) } static void -pe_find_data_imports () +pe_find_data_imports (void) { struct bfd_link_hash_entry *undef, *sym; if (link_info.pei386_auto_import == 0) return; - for (undef = link_info.hash->undefs; undef; undef=undef->next) + for (undef = link_info.hash->undefs; undef; undef=undef->und_next) { if (undef->type == bfd_link_hash_undefined) { @@ -969,23 +908,22 @@ pe_find_data_imports () } } } -#endif /* DLL_SUPPORT */ static bfd_boolean -pr_sym (h, string) - struct bfd_hash_entry *h; - PTR string ATTRIBUTE_UNUSED; +pr_sym (struct bfd_hash_entry *h, void *inf ATTRIBUTE_UNUSED) { if (pe_dll_extra_pe_debug) - printf ("+%s\n",h->string); + printf ("+%s\n", h->string); return TRUE; } +#endif /* DLL_SUPPORT */ static void -gld_${EMULATION_NAME}_after_open () +gld_${EMULATION_NAME}_after_open (void) { +#ifdef DLL_SUPPORT if (pe_dll_extra_pe_debug) { bfd *a; @@ -993,13 +931,14 @@ gld_${EMULATION_NAME}_after_open () printf ("%s()\n", __FUNCTION__); - for (sym = link_info.hash->undefs; sym; sym=sym->next) + for (sym = link_info.hash->undefs; sym; sym=sym->und_next) printf ("-%s\n", sym->root.string); - bfd_hash_traverse (&link_info.hash->table, pr_sym,NULL); + bfd_hash_traverse (&link_info.hash->table, pr_sym, NULL); for (a = link_info.input_bfds; a; a = a->link_next) printf ("*%s\n",a->filename); } +#endif /* Pass the wacky PE command line options into the output bfd. FIXME: This should be done via a function, rather than by @@ -1022,7 +961,7 @@ gld_${EMULATION_NAME}_after_open () #if ! (defined (TARGET_IS_i386pe) || defined (TARGET_IS_armpe)) if (link_info.shared) #else - if (!link_info.relocateable) + if (!link_info.relocatable) #endif pe_dll_build_sections (output_bfd, &link_info); @@ -1122,7 +1061,7 @@ gld_${EMULATION_NAME}_after_open () for (i = 0; i < nrelocs; i++) { - struct symbol_cache_entry *s; + struct bfd_symbol *s; struct bfd_link_hash_entry * blhe; bfd *other_bfd; char *n; @@ -1168,6 +1107,7 @@ gld_${EMULATION_NAME}_after_open () int is_ms_arch = 0; bfd *cur_arch = 0; lang_input_statement_type *is2; + lang_input_statement_type *is3; /* Careful - this is a shell script. Watch those dollar signs! */ /* Microsoft import libraries have every member named the same, @@ -1182,21 +1122,59 @@ gld_${EMULATION_NAME}_after_open () { if (is->the_bfd->my_archive) { + char *pnt; bfd *arch = is->the_bfd->my_archive; + if (cur_arch != arch) { cur_arch = arch; is_ms_arch = 1; - for (is2 = is; - is2 && is2->the_bfd->my_archive == arch; - is2 = (lang_input_statement_type *)is2->next) + + for (is3 = is; + is3 && is3->the_bfd->my_archive == arch; + is3 = (lang_input_statement_type *) is3->next) + { + /* A MS dynamic import library can also contain static + members, so look for the first element with a .dll + extension, and use that for the remainder of the + comparisons. */ + pnt = strrchr (is3->the_bfd->filename, '.'); + if (pnt != NULL && strcmp (pnt, ".dll") == 0) + break; + } + + if (is3 == NULL) + is_ms_arch = 0; + else { - if (strcmp (is->the_bfd->filename, is2->the_bfd->filename)) - is_ms_arch = 0; + /* OK, found one. Now look to see if the remaining + (dynamic import) members use the same name. */ + for (is2 = is; + is2 && is2->the_bfd->my_archive == arch; + is2 = (lang_input_statement_type *) is2->next) + { + /* Skip static members, ie anything with a .obj + extension. */ + pnt = strrchr (is2->the_bfd->filename, '.'); + if (pnt != NULL && strcmp (pnt, ".obj") == 0) + continue; + + if (strcmp (is3->the_bfd->filename, + is2->the_bfd->filename)) + { + is_ms_arch = 0; + break; + } + } } } - if (is_ms_arch) + /* This fragment might have come from an .obj file in a Microsoft + import, and not an actual import record. If this is the case, + then leave the filename alone. */ + pnt = strrchr (is->the_bfd->filename, '.'); + + if (is_ms_arch && (strcmp (pnt, ".dll") == 0)) { int idata2 = 0, reloc_count=0; asection *sec; @@ -1230,7 +1208,7 @@ gld_${EMULATION_NAME}_after_open () } static void -gld_${EMULATION_NAME}_before_allocation () +gld_${EMULATION_NAME}_before_allocation (void) { #ifdef TARGET_IS_ppcpe /* Here we rummage through the found bfds to collect toc information. */ @@ -1279,7 +1257,7 @@ gld_${EMULATION_NAME}_before_allocation () check here for .DEF files and pull them in automatically. */ static int -saw_option (char * option) +saw_option (char *option) { int i; @@ -1291,8 +1269,7 @@ saw_option (char * option) #endif /* DLL_SUPPORT */ static bfd_boolean -gld_${EMULATION_NAME}_unrecognized_file (entry) - lang_input_statement_type *entry ATTRIBUTE_UNUSED; +gld_${EMULATION_NAME}_unrecognized_file (lang_input_statement_type *entry ATTRIBUTE_UNUSED) { #ifdef DLL_SUPPORT const char *ext = entry->filename + strlen (entry->filename) - 4; @@ -1381,8 +1358,7 @@ gld_${EMULATION_NAME}_unrecognized_file (entry) } static bfd_boolean -gld_${EMULATION_NAME}_recognized_file (entry) - lang_input_statement_type *entry ATTRIBUTE_UNUSED; +gld_${EMULATION_NAME}_recognized_file (lang_input_statement_type *entry ATTRIBUTE_UNUSED) { #ifdef DLL_SUPPORT #ifdef TARGET_IS_i386pe @@ -1415,7 +1391,7 @@ gld_${EMULATION_NAME}_recognized_file (entry) } static void -gld_${EMULATION_NAME}_finish () +gld_${EMULATION_NAME}_finish (void) { #if defined(TARGET_IS_armpe) || defined(TARGET_IS_arm_epoc_pe) struct bfd_link_hash_entry * h; @@ -1462,7 +1438,7 @@ gld_${EMULATION_NAME}_finish () #ifdef DLL_SUPPORT if (link_info.shared #if !defined(TARGET_IS_shpe) && !defined(TARGET_IS_mipspe) - || (!link_info.relocateable && pe_def_file->num_exports != 0) + || (!link_info.relocatable && pe_def_file->num_exports != 0) #endif ) { @@ -1499,8 +1475,7 @@ gld_${EMULATION_NAME}_finish () 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; lang_statement_union_type *u; @@ -1542,9 +1517,7 @@ struct orphan_save }; 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 *hold_section_name; @@ -1557,7 +1530,7 @@ gld_${EMULATION_NAME}_place_orphan (file, s) /* Look through the script to see where to place this section. */ hold_section_name = xstrdup (secname); - if (!link_info.relocateable) + if (!link_info.relocatable) { dollar = strchr (hold_section_name, '$'); if (dollar != NULL) @@ -1648,7 +1621,7 @@ gld_${EMULATION_NAME}_place_orphan (file, s) /* If the name of the section is representable in C, then create symbols to mark the start and the end of the section. */ for (ps = outsecname; *ps != '\0'; ps++) - if (! isalnum ((unsigned char) *ps) && *ps != '_') + if (! ISALNUM ((unsigned char) *ps) && *ps != '_') break; if (*ps == '\0') { @@ -1663,7 +1636,7 @@ gld_${EMULATION_NAME}_place_orphan (file, s) } } - if (link_info.relocateable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0) + if (link_info.relocatable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0) address = exp_intop ((bfd_vma) 0); else { @@ -1674,7 +1647,6 @@ gld_${EMULATION_NAME}_place_orphan (file, s) } os = lang_enter_output_section_statement (outsecname, address, 0, - (bfd_vma) 0, (etree_type *) NULL, (etree_type *) NULL, (etree_type *) NULL); @@ -1825,10 +1797,9 @@ gld_${EMULATION_NAME}_place_orphan (file, s) } static bfd_boolean -gld_${EMULATION_NAME}_open_dynamic_archive (arch, search, entry) - const char * arch ATTRIBUTE_UNUSED; - search_dirs_type * search; - lang_input_statement_type * entry; +gld_${EMULATION_NAME}_open_dynamic_archive + (const char *arch ATTRIBUTE_UNUSED, search_dirs_type *search, + lang_input_statement_type *entry) { const char * filename; char * string; @@ -1916,16 +1887,14 @@ gld_${EMULATION_NAME}_open_dynamic_archive (arch, search, entry) } static int -gld_${EMULATION_NAME}_find_potential_libraries (name, entry) - char * name; - lang_input_statement_type * entry; +gld_${EMULATION_NAME}_find_potential_libraries + (char *name, lang_input_statement_type *entry) { return ldfile_open_file_search (name, entry, "", ".lib"); } 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. @@ -1935,11 +1904,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/sunos.em b/gnu/usr.bin/binutils/ld/emultempl/sunos.em index 8cabe3a0a2a..358bc9aabb9 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/sunos.em +++ b/gnu/usr.bin/binutils/ld/emultempl/sunos.em @@ -9,8 +9,8 @@ cat >e${EMULATION_NAME}.c <<EOF /* This file is is generated by a shell script. DO NOT EDIT! */ /* SunOS emulation code for ${EMULATION_NAME} - Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 - Free Software Foundation, Inc. + Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, + 2003, 2004 Free Software Foundation, Inc. Written by Steve Chamberlain <sac@cygnus.com> SunOS shared library support by Ian Lance Taylor <ian@cygnus.com> @@ -61,43 +61,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ # endif #endif -static void gld${EMULATION_NAME}_before_parse PARAMS ((void)); -static void gld${EMULATION_NAME}_set_symbols PARAMS ((void)); -static void gld${EMULATION_NAME}_create_output_section_statements - PARAMS ((void)); static void gld${EMULATION_NAME}_find_so - PARAMS ((lang_input_statement_type *)); + (lang_input_statement_type *); static char *gld${EMULATION_NAME}_search_dir - PARAMS ((const char *, const char *, bfd_boolean *)); -static void gld${EMULATION_NAME}_after_open PARAMS ((void)); + (const char *, const char *, bfd_boolean *); static void gld${EMULATION_NAME}_check_needed - PARAMS ((lang_input_statement_type *)); + (lang_input_statement_type *); static bfd_boolean gld${EMULATION_NAME}_search_needed - PARAMS ((const char *, const char *)); + (const char *, const char *); static bfd_boolean gld${EMULATION_NAME}_try_needed - PARAMS ((const char *, const char *)); -static void gld${EMULATION_NAME}_before_allocation PARAMS ((void)); + (const char *, const char *); static void gld${EMULATION_NAME}_find_assignment - PARAMS ((lang_statement_union_type *)); -static void gld${EMULATION_NAME}_find_exp_assignment PARAMS ((etree_type *)); + (lang_statement_union_type *); +static void gld${EMULATION_NAME}_find_exp_assignment + (etree_type *); static void gld${EMULATION_NAME}_count_need - PARAMS ((lang_input_statement_type *)); + (lang_input_statement_type *); static void gld${EMULATION_NAME}_set_need - PARAMS ((lang_input_statement_type *)); -static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile)); + (lang_input_statement_type *); 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/:.*//'`); config.dynamic_link = TRUE; config.has_shared = TRUE; } @@ -108,7 +94,7 @@ gld${EMULATION_NAME}_before_parse() list. */ static void -gld${EMULATION_NAME}_set_symbols () +gld${EMULATION_NAME}_set_symbols (void) { EOF if [ "x${host}" = "x${target}" ] ; then @@ -154,7 +140,7 @@ cat >>e${EMULATION_NAME}.c <<EOF search it after including the .so file. */ static void -gld${EMULATION_NAME}_create_output_section_statements () +gld${EMULATION_NAME}_create_output_section_statements (void) { lang_for_each_input_file (gld${EMULATION_NAME}_find_so); } @@ -162,8 +148,7 @@ gld${EMULATION_NAME}_create_output_section_statements () /* Search the directory for a .so file for each library search. */ static void -gld${EMULATION_NAME}_find_so (inp) - lang_input_statement_type *inp; +gld${EMULATION_NAME}_find_so (lang_input_statement_type *inp) { search_dirs_type *search; char *found = NULL; @@ -234,10 +219,8 @@ gld${EMULATION_NAME}_find_so (inp) /* Search a directory for a .so file. */ static char * -gld${EMULATION_NAME}_search_dir (dirname, filename, found_static) - const char *dirname; - const char *filename; - bfd_boolean *found_static; +gld${EMULATION_NAME}_search_dir + (const char *dirname, const char *filename, bfd_boolean *found_static) { int force_maj, force_min; const char *dot; @@ -302,9 +285,9 @@ gld${EMULATION_NAME}_search_dir (dirname, filename, found_static) } /* We accept libfoo.so without a version number, even though the - native linker does not. This is more convenient for packages - which just generate .so files for shared libraries, as on ELF - systems. */ + native linker does not. This is more convenient for packages + which just generate .so files for shared libraries, as on ELF + systems. */ if (strncmp (entry->d_name + 3 + len, ".so", 3) != 0) continue; if (entry->d_name[6 + len] == '\0') @@ -378,12 +361,12 @@ static bfd_boolean global_found; /* This is called after all the input files have been opened. */ static void -gld${EMULATION_NAME}_after_open () +gld${EMULATION_NAME}_after_open (void) { struct bfd_link_needed_list *needed, *l; /* We only need to worry about this when doing a final link. */ - if (link_info.relocateable || link_info.shared) + if (link_info.relocatable || link_info.shared) return; /* Get the list of files which appear in ld_need entries in dynamic @@ -514,9 +497,7 @@ cat >>e${EMULATION_NAME}.c <<EOF /* Search for a needed file in a path. */ static bfd_boolean -gld${EMULATION_NAME}_search_needed (path, name) - const char *path; - const char *name; +gld${EMULATION_NAME}_search_needed (const char *path, const char *name) { const char *s; @@ -559,9 +540,7 @@ gld${EMULATION_NAME}_search_needed (path, name) dynamic object. */ static bfd_boolean -gld${EMULATION_NAME}_try_needed (dir, name) - const char *dir; - const char *name; +gld${EMULATION_NAME}_try_needed (const char *dir, const char *name) { char *file; char *alc; @@ -603,8 +582,7 @@ gld${EMULATION_NAME}_try_needed (dir, name) dynamic object more than once. */ static void -gld${EMULATION_NAME}_check_needed (s) - lang_input_statement_type *s; +gld${EMULATION_NAME}_check_needed (lang_input_statement_type *s) { if (s->filename == NULL) return; @@ -679,7 +657,7 @@ static bfd_byte *need_pnames; sections, but before any sizes or addresses have been set. */ static void -gld${EMULATION_NAME}_before_allocation () +gld${EMULATION_NAME}_before_allocation (void) { struct bfd_link_hash_entry *hdyn = NULL; asection *sneed; @@ -689,11 +667,11 @@ gld${EMULATION_NAME}_before_allocation () /* The SunOS native linker creates a shared library whenever there are any undefined symbols in a link, unless -e is used. This is pretty weird, but we are compatible. */ - if (! link_info.shared && ! link_info.relocateable && ! entry_from_cmdline) + if (! link_info.shared && ! link_info.relocatable && ! entry_from_cmdline) { struct bfd_link_hash_entry *h; - for (h = link_info.hash->undefs; h != NULL; h = h->next) + for (h = link_info.hash->undefs; h != NULL; h = h->und_next) { if (h->type == bfd_link_hash_undefined && h->u.undef.abfd != NULL @@ -718,7 +696,7 @@ gld${EMULATION_NAME}_before_allocation () lang_output_section_statement_type *os; /* Set the .text section to start at 0x20, not 0x2020. FIXME: - This is too magical. */ + This is too magical. */ os = lang_output_section_statement_lookup (".text"); if (os->addr_tree == NULL) os->addr_tree = exp_intop (0x20); @@ -730,7 +708,7 @@ gld${EMULATION_NAME}_before_allocation () one. We need to create the symbol before calling size_dynamic_sections, although we can't set the value until afterward. */ - if (! link_info.relocateable) + if (! link_info.relocatable) { hdyn = bfd_link_hash_lookup (link_info.hash, "__DYNAMIC", TRUE, FALSE, FALSE); @@ -823,7 +801,7 @@ gld${EMULATION_NAME}_before_allocation () /* We must assign a value to __DYNAMIC. It should be zero if we are not doing a dynamic link, or the start of the .dynamic section if we are doing one. */ - if (! link_info.relocateable) + if (! link_info.relocatable) { hdyn->type = bfd_link_hash_defined; hdyn->u.def.value = 0; @@ -842,8 +820,7 @@ gld${EMULATION_NAME}_before_allocation () symbols which are referred to by dynamic objects. */ static void -gld${EMULATION_NAME}_find_assignment (s) - lang_statement_union_type *s; +gld${EMULATION_NAME}_find_assignment (lang_statement_union_type *s) { if (s->header.type == lang_assignment_statement_enum && (find_assign == NULL || ! found_assign)) @@ -853,8 +830,7 @@ gld${EMULATION_NAME}_find_assignment (s) /* Look through an expression for an assignment statement. */ static void -gld${EMULATION_NAME}_find_exp_assignment (exp) - etree_type *exp; +gld${EMULATION_NAME}_find_exp_assignment (etree_type *exp) { switch (exp->type.node_class) { @@ -902,8 +878,7 @@ gld${EMULATION_NAME}_find_exp_assignment (exp) for more information. */ static void -gld${EMULATION_NAME}_count_need (inp) - lang_input_statement_type *inp; +gld${EMULATION_NAME}_count_need (lang_input_statement_type *inp) { if (inp->the_bfd != NULL && (inp->the_bfd->flags & DYNAMIC) != 0) @@ -924,8 +899,7 @@ gld${EMULATION_NAME}_count_need (inp) /* Fill in the contents of the .need section. */ static void -gld${EMULATION_NAME}_set_need (inp) - lang_input_statement_type *inp; +gld${EMULATION_NAME}_set_need (lang_input_statement_type *inp) { if (inp->the_bfd != NULL && (inp->the_bfd->flags & DYNAMIC) != 0) @@ -974,8 +948,7 @@ gld${EMULATION_NAME}_set_need (inp) } static char * -gld${EMULATION_NAME}_get_script(isfile) - int *isfile; +gld${EMULATION_NAME}_get_script (int *isfile) EOF if test -n "$COMPILE_IN" @@ -989,11 +962,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 @@ -1010,9 +983,9 @@ 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"; diff --git a/gnu/usr.bin/binutils/ld/emultempl/vanilla.em b/gnu/usr.bin/binutils/ld/emultempl/vanilla.em index 8d4f6d4d32d..21410836752 100644 --- a/gnu/usr.bin/binutils/ld/emultempl/vanilla.em +++ b/gnu/usr.bin/binutils/ld/emultempl/vanilla.em @@ -35,17 +35,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "ldfile.h" #include "ldemul.h" -static void vanilla_before_parse PARAMS ((void)); -static void vanilla_set_output_arch PARAMS ((void)); -static char *vanilla_get_script PARAMS ((int *)); - - -static void vanilla_before_parse() +static void vanilla_before_parse (void) { } static void -vanilla_set_output_arch() +vanilla_set_output_arch (void) { /* Set the output architecture and machine if possible */ unsigned long machine = 0; @@ -53,14 +48,13 @@ vanilla_set_output_arch() } static char * -vanilla_get_script(isfile) - int *isfile; +vanilla_get_script (int *isfile) { *isfile = 0; return ""; } -struct ld_emulation_xfer_struct ld_vanilla_emulation = +struct ld_emulation_xfer_struct ld_vanilla_emulation = { vanilla_before_parse, syslib_default, |