diff options
Diffstat (limited to 'contrib/binutils/ld')
86 files changed, 32205 insertions, 0 deletions
diff --git a/contrib/binutils/ld/ChangeLog b/contrib/binutils/ld/ChangeLog new file mode 100644 index 0000000..abef050 --- /dev/null +++ b/contrib/binutils/ld/ChangeLog @@ -0,0 +1,7027 @@ +Wed May 21 17:44:15 1997 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (main): Correct check of fclose return value when + handling --force-exe-suffix. + +Tue May 13 10:43:26 1997 Ian Lance Taylor <ian@cygnus.com> + + * ldver.c: Set to "2.8.1". + +Mon May 12 11:11:06 1997 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * scripttempl/elf.sc: Don't align the data segment on the next 8 + byte boundary, instead let the linker use whatever the individual + sections require. + +Tue May 6 13:21:19 1997 Ian Lance Taylor <ian@cygnus.com> + + From Sean McNeil <sean@mcneil.com>: + * emultempl/pe.em (sort_by_file_name): Sort by archive name + first. + (sort_sections): Sort all sections, not just sections in the same + archive. + +Mon May 5 18:19:55 1997 Philip Blundell <pjb27@cam.ac.uk> + + * configure.tgt, configure.host: cope with '*-*-linux-gnuaout' + targets. + +Wed Apr 30 12:23:21 1997 Manfred Hollstein <manfred@s-direktnet.de> + + * scripttempl/m88kbcs.sc (__.initp.end, _etext): Added whitespace + around assignment of current location pointer. + +Mon Apr 14 12:06:15 1997 Ian Lance Taylor <ian@cygnus.com> + + From Thomas Graichen <graichen@rzpd.de>: + * configure.in: Use ${CONFIG_SHELL} when running $ac_config_sub. + * configure: Rebuild. + +Fri Apr 4 11:42:41 1997 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/pe.em: Include "libiberty.h". + (sort_sections_1): Use xmalloc rather than alloca. + +Thu Apr 3 18:54:20 1997 Ian Lance Taylor <ian@cygnus.com> + + * ldver.c (ld_program_version): Set to "2.8". + +Wed Apr 2 11:55:27 1997 Ian Lance Taylor <ian@cygnus.com> + + * mpw-idtmips.c: Rename from mpw-emipsidt.c. + * mpw-elfmips.c: Rename from mpw-emipself.c. + * mpw-config.in: Update accordingly. + + * ldlang.c (lang_process): Call lang_check immediately after + opening the input files, rather than at the end of the link. + +Mon Mar 31 23:44:00 1997 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/pe.em (init): Fully bracket initializer. + (set_pe_stack_heap): Remove locals begin_commit and end. + (gld_${EMULATION_NAME}_after_open): Remove unused local i. + (gld${EMULATION_NAME}_place_orphan): Remove unused local ptr. + +Mon Mar 31 16:35:51 1997 Joel Sherrill <joel@oarcorp.com> + + * configure.tgt (hppa*-*-rtems*): New target, like hppa-*-*elf*. + +Fri Mar 28 15:29:23 1997 H.J. Lu <hjl@gnu.ai.mit.edu> + + Contributed by David S. Miller <davem@caip.rutgers.edu>: + * configure.tgt (sparc*-*-linuxaout*): New target. + (sparc*-*-linux*): New target. + * emulparams/sparclinux.sh: New file. + * Makefile.in (ALL_EMULATIONS): Add esparclinux.o. + (esparclinux.c): New target. + +Fri Mar 28 14:30:12 1997 Ian Lance Taylor <ian@cygnus.com> + + From Ralf Baechle <ralf@gnu.ai.mit.edu>: + * configure.tgt: Set targ_extra_emuls for mips*el-*-linux* and + mips*-*-linux*. Use elf32bmip and elf32lmip, not elf32ebmip and + elf32elmip. + +Thu Mar 27 17:14:32 1997 Ian Lance Taylor <ian@cygnus.com> + + * lexsup.c (parse_args): Update copyright date in version + message. + +Fri Mar 21 12:28:41 1997 Philippe De Muyter <phdm@info.ucl.ac.be> + + * emulparams/delta68.sh (OUTPUT_FORMAT): Set to "coff-m68k-sysv". + +Tue Mar 18 11:16:23 1997 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in: Rebuild dependencies. + + * emultempl/aix.em: Include "obstack.h". + +Mon Mar 17 19:26:06 1997 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c: Include "obstack.h". + +Sat Mar 15 23:23:46 1997 Fred Fish <fnf@cygnus.com> + + * configure.tgt (powerpc-*-beos*): Use aixppc for targ_emul. + +Sat Mar 15 18:10:38 1997 H.J. Lu <hjl@lucon.org> + + * ldemul.h (ldemul_list_emulations): Use full prototype. + * ldlang.c (print_one_symbol): Add declaration. + * ldlang.h (dprint_statements): Declare. + * ldmain.c (remove_output): Declare. + * ldmisc.c (vfinfo): Declare. + * ldwrite.c (clone_section): Declare. + (split_sections): Make static. Declare. + * mri.c: Include libiberty.h. + (strdup): Don't declare. + (mri_alias): Use xstrdup rather than strdup. + +Fri Mar 14 21:30:06 1997 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/elfmips.sc: Change handling of data area when + generating a shared library to not skip a large block of memory. + From Per Fogelstrom <pefo@cvs.openbsd.org>. + +Wed Mar 12 21:33:09 1997 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (multiple_definition): Only skip the warning if the + output section is absolute when the input section is not + absolute. + + * ldlex.l: Accept whitespace in VERS_START state. Warn about + invalid characters in VERS_* states. + +Tue Mar 11 13:51:31 1997 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em (gld${EMULATION_NAME}_read_file): Don't let a + trailing space lead us to think that there is a zero address. + +Sun Mar 9 23:06:35 1997 Eric Youngdale <eric@andante.jic.com> + + * ldgram.y (vers_node): Correct typo of '(' for '{'. + +Sun Mar 2 22:59:49 1997 Fred Fish <fnf@cygnus.com> + + * Makefile.in (ld.dvi): Set MAKEINFO environment variable as well + as TEXINPUTS. Needed for building in separate build dir. + * ldint.texinfo (SCRIPT_NAME): Fix typo. + +Fri Feb 28 17:42:27 1997 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (main): Call bfd_set_default_target. + * Makefile.in (ldmain.o): Define TARGET when compiling. + +Thu Feb 27 11:41:03 1997 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (main): Don't initialize link_info.lprefix or + link_info.lprefix_len. + * emultempl/hppaelf.em (hppaelf_before_parse): Likewise. + + * emultempl/m88kbcs.em: Remove. + * emulparams/m88kbcs.sh (TEMPLATE_NAME): Don't set. + * Makefile.in (em88kbcs.c): Depend upon generic.em rather than + m88kbcs.em. + + * mri.c (mri_draw_tree): Pass noload_section, not SEC_NEVER_LOAD, + to lang_enter_output_section_statement. From Mark Rasin + <mark.rasin@telrad.co.il>. + +Wed Feb 26 11:51:44 1997 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_one_common): Clear SEC_IS_COMMON from common + section. + +Tue Feb 25 20:38:11 1997 Stan Shebs <shebs@andros.cygnus.com> + + * configure.tgt (mips*-*-lnews*): New target. + * Makefile.in (emipslnews.c): New target. + * emulparams/mipslnews.sh: New file. + +Tue Feb 25 16:04:09 1997 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em (hold_interp): New static variable. + (gld${EMULATION_NAME}_place_orphan): Put loadable .note sections + after hold_interp. Choose a unique output section name. + (gld${EMULATION_NAME}_place_section): Don't set hold_use if the + SEC_LOAD or SEC_ALLOC flags differ. Set hold_interp. + +Mon Feb 24 18:16:09 1997 Ian Lance Taylor <ian@cygnus.com> + + From Eric Youngdale <eric@andante.jic.com>: + * ldlex.l (V_TAG, V_IDENTIFIER): New macros. + (VERS_START, VERS_SCRIPT, VERS_NODE): New states to parse version + information. + (ldlex_version_script, ldlex_version_file): New functions. + * ldlex.h (enum input_enum): Add input_version_script. + (ldlex_version_script): Declare. + (ldlex_version_file): Declare. + * ldgram.y (%union): Add deflist, versyms, and versnode. + (VERS_TAG, VERS_IDENTIFIER): New terminals. + (GLOBAL, LOCAL, VERSION, INPUT_VERSION_SCRIPT): New terminals. + (file): Accept INPUT_VERSION_SCRIPT. + (ifile_p1): Accept version. + (version_script_file): New nonterminal. + (version, vers_nodes, vers_node): Likewise. + (verdep, vers_tag, ver_defns): Likewise. + * ldlang.c (lang_elf_version_info): New global variable. + (lang_new_vers_regex): New function. + (lang_new_vers_node): New function. + (version_index): New static variable. + (lang_register_vers_node): New function. + (lang_add_vers_depend): New function. + * ldlang.h (lang_elf_version_info): Declare. + (lang_new_vers_regex, lang_new_vers_node): Declare. + (lang_add_vers_depend, lang_register_vers_node): Declare. + * lexsup.c (OPTION_VERSION_SCRIPT): Define. + (ld_options): Add "version-script". + (parse_args): Handle OPTION_VERSION_SCRIPT. + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): + Pass lang_elf_version_info to size_dynamic_sections. + * scripttempl/elf.sc: Add .gnu.version sections. + * ld.texinfo: Document symbol versioning. + +Fri Feb 14 18:28:31 1997 Ian Lance Taylor <ian@cygnus.com> + + * ld.texinfo (Option Commands): Document the INCLUDE command. + +Thu Feb 13 20:31:37 1997 Philippe De Muyter <phdm@info.ucl.ac.be> + + * configure.in: Call BFD_NEED_DECLARATION on getenv. + * acconfig.h (NEED_DECLARATION_GETENV): New macro. + * sysdep.h (getenv): Declare if NEED_DECLARATION_GETENV. + * ldemul.c (ld_emul_default_target): Do not cast getenv return + value. + * ldmain.c (get_emulation): Likewise. + * configure, config.in: Rebuild. + +Tue Feb 11 15:34:26 1997 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/elfmips.sc: When relocating, put .mips16.fn.* and + .mips16.call.* in .text. + +Fri Jan 31 13:16:53 1997 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/sunos.em (gld${EMULATION_NAME}_find_so): Search for + ".so" in the name, not ".so.". + (gld${EMULATION_NAME}_search_dir): Accept a plain .so file. + + * Makefile.in (ld.info): Add -I$(srcdir). From Alan Modra + <alan@spri.levels.unisa.edu.au>. + +Thu Jan 30 11:31:52 1997 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/sunos.em: Include <ctype.h>. + (gld${EMULATION_NAME}_find_so): Skip the directory name when + searching for ".so.". + (gld${EMULATION_NAME}_search_dir): Make sure that the library name + has a version number, and that only version numbers follow .so. + +Wed Jan 29 18:15:00 1997 Geoffrey Noer <noer@cygnus.com> + + * scripttempl/pe.sc: + * scripttempl/ppcpe.sc: add *(.gcc_except_table) to the text + section so Win32 executables are valid. + +Mon Jan 27 12:28:43 1997 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/elf.sc: Put linkonce reloc section in other + appropriate reloc sections. + * scripttempl/elfmips.sc: Add linkonce support. + * scripttempl/elfppc.sc: Likewise. + +Fri Jan 24 10:44:09 1997 Jeffrey A Law (law@cygnus.com) + + * emulparms/mn10200.sh (OTHER_RELOCATING_SECTIONS): Move the + stack up to 0x80000. + * emulparms/mn10300.sh (OTHER_RELOCATING_SECTIONS): Likewise. + +Tue Jan 21 12:11:10 1997 Doug Evans <dje@seba.cygnus.com> + + * emulparams/m32relf.sh (OTHER_RELOCATING_SECTIONS): Use PROVIDE + to define `_stack'. + +Thu Jan 16 17:07:52 1997 Ian Lance Taylor <ian@cygnus.com> + + * ld.h (args_type): Rename auxiliary_filter_shlib to + auxiliary_filters, and make it char **. + * lexsup.c (parse_args): Handle -f by setting up an array. + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Use + new name of auxiliary_filters. + + * ld.texinfo (Options): Improve documentation of --filter and + --auxiliary. + +Tue Jan 14 15:44:28 1997 Ian Lance Taylor <ian@cygnus.com> + + * ld.texinfo (Options): Clarify that the normal usage is -T. + (Commands): Likewise. + +Thu Jan 9 11:26:27 1997 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/armcoff.sc: Correct mask used for .data address. + +Wed Jan 8 15:14:59 1997 Geoffrey Noer <noer@cygnus.com> + + * emultempl/pe.em: make default executable a.exe instead of + a.out + +Fri Jan 3 17:33:34 1997 Richard Henderson <rth@tamu.edu> + + * scripttempl/elf.sc: Move .got closer to .sdata and .sbss by + shifting .plt back. Rumour has it that the NetBSD ld.so depends + on .dynamic being after .got, so we leave that. + +Fri Jan 3 14:04:40 1997 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in (clean): Don't remove configdoc.texi. + (maintainer-clean): Do remove configdoc.texi. + + * ld.texinfo (Operators): Remove '@' from @smallexmple in comment + to avoid confusing texi2roff. + +Thu Jan 2 18:14:32 1997 Ian Lance Taylor <ian@cygnus.com> + + * configure.tgt (mips*el-*-linux*, mips*-*-linux*): New targets. + * scripttempl/elfmips.sc: Use __start as the entry address for + mips*-*-linux*. + +Tue Dec 31 14:48:30 1996 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in (ALL_CFLAGS): Add -D_GNU_SOURCE. + + * ld.h (args_type): Add filter_shlib and auxiliary_filter_shlib + fields. + * lexsup.c (parse_args): Recognize --auxiliary/-f and + --filter/-F. + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): + Pass filter_shlib and auxiliary_filter_shlib to + size_dynamic_sections. + * ld.texinfo, ld.1: Document --filter/-F and --auxiliary/-f. + +Wed Dec 18 22:57:35 1996 Stan Shebs <shebs@andros.cygnus.com> + + * mpw-make.sed: Use NewFolderRecursive for installation. + +Fri Dec 13 10:19:57 1996 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (emn10200.c): Add dependencies. + * configure.tgt: Handle mn10200. + * emulparms/mn10200.sh: New file. + +Thu Dec 12 17:04:55 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/gld960c.em: Include <ctype.h>. + (gld960_set_output_arch): Get the machine type from the -A option + if there is one, rather than always using core. + +Sat Dec 7 10:07:51 1996 Jeffrey A Law (law@cygnus.com) + + * emulparms/mn10300.sh: Handle leading underscores. + +Thu Dec 5 13:45:58 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em (gld${EMULATION_NAME}_place_section): Only + set hold_rel if SEC_ALLOC is set. + +Tue Dec 3 11:29:20 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (section_already_linked): Set the output_offset as well + as the output_section when only reading symbols from a file. + +Mon Dec 2 11:43:50 1996 Ian Lance Taylor <ian@cygnus.com> + + * emulparams/*.sh: Make sure that each set of parameters which + uses the elf.sc script sets MACHINE. + +Wed Nov 27 03:22:05 1996 Jason Merrill <jason@yorick.cygnus.com> + + * scripttempl/elf{,mips,ppc}.sc: Add the remaining DWARF sections. + + * scripttempl/elfd10v.sc: Likewise. + +Tue Nov 26 16:58:33 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure: Rebuild with autoconf 2.12. + +Mon Nov 25 12:17:55 1996 Jim Wilson <wilson@cygnus.com> + + * emultempl/pe.em (gld_${EMULATION_NAME}_set_symbols): Add case + for bfd_vma to init loop. + +Mon Nov 25 09:55:07 1996 Jeffrey A Law (law@cygnus.com) + + * emulparms/mn10300.sh: Remove bogus '_' prefix for + entry symbol and ctor/dtor stuff. + +Fri Nov 15 13:00:18 1996 Jeffrey A Law (law@cygnus.com) + + * Makefile.in (emn10300.c): Add dependencies. + * configure.tgt: Handle mn10300. + * emulparms/mn10300.sh: New file. + +Tue Nov 5 10:57:50 1996 Martin M. Hunt <hunt@pizza.cygnus.com> + + * emulparams/d10velf.sh (READONLY_START_ADDR): Changed to 0x2000004. + (EMBEDDED): Define. + +Fri Nov 1 10:01:27 1996 Ian Lance Taylor <ian@cygnus.com> + + * ld.texinfo: Add section on reporting bugs. + + * scripttempl/m68kcoff.sc: Make sure the etext and __CTOR_LIST__ + symbols are correctly aligned. + +Tue Oct 29 12:33:05 1996 Martin M. Hunt <hunt@pizza.cygnus.com> + + * emulparams/d10velf.sh: Changes needed for D10V-EVA board. + Set TEXT_START_ADDR to 0x1000000. Set READONLY_START_ADDR to + 0x2000000. + + * scripttempl/elfd10v.sc: Fix calculation of .text. Change + .stack to start at 0x2007ffe. + +Mon Oct 28 15:37:00 1996 Doug Evans <dje@canuck.cygnus.com> + + * configure.tgt (sparclet*-*-aout*): Delete, use sparc*-*-aout*. + +Mon Oct 21 17:16:59 1996 Michael Meissner <meissner@wogglebug.tiac.net> + + * scripttempl/elfd10v.sc: Clone from elf.sc, move .text to + 0x10000, so that is more room for data. + + * emulparams/d10velf.sh (TEXT_START_ADDR): Now 0x100000. + (READONLY_START_ADDR): Now 0x0. + (SCRIPT_NAME): Now elfd10v. + + * Makefile.in (ed10velf.c): Depend on elfd10v.sc, not elf.sc. + +Fri Oct 18 22:12:49 1996 Doug Evans <dje@canuck.cygnus.com> + + * emulparams/m32relf.sh (TEXT_START_ADDR): Change from 0 to 0x100. + +Fri Oct 18 15:43:38 1996 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in (ALL_EMULATIONS): Remove eelf64alpha.o. + (ALL_64_EMULATIONS): New variable. + * configure.in: Accept --enable-64-bit-bfd option. If it is set + with --enable-targets=all, include ALL_64_EMULATIONS in + EMULATION_OFILES. + * configure: Rebuild. + +Thu Oct 17 18:14:07 1996 Ian Lance Taylor <ian@cygnus.com> + + * ld.texinfo: Try to consistently use a single or a double dash + for each option. + +Thu Oct 17 10:17:20 1996 Doug Evans <dje@canuck.cygnus.com> + + * emulparams/m32relf.sh (EMBEDDED): Define. + +Thu Oct 10 17:57:00 1996 Ian Lance Taylor <ian@cygnus.com> + + * emulparams/elf32b4300.sh: Define _gp in OTHER_GOT_SYMBOLS, not + OTHER_READWRITE_SECTIONS. + * emulparams/elf32l4300.sh: Likewise. + +Wed Oct 9 14:36:18 1996 Ian Lance Taylor <ian@cygnus.com> + + * ld.h (ld_config_type): Add warn_section_align field. + * lexsup.c (OPTION_WARN_SECTION_ALIGN): Define. + (ld_options): Add --warn-section-align. + (parse_args): Handle --warn-section-align. + * ldlang.c (lang_size_sections): If warn_section_align, warn if + the start of a section changes due to alignment. + * ld.texinfo, ld.1: Document --warn-section-align. + * ld.texinfo: Change some single dashes to double dashes. + + * emultempl/pe.em (set_pe_subsystem): Record entry symbol for each + subsystem type. Ifdef out os2 type. Recognize a version number. + +Tue Oct 8 12:07:13 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/pe.em (set_pe_subsystem): When setting the subsystem + to windows, set the entry point. + + * Makefile.in (ldlex.c): Don't pass any options to $(LEX). + +Mon Oct 7 17:29:05 1996 Ian Lance Taylor <ian@cygnus.com> + + * ld.texinfo (Options): Mention .so extensions for shared + libraries. + +Sun Oct 6 22:35:36 1996 Jason Merrill <jason@yorick.cygnus.com> + + * scripttempl/elf{,mips,ppc}.sc: Add DWARF 2 sections. + +Fri Oct 4 18:49:31 1996 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/m68kcoff.sc: Only set the address of .text if + RELOCATING. + +Fri Oct 4 10:59:52 1996 Doug Evans <dje@canuck.cygnus.com> + + * emulparams/sparcaout.sh ({BIG,LITTLE}_OUTPUT_FORMAT): Define. + * scripttempl/aout.sc ({BIG,LITTLE}_OUTPUT_FORMAT): Provide default. + (OUTPUT_FORMAT): Support bi-endian targets. + +Thu Oct 3 13:52:03 1996 Ian Lance Taylor <ian@cygnus.com> + + * fnmatch.h, fnmatch.c: Remove (now in libiberty). + * Makefile.in: Rebuild dependencies. + (CFILES): Remove fnmatch.c. + (HFILES): Remove fnmatch.h. + (OFILES): Remove fnmatch.o. + +Thu Oct 3 15:41:24 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (mostlyclean): Move config.log to distclean. + +Wed Oct 2 23:45:25 1996 Geoffrey Noer <noer@cygnus.com> + + * emultmpl/pe.em: increase size of stack reserve to 0x2000000 + (necessary in order to compile parse.c in gcc sources under NT) + +Wed Oct 2 14:49:10 1996 Ian Lance Taylor <ian@cygnus.com> + + * lexsup.c (ld_options): Fix typo in --rpath-link description. + * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Suggest + --rpath if a needed library is not found. + +Tue Oct 1 16:17:33 1996 Joel Sherrill <joel@oarcorp.com> + + * configure.tgt (mips*-*-rtems*): New target, like mips*-*-elf*. + +Tue Oct 1 15:50:34 1996 Ian Lance Taylor <ian@cygnus.com> + + * ld.texinfo (Options): Give more detail on -l option. + + * scripttempl/elfmips.sc: Handle CREATE_SHLIB the same way that + elf.sc does, so that glibc works better. + + * ldver.c (ld_program_version): New variable. + (ldversion): Use it. + * ldver.h (ld_program_version): Declare. + * lexsup.c (ld_options): Handle --dll-verbose like --verbose, not + --version. Change --version handling to match current GNU + standards. + (help): Print bug report address. + +Mon Sep 30 12:14:43 1996 Doug Evans <dje@canuck.cygnus.com> + + * Makefile.in (em32relf.c): Add rule for. + * configure.tgt (m32r-*-*): Recognize. + * emulparams/m32relf.sh: New file. + +Thu Sep 26 13:58:47 1996 Stan Shebs <shebs@andros.cygnus.com> + + * mpw-make.sed: Add symbolic doublequoting to ldmain compile edit. + * mpw-config.in: Add mips-*-* case as mips-elf, and use more + wildcards in matching. + * mpw-emipself.c: New file, pregenerated mips elf emulation. + +Tue Sep 17 12:18:21 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldint.texinfo: Rewrote. + + * configure.tgt: Add cases for MIPS 5000 like MIPS 4300. + +Mon Sep 16 17:55:21 1996 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/armcoff.sc: Only define symbols if RELOCATING. Fix + syntax error on __end__ line. + + * scripttempl/armcoff.sc: For -N or -n, don't align .data. From + Chris Hadley <Christopher.Hadley@cl.cam.ac.uk> + +Sun Sep 15 10:38:16 1996 Mark Alexander <marka@cygnus.com> + + * emulparms/d10v.sh: Set OTHER_RELOCATING_SECTIONS to put + stack at top of simulator memory. + +Fri Sep 13 15:49:45 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlex.l (SYMBOLCHARN): Add $, _, and ~. + +Wed Sep 11 23:30:42 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (get_emulation): Check for -mips4 like -mips1, et. al. + +Thu Sep 5 15:24:12 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (section_already_linked): Accept a lang_input_statement + as the PTR argument. If the file is symbols only, discard all + input sections. + (ldlang_add_file): Pass entry to bfd_map_over_sections. + +Wed Sep 4 15:53:43 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.tgt (alpha-*-gnu*): New target. From Fila Kolodny + <fila@ibi.com>. + +Fri Aug 30 18:32:31 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.tgt (sh-*-elf*): New target. + * emulparams/shelf.sh: New file. + * emulparams/shlelf.sh: New file. + * Makefile.in (ALL_EMULATIONS): Add eshelf.o and eshlelf.o. + (eshelf.c, eshlelf.c): New targets. + * scripttempl/elf.sc: If EMBEDDED is defined, then don't add + SIZEOF_HEADERS to TEXT_START_ADDR. Expand CTOR_START and CTOR_END + around .ctors, and DTOR_START and DTOR_END around .dtors. Expand + OTHER_RELOCATING_SECTIONS if RELOCATING. + +Thu Aug 29 16:57:46 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * configure.{host,tgt} (i[345]86-*-*): Recognize i686 for pentium + pro. + +Mon Aug 26 12:58:11 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldgram.y (section): Add opt_nocrossrefs; pass value to + lang_enter_overlay. + (opt_nocrossrefs): New nonterminal. + * ldlex.l: Recognize NOCROSSREFS keyword in EXPRESSION mode. + * ldlang.c (overlay_nocrossrefs): New static variable. + (lang_enter_overlay): Add nocrossrefs parameter. + (lang_leave_overlay): Only add nocrossrefs if overlay_nocrossrefs + is set. Initialize overlay_nocrossrefs. + * ldlang.h (lang_enter_overlay): Update declaration. + * ld.texinfo (Overlays): Update documentation. + + * ldver.c (ldversion): Print GNU ld in the version message. + +Thu Aug 22 17:10:40 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.host: Set HLDENV. + * configure.in: Substitute HLDENV. + * configure: Rebuild. + * Makefile.in (HLDENV): New variable. + ($(LD_PROG)): Use $(HLDENV). + +Thu Aug 22 11:16:02 1996 Stan Shebs <shebs@andros.cygnus.com> + + * mpw-make.sed: Add @DASH_C_FLAG@ to compiler edit. + +Wed Aug 21 11:26:37 1996 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/elf.sc: Put .gnu.linkonce* sections in appropriate + containing sections. + +Mon Aug 19 13:01:42 1996 Ian Lance Taylor <ian@cygnus.com> + + * fnmatch.c: Include sysdep.h. + +Mon Aug 19 11:28:29 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * genscripts.sh: Undo 8/16 change. + + * emulparams/d10velf.sh (MACHINE): Explicitly set to nothing. + +Fri Aug 16 19:18:08 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * genscripts.sh: Explicitly reset any shell variables set or used + by the various .sc scripts to allow inadvertant use of these + names as normal environment variables by the person running + configure. + + * Makefile.in (ed10velf.c): Use tdir_d10v, not tdir_arcelf. + +Fri Aug 16 14:15:41 1996 James G. Smith <jsmith@cygnus.co.uk> + + * scripttempl/armcoff.sc (__bss_start__, __bss_end__, + __data_start__, __data_end__): Added to keep in sync. with the + default ARM crt0.s. Added __CTOR_LIST__ and __DTOR_LIST__ support. + +Thu Aug 8 14:24:56 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldcref.c (check_reloc_refs): If info->same, look for any symbol + defined in info->defsec, not just the section symbol. + +Wed Aug 7 14:40:48 1996 Philippe De Muyter <phdm@info.ucl.ac.be> + + * configure.in: Call BFD_NEED_DECLARATION on strstr and sbrk. + * acconfig.h (NEED_DECLARATION_STRSTR): New macro. + (NEED_DECLARATION_SBRK): New macro. + * configure, config.in: Rebuild. + * sysdep.h (strstr): Declare if NEED_DECLARATION_STRSTR. + * ldmain.c (sbrk): Declare if HAVE_SBRK and + NEED_DECLARATION_SBRK. + + * ldlang.c (lang_record_phdrs): Cast xmalloc and xrealloc return. + +Mon Aug 5 16:26:14 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlex.l: Recognize OVERLAY. + * ldgram.y: Add section_phdr field to %union. + (section): Handle phdr_opt result. Add OVERLAY case. + (opt_exp_without_type): New nonterminal. + (phdr_opt): Return list of phdrs. + (overlay_section): New nonterminal. + * ldlang.c: Include <ctype.h>. + (lang_leave_output_section_statement): Add phdrs parameter. + Change all callers. + (lang_section_in_phdr): Remove. + (overlay_vma, overlay_lmn, overlay_max): New static variables. + (struct overlay_list): Define. + (overlay_list): New static variable. + (lang_enter_overlay, lang_enter_overlay_section): New functions. + (lang_leave_overlay_section, lang_leave_overlay): New functions. + * ldlang.h (lang_leave_output_section_statement): Update + declaration for new parameter. + (lang_section_in_phdr): Don't declare. + (lang_enter_overlay, lang_enter_overlay_section): Declare. + (lang_leave_overlay_section, lang_leave_overlay): Declare. + * ld.texinfo (Overlays): New node under SECTIONS, documenting + overlays. + + * ldlex.l: Recognize MAX and MIN. + * ldgram.y (MAX, MIN): New terminals. + (exp): Recognize MAX and MIN. + * ldexp.c (fold_binary): Handle MAX and MIN. + * ld.texinfo (Arithmetic Functions): Document MAX and MIN. + + * ld.texinfo (PHDRS): Use @cindex, not @kindex, for program header + index entries. + + * ldgram.y (SIZEOF, ADDR): Do not specify type. + + * ldcref.c (check_nocrossref): Skip symbols with no output + sections. + +Fri Aug 2 14:57:49 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldgram.y (LOADADDR): New terminal. + (exp): Handle LOADADDR. + * ldlex.l: Recognize LOADADDR. + * ldexp.c (exp_print_token): Add LOADADDR. + (fold_name): Implement LOADADDR. + * ldlang.c (exp_init_os): Treat LOADADDR like ADDR. + * ld.texinfo (Arithmetic Functions): Document LOADADDR. + +Thu Aug 1 12:52:19 1996 Ian Lance Taylor <ian@cygnus.com> + + * ld.h (check_nocrossrefs): Declare. + * ldlang.h (struct lang_nocrossref): Define. + (struct lang_nocrossrefs): Define. + (nocrossref_list): Declare. + (lang_add_nocrossref): Declare. + * ldlex.l: Recognize NOCROSSREFS keyword. + * ldgram.y (%union): Add nocrossref field. + (NOCROSSREFS): New terminal. + (ifile_p1): Recognize NOCROSSREFS. + (nocrossref_list): New nonterminal. + * ldlang.c (nocrossref_list): Define. + (lang_add_nocrossref): New function. + * ldmain.c (main): If nocrossref_list is not NULL, call + check_nocrossrefs. + (warning_callback): Free symbols if there is no place to store + them. + (notice): Call add_cref if nocrossref_list is not NULL. + * ldcref.c: Include "ldexp.h" and "ldlang.h". + (check_nocrossrefs): New function. + (check_nocrossref): New static function. + (struct check_refs_info): Define. + (check_refs, check_reloc_refs): New static functions. + * Makefile.in: Rebuild dependencies. + * ld.texinfo (Option Commands): Document NOCROSSREFS. + + * ld.texinfo (Section Placement): Improve the wording of the + wildcard documentation. Mention that wildcards are only searched + for on the command line, not in the file system. + + * emultempl/sunos.em (gld${EMULATION_NAME}_after_open): Move + definition of lib_path inside condition where it is used. + +Wed Jul 31 13:17:10 1996 Martin M. Hunt <hunt@pizza.cygnus.com> + + * emulparams/d10velf.sh: Now works with elf.sc. + +Wed Jul 31 11:52:03 1996 Martin M. Hunt <hunt@pizza.cygnus.com> + + * emulparams/d10velf.sh (SCRIPT_NAME): Change to vanilla. + +Tue Jul 30 14:46:42 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_size_sections): Add the section VMA to the result + value when computing the address of a section. + + * ld.h (args_type): Add cref field. + * lexsup.c (parse_args): Set command_line.cref. + * ldmain.c (main): Check command_line.cref rather than + link_info.notice_all. + (notice): Likewise. + + * ldcref.c (output_one_cref): Don't crash if a symbol is defined + in a section without an owner. + +Mon Jul 29 17:23:33 1996 Ian Lance Taylor <ian@cygnus.com> + + * fnmatch.h, fnmatch.c: New files. + * ldlex.l: Remove unused definition of FILENAME. Add definition + of WILDCHAR. In SCRIPT mode, accept any sequence of WILDCHAR as a + NAME. + * ldgram.y (file_NAME_list): Accept '*' and '?' specially. + (input_section_spec): Accept '?' specially. + (statement): Change exp to mustbe_exp in length and FILL cases. + (section): Call ldlex_script before section statements, and call + ldlex_popstate after them. + * ldlang.c: Include "fnmatch.h". + (wildcardp): New static function. + (wild_section): Permit the section name to be a wildcard. + (wild_file): New static function, broken out of wild. + (wild): Call wild_file. Permit the file name to be a wildcard. + (open_input_bfds): Don't call lookup_name for a wildcard pattern. + * Makefile.in: Rebuild dependencies. + (CFILES): Add fnmatch.c. + (HFILES): Add fnmatch.h. + (OFILES): Add fnmatch.o. + * ld.texinfo: Document that file and section names can now be + wildcard patterns. + + * ldlang.c (lang_place_orphans): Correct condition: place a common + section if not relocateable or if common definitions are forced. + +Wed Jul 24 12:16:38 1996 Martin M. Hunt <hunt@pizza.cygnus.com> + + * emulparams/d10velf.sh (SCRIPT_NAME): Change to elf. + +Wed Jul 24 13:38:22 1996 Michael Meissner <meissner@wogglebug.tiac.net> + + * configure.tgt (d10v-*-*): Don't require the -elf, allow plain d10v. + +Tue Jul 23 10:36:19 1996 Martin M. Hunt <hunt@pizza.cygnus.com> + + * Makefile.in (ed10velf.c): New target. + * configure.tgt (d10v-*-elf*): New target. + * emulparams/d10velf.sh: New file. + +Thu Jul 18 16:25:39 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.tgt (sparc*-*-sysv4*): New target. From Andrew Gierth + <ANDREWG@microlise.co.uk>. + + * configure.host: Change irix5 to irix[56]*. + * configure.tgt: Likewise. + +Wed Jul 17 10:52:46 1996 Kim Knuttila <krk@cygnus.com> + + * emultempl/pe.em (sort_sections): Pay attention to return code. + + * ldmisc.c (demangle): Remove all prefix '.'s from a name. + +Mon Jul 15 11:49:49 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Round + the value of __start_SECNAME to the alignment required by the + section to be placed. + +Tue Jul 9 12:09:02 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.tgt (mips*el-*-elf*): Use elf32elmip. + (mips*-*-elf*): Use elf32ebmip. + * emulparams/elf32bmip.sh (EMBEDDED): Don't define. + * emulparams/elf32lmip.sh (EMBEDDED): Don't define. + * emulparams/elf32elmip.sh: New file; copy of elf32lmip.sh with + EMBEDDED defined. + * emulparams/elf32ebmip.sh: New file; copy of elf32bmip.sh with + EMBEDDED defined. + * emulparams/elf32b4300.sh (EMBEDDED): Define. + * emulparams/elf32l4300.sh (EMBEDDED): Define. + * Makefile.in (ALL_EMULATIONS): Add eelf32ebmip.o eelf32elmip.o. + (eelf32ebmip.c, eelf32elmip.c): New targets. + +Thu Jul 4 12:01:03 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldver.c (ldversion): Set version to cygnus-2.7.1. + + * Released binutils 2.7. + + * emulparams/pc532macha.sh: Rename from pc532machaout.sh to avoid + System V file name limitations. + * configure.tgt (nc32k-pc532-mach*, ns32k-pc532-ux*): Use + pc532macha rather than pc532machaout. + * Makefile.in (ALL_EMULATIONS): Change epc532machaout.o to + epc532macha.o. + (epc532macha.c): Rename target from epc532machaout.c. + +Wed Jul 3 11:40:10 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (print_padding_statement): Use %u, not %x, to print + fill value. + +Sun Jun 30 11:16:43 1996 Stan Shebs <shebs@andros.cygnus.com> + + * mpw-eppcmac.c: Update to reflect May 23 change to aix.em. + +Thu Jun 27 14:03:42 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/sunos.em (gld${EMULATION_NAME}_find_so): Put the .sa + file just before the .so file, rather than just after. + + * configure.host: Use -print-file-name=FILE rather than piping + -print-libgcc-file-name through sed. + (i[345]86*-*-sco*, i[345]86-*-isc*): Create crtbegin.o and + crtend.o files, in case gcc doesn't use them. + * Makefile.in (mostlyclean): Remove crtbegin.o and crtend.o. + +Wed Jun 26 15:57:21 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.tgt (mips*-dec-osf*): New target. + +Tue Jun 25 22:15:29 1996 Jason Molenda (crash@godzilla.cygnus.co.jp) + + * Makefile.in (bindir, libdir, datadir, mandir, infodir, includedir, + INSTALL_PROGRAM, INSTALL_DATA): Use autoconf-set values. + (docdir): Removed. + * configure.in (AC_PREREQ): autoconf 2.5 or higher. + (AC_PROG_INSTALL): Added. + * configure: Rebuilt. + +Mon Jun 24 18:48:16 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * scripttempl/elfppc.sc (_GLOBAL_OFFSET_TABLE_): Don't do a + PROVIDE of _GLOBAL_OFFSET_TABLE_, since it needs to be at a + non-fixed location. + +Mon Jun 24 17:55:31 1996 Jouke Numan <jnuman@bazis.nl> + + * ldlang.h (enum section_type): Define. + (lang_output_section_statement_type): Remove loadable field. Add + sectype field. + (lang_enter_output_section_statement): Change flags parameter in + prototype to sectype. + * ldgram.y (typebits): Remove. + (sectype): New static variable. + (opt_at): Use sectype rather than typebits. + (type): Set sectype rather than typebits. + (atype): Likewise. + * ldlex.l: Recognize DSECT, COPY, INFO, and OVERLAY in + EXPRESSION mode. + * ldlang.c (lang_output_section_statement_lookup): Set sectype + field rather than loadable field. + (wild_doit): Check sectype rather than loadable. + (lang_record_phdrs): Likewise. + (lang_enter_output_section_statement): Rename flags parameter to + sectype. Set sectype field rather than loadable field. Set flags + field based on sectype. + +Mon Jun 24 12:00:32 1996 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/elf.sc: Force .stab* and .comment sections to start + at 0. + + * configure.in: On alpha*-*-osf*, link against libbfd.a if not + using shared libraries. + * configure: Rebuild with autoconf 2.10. + +Fri Jun 21 17:40:56 1996 Joel Sherrill <joel@merlin.gcs.redstone.army.mil> + + * configure.tgt: Add support for *-*-rtems* configurations. + +Fri Jun 21 13:05:51 1996 Richard Henderson <rth@tamu.edu> + + * configure.tgt (alpha-*-linuxecoff*): New target. + (alpha-*-linux*): Use elf64alpha. + * emulparams/elf64alpha.sh: New file. + * emultempl/elf32.em: If ELFSIZE is not set, set it to 32. Use + ${ELFSIZE} rather than 32 when calling BFD routines. + (hold_rodata): New static variable. + (gld${EMULATION_NAME}_place_orphan): Use hold_rodata for a + readonly section that is not code. + (gld${EMULATION_NAME}_place_section): Set hold_rodata. Don't use + a .rel section unless its bfd_section field is not NULL. + * Makefile.in (ALL_EMULATIONS): Add eelf64alpha.o. + (eelf64alpha.c): New target. + +Fri Jun 21 12:45:46 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldmisc.c (vfinfo): Correct handling of 0 in %W case. + +Thu Jun 20 13:55:28 1996 Ian Lance Taylor <ian@cygnus.com> + + Add enough support to understand the gcc svr3.ifile script: + * ldlex.l: Recognize BLOCK and GROUP in EXPRESSION context. Add + BIND keyword. + * ldgram.y: Add BIND token. + (section): Recognize GROUP. + (opt_ext_with_type): Recognize a couple of cases of BIND. + * ldlang.c (init_os): Don't do anything if section is already + initialized. Call exp_init_os on addr_tree field. + (exp_init_os): New static function. + (map_input_to_output_sections): Call exp_init_os on assignment + expression. + (lang_place_orphans): Check for common sections by name COMMON + rather than by common_section field. Don't warn about absence of + [COMMON] command. + + * ldlang.h (lang_input_statement_type): Remove useless fields + common_section, common_output_section, and complained, as well as + all references to them. + + * ldexp.c: Reindent a lot of code. + (exp_fold_tree): Call FAIL rather than einfo in default case. + +Wed Jun 19 11:40:14 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.host (m88*-*-dgux*): Quote HOSTING_CRT0. From + <randall.hron@medaphis.com>. + +Tue Jun 18 15:53:09 1996 Jeffrey A. Law <law@rtl.cygnus.com> + + * scripttempl/h8300s.sc: New file for H8/S. + * emulpararms/h8300s.sh: New file for H8/S. + * Makefile.in (ALL_EMULATIONS): Add H8/S. + (e_h8300s.c): Add dependencies. + * configure.tgt: Add H8/S to targ_extra_emuls. + +Tue Jun 18 17:55:39 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.tgt (i[345]86*-*-isc*): New target. From + <uddeborg@carmen.se>. + +Wed Jun 12 12:46:21 1996 Ian Lance Taylor <ian@cygnus.com> + + * lexsup.c: Include "libiberty.h". + (parse_args): Copy the -Y argument into memory. + (set_default_dirlist): Don't put the ':' back into the directory + list. + +Fri Jun 7 11:27:42 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/sunos.em: Include libiberty.h. + (gld${EMULATION_NAME}_set_symbols): New static function to add + LD_LIBRARY_PATH to the list of search directories. + (ld_${EMULATION_NAME}_emulation): Add new set_symbols routine. + +Thu Jun 6 11:50:31 1996 Ian Lance Taylor <ian@cygnus.com> + + * emulparams/elf32bmip.sh (OTHER_GOT_SYMBOLS): Use ALIGN(16) + rather than . when computing _gp value. From Per Fogelstrom. + * emulparams/elf32lmip.sh (OTHER_GOT_SYMBOLS): Likewise. + + * ldmain.c (main): Don't close and unlink the file on error, since + remove_output will do it anyhow. + * ldlang.c (open_output): Set boolean variable to true, not 1. + +Wed Jun 5 18:34:14 1996 James G. Smith <jsmith@cygnus.co.uk> + + * emulparams/{elf32b4300.sh,elf32l4300.sh} (SCRIPT_NAME): Use + elfmips instead of elf. + +Tue Jun 4 18:43:07 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldcref.c: New file. + * ld.h (add_cref, output_cref): Declare. + * ldmain.c (main): Initialize notice_all field. If it is set at + end of link, call output_cref. + (notice): Rename from notice_ysym. Check notice_all. + * ldmisc.c (finfo): Make globally visible. + * ldmisc.h (finfo): Declare. + * lexsup.c (OPTION_CREF): Define. + (ld_options): Add "cref". + (parse_args): Handle OPTION_CREF. + * Makefile.in: Rebuild dependencies. + (CFILES): Add ldcref.c. + (OFILES): Add ldcref.o. + * ld.texinfo, ld.1: Document --cref. + +Tue Jun 4 12:12:25 1996 Tom Tromey <tromey@csk3.cygnus.com> + + * Makefile.in (install): Make $(tooldir) and $(tooldir)/bin. + +Fri May 31 12:40:55 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/pe.em (sort_sections): Don't assume that a + wild_statement has a section name. + +Wed May 29 13:13:35 1996 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/elfmips.sc: Quote test -z argument. + + * ld.texinfo: Clarify the CONSTRUCTORS command. + +Thu May 23 16:07:44 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em (gld${EMULATION_NAME}_read_file): Initialize + file, not impfile. + +Wed May 22 11:31:30 1996 Doug Evans <dje@seba.cygnus.com> + + * ldlang.c (wild_doit): Don't copy over SEC_LINK_{ONCE,DUPLICATES} + if final link. + * emultempl/pe.em (sfunc): Renamed to sort_by_file_name. + (sort_by_section_name, sort_sections_1): New functions. + (sort_sections): Only sort by file name sections in .idata. + Add "Grouped Sections" support. + (gld${EMULATION_NAME}_place_orphan): Rewrite to support Grouped + Sections. + (gld${EMULATION_NAME}_place_section): Delete. + * scripttempl/pe.sc (.text,.data,.rdata): Add *(.foo\$). + (.CRT,.rsrc): Rewrite to use Grouped Section support. + +Tue May 21 14:31:48 1996 Stan Shebs <shebs@andros.cygnus.com> + + * mpw-eppcmac.c: Update to reflect changes to aix.em. + +Sun May 19 16:59:44 1996 Doug Evans <dje@seba.cygnus.com> + + * ldlang.c (dprint_statement): Stop printing at end of list. + +Sat May 18 13:12:05 1996 Steve Chamberlain <sac@slash.cygnus.com> + + Support for --force-exe-suffix + * ld.h (args_type): Add force_exe_suffix. + * ld.texinfo: Add documentation. + * ldmain.c (main): Add support for option. + * lexsup.c (OPTION_FORCE_EXE_SUFFIX): New. + (ld_options, parse_args): Add support for option. + +Wed May 15 12:50:25 1996 Jim Wilson <wilson@chestnut.cygnus.com> + + * emultempl/pe.em (set_pe_value): Pass 0 not 16 to strtoul call. + +Fri May 10 16:28:44 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * scripttempl/elfppc.sc (__stack): Make __stack 0 if it was + referenced but not defined. + +Thu May 9 08:52:23 1996 Rob Savoye <rob@chinadoll.cygnus.com> + + * emulparams/{elf32bmip.sh,elf32lmip.sh,mipsidt.sh,mipsidtl.sh}: + Set a new variable to signify if the final target is an embedded + system. + * scripttempl/{mips.sc,elfmips.sc}: Don't add SIZEOF_HEADERS to + .text for an embedded system. + +Tue May 7 10:56:11 1996 Doug Evans <dje@canuck.cygnus.com> + + * scripttempl/pe.em (gld${EMULATION_NAME}_place_orphan): New function. + (gld${EMULATION_NAME}_place_section): New function. + (hold_{section,use,text,rdata,data}): New static locals. + (ld_${EMULATION_NAME}_emulation): Update orphan field. + * scripttempl/pe.sc: Whitespace cleanup. Semicolon usage cleanup. + (INIT,FINI): Delete, unused. + (.text): Document orphan .text.foo sections. + (.rdata): Document orphan .rdata.foo sections. + (.data): Document orphan .data.foo sections. + +Tue May 7 11:35:46 1996 Jeffrey A Law (law@cygnus.com) + + * scripttempl/h8300.sc: Place ".tiny" sections right + after ".data" sections. + * scripttempl/h8300h.sc: Place ".tiny" sections into + the "tiny" memory region, 0xff8000 through 0xffff00. + + * scripttempl/h8300.sc: Set the entry point to the value of + "_start" rather than the start of the text segment. + * scripttempl/h8300h.sc: Likewise. + + * scripttempl/h8300.sc: Place .rodata sections before .text + sections in main ram. + * scripttempl/h8300h.sc: Likewise. + +Mon May 6 23:32:30 1996 Jeffrey A Law (law@cygnus.com) + + * scripttempl/h8300h.sc: Use "eight", not "eightbit" for the + 8-bit region and 8-bit sections. + +Wed May 1 17:50:06 1996 Doug Evans <dje@canuck.cygnus.com> + + * ldlang.c (section_already_linked): Fix typos. + +Mon Apr 29 20:31:06 1996 Doug Evans <dje@canuck.cygnus.com> + + * scripttempl/pe.sc (.endjunk): Define __end__. + +Mon Apr 29 17:05:13 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (longest_section_name): Remove. + (SECTION_NAME_MAP_LENGTH): Define. + (print_size, print_alignment, print_fill, print_section): Remove. + (print_flags): Remove. + (lang_map): Rewrite. + (print_output_section_statement): Rewrite. + (print_assignment): Rewrite. + (print_one_symbol): Rewrite. + (print_input_section): Rewrite. + (print_fill_statement): Rewrite. + (print_data_statement): Rewrite. + (print_address_statement): New static function. + (print_reloc_statement): Rewrite. + (print_padding_statement): Rewrite. + (print_wild_statement): Rewrite. + (print_statement_list): Clean up. + (print_statement): Clean up. Some minor output changes. + (print_statements): Clean up. + (load_symbols): Put another - before -whole-archive. + * ldexp.c (exp_print_tree): Change etree_value and etree_rel to + print 0x and to omit leading zeroes. For etree_rel, use %B to + print the BFD. For etree_assign, remove the space after the + destination name. + * ldwrite.c: Include "libiberty.h". + (clone_section): Call xstrdup, not strdup. + (ldwrite): Don't print any map information. + (print_symbol_table, print_file_stuff, print_symbol): Remove. + * ldmain.c (main): Call lang_map when appropriate. + * ldmisc.c (vfinfo): Add support for %W. + (print_address): Remove. + * ldmisc.h (print_address): Don't declare. + * Makefile.in: Rebuild dependencies. + +Mon Apr 29 10:29:07 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * configure.host (m68*-*-linux*): Add -dynamic-linker to + HOSTING_CRT0. Search -lgcc both before and after -lc in + HOSTING_LIBS. Look for crt{begin,end}.o in the compiler directory + at first. + (i[345]86-*-linux*): Look for crt{begin,end}.o in the compiler + directory at first. + +Fri Apr 26 14:42:27 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldmisc.h (demangle): Declare. + * ldmisc.c: Include "libiberty.h". Include demangle.h with "", + not <>. + (demangle): Make non-static. Remove remove_underscore paramter. + Always return an allocated string. + (vfinfo): Free result of demangle. Add case 'G'. Use %T to print + functionname, rather than calling demangle. Print a colon between + the BFD(section+offset) and the line number. + * ldmain.c (add_archive_element): Improve format of archive + information in map file. + (constructor_callback): Don't print anything to the map file. + * ldlang.c (lang_one_common): Improve format of common symbol + information in map file. + * ldctor.c (ldctor_build_sets): If producing a map file, print set + information. + * ldwrite.c (print_symbol_table): Print a newline before the + header in the map file. + * Makefile.in: Rebuild dependencies. + + * ldmisc.c (vfinfo): Reindent. + +Mon Apr 22 12:07:32 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_size_sections): If _cooked_size is not 0, then + don't clobber it when not relaxing. + + * ld.h (ld_config_type): Remove traditional_format field. + * ldmain.c (main): Use link_info.traditional_format rather than + config.traditional_format. + * ldlang.c (ldlang_open_output): Likewise. + * lexsup.c (parse_args): Likewise. + * emultempl/aix.em (gld${EMULATION_NAME}_parse_args): Likewise. + * mpw-eppcmac.c (gldppcmacos_parse_args): Likewise. + + * ldlang.c (wild_doit): Discard debugging sections if we are + stripping debugging information. + + * emulparams/z8002.sh (ARCH): Set to z8002, not z8k. + +Tue Apr 16 16:38:32 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldexp.c (fold_binary): Correct handling of subtraction with + absolute values. + (fold_name): Permit symbols in lang_allocating_phase_enum. + + * scripttempl/aout.sc: Only PROVIDE __stack when RELOCATING. Undo + accidental changes in last patch. + +Tue Apr 16 10:25:42 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * configure.tgt (powerpc*-*-{sysv,linux}): Add aliases. + (powerpcle*-*-{sysv,solaris}): Ditto. + +Mon Apr 15 14:50:56 1996 Rob Savoye <rob@chinadoll.cygnus.com> + + * scripttempl/aout.sc: Add PROVIDE (__stack = 0) so I can use it + in m68k/crt0.S without things blowing up. + +Fri Apr 12 16:40:56 1996 Rob Savoye <rob@chinadoll.cygnus.com> + + * scripttempl/m68kcoff.sc: Remove default address for .data so + .text, .data, and .bss are all sequential. + +Thu Apr 11 12:05:35 1996 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/m68kcoff.sc: Remove regions and simplify. + +Wed Apr 10 14:41:53 1996 Jeffrey A Law (law@cygnus.com) + + * scripttempl/h8300.sc: Add the "8-bit area" in the upper 256 + bytes of the address space. Put data from the ".eight" sections + into the 8-bit area. + * scripttempl/h8300h.sc: Likewise. + +Tue Apr 9 14:10:42 1996 Doug Evans <dje@canuck.cygnus.com> + + * emultempl/generic.em (gld${EMULATION_NAME}_before_parse): + Pass $ARCH to ldfile_set_output_arch instead of setting + ldfile_output_architecture directly. + +Tue Apr 9 14:22:15 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * scripttempl/elfppc.sc (.init,.fini): Put .init, .fini section + next to .text. Put _etext after .text, .init, .fini, and + .rodata{,2} sections. + +Tue Apr 9 12:18:57 1996 Ian Lance Taylor <ian@cygnus.com> + + * ld.texinfo: Rearrange option documentation. + + * lexsup.c (ld_options): New static array. + (parse_args): Build shortopts and longopts from ld_options array. + (help): New static function. + * ldver.h (help): Don't declare. + * ldver.c (ldversion): Reindent. + (help): Remove. + + * ld.texinfo, ld.1: Mention -E as a synonym for -export-dynamic. + +Mon Apr 8 11:56:23 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em: When checking for a native emulation, check + that the current emulation is the default emulation. + * emultempl/sunos.em: Likewise. + + * configure.in: Permit --enable-shared to specify a list of + directories. + * configure: Rebuild. + + * lexsup.c (parse_args): Add -E as a synonym for -export-dynamic, + for HP/UX compatibility. + +Fri Apr 5 14:30:14 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em (gld${EMULATION_NAME}_check_ld_so_conf): New + static function, if ${host} = ${target}. + (gld${EMULATION_NAME}_after_open): Call check_ld_so_conf to find a + needed shared library if ${host} = $[target}. + + * configure.host (i[345]86-*-linux*): Add -dynamic-linker to + HOSTING_CRT0. Search -lgcc both before and after -lc in + HOSTING_LIBS. + + * configure.tgt: Add i[345]86-*-freebsdelf* target; from John + Polstra <jdp@polstra.com>. + +Fri Apr 5 18:11:25 1996 James G. Smith <jsmith@cygnus.co.uk> + + * emulparams/elf32{b,l}4300.sh (MACHINE): Add explicit + architecture number. + * scripttempl/elf.sc: Use $MACHINE definition if present. + * configure.tgt (targ_extra_emuls): Force 4100 build to use same + template as 4300. + +Mon Apr 1 17:35:40 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_size_sections): Change region check to handle + regions which end at the highest possible address correctly. + From Roland Weber <roweber@ira.uka.de>. + + * ldlang.c (section_already_linked): New static function. + (wild_doit): Discard sections with SEC_EXCLUDE set if not doing a + relocateable link. Don't worry about section being NULL, since it + never should be. Don't call init_os unless the section is going + to be added. + (ldlang_add_file): Call section_already_linked for each section. + * ldmain.c (multiple_definition): Don't warn about multiple + definitions in sections which are being discarded. + +Sun Mar 31 00:30:47 1996 steve chamberlain <sac@slash.cygnus.com> + + * scripttempl/{ppcpe.sc, pe.sc} (.junk): Remove and use /DISCARD/. + * emultempl/pe.em (init): Remove special case PPC code. + +Fri Mar 29 00:01:29 1996 Jeffrey A Law (law@cygnus.com) + + * scripttempl/h8300.sc: Make vectors section 0xc4 bytes long + so as not to overwrite the magic syscall entry at 0xc4. + * scripttempl/h8300h.sc: Likewise. + +Thu Mar 28 11:05:47 1996 Doug Evans <dje@canuck.cygnus.com> + + * configure.tgt (sparc64-*-solaris2*): Delete. + Stick with sparc-*-solaris2*. + +Wed Mar 27 12:33:24 1996 Ian Lance Taylor <ian@cygnus.com> + + * ld.h (DISCARD_SECTION_NAME): Define to "/DISCARD/". + * ldlang.c (init_os): Fail on an attempt to initialize any section + named DISCARD_SECTION_NAME. + (wild_doit): Discard input sections assigned to an output section + named DISCARD_SECTION_NAME. + * ld.texinfo: Document use of /DISCARD/. + + * ldlang.c: Fix some indentation and comments. + +Tue Mar 26 18:14:49 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (main): Call bfd_set_error_program_name. + +Thu Mar 21 13:17:34 1996 Ian Lance Taylor <ian@cygnus.com> + + * ld.texinfo: Fix a couple of indexing entries. Mention that + --verbose displays builtin linker scripts. + + * ldmisc.c (vfinfo): case 'I': If the file is not in an archive, + and the local symbol name does not match the filename, print the + filename as well. + + Patches from John Polstra <jdp@polstra.com> for FreeBSD ELF: + * lexsup.c (parse_args): -Bshareable is a synonym for -shared. + * emulparams/elf_i386.sh (NONPAGED_TEXT_START_ADDR): Make the same + as TEXT_START_ADDR. + +Wed Mar 20 18:18:25 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * ld.texinfo: Fix typos. Use @pxref only inside parentheses. + +Wed Mar 20 16:56:15 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (add_wrap): New function. + * ldmain.h (add_wrap): Declare. + * lexsup.c (parse_args): Call add_wrap. + +Tue Mar 19 16:44:20 1996 Doug Evans <dje@canuck.cygnus.com> + + * configure.host (sparc*-*-solaris2* host): Accept any sparc variant. + +Wed Mar 13 17:47:31 1996 Jeffrey A Law (law@cygnus.com) + + * scripttempl/h8300.sc: Change name of page zero memory + from "null" to "vectors". Create an output section for + vectors. Add comments on how to explicitly place items + in the vector table. + * scripttempl/h8300h.sc: Likewise. + +Wed Mar 13 12:40:18 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/lnk960.em (machine_table): Add jx and hx. + + * genscripts.sh: Don't use ${9:-xx}, since Ultrix /bin/sh doesn't + support it. + +Tue Mar 12 12:43:59 1996 David Mosberger-Tang <davidm@koala.azstarnet.com> + + * ld.h (ld_config_type): Add warn_multiple_gp field. + * lexsup.c (parse_args): Handle --warn-multiple-gp. + * ldmain.c (warning_callback): Suppress multiple gp values warning + if --warn_multiple_gp was not used. + * ld.texinfo, ld.1: Document --warn-multiple-gp. + +Tue Mar 12 12:02:21 1996 Ian Lance Taylor <ian@cygnus.com> + + * lexsup.c (parse_args): Handle --wrap. + * ldmain.c (main): Initialize link_info.wrap_hash. + * ldexp.c (fold_name): Use bfd_wrapped_link_hash_lookup in DEFINED + and NAME cases. + * ld.texinfo, ld.1: Document --wrap. + + * configure: Rebuild with autoconf 2.8. + + Don't do SunOS style dynamic linking for sparc-aout: + * configure.tgt (sparc64-*-aout*): Use sparcaout, not sun4. + (sparclite*-fujitsu-*, sparc*-*-aout): Likewise. + (sparc*-wrs-vxworks*): Likewise. + * emulparams/sparcaout.sh: New file. + * Makefile.in (ALL_EMULATIONS): Add esparcaout.o. + (esparcaout.c): New target. + +Wed Mar 6 16:06:52 1996 J.T. Conklin <jtc@rtl.cygnus.com> + + * scripttempl/elfppc.sc (.sdata2, .sbss2): Implement Feb 2 change + in a different manner to work around differences in shell variable + expansion. + +Wed Mar 6 18:08:18 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldemul.h (ldemul_unrecognized_file): Declare. + (ldemulation_xfer_type): Add unrecognized_file field. + * ldemul.c (ldemul_unrecognized_file): New function. + * ldlang.c (load_symbols): If a file can not be recognized, call + ldemul_unrecognized_file before trying it as a linker script. + * aix.em (gld${EMULATION_NAME}_unrecognized_file): New static + function. + (gld${EMULATION_NAME}_read_file): Use FOPEN_RT, not "r". + (ld_${EMULATION_NAME}_emulation): Initialize unrecognized_file. + +Mon Mar 4 14:11:17 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (wild): Handle foo.a(.text) by mapping each included + member of foo.a separately. From Jouke Numan <jnuman@bazis.nl>. + +Fri Mar 1 10:24:59 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * emultempl/elf32.em (gld${EMULATION_NAME}_find_exp_assignment): + Search trinary.cond rather than searching trinary.lhs twice. + +Tue Feb 27 15:08:43 1996 Stan Shebs <shebs@andros.cygnus.com> + + * mpw-make.sed: Edit out shared library support. + (@TDIRS@): Edit out, can't use genscripts. + +Tue Feb 27 15:09:21 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * configure.tgt (m68k-*-linuxaout*, m68k-*-linux*): New targets. + * emulparams/m68klinux.sh: New file. + * emultempl/linux.em (gld${EMULATION_NAME}_before_allocation): + Call bfd_${EMULATION_NAME}_size_dynamic_sections instead of + bfd_linux_size_dynamic_sections. + * Makefile.in (ALL_EMULATIONS): Add em68klinux.o. + (em68klinux.c): New target. + * configure.host (m68*-*-linuxaout*, m68*-*-linux*): New hosts. + +Tue Feb 27 12:55:46 1996 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in (ALL_EMULATIONS): Sort into alphabetical order. + Fill in missing entries. + + * lexsup.c (parse_args): Recognize --no-whole-archive. + * ldlang.h (lang_input_statement_type): Add whole_archive field. + * ldlang.c (new_afile): Set whole_archive field. + (load_symbols): Check input file specific whole_archive field + rather than global variable. + * ld.texinfo, ld.1: Document --no-whole-archive. + +Tue Feb 20 16:07:00 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.tgt: Correct gldi960 to gld960. + +Mon Feb 19 11:16:44 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em (gld${EMULATION_NAME}_check_needed): Check + the SONAME if it is available. + (gld${EMULATION_NAME}_stat_needed): Use the SONAME, not the + filename, when checking for conflicting library versions. Don't + assume that the suffix is only numbers and dots. + + * ld.texinfo: Mention that -R can be used for -rpath. + +Sun Feb 18 15:05:17 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.host: Check for 'do not mix' from native linker before + trying to use -rpath. + +Thu Feb 15 13:58:06 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.in: Remove explicit substitution of CFLAGS; autoconf + does it anyhow. + * configure: Rebuild. + * Makefile.in (LDFLAGS): Set to @LDFLAGS@. + + * configure.in: Call AC_PROG_CC before configure.host. + * configure: Rebuild. + * configure.host: Remove go32 host, since it should no longer be + necessary. Don't set CC for romp host. + + * scripttempl/elf.sc: Don't skip a page in virtual memory space if + the text segment ends exactly on a page boundary. + + * configure.in: Substitute RPATH_ENVVAR. + * configure: Rebuild. + * configure.host: Set RPATH_ENVVAR. + * Makefile.in (RPATH_ENVVAR): New variable. + (check): Use $(RPATH_ENVVAR) rather than LD_LIBRARY_PATH. + +Wed Feb 14 18:49:01 1996 Alan Modra <alan@spri.levels.unisa.edu.au> + + * configure.in: Redo emulation handling so that each emulation + searches the correct tool directory, based on the target alias. + For example, "configure --enable-targets=m68k-coff i386-linux" + will search /usr/local/i386-linux/lib for linux and + /usr/local/m68k-coff/lib for m68k-coff. + * configure: Rebuild. + * configure.tgt: Add special tdir settings for Linux. + * Makefile.in: Add @TDIRS@. Pass "$(tdir_EMUL)" to ${GENSCRIPTS} + for each eEMUL.c target. + * genscripts.sh: Accept specific alias as 9th argument, and use it + in LIB_PATH. + +Wed Feb 14 16:38:36 1996 Martin Anantharaman <martin@mail.imech.uni-duisburg.de> + + * ldlang.c (lang_set_startof): Don't do anything for a + relocateable link. + + * ldgram.y (mri_script_file): Call mri_draw_tree. + * mri.c (mri_draw_tree): Make globally visible. Don't bother to + create memory regions. + (mri_load): Don't call mri_draw_tree. + * mri.h (mri_draw_tree): Declare. + + * configure.tgt (m68*-*-psos): New target. + * emulparams/m68kpsos.sh: New file. + * scripttempl/psos.sc: New file. + * Makefile.in (ALL_EMULATIONS): Add em68kpsos.o. + (em68kpsos.c): New target. + +Wed Feb 14 11:09:25 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.tgt (*-*-ieee*): New target; use vanilla. + + * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Strip + `:foo' from ${ARCH}. + +Tue Feb 13 15:58:58 1996 Bryan Ford <baford@snake.cs.utah.edu> + + * scripttempl/i386msdos.sc: Don't pad the .text section. Put + .rodata in .data. + +Tue Feb 13 14:04:19 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.host: Set HDLFLAGS for *-*-hpux with --enable-shared. + + * emultempl/elf32.em (gld${EMULATION_NAME}_stat_needed): Warn if + it looks like we might be linking in two different versions of the + same shared library. Based on a patch from H J Lu <hjl@zoom.com>. + +Thu Feb 8 19:25:54 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_size_sections): Increment the section size when a + padding statement is encountered. + +Wed Feb 7 14:01:33 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.in: Look for --enable-shared. Change the value of + BFDLIB when linking against a shared library on SunOS. + * configure: Rebuild. + * configure.host: If using a shared BFD library, try to pass a + reasonable -rpath option when linking. + * Makefile.in (BFDLIB): Set to @BFDLIB@. + +Tue Feb 6 12:29:14 1996 Doug Evans <dje@charmed.cygnus.com> + + * emulparams/elf64_sparc.sh (ARCH): Change to `sparc:v9'. + * emultempl/generic.em: Strip `:foo' from ${ARCH}. + +Mon Feb 5 16:25:30 1996 Ian Lance Taylor <ian@cygnus.com> + + Support for building bfd and opcodes as shared libraries, based on + patches from Alan Modra <alan@spri.levels.unisa.edu.au>: + * configure.in (HLDFLAGS): New substitution. + * configure: Rebuild. + * configure.host: Set HLDFLAGS on SunOS. + * Makefile.in (HLDFLAGS): New variable. + (BFDDEP): New variable. + (BFDLIB): Change to -L../bfd -lbfd. + ($(LD_PROG)): Depend upon $(BFDDEP) rathern than $(BFDLIB). Use + $(HLDFLAGS) in link. + (check): Set LD_LIBRARY_PATH in the environment. + +Fri Feb 2 19:26:25 1996 Michael Meissner <meissner@wogglebug.tiac.net> + + * scripttempl/elfppc.sc (.sdata2, .sbss2): Put .sdata2 and .sbss + in the read-only section, not read/write unless we are making a + shared library. + (.debug*): Add dwarf debug sections. + (.rela.{sdata*,sbss*}): Add sections. + +Fri Feb 2 16:50:21 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure: Regenerate. + +Thu Feb 1 10:50:46 1996 Ian Lance Taylor <ian@cygnus.com> + + * emulparams/elf_i386.sh (TEXT_START_ADDR): Change to 0x8048000, + for SVR4 compatibility. + + * ldexp.c (exp_fold_tree): Correct handling of ABSOLUTE. + +Wed Jan 31 17:30:19 1996 Steve Chamberlain <sac@slash.cygnus.com> + + * configure.tgt (i[345]86-*-cygwin32, powerpcle-*-cygwin32): New. + * emultempl/pe.em (definfo init): Make the default stack reserve + of a PPC larger. + +Wed Jan 31 14:34:23 1996 Richard Henderson <rth@tamu.edu> + + * configure.tgt (m68*-apple-aux*): New target. + * emulparams/m68kaux.sh: New file. + * scripttempl/m68kaux.sc: New file. + * Makefile.in (ALL_EMULATIONS): Add em68kaux.o. + (em68kaux.c): New target. + +Tue Jan 30 13:18:56 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em (gld${EMULATION_NAME}_parse_args): Ignore + -bnoentry, since the right thing tends to happen anyhow. + +Mon Jan 29 12:29:26 1996 Ian Lance Taylor <ian@cygnus.com> + + * ld.texinfo, ld.1: Document -export-dynamic. + +Fri Jan 26 11:11:55 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * emultempl/sunos.em: Check for native compile by comparing + ${target} and ${host}. + +Thu Jan 25 16:46:58 1996 James G. Smith <jsmith@cygnus.co.uk> + + * emulparams/{elf32b4300.sh, elf32l4300.sh}: Changed + TEXT_START_ADDR to allow use on IDT and PMON systems. + +Wed Jan 24 20:59:40 1996 Steve Chamberlain <sac@slash.cygnus.com> + + * emultempl/pe.em (gld_${EMULATION_NAME}_parse_args): + correct spelling. + +Wed Jan 24 16:59:19 1996 Doug Evans <dje@charmed.cygnus.com> + + * configure.tgt (sparc64-*-solaris2*): New configuration. + (sparc64-*-aout*): Renamed from sparc64*. + +Mon Jan 22 13:01:35 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * Makefile.in (GENSCRIPTS): Pass @host@ @target@ @target_alias@. + * genscripts.sh: Set host, target and target_alias variables. + Check for native compile by comparing ${target} and ${host}. + * emultempl/elf32.em: Likewise. + * scripttempl/elfmips.sc: Test ${target}, not ${target_alias}. + +Mon Jan 22 11:03:23 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * scripttempl/elfppc.sc: Refine eabi support to better support + .sdata, .sdata2, .sbss, etc. sections. + +Tue Jan 16 15:16:58 1996 Ian Lance Taylor <ian@cygnus.com> + + * ldgram.y (%union): Add phdr field. + (phdr): Use phdr_qualifiers rather than opt_hdrs and opt_at. + (phdr_qualifiers): New nonterminal. Add support for FLAGS. + (opt_hdrs, hdr): Remove. + (phdr_val): New nonterminal. + * ldlang.c (lang_new_phdr): Replace hdrs parameter with filehdr + and phdrs parameters. Add flags parameter. + (lang_record_phdrs): Update for changes to lang_phdr. Pass flags + to bfd_record_phdr. + * ldlang.h (struct lang_phdr): Replace hdrs field with filehdr and + phdrs fields. Add flags field. + (LANG_PHDR_FILEHDR, LANG_PHDR_PHDRS): Remove. + (lang_new_phdr): Update declaration. + * ld.texinfo: Document FLAGS. + +Mon Jan 15 15:07:19 1996 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): + Don't make a shared library because of an undefined reference to + __GLOBAL_OFFSET_TABLE_. + + Add some Irix 5 support, mostly from Kazumoto Kojima + <kkojima@info.kanagawa-u.ac.jp>: + * emulparams/elf32bmip.sh (SCRIPT_NAME): Change to elfmips. + (SHLIB_TEXT_START_ADDR): Define. + (OTHER_GOT_SYMBOLS): Define. + (OTHER_READWRITE_SECTIONS): Remove initialization of _gp. + (EXECUTABLE_SYMBOLS): Don't define. + (DYNAMIC_LINK): Don't define. + * emulparams/elf32lmip.sh: Same changes as elf32bmip.sh. + * scripttempl/elfmips.sc: New file. + * configure.host (mips*-dec-bsd*): Change mips to mips*. + (mips*-sgi-irix4*): Likewise. + (mips*-sgi-irix5*): New entry. + * Makefile.in (eelf32bmip.c): Depend upon elfmips.sc rather than + elf.sc. + (eelf32lmip.c): Likewise. + +Sat Jan 13 09:41:43 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * scripttempl/elfppc.sc: Remove support for .rel.* sections. Add + .rela.got.neg section. + +Fri Jan 12 14:56:19 1996 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/sh.sc: Only build constructors when CONSTRUCTING. + + * ldmisc.c: Include <stdarg.h> rather than <varargs.h> if + ANSI_PROTOTYPES is defined. Remove special handling of + WINDOWS_NT. Various indendation fixes. + (vfinfo): Change fmt parameter to const char *. + (info_msg): Write <stdarg.h> version. + (einfo, minfo, finfo): Likewise. + (info_assert): Change file parameter to const char *. + * ldmisc.h (einfo, minfo, info_msg): If ANSI_PROTOTYPES is + defined, use a real prototype. + (info_assert): Change first parameter to be const char *. + +Fri Jan 12 13:29:55 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * scripttempl/elfppc.sc: Add support for .sdata2/.sbss2, etc. Add + in old support that 2.7.2 needs, but the current compiler does + not. + + * Makefile.in (eelf32{,l}ppc.c): Fix up dependencies to use the + correct Linker script template. + + * emulparams/elf32{,l}ppc.sh (TEXT_START_ADDR): Set to 0x40000, + not 0x400000. + (DATA_ADDR,NONPAGED_TEXT_START_ADDR): Delete. + +Tue Jan 9 15:53:02 1996 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/alpha.sc: Put .rconst right after .rdata. + +Fri Jan 5 14:07:45 1996 Steve Chamberlain <sac@slash.cygnus.com> + + * emultempl/pe.em (gld_${EMULATION_NAME}_before_allocation): + sort using right pointer. + +Fri Jan 5 12:25:47 1996 Michael Meissner <meissner@tiktok.cygnus.com> + + * scripttempl/elfppc.sc: Remove support for creating special + labels for eabi section begin/end here. The compiler now uses + crt{i,n}.o to create these symbols. + +Thu Jan 4 17:08:58 1996 Ian Lance Taylor <ian@cygnus.com> + + * configure.host: Change existing Linux HOSTING_CRT0 to be used + for a.out only, and put in appropriate HOSTING_CRT0 and + HOSTING_LIBS values for Linux ELF. + +Thu Jan 4 12:02:05 1996 Doug Evans <dje@canuck.cygnus.com> + + * scripttempl/h8300.sc: Use all 64K for ram. + * scripttempl/h8300h.sc: Define 256K ram size. + +Thu Dec 21 15:57:18 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em (gld${EMULATION_NAME}_before_allocation): Pass + export_defines as true to bfd_xcoff_size_dynamic_sections if -unix + was used, regardless of whether -bE was used. + +Tue Dec 19 17:35:38 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em (gld${EMULATION_NAME}_after_open): Only set + relocateable before calling ldctor_build_sets if the output file + is in an XCOFF format. + +Fri Dec 15 16:34:36 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldwrite.c (build_link_order): When handling a data statement, if + the endianness of the output file is unknown, use the endianness + of the input file. + +Tue Dec 12 13:55:41 1995 Stan Shebs <shebs@andros.cygnus.com> + + * mpw-config.in: Recognize mips-*-* as equivalent to + mips-idt-ecoff. + * mpw-eppcmacos.c: Rename to shorter mpw-eppcmac.c. + * mpw-ld.r: Add version resources. + (cfrg): Use symbolic instead of literal name for executable. + +Mon Dec 11 15:13:41 1995 Kim Knuttila <krk@cygnus.com> + + * scripttempl/ppcpe.sc (FINI): Moved the .reloc section. + +Wed Dec 6 14:33:50 1995 Doug Evans <dje@canuck.cygnus.com> + + * ldlang.c (print_statement{,s}): Delete duplicate prototype. + (print_statement_list): Renamed from print_statement. All callers + updated. + (print_statement): New function to print just one statement. + (print_{data,reloc,padding}_statement): Don't crash if + output_section == NULL. + (dprint_statement): New function. + + * emultempl/pe.em (gld_${EMULATION_NAME}_before_allocation): Fix + call to sort_sections. + +Wed Dec 6 14:59:06 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em (unix_ld): New static variable. + (gld${EMULATION_NAME}_parse_args): Handle -unix. + (gld${EMULATION_NAME}_before_allocation): If unix_ld, pass + gc as false and export_defineds as true to size_dynamic_sections. + + * ldexp.c (exp_fold_tree): Permit assignments to dot in the final + phase if the current section is abs_output_section. + + +Tue Dec 5 09:49:39 1995 Doug Evans <dje@canuck.cygnus.com> + + * emultempl/pe.em (gld_${EMULATION_NAME}_before_allocation): Fix call + to sort_sections. + +Fri Dec 1 16:48:36 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldgram.y (PHDRS): New token. + (ifile_p1): Accept phdrs. + (section): Accept phdr_opt at the end of the section definition. + (phdr_op): New nonterminal. + (phdrs, phdr_list, phdr, phdr_type, opt_hdrs, hdr): Likewise. + * ldlex.l: Accept PHDRS. + * ldlang.h (struct lang_output_section_phdr_list): Define. + (lang_output_section_statement_type): Add phdrs field. + (struct lang_phdr): Define. + (LANG_PHDR_FILEHDR, LANG_PHDR_PHDRS): Define. + (lang_new_phdr): Declare. + * ldlang.c (lang_phdr_list): New static variable. + (lang_output_section_statement_lookup): Initialize phdrs field. + (lang_process): Call lang_record_phdrs. + (lang_new_phdr): New function. + (lang_section_in_phdr): New function. + (lang_record_phdrs): New static function. + * ld.texinfo: Document PHDRS. + +Thu Nov 30 13:14:30 1995 Kim Knuttila <krk@cygnus.com> + + * scripttempl/ppcpe.sc: Moved .edata into its own section to + expose it. + +Thu Nov 30 11:32:34 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 <manfred@lts.sel.alcatel.de> + + * configure.host (m68*-motorola-sysv): Define HOSTING_CRT0 and + HOSTING_LIBS for testing. + (m88*-motorola-sysv3): Define HOSTING_CRT0 and HOSTING_LIBS for + testing. + +Tue Nov 28 12:14:53 1995 Ian Lance Taylor <ian@cygnus.com> + + * lexsup.c (parse_args): Set config.dynamic_link to false for -N + and -n. + +Mon Nov 27 13:12:09 1995 Ian Lance Taylor <ian@cygnus.com> + + * configure: Rebuild with autoconf 2.7. + +Fri Nov 24 18:35:35 1995 Doug Evans <dje@canuck.cygnus.com> + + * scripttempl/pe.sc: Two .junk's is too much junk. + +Tue Nov 21 16:14:32 1995 Ian Lance Taylor <ian@cygnus.com> + + * configure.in: Use BFD_NEED_DECLARATION. + * acconfig.h: Put NEED_DECLARATION_FREE in @TOP@ section. + * configure, config.in: Rebuild with autoconf 2.6. + + * ldmain.c (constructor_callback): Don't warn about BFD_RELOC_CTOR + being unsupported if this is not a relocateable link and the input + BFD supports it, since ldctor_build_sets can cope with that case. + +Fri Nov 17 16:23:15 1995 Stan Shebs <shebs@andros.cygnus.com> + + * configure.tgt (powerpc-*-macos*): New target. + * emulparams/ppcmacos.sh: New file, PowerMac emulation. + * Makefile.in (ALL_EMULATIONS): Add eppcmacos.o. + (eppcmacos.c): New target. + * mpw-eppcmacos.c: Update. + * mpw-make.sed: Edit out attempts to use {GENSCRIPTS}. + +Fri Nov 17 10:37:27 1995 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in (CC_FOR_TARGET): Use @host@ and @target@, not + $(host_canonical) and $(target_canonical). + (CXX_FOR_TARGET): Likewise. + +Thu Nov 16 11:23:42 1995 Doug Evans <dje@canuck.cygnus.com> + + * scripttempl/pe.sc (.endjunk): Move definition of `end' to here + so the malloc heap begins at a sane place. + +Thu Nov 16 03:09:32 1995 Ken Raeburn <raeburn@cygnus.com> + + Version 2.6 released. + * ldver.c (ldversion): Update to 2.6. + + * Makefile.in (mostlyclean): Delete ldemul-list.h here, but not + $(GENERATED_*FILES), since they need to be retained by distclean. + (maintainer-clean, realclean): Delete them here. + +Tue Nov 14 17:08:06 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/pe.em (gld_${EMULATION_NAME}_parse_args): Open the + base file with FOPEN_WB, not "w". + + * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Use the + environment variable LD_RUN_PATH if neither -rpath nor -rpath-link + were used. + (gld${EMULATION_NAME}_before_allocation): Use the environment + variable LD_RUN_PATH if -rpath was not used. + * ld.texinfo, ld.1: Document LD_RUN_PATH. + +Thu Nov 9 13:09:29 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em (gld${EMULATION_NAME}_parse_args): Recognize + -bl and -bloadmap options. + + * ldfile.c (ldfile_try_open_bfd): If bfd_error_invalid_target, + report a better error. + + * emultempl/aix.em (gld${EMULATION_NAME}_before_allocation): Add + new local variable special_sections, and pass it to + size_dynamic_sections. Look through the results, and move the + sections around in the mapping so that they are defined correctly. + +Wed Nov 8 11:40:59 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldemul.c (ldemul_default_target): Cast getenv return value. + +Tue Nov 7 11:15:36 1995 Kim Knuttila <krk@cygnus.com> + + * emulparams/ppcpe.sh (ARCH): New file for PowerPC Portable + Executable support. + * scripttempl/ppcpe.sc: New file for PowerPC Portable Executable + support. + + * configure.tgt (targ_extra_emuls): Added powerpcle-pe target. + * Makefile.in (ALL_EMULATIONS): Added eppcpe.o target. + + * emultempl/pe.em (TARGET_IS_ppcpe): file tailoring macro + (gld_$_before_allocation): added hooks for toc construction based + on the above macro. + +Tue Nov 7 11:47:23 1995 Ian Lance Taylor <ian@cygnus.com> + + * ld.texinfo: The linker does not use _main as an entry point. + +Tue Nov 7 11:46:11 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 <manfred@lts.sel.alcatel.de> + + * scripttempl/m88kbcs.sc (.data): Calculate next boundary modulo + 0x2000 not 0x200. + +Mon Nov 6 10:59:21 1995 Ian Lance Taylor <ian@cygnus.com> + + * configure.in: Add test for whether free must be declared. + * sysdep.h: Declare free if necessary. Include "ansidecl.h". + * acconfig.h: Explain NEED_DECLARATION_FREE. + * configure, config.in: Rebuild. + + * lexsup.c (parse_args): Take B:: out of shortopts. + +Sun Nov 5 03:08:28 1995 Ken Raeburn <raeburn@cygnus.com> + + * emulparams/i386nbsd.sh (EXECUTABLE_SYMBOLS): Set __DYNAMIC to 0 + for now, as with m68k4kbsd, until shared library support gets + done. + + * configure.host: For i386 BSD variants, crt0.o lives in + /usr/lib. (True for NetBSD at least, unconfirmed for others.) + +Wed Nov 1 15:42:45 1995 Manfred Hollstein KS/EF4A 60/1F/110 #40283 <manfred@lts.sel.alcatel.de> + + * Makefile.in (ALL_EMULATIONS): Add edelta68.o. + (edelta68.c): New target. + * configure.tgt (m68*-motorola-sysv*): New target. + * emulparams/delta68.sh: New file. + * scripttempl/delta68.sc: New file. + + * scripttempl/m88kbcs.sc: Handle .init and .fini. Change section + addresses. + +Wed Nov 1 11:41:56 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldgram.y (mri_script_command): Accept ',' as well as '=' in + ALIGN and ALIGNMOD statements. + + * emultempl/aix.em: Include ldgram.h. + (gld${EMULATION_NAME}_parse_args): Handle -pD and -pT, as used on + AIX 4.1. + * Makefile.in ($(EMULATION_OFILES)): Depend upon ldgram.h. + +Tue Oct 31 18:22:24 1995 David Mosberger-Tang <davidm@azstarnet.com> + + * configure.host (alpha-*-linux*): New host. + * configure.tgt (alpha-*-linux*): New target. + +Tue Oct 31 12:36:52 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em (export_files): Remove. + (import_files): Make static. + (struct export_symbol_list): Define. + (export_symbols): New static variable. + (gld${EMULATION_NAME}_parse_args): Handle an initial -b option + correctly. Call read_file for an export file. + (gld${EMULATION_NAME}_before_allocation): Call + bfd_xcoff_export_symbol for each export symbol, rather than + calling read_file for each export file. + (gld${EMULATION_NAME}_read_file): For an export file, make the + exported symbols undefined, and store them on the export_symbols + list. + +Sat Oct 28 00:10:03 1995 steve chamberlain <sac@slash.cygnus.com> + + * emultempl/pe.em (gld_${EMULATION_NAME}_parse_args): + Don't hang if last option is unrecognised. + (gld_${EMULATION_NAME}_set_symbols): Insert created + symbols into ABS output section. + +Fri Oct 27 18:03:17 1995 Niklas Hallqvist <niklas@appli.se> + + * Makefile.in (ALL_EMULATIONS): Added support for the NetBSD + m68k4k arch. + (em68k4knbsd.c): New rule. + + * configure.tgt: Added support for the NetBSD m68k4k arch. + + * genscripts.sh, ldint.texinfo, + emulparams/{a29k,armaoutb,armaoutl,coff_sparc,ebmon29k,gld960, + gld960coff,go32,h8300,h8300h,h8500,h8500b,h8500c,h8500m,h8500s, + hp300bsd,hp3hpux,hppaelf.sh,i386aout,i386bsd,i386coff,i386go32, + i386linux,i386lynx,i386nbsd,lnk960,m68kaout,m68kcoff,m68klynx, + m88kbcs,mipsbig,mipsbsd,mipsidt,mipsidtl,mipslit,news,ns32knbsd, + pc532machaout,riscix,sa29200,sh,shl,sparclynx,sparcnbsd, + st2000,sun3,sun4,vanilla,vax,vsta,w65,z8001,z8002}.sh: Changed + PAGE_SIZE to TARGET_PAGE_SIZE. + + * emulparams/m68knbsd.h: Ditto. + (TEXT_START_ADDR, NONPAGED_TEXT_START_ADDR): We have 8K pagesize. + (EXECUTABLE_SYMBOLS): Hardcode __DYNAMIC to zero for the time + being. + + * emulparams/m68k4knbsd.sh: New file. + + * scripttempl/aout.sc: Expand EXECUTABLE_SYMBOLS if relocating. + +Fri Oct 27 17:59:09 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em: Include ldctor.h. + (gld${EMULATION_NAME}_after_open): New static function. + (gld${EMULATION_NAME}_before_allocation): Call find_relocs. + (gld${EMULATION_NAME}_find_relocs): New static function. + (gld${EMULATION_NAME}_find_exp_assignment): New static function. + (ld_${EMULATION_NAME}_emulation): Use new after_open function. + * scripttempl/aix.sc: Use CONSTRUCTORS in .data. + * ldctor.c (struct set_info): Move definition into ldctor.h. + (struct set_element): Likewise. + (sets): Make non-static. + (ldctor_add_set_entry): Add name parameter. Save it in the new + set element. + (ldctor_build_sets): Avoid being called twice. Pass set element + name to lang_add_reloc. + * ldctor.h (struct set_info): Move definition here from ldctor.c. + (struct set_element): Likewise. Add new field name. + (sets): Declare. + (ldctor_add_set_entry): Declare new name parameter. + * ldwrite.c (build_link_order): Don't insist that either name or + section be NULL in a lang_reloc_statement. + * ldmain.c (add_to_set): Pass NULL to ldctor_add_new_set_entry for + new name parameter. + (constructor_callback): Pass name to ldctor_add_new_set_entry for + new name parameter. + + * ldmisc.c (demangle): Fix indentation. Remove a leading period. + +Thu Oct 26 22:22:49 1995 Stan Shebs <shebs@andros.cygnus.com> + + * mpw-config.in: Add PowerMac target support, generate config.h. + * mac-ld.r: New file, Mac resources. + * mpw-make.sed: New file, edits Makefile.in into MPW syntax. + * mpw-make.in: Remove. + * mpw-eppcmacos.c: Prebuilt version of PowerMac linking script. + +Thu Oct 26 14:11:26 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em (gld${EMULATION_NAME}_parse_args): Treat + -static as a synonym for -bnso. + + * scripttempl/aix.sc: Move special symbols inside sections. + Always start .data at 0. + +Wed Oct 25 11:52:12 1995 Per Bothner <bothner@kalessin.cygnus.com> + + * Makefile.in (diststuff): Also make info. + (maintainer-clean realclean): Also delete *.info*. + +Wed Oct 25 11:27:25 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/aix.em: Add support for various AIX linker options, + for AIX import and export files, and for AIX shared objects. + * scripttempl/aix.sc: Add .pad. Put .ds just before the TOC. + + * ldmain.c (main): Initialize new field link_info.static_link. + + * ldmain.c (add_keepsyms_file): Add \n at end of einfo calls. + (constructor_callback): Likewise. + * ldmisc.c (vfinfo): Likewise. + * ldwrite.c (build_link_order): Likewise. + + * ld.texinfo: The MRI ALIGN directive is supported. + +Mon Oct 23 11:46:43 1995 James G. Smith <jsmith@pasanda.cygnus.co.uk> + + * emulparams/elf32vr4300.sh: Deleted. + * emulparams/elf32vr4300el.sh: Deleted. + * emulparams/elf32b4300.sh: Added. + * emulparams/elf32l4300.sh: Added. + * configure.tgt, Makefile.in: Updated the build to use the + new 8.3 unique names. + +Thu Oct 19 17:41:46 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (entry_symbol): Make non-static. + * ldlang.h (entry_symbol): Declare. + + * ldlex.l: Treat PROVIDE as a keyword in expression state. + +Wed Oct 18 17:34:06 1995 steve chamberlain <sac@slash.cygnus.com> + + * scripttempl/pe.sc (.bss): Move to be after .text + +Tue Oct 17 12:22:05 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/sunos.em (gld${EMULATION_NAME}_find_exp_assignment): + Search trinary.cond rather than searching trinary.lhs twice. From + linli@ihp.PHys.ethz.CH. + + * emultempl/sunos.em (gld${EMULATION_NAME}_find_so): Move + directory searching code into gld${EMULATION_NAME}_search_dir. + (gld${EMULATION_NAME}_search_dir): New static function, extracted + from gld${EMULATION_NAME}_find_so. + (global_needed, global_found): New static variables. + (gld${EMULATION_NAME}_after_open): New static function. + (gld${EMULATION_NAME}_search_needed): New static function. + (gld${EMULATION_NAME}_try_needed): New static function. + (gld${EMULATION_NAME}_check_needed): New static function. + (ld_${EMULATION_NAME}_emulation): Use new after_open function. + * ld.texinfo, ld.1: Mention -rpath-link on SunOS. + + * Makefile.in (eelf32ppc.c): Depend upon elf32.em, not generic.em. + (eelf32lppc.c): Likewise. + * emulparams/elf32lppc.sh (TEMPLATE_NAME): Define as elf32. + (GENERATE_SHLIB_SCRIPT): Define as yes. + +Mon Oct 16 19:11:13 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em: Struct bfd_elf_link_needed_list is now named + bfd_link_needed-list; make appropriate changes. + + * configure.tgt (powerpc-*-aix*): New target; use aixppc. + (rs6000-*-aix*): New target; use aixrs6. + * emulparams/aixppc.sh, emulparams/aixrs6.sh: New files. + * emultempl/aix.em: New file. + * scripttempl/aix.sc: New file. + * Makefile.in (ALL_EMULATIONS): Add eaixppc.o and eaixrs6.o. + (eaixppc.c, eaixrs6.c): New targets. + +Fri Oct 13 14:00:37 1995 steve chamberlain <sac@slash.cygnus.com> + + * scripttemp/pe.sc (.reloc): Move to the end. + +Tue Oct 10 17:53:22 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_finish): Don't try to use an entry_symbol from a + section which was not linked into the final output. + +Tue Oct 10 10:17:22 1995 steve chamberlain <sac@slash.cygnus.com> + + * emultempl/pe.em (gld_${EMULATION_NAME}_parse_args): Fix + fatal typos. + +Tue Oct 10 01:01:51 1995 Ian Lance Taylor <ian@cygnus.com> + + * ld.h (args_type): Add rpath_link field. + * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Search for + required dependencies in rpath_link path. Only search + LD_LIBRARY_PATH when configured native. + * lexsup.c (parse_args): Recognize -rpath-link. + * ld.1, ld.texinfo: Document -rpath-link. + +Sat Oct 7 17:07:17 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Don't + bother searching for needed libraries unless doing a final link. + +Fri Oct 6 16:26:16 1995 Ken Raeburn <raeburn@cygnus.com> + + Mon Sep 25 22:49:32 1995 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> + + * ld/ld.1: Fix formatting bugs. + +Wed Oct 4 17:37:46 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldexp.c (exp_get_abs_int): Return bfd_vma, not int. + * ldexp.h (exp_get_abs_int): Update declaration. + * ldlang.c (print_output_section_statement): Use fprintf_vma to + print return value of exp_get_abs_int. + +Mon Oct 2 13:56:09 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em (global_stat): New file static variable. + (gld${EMULATION_NAME}_try_needed): Call stat_needed to make sure + that the file has not already been included under another name. + (gld${EMULATION_NAME}_stat_needed): New static function. + +Fri Sep 29 12:00:18 1995 Doug Evans <dje@deneb.cygnus.com> + + * scripttempl/armcoff.sc: Start .text at 0x8000. + Start .data at 0x40000. + +Fri Sep 29 11:09:46 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): If + command_line.rpath is set, use it, rather than the -L options, to + build the rules section. + * ld.texinfo: Document this use of -rpath. + + * lexsup.c (parse_args): Don't set link_info.shared for -assert + pure-text. Pass true, not 1, to lang_add_entry. + * emultempl/sunos.em (find_assign): New static variable. + (found_assign): New static variable. + (gld${EMULATION_NAME}_before_allocation): Rename local h to hdyn. + If not a relocateable link, and no start symbol was specified on + the command line, and there are any undefined symbols, set + link_info.shared. If link_info.shared is set, set the address of + the .text section to 0x20. + (gld${EMULATION_NAME}_find_assignment): Rename from + gld${EMULATION_NAME}_find_statement_assignment. If find_assign is + set, then just set found_assign based on whether an assignment is + found to find_assign. + (gld${EMULATION_NAME}_get_script): Don't use a special script when + producing a shared library. + * emulparams/sun4.sh (GENERATE_SHLIB_SCRIPT): Remove. + * scripttempl/aout.sc: Remove CREATE_SHLIB tests. + * ldlang.c (entry_from_cmdline): New global variable. + (lang_add_entry): Change cmdline parameter from int to boolean. + Use global entry_from_cmdline rather than function static + from_cmdline. + * ldlang.h (entry_from_cmdline): Declare. + (lang_add_entry): Change declaration of second parameter from int + to boolean. + * ldgram.y: Pass false, not 0, to lang_add_entry. + +Thu Sep 28 12:34:13 1995 Ian Lance Taylor <ian@cygnus.com> + + * ld.h (parsing_defsym): Declare. + * ldlex.h (lex_string): Declare. + * ldlex.l (lex_string): Define. + * lexsup.c (parsing_defsym): Define. + (parse_args): In OPTION_DEFSYM case, set lex_string before calling + lex_redirect, and clear it after calling yyparse. Set + parsing_defsym around call to yyparse. + * ldmain.c (main): Set lex_string before calling lex_redirect, and + clear it after calling yyparse. + * ldmisc.c (vfinfo): For %S, handle --defsym arguments and built + in linker scripts correctly. + + * scripttempl/sparccoff.sc: Add .ctors/.dtors handling like other + COFF targets, allowing for the leading underscore used on SPARC + COFF. + + * lexsup.c (parse_args): Handle -assert. + * emulparams/sun4.sh (GENERATE_SHLIB_SCRIPT): Define. + * emultempl/sunos.em (gld${EMULATION_NAME}_get_script): Use the + shared library script when appropriate. + * scripttempl/aout.sc: If CREATE_SHLIB is set, start the .text + section at SIZEOF_HEADERS. + +Thu Sep 28 01:40:37 1995 Doug Evans <dje@deneb.cygnus.com> + + * Makefile.in (earmcoff.c): Build. + * configure.tgt (arm-*-coff): New target + * emulparms/armcoff.sh: New file. + * scripttempl/armcoff.sc: New file. + +Tue Sep 26 10:59:32 1995 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/i386coff.sc: Remove .data2; no longer needed. + +Fri Sep 22 18:09:02 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldfile.c (ldfile_set_output_arch): Make arch const. + +Thu Sep 21 17:55:24 1995 Michael Meissner <meissner@tiktok.cygnus.com> + + * scripttempl/elfppc.sc: Correctly locate __bss_start at the + beginning of the .bss area, not at the end of data. Add + __sbss_{start,end} symbols. + +Wed Sep 20 12:29:36 1995 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in (CC_FOR_TARGET): Quote $(program_transform_name). + (CXX_FOR_TARGET, install): Likewise. + +Mon Sep 18 14:53:22 1995 Ian Lance Taylor <ian@cygnus.com> + + Based on patches by Alan Modra <alan@spri.levels.unisa.edu.au>: + * Makefile.in (CC_FOR_TARGET): Remove brokensed stuff. + (CXX_FOR_TARGET): Likewise. + (install): Likewise. + (GENERATED_HFILES): Remove config.h. + (.dep): Depend upon config.h. + +Mon Sep 18 14:39:38 1995 Arne H. Juul <arnej@pvv.unit.no> + + * configure.tgt (mips*-dec-netbsd*): New target. + +Fri Sep 15 20:01:52 1995 Ken Raeburn <raeburn@cygnus.com> + + * configure.host (m88*-*-dgux*): Fix another shell syntax error. + +Fri Sep 15 23:28:05 1995 Andrew Cagney <cagney@highland.com.au> + + * configure.host (i[345]86-*-bsd*): Fix shell syntax error. + +Thu Sep 12 12:50:49 1995 steve chamberlain <sac@slash.cygnus.com> + + * scripttemp/pe.sc: Allow both spellings of .ctors/.dtors. + Start .text section on the right boundary. Always align + stabs. + +Tue Sep 12 12:24:17 1995 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in (maintainer-clean): New target. + + * ldmain.c (struct warning_callback_info): Define. + (warning_callback): Add new parameter symbol. Call + warning_find_reloc to try to find the section and VMA. + (warning_find_reloc): New static function. + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): + Pass NULL as symbol parameter to warning callback. + + * ld.texinfo: Clarify -L option. + + * ldlang.c (lang_one_common): Add cast to avoid warning. + (topower): Likewise. Also, reindent. + * ldwrite.c (clone_section): Change i to unsigned int. + * emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): Add + cast to avoid warning. + +Fri Sep 8 16:32:43 1995 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in (config.status): Depend upon configure.tgt. + + * ldemul.h (ldemul_set_symbols): Declare. + (ldemul_parse_args): Declare. + * ldemul.c (ldemul_parse_args): Fix indentation. + + * configure.in: Call AC_HEADER_DIRENT. + * configure, config.in: Rebuild. + * emultempl/sunos.em: Use autoconf recommend mechanism to define + DIR and struct dirent. + + * configure.tgt (mips*-*-bsd*): New case. + + * configure.host (i[345]86-sequent-ptx* | i[345]86-sequent-sysv*) + New case. + * configure.tgt (i[345]86-*-ptx*): New case. + +Thu Sep 7 10:48:26 1995 Ian Lance Taylor <ian@cygnus.com> + + * config.in: Rename from config.h.in. + * configure.in: Call AC_CONFIG_HEADER with config.h:config.in. + Check for config.h:config.in when creating stamp-h. + * configure: Rebuild. + * Makefile.in (stamp-h): Depend upon config.in rather than + config.h.in. Set CONFIG_HEADERS to config.h:config.in when + calling config.status. + + * Makefile.in (distclean): Remove config.h and stamp-h. + + * configure.host (sparc-*-sunos64*): Remove. + * ldlang.c (lang_map): Check BFD64, not HOST_64_BIT. + + * ldexp.c (exp_fold_tree): Don't warn about moving the location + counter backward in the absolute section. + +Wed Sep 6 14:42:11 1995 Ian Lance Taylor <ian@cygnus.com> + + * configure.in: Rewrite to use autoconf. + * configure.host: New file. + * configure.tgt: New file. + * aclocal.m4: New file. + * configure: New file, built by autoconf. + * acconfig.h: New file. + * config.h.in: New file, built by autoheader. + * sysdep.h: New file. + * ld.h: Incorporate old contents of config.h. + * config.h: Remove. + * Makefile.in: Various changes for new configure script. Also: + (CC_FOR_BUILD): Remove. + (ldmain.o): Don't bother to ensure that EMUL is non-empty. + (dep.sed): Use @SRCDIR@, not @srcdir@. + * dep-in.sed: Use @SRCDIR@, not @srcdir@. + * genscripts.sh: Create ldscripts if it does not exist. + * ldemul.c, lexsup.c, mpw-emipsidt.c: Don't include "config.h". + * mpw-esh.c, emultemp/*.em: Likewise. + * ldmain.c: Likewise. Include <ctype.h>. Don't try to set + HAVE_SBRK here. + * config/*.mt, config/*.mh: Remove. + +Tue Sep 5 14:55:24 1995 Ken Raeburn <raeburn@cygnus.com> + + * configure.in: Treat ns32k-pc532-ux* like ns32k-pc532-mach*, and + ns32k-pc532-lites* like ns32k-pc532-netbsd*. From Ian Dall. + +Fri Sep 1 22:29:52 1995 Doug Evans <dje@canuck.cygnus.com> + + * scripttempl/pe.sc: Fix typo in spelling of .ctors/.dtors. + +Fri Sep 1 13:13:29 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (warning_callback): Add abfd, section, and address + parameters. + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): + Change call to warning accordingly. + + * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): If not + relocateable and not shared, put .gnu.warning.SYMBOL sections into + the .text section. + +Fri Sep 1 08:35:16 1995 James G. Smith <jsmith@beauty.cygnus.com> + + * configure.in: Added mips*vr4300-idt-elf* and + mips*vr4300el-idt-elf* targets. + * Makefile.in: Added eelf32vr4300* targets. + * emulparams/{elf32vr4300.sh, elf32vr4300el.sh}: Added. + * config/{mips-vr4300.mt, mips-vr4300el.mt}: Added. + +Fri Sep 1 10:51:45 1995 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/a29k.sc: Fix to be reasonable. From Brendan Kehoe + <brendan@cygnus.com>. + +Thu Aug 31 16:37:07 1995 steve chamberlain <sac@slash.cygnus.com> + + * ldemul.c (ldemul_parse_args): New. + * ldemul.h (ld_emulation_xfer_struct): Add parse_args. + * lexsup.c (all pe stuff): Moved into pe.em + (parse_args): Call emulation arg parser. + * emultempl/pe.em (parse_args): handle PE specfic args. + +Thu Aug 31 17:01:37 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_memory_region_lookup): Don't use the first region + as the default region. Create a new region instead. + +Tue Aug 29 14:21:41 1995 steve chamberlain <sac@slash.cygnus.com> + + * ldemul.c (ldemul_set_symbols): New function. + * ldemul.h (ld_emulation_xfer_struct): Add set_symbols. + * ldmain.c (main): Add call to ldemul_set_symbols. + * lexsup.c (set_pe_value): New args. + (set_pe_name): New. + (parse_args): Cope with new set_pe_value args. + * emultempl/pe.em (set_symbols): New function. + (ld_emulation_xfer_struct): Add set_symbols. + * scripttempl/pe.sc: Use new symbols. + +Thu Aug 24 18:12:18 1995 Ian Lance Taylor (ian@cygnus.com) + + * lexsup.c (parse_args): Don't call set_default_dirlist for -O. + For -Y, ignore a leading `P,', and only call set_default_dirlist + after processing all the other arguments. + +Tue Aug 22 07:36:58 1995 steve chamberlain <sac@slash.cygnus.com> + + * scripttempl/pe.sc: Keep .edata, don't base stabs at 0. + * emulparams/armpe.sh: Run PE script. + +Mon Aug 21 18:30:42 1995 steve chamberlain <sac@slash.cygnus.com> + + * ldmain.c (main): Remove PE stuff. + * lexsup.c (options): Load more PE options. + (set_pe_value): New function. + +Thu Aug 17 13:35:49 1995 steve chamberlain <sac@slash.cygnus.com> + + + * emultempl/{armpe.sc, i386pe.sc}: Deleted. + * emultempl/pe.sc: New file performs generic PE support and sorts + archive members. + * emulparams/{armpe.sh,i386pe.sh}: Use new file. + * scripttempl/{armpe.sc, i386pe.sc}: Deleted + * scripttempl/pe.sc: New. + * Makefile.in: Use new files. + +Thu Aug 17 14:46:34 1995 Doug Evans <dje@canuck.cygnus.com> + + * scripttempl/h8500s.sc (.rdata): All data must go in data segment. + (.strings,.ctors,.dtors): Likewise. + +Wed Aug 16 11:38:59 1995 steve chamberlain <sac@slash.cygnus.com> + + * scripttempl/armpe.sc: Always start code at 0x401000, even + if -r. + * ldwrite.c (strdup): New extern declaration. + * ldgram.y (atype): New rule to clarify type parsing. + * ldlang.c (init_os): Remove commented out code. + (lang_size_sections): Set SEC_ALLOC and SEC_LOAD bits + unless told not to by the link script. + +Wed Aug 16 11:45:11 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_set_startof): New static function. + (lang_process): Call it. + + * ldgram.y: Tweak casesymlist to avoid bison errors. + + * lexsup.c (parse_args): Accept -h as a synonym for --soname, for + Solaris compatibility. + +Tue Aug 15 17:31:16 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldgram.y (YYDEBUG): If not defined, define as 1. + (CASE, EXTERN, START): New tokens. + (mri_script_command): Handle CASE, EXTERN, INCLUDE, START. + (casesymlist): New nonterminal. + (extern_name_list): New nonterminal. + * ldlex.l: Accept lower case trailing base specifiers. Don't + ignore the first digit when the base is a suffix. Accept many + EXPRESSION state tokens in MRI state. Support MRI continuation + lines and MRI semicolon comments. Accept all MRI keywords in + lower case. Add CASE, EXTERN, and START MRI keywords. + +Tue Aug 8 19:14:58 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com> + + * emultempl/sunos.em (gld${EMULATION_NAME}_find_so): Use xmalloc + instead of alloca. + +Tue Aug 8 15:24:05 1995 J.T. Conklin <jtc@rtl.cygnus.com> + + * Makefile.in (CC_FOR_TARGET, CXX_FOR_TARGET): Don't use + $r/../gcc/xgcc unless it is present. + +Thu Aug 3 11:56:22 1995 Ian Lance Taylor <ian@cygnus.com> + + * scripttempl/m68kcoff.sc: Only put .ctors and .dtors in .text + when CONSTRUCTING. + * scripttempl/m68klynx.sc: Likewise. + * scripttempl/nw.sc: Likewise. + * scripttempl/sa29200.sc: Likewise. + * scripttempl/sparclynx.sc: Likewise. + +Fri Jul 28 12:02:23 1995 steve chamberlain <sac@slash.cygnus.com> + + * emulparams/{z8001.sh, z8002.sh}: Fix typo. + +Thu Jul 27 21:06:21 1995 Ken Raeburn <raeburn@cygnus.com> + + * configure.in (i[345]86-*-linuxoldld): Treat like linuxaout*. + +Thu Jul 27 15:26:28 1995 steve chamberlain <sac@slash.cygnus.com> + + * scripttempl/i386pe.sc: Cope with constructors. + * scripttempl/z8ksim.sc: Deleted. + * scripttempl/z8000.sc: Resurrected as this, but + can handle z8001 and z8002 formats. + * emulparams/z8ksim.sh: Deleted. + * emulparams/{z8001.sh, z8002.sh}: New files. + * config/z8ksim.mt: Deleted + * config/z8k-coff.mt: New, generates both emulations. + +Tue Jul 25 14:53:02 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldmisc.c (vfinfo): In %C and %D case, always print the BFD using + %B, in case it is in an archive. + +Mon Jul 24 15:23:39 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_process): Call reset_memory_regions for each + relaxation pass. + +Fri Jul 21 22:49:44 1995 Michael Meissner <meissner@cygnus.com> + + * scripttempl/elfppc.sc: Add support for .sdata, .sbss, and + _SDA_BASE. + +Thu Jul 20 16:26:55 1995 Ken Raeburn <raeburn@cygnus.com> + + * ldmain.c (constructor_callback): Allocate set_name in stack + frame, rather than always calling alloca with a fixed size. + +Wed Jul 19 16:21:43 1995 Doug Evans <dje@canuck.cygnus.com> + + * emulparams/armpe.sh (OUTPUT_FORMAT): Change to pei-arm-little. + (LITTLE_OUTPUT_FORMAT, BIG_OUTPUT_FORMAT): Define. + +Mon Jul 17 13:57:00 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldwrite.c (clone_section): Set the alignment of the clone + section to that of the section being cloned. + + * ldwrite.c (split_sections): Don't split the first input section + into a new output section. + +Sat Jul 15 00:26:35 1995 Michael Meissner <meissner@cygnus.com> + + * emulparams/elf32ppc.sh (TEMPLATE_NAME): Define as elf32. + (GENERATE_SHLIB_SCRIPT): Define as yes. + +Fri Jul 14 12:11:46 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/mipsecoff.em (check_sections): Use %P, not %F. + + * ldver.c (help): Update list of options to match currently + supported list. + +Thu Jul 13 13:52:10 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/lnk960.em (ld_lnk960_emulation): Initialize + after_open field. + + * ldexp.c (exp_intop): Don't cast stat_alloc arg to bfd_size_type; + it takes a size_t anyhow. + (exp_binop): Likewise. + (exp_trinop): Likewise. + (exp_unop): Likewise. + (exp_nameop): Likewise. + (exp_assop): Likewise. + * ldlang.c (lang_memory_region_lookup): Likewise. + (init_os): Likewise. + (ldlang_add_undef): Likewise. + (insert_pad): Likewise. + * ldfile.c (ldfile_add_arch): Don't cast xmalloc arg to + bfd_size_type. + + * Makefile.in (ALL_EMULATIONS): It's earmaoutb.o, not earmoutb.o. + +Wed Jul 12 11:32:22 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldemul.h (ldemul_open_dynamic_archive): Add search parameter to + declaration. + (ld_emulation_xfer_type): Add search parameter to + open_dynamic_archive entry point. + * ldemul.c (ldemul_open_dynamic_archive): Add search parameter. + * ldfile.c (ldfile_try_open_bfd): Rename from try_open_bfd, and + make non-static. Change all callers to use new name. + (ldfile_open_file_search): Make static. If entry is dynamic, call + ldemul_open_dynamic_archive. + (ldfile_open_file): Don't call ldemul_open_dynamic_archive. + * ldfile.h (ldfile_open_file_search): Don't declare. + (ldfile_try_open_bfd): Declare. + * emultempl/elf32.em (gld${EMULATION_NAME}_open_dynamic_archive): + Accept search parameter. Don't search for a library, just look in + a single place. + * emultempl/linux.em (gld${EMULATION_NAME}_open_dynamic_archive): + Likewise. + +Tue Jul 11 16:44:21 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (set_scripts_dir): Don't base script directory on + current directory. + +Tue Jul 11 12:29:02 1995 Rick Sladkey <jrs@world.std.com> + + * ldmisc.c (vfinfo): Don't print the line number if it isn't + meaningful. + +Mon Jul 10 13:38:28 1995 Ian Lance Taylor <ian@cygnus.com> + + * ld.h (ld_config_type): Add field warn_constructors. + * ldmain.c (add_to_set): Warn if config.warn_constructors. + (constructor_callback): Likewise. + * lexsup.c (parse_args): Handle -warn-constructors. + * ld.texinfo, ld.1: Document -warn-constructors. + + * emultempl/elf32.em (gld${EMULATION_NAME}_check_needed): Don't + get confused by directory names if we searched for the file. + + Based on patches from H.J. Lu <hjl@nynexst.com>: + * ldlang.h (lang_input_statement_type): Add new field dynamic. + * ldlang.c (new_afile): Set dynamic from config.dynamic_link. + * ldfile.c: Include bfdlink.h. + (ldfile_open_file): Check dynamic field of entry, not global + dynamic_link field. Don't do a dynamic search when doing a + relocateable link. + * ldmain.c (main): Don't warn about dynamic_link for a + relocateable link. + * emultempl/sunos.em (gld${EMULATION_NAME}_find_so): Skip file if + dynamic is false. + (gld${EMULATION_NAME}_create_output_section_statements): Always + loop over input files. + * Makefile.in: Rebuild dependencies. + + * ld.texinfo, ld.1: Document -Bstatic, -Bdynamic, -Bshared, and + -shared. + +Mon Jul 10 13:29:43 1995 Eric Youngdale <eric@aib.com> + + * ldmain.c (main): Set link_info.symbolic to false. + * lexsup.c (parse_args): Handle -Bsymbolic. + +Wed Jul 5 00:12:11 1995 Fred Fish (fnf@cygnus.com) + + * ldmain.c (HAVE_SBRK): Define for everything except + specific systems that are known to not support sbrk. + (main): Use HAVE_SBRK to decide whether or not to use sbrk. + +Tue Jul 4 12:55:48 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em (gld${EMULATION_NAME}_find_exp_assignment): + Handle etree_provide. + + * emultempl/elf32.em (global_needed): New static variable. + (global_found): Likewise. + (gld${EMULATION_NAME}_after_open): New static function. + (gld${EMULATION_NAME}_search_needed): Likewise. + (gld${EMULATION_NAME}_try_needed): Likewise. + (gld${EMULATION_NAME}_check_needed): Likewise. + (ld_${EMULATION_NAME}_emulation): Replace after_open_default with + gld${EMULATION_NAME}_after_open. + +Mon Jul 3 14:26:37 1995 Steve Chamberlain <sac@slash.cygnus.com> + + * configure.in (i386-*-win32): New target. + +Mon Jul 3 14:39:22 1995 Ian Lance Taylor <ian@cygnus.com> + + * lexsup.c (parse_args): Let -G either set the small data size or + be equivalent to --shared, depending on the next argument. Accept + and ignore -z for Solaris compatibility. + +Sun Jul 2 17:52:34 1995 Ian Lance Taylor <ian@cygnus.com> + + * lexsup.c (parse_args): Cast fopen result to PTR before storing + it in link_info.base_file. Fix indentation. + +Wed Jun 28 17:11:25 1995 Steve Chamberlain <sac@slash.cygnus.com> + + * ldmain.c (main): Always initialize PE info in link_info. + * lexsup.c (OPTION_BASE_FILE): New option. + (parse_args): Handle new option. + * emulparams/armpe.sh: Output pei. + * emultempl/i386pe.em: Add newline to end. + * scripttempl/armpe.sc: Change output and quote the $s. + * scripttempl/i386pe.sc: Change output and quote the $s. + +Thu Jun 22 19:55:41 1995 Ken Raeburn <raeburn@cujo.cygnus.com> + + Sun May 7 11:53:41 MDT 1995 Bryan Ford <baford@cs.utah.edu> + + * configure.in (i386-*-msdos*, i386-*-moss*): New targets. + * Makefile.in (ALL_EMULATIONS): Added i386msdos.o. + (i386msdos.o): New target. + * config/i386-msdos.mt: Created. + * emulparams/i386msdos.sh: Created. + * scripttempl/i386msdos.sc: Created. + +Thu Jun 22 15:06:35 1995 Michael Meissner <meissner@tiktok.cygnus.com> + + * scripttempl/elfppc.sc (.fixup): Add support for a .fixup section + that contains pointers to be relocated. + +Tue Jun 20 17:47:20 1995 Stan Shebs <shebs@andros.cygnus.com> + + * mpw-esh.c: New file, modified for MPW from esh.c. + * scripttempl/sh.sc: Reformatted to simplify MPWification, + use *() to concat stab sections instead of []. + +Thu Jun 15 08:48:16 1995 Steve Chamberlain <sac@slash.cygnus.com> + + * scripttempl/armpe.sc: Add constructor support. + +Tue Jun 13 09:11:20 1995 Steve Chamberlain <sac@slash.cygnus.com> + + * ldlang.c (lang_size_sections): Any section with a DATA + statement has contents. + +Sun Jun 11 15:20:46 1995 Ken Raeburn <raeburn@cujo.cygnus.com> + + * emulparams/m68kelf.sh (NOP): Define. + (DYNAMIC_LINK): Don't define. + (TEXT_START_ADDR): Set to 0x80000000; the extra 0x100 for headers + will come from the linker script. + +Thu Jun 8 14:17:33 1995 Steve Chamberlain <sac@slash.cygnus.com> + + * emulparams/armpe.sh, scriptempl/armpe.sc: Add end and stack. + +Mon Jun 5 02:16:24 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com> + + * configure.in (i[345]86-*-gnu*): Use GNU elf config. + +Thu May 25 11:49:28 1995 Michael Meissner <meissner@tiktok.cygnus.com> + + From Andrew Cagney <cagney@highland.com.au> + * Makefile.in: Fixup more gotchas from renaming elf32ppcle to + elf32lppc. + +Wed May 24 11:23:21 1995 Steve Chamberlain <sac@slash.cygnus.com> + + Add support for ARM-PE. + * Makefile.in (ALL_EMULATIONS): Add armpe.o + * configure.in: Recognize armpe. + * config/arm-pe.mt: New file. + * emulparams/armpe.sh: New file. + * scripttempl/armpe.sc: New file. + + +Mon May 22 15:19:26 1995 Doug Evans <dje@chestnut.cygnus.com> + + * configure.in (h8300h-*-hms): Deleted + * config/cf-h8300h.mt: Deleted. + +Thu May 18 04:26:10 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com> + + Wed May 10 14:28:16 1995 Richard Earnshaw (rearnsha@armltd.co.uk) + + From David Taylor (dtaylor@armltd.co.uk) + * Makefile.in (ALL_EMULATIONS): Add earmout[lb].o + * configure.in: Recognize arm{,e[lb]-*-aout. + * config/arm[lb]-aout.mt: New files. + * emulparams/armaout[lb].sh: New files. + * scripttempl/armaout.sc: New file. + +Tue May 16 18:27:11 1995 Michael Meissner <meissner@tiktok.cygnus.com> + + * config/ppcle-elf32.mt (EMUL): Use elf32lppc, not elf32ppcle, to + be unique in 8 characters for DOS. + + * emulparams/elf32lppc.sh: New file, renamed from elf32ppcle.sh. + * emulparams/elf32ppcle.sh: Deleted. + +Fri May 12 11:03:55 1995 Steve Chamberlain <sac@slash.cygnus.com> + Tom Griest <griest@cs.yale.edu> + + Initial support for PE executables (eg NT, win32) + + * Makefile.in (configure.in, ei386pe): Add support. + * ldmain.c (main): Initialize PE argument info. + * ldwrite.c (print_file_stuff): Don't print out .drectve + and .debug section info. + * lexsup.c (set_subsystem, set_stack_heap, OPTION_HEAP, + OPTION_SUBSYSTEM, parse_argsm set_subsystem, set_stack_heap): + Handle new arguments. + * config/i386-pe.mt, emultempl/i386pe.em, scripttempl/i386pe.sc: + New files + +Wed May 10 18:37:59 1995 Stu Grossman (grossman@andros.cygnus.com) + + * scripttempl/hppaelf.sc: Remove .PARISC.unwind section from text + segment. This allows ld -r to preserve unwind sections. + +Tue May 9 17:19:57 1995 Michael Meissner <meissner@tiktok.cygnus.com> + + * configure.in: Add little endian PowerPC support. + + * Makefile.in (ALL_EMULATIONS): Add eelf32ppcle.o. + (eelf32ppcle.c): Support for little endian PowerPC. + + * config/ppcle-elf32.mt: New file for little endian PowerPC. + * emulparams/elf32ppcle.sh: Ditto. + +Wed May 3 12:56:32 1995 Ken Raeburn <raeburn@cujo.cygnus.com> + + * ldlang.c (print_output_section_statement): Check + subsection_alignment, instead of checking section_alignment twice. + Noticed by Alan Modra <alan@spri.levels.unisa.edu.au>. + +Tue May 2 16:36:07 1995 Jeff Law (law@snake.cs.utah.edu) + + * configure.in (hppa*-*-lites*): Handle like hppa*-*-*elf*. + +Mon Apr 24 19:21:02 1995 Michael Meissner <meissner@cygnus.com> + + * ldwrite.c (ldwrite): Before doing anything, reset the error + code. If bfd_final_link returns an error, but the error code is + unset, don't issue an extra message. Assume a correct error + message was already set. + +Fri Apr 14 16:31:24 1995 Ken Raeburn <raeburn@cujo.cygnus.com> + + * Makefile.in (ALL_EMULATIONS): Added em68kelf.o. + (em68kelf.o): New target. + * config/m68k-elf.mt, emulparams/m68kelf.sh: New files. + * configure.in: Use them for m68*-*-elf. + +Tue Apr 11 12:02:03 1995 Stan Shebs <shebs@andros.cygnus.com> + + Merge in support for Mac MPW as a host. + (Old change descriptions retained for informational value.) + + * mpw-config.in (i386-unknown-aout): Change to i386-unknown-go32. + (i386-unknown-coff): Remove. + (sh-hitachi-hms): New target. + (emulation_ofiles): Set correctly for each target. + (version, TDEFINES): Add to makefile fragment. + * mpw-make.in (BISON): Use byacc instead of bison. + (em_*.c): Replace with e*.c everywhere. + (ldgram.h): Separate action from ldgram.c generation. + (LD_PROG): Depend on Version.r. + (Version.r): generate from version info. + * mpw-emipsidt.c: New file, modified for MPW from emipsidt.c. + + * mpw-config.in (m68k-apple-macos, ppc-apple-macos, + i386-unknown-aout, i386-unknown-coff): New targets. + (m68k-aout, m68k-coff): Remove targets. + (mk.tmp): Add definition of EMUL. + + * mpw-config.in (emulname): Set based on target. + (ldemul-list.h): Construct. + * mpw-make.in (install-only): New target. + (install): Depend on install-only. + + * mpw-make.in (bindir): Fix pathname. + (install): Move here from mpw-build.in. + + * mpw-config.in: New file, MPW configuration fragment. + * mpw-make.in: New file, MPW makefile fragment. + (This file is semi-automatically generated from Makefile.in.) + * ldfile.c (slash): If MPW, set to `:'. + * ldlex.l (TRUE_FALSE_ALREADY_DEFINED): If MPW, set this to + prevent redefinition errors. + + +Tue Apr 4 17:55:18 1995 Steve Chamberlain <sac@bang.hack.com> + + * ldwrite.c (clone_section): Align clone sections on even + boundaries. + +Thu Mar 30 14:32:26 1995 H.J. Lu (hjl@nynexst.com) + + * configure.in: Change linux to default to elf. Using + i[345]86-*-linuxaout will build a linker which defaults to a.out. + * config/i386-laout.mt: Rename from old config/i386-linux.mt. + * config/i386-linux.mt: Rename from old config/i386-lelf.mt. + * config/i386-lelf.mt: Remove. + +Thu Mar 30 13:09:46 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (main): If opening the map file fails, call + bfd_set_error before calling einfo. + + * ld.texinfo, ld.1: Document the -no-keep-memory option. + +Mon Mar 27 11:10:08 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (main): Revert patch of March 10, since the SVR4 linker + does mark shared libraries as executable. + +Tue Mar 21 15:15:38 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_common): Change power to int. Pass larger values + before smaller values. + (lang_one_common): Treat info as int *. Don't bother to check for + last value, since it is now zero. + +Sat Mar 18 01:49:14 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (load_symbols): An empty archive is OK. + +Fri Mar 17 16:15:31 1995 Stan Shebs <shebs@andros.cygnus.com> + + * ldmain.c (progress.h): Include. + (main): Call START_PROGRESS and END_PROGRESS. + +Thu Mar 16 17:17:33 1995 Michael Meissner <meissner@cygnus.com> + + * scripttempl/elfppc.sc: Move _GOT2_END_ after the .ctors and + .dtors sections, so that these pointers get relocated also. + Define the symbols __{C,D}TOR_{LIST,END}__ to mark the beginning + and end of the constructors/destructors. + +Thu Mar 16 13:59:14 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> + + * ldlang.c (load_symbols): If whole_archive is true and ENTRY + describes an archive, call bfd_link_add_symbols on each member. + * ldmain.c (whole_archive): New variable. + (main): Initialize it to false. + * ldmain.h: Declare whole_archive. + * lexsup.c (parse_args): Grok --whole-archive switch. + * ld.texinfo, ld.1: Document --whole-archive. + +Thu Mar 16 11:38:48 1995 Ian Lance Taylor <ian@cygnus.com> + + * genscripts.sh (EMULATION_NAME): Set LIB_PATH to empty when not + using the default emulation. + + * config/dgux.mh (HOSTING_EMU): Use -m rather than trying to set + LDEMULATION. + * config/hppaelf.mh (HOSTING_EMU): Likewise. + +Tue Mar 14 12:28:03 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/sunos.em (gld${EMULATION_NAME}_find_so): Set force_maj + for -lc.N. From H.J. Lu <hjl@nynexst.com>. + +Fri Mar 10 14:43:48 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (main): Don't set EXEC_P if link_info.shared is set. + + * ldlex.l: Return -lFILENAME as the token LNAME. + * ldgram.y: Add token LNAME. + (input_list): Treat LNAME like NAME, but pass it to + lang_add_input_file as lang_input_file_is_l_enum. + * ld.texinfo: Document using -lFILENAME in INPUT. + +Thu Mar 9 12:21:51 1995 Michael Meissner <meissner@tiktok.cygnus.com> + + * ldlang.c (lang_check): If the architectures are compatible call + bfd_merge_private_bfd_data to let the backend do additional + checks. + + +Tue Mar 7 00:53:08 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldemul.c (ldemul_choose_mode): If emulation not recognized, list + all supported emulations. + +Mon Mar 6 14:03:50 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldemul.c (ldemul_list_emulations): New function. + * ldemul.h (ldemul_list_emulations): Declare. + * ldver.c (help): List supported targets and emulations. + +Fri Mar 3 15:40:36 1995 Doug Evans <dje@canuck.cygnus.com> + + * scripttempl/elf.sc (.debug): Relocate to address 0. + (.debug_srcinfo, .debug_aranges, .debug_pubnames, + .debug_sfnames, .line): Likewise. + +Fri Mar 3 17:07:14 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em (hold_rel): New static variable. + (gld${EMULATION_NAME}_place_orphan): Place readonly sections with + contents whose names begin with ".rel" after hold_rel. Remove the + assertion which checked for unplaced .rel sections. Don't try to + sort the section into place if place->bfd_section is NULL. + (gld${EMULATION_NAME}_place_section): Set hold_rel to the first + section beginning with ".rel". + +Thu Mar 2 14:34:43 1995 Ian Lance Taylor <ian@cygnus.com> + + Doc note from pierre@phi.la.tce.com (Pierre Willard): + * ld.texinfo: -X and -x work even if -s or -S are not specified. + * ld.1: Similar change. + +Wed Mar 1 13:51:16 1995 Ian Lance Taylor <ian@cygnus.com> + + * emulparams/gld960coff.sh (COFF_CTORS): Define. + * scripttempl/i960.sc: Use COFF_CTORS if CONSTRUCTING. + +Tue Feb 28 12:42:56 1995 Ian Lance Taylor <ian@cygnus.com> + + * configure.in (i[345]86-*-linuxelf*): New target. Use i386-lelf. + (i[345]86-*-gnuelf*): New target. Use i386-gelf. + * config/i386-lelf.mt: New file. + * config/i386-gelf.mt: New file. + +Tue Feb 28 10:27:54 1995 Rob Savoye <rob@darkstar.cygnus.com> + + * configure.in: Match on mips-ecoff, and default to the IDT + configuration. + +Fri Feb 17 13:06:47 1995 Michael Meissner <meissner@cygnus.com> + + * scripttempl/elfppc.sc: Add support for .got1 and .got2 sections. + Offset _GLOBAL_OFFSET_TABLE_ 32768 from the start of the GOT area + to double the size of the table. + + +Thu Feb 9 18:29:43 1995 Ken Raeburn <raeburn@cujo.cygnus.com> + + * Makefile.in (distclean): Do recursive deletion, since ldscripts + is a directory. + +Thu Feb 9 11:38:22 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (main): If trace_file_tries is true, and we are using + an internal linker script, print out the script. + * ldfile.c (try_open): Reindent function. Make the messages about + opening script files more informative. + + * lexsup.c (parse_args): For -V, call ldversion with 1, not 0. + * ld.texinfo, ld.1: Update accordingly. + +Wed Feb 8 17:34:45 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldlang.c (lang_one_common): Adjust references to common symbol + information for new structure. + +Mon Feb 6 12:17:24 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldmain.c (undefined_symbol): Handle section being NULL. + + * ldctor.c (ldctor_build_sets): Handle bfd_link_hash_defweak. + * ldexp.c (fold_name): Likewise. + * ldlang.c (print_one_symbol): Likewise. + (lang_finish): Likewise. + * ldmain.c (multiple_common): Likewise. + * ldwrite.c (print_symbol): Likewise. Also, bfd_link_hash_weak + renamed to bfd_link_hash_undefweak. + + * scripttempl/alpha.sc: Set address of .data section correctly + when -n or -N is used. Patch from Chris G Demetriou + <Chris_G_Demetriou@LAGAVULIN.PDL.CS.CMU.EDU>. + * scripttempl/mips.sc: Similar change. + +Tue Jan 31 16:20:52 1995 Doug Evans <dje@canuck.cygnus.com> + + * ldlang.c (lang_size_sections): Clarify error message when user + specified start addr conflicts with region. Fix resetting of + region pointer. + +Tue Jan 31 12:37:09 1995 Ian Lance Taylor <ian@cygnus.com> + + * ldexp.c (fold_name): In case NAME, permit an absolute symbol + in lang_allocating_phase_enum. + +Mon Jan 30 11:33:25 1995 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in (distclean): Depend upon clean. Don't bother to + remove files which will be removed by clean. From patch by + alan@SPRI.Levels.UniSA.Edu.Au (Alan Modra). + +Fri Jan 27 16:27:34 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): For + a MIPS target, clobber the size of all but the first input + .reginfo section to be 0, so that lang_size_sections sets the + correct size for the output .reginfo section. + +Thu Jan 26 19:53:37 1995 Ian Lance Taylor <ian@cygnus.com> + + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): + Remove unused variable is. + +Thu Jan 26 12:33:05 1995 Michael Meissner <meissner@tiktok.cygnus.com> + + * configure.in: Add support for powerpc-*-eabi. + + * scripttempl/elfppc.sc: New file for PowerPC embedded ABI + support. + + * emulparams/elf32ppc.sh (SCRIPT_NAME): Use elfppc.sc instead of + elf.sc, which defines some new symbols PowerPC elf needs. + +Tue Jan 24 10:32:15 1995 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * ldctor.c (ldctor_add_set_entry): Don't dump core if a + constructor entry is in the absolute section. + +Mon Jan 23 13:58:13 1995 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * configure.in (i[345]86-*-gnu*): Set ld_target to i386-gnu. + * config/i386-gnu.mt: New file. Include ELF support. + +Thu Jan 19 16:22:11 1995 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): If + there are any input sections named .gnu.warning, treat them as + containing a warning message to be printed by the linker, and + clobber the size so that the message is not copied into the output + file. + * scripttempl/elf.sc: Put .gnu.warning sections into the .text + section. + +Sun Jan 15 16:45:00 1995 Steve Chamberlain <sac@splat> + + * configure.in (w65-*-*): New target. + * Makefile.in: Update. + * scripttempl/w65.sc: New. + * config/coff-w65.mt: New. + +Thu Jan 12 01:32:25 1995 Ian Lance Taylor <ian@tweedledumb.cygnus.com> + + * ldlang.c (lang_place_orphans): Don't ignore files with + just_syms_flag set. Instead, put all their sections in + bfd_abs_section_ptr, using the section VMA as the output_offset. + +Wed Jan 11 22:59:09 1995 Ken Raeburn <raeburn@cujo.cygnus.com> + + * ldctor.c (ldctor_build_sets): Don't use `const' with typedef + name `reloc_howto_type', since it's now defined to be const. + * ldlang.c (lang_add_reloc): Ditto. + * ldlang.h (lang_reloc_statement_type, lang_add_reloc): Ditto. + +Wed Jan 11 11:24:45 1995 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * ldexp.c (fold_binary): Adding or subtracting an absolute value + to a relative value does not require forcing the relative value to + be absolute. Also, reindent function. + +Wed Dec 28 22:05:52 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * ldwrite.c (clone_section): Create a symbol with the + same name as the section. + +Mon Dec 19 14:02:13 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * ld.h (split_by_reloc, split_by_file): New flags. + * ldwrite.c (clone_section, split_sections): New functions. + * lexsup.c (parse_args): Understand new split options. + + +Fri Dec 9 17:22:55 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * scripttempl/elf.sc: Move .ctors and .dtors from .text segment to + .data segment. They must be writable when creating a shared + library. From H.J. Lu <hjl@nynexst.com>. + +Fri Dec 2 14:09:00 1994 Ian Lance Taylor <ian@rtl.cygnus.com> + + * emultempl/miposecoff.em: New file. + * emulparams/mipsidt.sh (TEMPLATE_NAME): Set to mipsecoff. + * emulparams/mipsidtl.sh (TEMPLATE_NAME): Likewise. + * scripttempl/mips.sc: Put .rel.sdata sections in .text, and + provide __runtime_reloc_start and __runtime_reloc_stop if they are + used. Align _fdata to a 16 byte boundary. + * Makefile.in (emipsidt.c): Depend upon mipsecoff.em rather than + generic.em. + (emipsidtl.c): Likewise. + (check): Pass CC_FOR_HOST and CFLAGS_FOR_HOST to runtest. + + * ld.h (args_type): Add new field embedded_relocs. + * ldemul.h (ldemul_after_open, after_open_default): Declare. + (ld_emulation_xfer_struct): Add new field after_open. + * ldemul.c (ldemul_after_open): New function. + (after_open_default): New function. + * ldlang.c (lang_process): Call ldemul_after_open. + * lexsup.c (parse_args): Handle --embedded-relocs. + * emultempl/elf32.em (ld_${EMULATION_NAME}_emulation): Initialize + new after_open field to after_open_default. + * emultempl/generic.em, emultempl/gld960.em: Likewise. + * emultempl/gld960c.em, emultempl/hppaelf.em: Likewise. + * emultempl/linux.em, emultempl/m88kbcs.em: Likewise. + * emultempl/sunos.em, emultempl/vanilla.em: Likewise. + * ld.texinfo, ld.1: Mention -embedded-relocs. + +Wed Nov 23 22:04:47 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * Makefile.in: Add eshl.o. + * config/coff-sh.mt: Add shl emulation. + +Tue Nov 22 11:55:37 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * scripttempl/elf.sc: Fill .text section with NOPS. From Eric + Youngdale <eric@aib.com>. + +Thu Nov 17 14:39:48 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + Patches from pirker@eiunix.tuwien.ac.at (Martin Pirker). + * config/i386linux.mh: New file; set HOSTING_CRT0. + * genscripts.sh: Don't put ${libdir} in LIB_PATH if it is + /usr/lib, since that is already in LIB_PATH. + +Wed Nov 16 10:03:03 1994 Jeff Law (law@snake.cs.utah.edu) + + * scripttempl/hppaelf.sc (.text): Handle a use rdefined text start + address. + (.data, .bss): If "-N", then place the data/bss just after the end + of the .text section rather than at the default 0x40000000. + + * scripttempl/hppaelf.sc (.text): Place unwind descriptors in the + text segment. + +Sat Nov 12 15:55:56 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Patches from Eric Youngdale <eric@aib.com>: + * ldlang.c (lang_finish): Don't warn if entry symbol not found + when generating a shared library. + * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Warn if + attempting to place an orphaned relocation section when generating + a dynamically linked object. + + * scripttempl/elf.sc: Add ENTRY(${ENTRY}), and default ${ENTRY} to + _start. + +Fri Nov 11 14:27:23 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * ld.h (args_type): Add field export_dynamic. + * lexsup.c (parse_args): Recognize --export-dynamic. + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): + Pass export_dynamic argument to bfd_elf32_size_dynamic_sections. + +Wed Nov 9 12:47:11 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * ldlang.c (lang_one_common): Set SEC_ALLOC in any section where + we allocate common symbols. + +Tue Nov 8 17:50:43 1994 Eric Youngdale (eric@aib.com) + + * scripttempl/elf.sc: Add .rel.init, .rela.init, .rel.fini, and + .rela.fini to the list of .rel* sections. + +Tue Nov 8 17:47:45 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * ldlang.c (load_symbols): Add new argument place. Only accept + linker scripts if place is not NULL. Put commands found in an + assumed linker script into place. + (lookup_name): Pass NULL as place argument to load_symbols. + (open_input_bfds): In lang_input_statement_enum case, pass a place + argument to load_symbols, and store any new statements after the + current one. + +Mon Nov 7 15:53:02 1994 Ken Raeburn <raeburn@cujo.cygnus.com> + + * ldver.c (ldversion): Bump to 2.5.3. + +Fri Nov 4 15:11:26 1994 Ken Raeburn <raeburn@cujo.cygnus.com> + + * Makefile.in (e*nbsd.c): Fix typo in dependencies. + +Thu Nov 3 19:35:44 1994 Ken Raeburn <raeburn@cujo.cygnus.com> + + * Makefile.in (check): Add missing "else true" clause. + + * emulparams/vax.sh (OUTPUT_FORMAT): Use "a.out". + + * scripttempl/go32coff.sc: Changes from DJ Delorie: Change default + entry point to "start". Align at end of each section to 0x200. + Start .text section 0x1000 later. Add _etext, _edata, _end + symbols. + +Wed Nov 2 12:17:49 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * ldctor.c (ldctor_add_set_entry): Don't permit a set to be + composed of different object file formats. + (ldctor_build_sets): If the output format does not support the + reloc, and we are not generating a relocateable link, try getting + the reloc from the input format. + +Tue Nov 1 10:30:19 1994 J.T. Conklin (jtc@rtl.cygnus.com) + + * Makefile.in (ALL_EMULATIONS): Added em68knbsd.o. + (em68knbsd.c): New target. + + * config/m68k-nbsd.mt: New file. + * emulparams/m68knbsd.sh: New file. + * configure.in (m68*-*-netbsd*): Use above configs. + +Mon Oct 31 19:35:17 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * emultempl/sunos.em (gld${EMULATION_NAME}_find_so): If we find an + appropriately named static library, stop the search at that + directory. + +Wed Oct 26 13:59:12 1994 J.T. Conklin (jtc@phishhead.cygnus.com) + + * Makefile.in (ALL_EMULATIONS): Added ei386nbsd.o, ens32knbsd.o + and esparcnbsd.o; sorted entries. + (ei386nbsd.c,ens32knbsd.c,esparcnbsd.c): New targets. + + * config/netbsd532.mt: Removed. + * emulparams/netbsd532.sh: Removed. + + * config/{i386-nbsd.mt,ns32k-nbsd.mt,sparc-nbsd.mt}: New files. + * emulparams/{i386nbsd.sh,ns32knbsd.sh,sparcnbsd.sh}: New files. + * configure.in (i[345]86-*-netbsd*, ns32k-pc532-netbsd*, + sparc*-*-netbsd*): Use above configs. + +Tue Oct 25 11:47:10 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * ldmain.c (multiple_common): One of the types may now be + bfd_link_hash_indirect. The old BFD argument may be NULL. + +Thu Oct 20 22:01:39 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in: Add * at the end of m68k-hp-hpux. + +Tue Oct 18 15:58:39 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * ldlex.l: Cast assignment to yy_ch_buf field to char *, not to + YY_CHAR *. + +Mon Oct 17 14:53:16 1994 J.T. Conklin (jtc@phishhead.cygnus.com) + + * scripttempl/nw.sc: Gather constructors and destructors and + define __CTOR__LIST__ and __DTOR_LIST__ appropriately. + +Fri Oct 14 14:35:38 1994 J.T. Conklin (jtc@rtl.cygnus.com) + + * Makefile.in (ALL_EMULATIONS): Add ei386nw.o and eppcnw.o. + (ei386nw.c, eppcnw.c): New targets. + + * config/{i386,ppc}-nw.mt, emulparams/{i386,ppc}nw.sh, + scripttempl/nw.sc: New files, for i386 and powerpc netware. + + * configure.in: Changed netware ld_target name to be {i386,ppc}-nw + instead of {i386,ppc}-elf. + + * configure.in (sparc*-*-netware): Removed. There is no such + thing anymore. + + * ldint.texinfo: Move misplaced `@end iftex'. + +Fri Oct 14 12:02:18 1994 Eric Youngdale (eric@aib.com) + + * scripttempl/elf.sc: Add .rel.ctors, .rela.ctors, .rel.dtors, and + .rela.dtors to the list of .rel* sections. + +Thu Oct 13 14:16:27 1994 Ken Raeburn <raeburn@cujo.cygnus.com> + + * ldver.c (ldversion): Update to version 2.5. + * Version 2.5 released. + + * configure.in (all_targets): Handle i386-linux*. + +Thu Oct 13 11:24:33 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * scripttempl/aout.sc: Set _etext and __etext to ., not + ${DATA_ALIGNMENT}. This is compatible with SunOS, and, with luck, + will not break any other system. From Eric Valette + <ev@chorus.fr>. + +Wed Oct 12 16:22:58 1994 Ian Lance Taylor <ian@sanguine.cygnus.com> + + * lexsup.c (parse_args): Change -V to be a synonym for -v. Add + --verbose to get the old -V behaviour. + * ld.1, ld.texinfo: Document this change. + +Tue Sep 27 14:56:20 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Remove + assertion, since it could fail with a user defined linker script. + + * ldexp.c (fold_name): For DEFINED case, don't try to look up the + name in the hash table during the first phase--the hash table does + not even exist at that point, much less have the right value. + + * Makefile.in (CC): Define. + (CXX): Move definition, change from g++ to gcc. + (EXPECT, RUNTEST): Copy definitions from top level Makefile.in. + (RUNTEST_CC, RUNTEST_CFLAGS): Remove. + (RUNTEST_CXX, RUNTEST_CXXFLAGS): Remove. + (CC_FOR_TARGET, CXX_FOR_TARGET): Copy from top level Makefile.in. + (.cc.o): Comment out. + (testdir): Remove. + (site.exp): Don't create testdir or set tmpdir. + (check): Run checks even if not running native. Use CC_FOR_TARGET + instead of RUNTEST_CC, and likewise for CXX. + (cdtest targets): Comment out. + * config/solaris2.mh (HOSTING_LIBS): Only mention crtend.o once. + * cdtest-bar.cc, cdtest-foo.cc, cdtest-foo.h: Remove. + * cdtest-main.cc, cdtest.exp: Remove. + +Mon Sep 26 11:40:30 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * emulparams/elf32bmip.sh: Rename from elf32mipb.sh to avoid DOS + file naming problems. + * emulparams/elf32lmip.sh: Rename from elf32mipl.sh. + * Makefile.in (ALL_EMULATIONS): Rename eelf32mipb.o to + eelf32bmip.o and eelf32mipl.o to eelf32lmip.o. + (eelf32bmip.c): Rename from eelf32mipb.c. Use elf32bmip.sh. + (eelf32lmip.c): Rename from eelf32mipl.c. Use elf32lmip.sh. + * config/mipsb-elf32.mt (EMUL): Use elf32bmip, not elf32mipb. + * config/mipsl-elf32.mt (EMUL): Use elf32lmip, not elf32mipl. + + * genscripts.sh: Always search /usr/local/TARGET/lib. + + * scripttempl/elf.sc: If -N is set, force DATA_ADDR to be ".". + +Fri Sep 23 15:05:49 1994 Ken Raeburn <raeburn@cujo.cygnus.com> + + * configure.in: Handle i386-bsdi* targets like i386-bsd. + +Fri Sep 23 00:06:59 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * lexsup.c (parse_args): Add support for -a for HP/UX + compatibility. + + * lexsup.c (parse_args): -c takes an argument. + +Tue Sep 20 14:35:27 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ld.h (args_type): Add new field endian. + * lexsup.c (parse_args): Handle -EB and -EL by setting + command_line.endian. + * ldgram.y (ifile_p1): Accept OUTPUT_FORMAT with three arguments. + * ldlang.c (lang_add_output_format): Add arguments big and little. + If command_line.endian is set, use it to select big or little + rather than the default. Changed all callers. + * ldlang.h (lang_add_output_format): Update declaration. + * emulparams/elf32mipb.sh: Define BIG_OUTPUT_FORMAT and + LITTLE_OUTPUT_FORMAT. + * emulparams/elf32mipl.sh: Likewise. + * emulparams/mipsbig.sh: Likewise. + * emulparams/mipsbsd.sh: Likewise. + * emulparams/mipsidt.sh: Likewise. + * emulparams/mipsidtl.sh: Likewise. + * emulparams/mipslit.sh: Likewise. + * scripttempl/elf.sc: Define BIG_OUTPUT_FORMAT and + LITTLE_OUTPUT_FORMAT if not already defined. Pass them to + OUTPUT_FORMAT. + * scripttempl/mips.sc: Pass BIG_OUTPUT_FORMAT and + LITTLE_OUTPUT_FORMAT to OUTPUT_FORMAT. + * scripttempl/mipsbsd.sc: Likewise. + + * Makefile.in (ldgram.h): Make separate target from ldgram.c, + depending upon ldgram.c, so that a parallel make does not try to + build both at once. + + * configure.in (mips*el-elf*): New target. + * Makefile.in (ALL_EMULATIONS): Add eelf32mipb.o and eelf32mipl.o. + (eelf32mipl.c): New target. + + * config/mipsl-elf32.mt: New file. + * emulparams/elf32mipl.sh: New file. + +Fri Sep 16 12:16:20 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ldmain.c (main): Rather than prohibiting ld -r -s, treat it as + ld -r -S -x. + +Thu Sep 15 13:05:44 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ldmisc.c (vfinfo): Print BFD file name as well as file name + returned by find_nearest_line, in case the file name is something + unhelpful such as a .h file. Handle %u. + +Wed Sep 14 12:49:12 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * ldlang.c (lang_do_assignments): Make sure output statement + has an attached bfd_section before trying to dereference it. + +Wed Sep 14 12:48:09 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ld.h (ld_config_type): Add new field warn_once. + * ldmain.c (undefined_symbol): Handle -warn-once. + * lexsup.c (parse_args): Recognize -warn-once. + * ld.texinfo (Options): Document -warn-once. + * ld.1: Likewise. + + * ldmisc.c (vfinfo): Handle %D as %C, but never print the function + name. For %C, print the function name on a separate line, to keep + the length of error messages under control. + * ldmain.c (multiple_definition): Use %D for ``first defined + here.'' + (undefined_symbol): Use %D for ``more undefined references + follow''. + + * ldmisc.c (multiple_warn): Remove; no longer used. + * ldmisc.h (multiple_warn): Don't declare. + +Tue Sep 13 20:47:58 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * ldlang.c (print_output_section_statement): Print all lines + to the map file. + +Tue Sep 13 16:30:11 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ldlang.c (load_symbols): Check for archive before object. Use + bfd_check_format_matches, and, if ambiguous, print a list of + matching formats. If file format is not recognized, treat file as + a linker script. + * ldgram.y (yyerror): If assuming an object file is a script, + mention that. Tweak the format of the error messages. + * ldlex.l (lex_warn_invalid): If assuming an object is a script, + guess that this is not actually a script, and just report that the + file format was not recognized. + * ld.texinfo (Options): Admit that -( may be used more than once. + Add note that unrecognized object files are now treated as linker + scripts. + + * ldfile.c (ldfile_input_filename): Make const. + (ldfile_assumed_script): New variable. + (try_open): Change arguments types to const. + (ldfile_find_command_file): Likewise. + (ldfile_open_command_file): Likewise. Also, set lineno to 1. + * ldfile.h: Update declarations for ldfile.c changes. + * ldlex.l: Include <ctype.h>. + (file_name_stack): Change to be const char *. + (lineno_stack): New static variable. + (<<EOF>>): Set lineno as well as ldfile_input_filename. + (lex_push_file): Make name argument const. Initialize + lineno_stack entry. + (lex_redirect): Initialize lineno_stack entry. + (lex_warn_invalid): Handle non printable characters nicely. + * ldlex.h (lex_push_file): Declare second argument as const. + + * ldgram.y (ifile_p1): Recognize GROUP. + * ldlex.l: Recognize GROUP. + * ld.texinfo (Option Commands): Document GROUP. + +Mon Sep 12 17:04:27 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * config/m68klynx.mh: New file. + +Mon Sep 12 01:50:03 1994 Jeff Law (law@snake.cs.utah.edu) + + * emultempl/hppaelf.em: Add newlines to the error messages. + +Sat Sep 10 16:05:38 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * config/i386lynx.mh: New file. + * scripttempl/i386lynx.sc: Don't put .ctors and .dtors in .text + unless CONSTRUCTING. + +Thu Sep 8 13:25:24 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * emulparams/elf32mipb.sh (TEMPLATE_NAME): Define as elf32. + (GENERATE_SHLIB_SCRIPT): Define as yes. + (DYNAMIC_LINK): Define as false. + * emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): + Initialize config.dynamic_link to DYNAMIC_LINK if it is defined. + (gld${EMULATION_NAME}_place_orphan): Reset stat_ptr at end. + * Makefile.in (eelf32mipb.c): Depend upon elf32.em rather than + generic.em. + +Thu Sep 8 16:30:37 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * scripttempl/h8500b.sc: Put rdata stuff into own segment. + +Thu Sep 8 13:25:24 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * emulparams/elf32ppc.sh (OTHER_READWRITE_SECTIONS): Don't define; + .got section is now explicitly handled in elf.sc. + +Wed Sep 7 13:08:34 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * scripttempl/alpha.sc: Redo script to set . outside of sections + and not bother to explicitly specify section addresses. + Explicitly place .sdata section. + +Tue Sep 6 23:51:45 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * scripttempl/m68kcoff.sc: Put .bss in data segment. + + * scripttempl/h8300.sc: Change .stab and .stabstr to use a VMA of + 0, and to only be marked as NOLOAD if relocating. + * scripttempl/h8500.sc, scripttempl/h8500b.sc: Likewise. + * scripttempl/h8500c.sc, scripttempl/h8500m.sc: Likewise. + * scripttempl/h8500s.sc, scripttempl/i386coff.sc: Likewise. + * scripttempl/i386go32.sc, scripttempl/i386lynx.sc: Likewise. + * scripttempl/m68kcoff.sc, scripttempl/m68klynx.sc: Likewise. + * scripttempl/sh.sc, scripttempl/sparccoff.sc: Likewise. + * scripttempl/sparclynx.sc: Likewise. + +Sun Sep 04 17:58:10 1994 Richard Earnshaw (rwe@pegasus.esprit.ec.org) + + * Makefile.in, configure.in: Add support (disabled) the ARM/RISCiX. + * config/riscix.mt, emulparams/riscix.sh, scripttempl/riscix.sc: + New files. + +Tue Aug 30 11:48:08 1994 Eric Youngdale (ericy@cais.cais.com) + + * ld.h (args_type): Add field soname. + * lexsup.c (parse_args): Handle -soname argument. + * emultempl/elf32.em: In call to bfd_elf32_size_dynamic_sections, + pass soname. + * ld.texinfo: Document -soname. + +Mon Aug 29 15:21:50 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ldlang.c (lang_check): Don't try to set the architecture if the + input and output files are incompatible. Just warn. + +Wed Aug 24 12:52:30 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * configure.in: Change i[34]86 to i[345]86. + +Sun Aug 21 16:17:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * emulparams/hp3hpux.sh: Define __DYNAMIC to be 0. + +Thu Aug 18 15:37:45 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + Make the ELF linker handle orphaned sections reasonably. Also, + define __start_SECNAME and __stop_SECNAME around sections whose + names can be represented in C, for the benefit of symbol sets in + glibc. + * ldemul.h (ldemul_place_orphan): Declare. + (ld_emulation_xfer_type): Add place_orphan field. + * ldemul.c (ldemul_place_orphan): New function. + * ldlang.h (wild_doit): Declare. + * ldlang.c (wild_doit): Make nonstatic. + (lang_place_orphans): Call ldemul_place_orphan. + * emultempl/elf32.em: Include <ctype.h> and "ldgram.h". + (hold_section, hold_use, hold_text, hold_data, hold_bss): New + static variables. + (gld${EMULATION_NAME}_place_orphan): New static function. + (gld${EMULATION_NAME}_place_section): New static function. + (ld_${EMULATION_NAME}_emulation): Initialize place_orphan field. + +Tue Aug 16 00:17:20 1994 Eric Youngdale (ericy@cais.cais.com) + + * scripttempl/aout.sc: Add .linux-dynamic after .data. + +Tue Aug 16 00:08:22 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * lexsup.c (parse_args) Treat --dll-verbose as --version, for + Linux compatibility. From hjl@nynexst.com (H.J. Lu). + +Mon Aug 15 17:17:33 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ldexp.h (exp_get_abs_int): Declare. + +Sat Aug 6 01:45:39 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * ldlang.c (lang_do_assignments): Handle complex AT's better. + * ldexp.c (exp_get_abs_int): New function. + +Fri Aug 5 20:55:55 1994 Jason Molenda (crash@phydeaux.cygnus.com) + + * configure.in: add i960-nindy-coff support. + +Thu Aug 4 14:45:50 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ldlex.l (yy_create_string_buffer): Handle change to internal + interface in flex 2.4.7. + +Tue Aug 2 11:52:06 1994 Eric Youngdale (ericy@cais.cais.com) + + * emultempl/linux.em (gld${EMULATION_NAME}_find_address_statement): + New function; add 0x20 to any use of -Ttext. + (gld${EMULATION_NAME}_create_output_section_statements): New + function. + (ld_${EMULATION_NAME}_emulation): Use the new function + gld${EMULATION_NAME}_create_output_section_statements. + +Mon Aug 1 15:50:44 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * scripttempl/mips.sc: Redo script to set . outside of sections + and not bother to explicitly specify section addresses. + +Tue Jul 26 11:02:35 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * scripttempl/elf.sc: Copy several more relocation sections into + the output. Put .got.plt sections into .got. + +Fri Jul 22 12:15:36 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * scripttempl/elf.sc: Use PROVIDE to define etext, edata, and end. + + Add a new script operator, PROVIDE, to define a symbol only if it + is needed. + * ldgram.y (PROVIDE): New token. + (assignment): Accept PROVIDE. + * ldlex.l (PROVIDE): New token. + * ldexp.h (node_type): Add etree_provide to node_class enum. + (exp_provide): Declare. + * ldexp.c (exp_fold_tree): Handle etree_provide. + (exp_provide): New function. + (exp_print_tree): Handle etree_provide. + * ld.texinfo: Document PROVIDE. + + * ldlang.c (lang_common): Pass desired alignment to + lang_one_common as power of two. + (lang_one_common): Get common symbol alignment from linker hash + table entry. Treat desired alignment as a power of two. + + * ldlang.c (wild_section): Attach all section with the given name, + not just the first one. If there is no name, attach all sections + even if the SEC_IS_COMMON flag is set. + +Wed Jul 20 15:49:27 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ld.h (args_type): Add field rpath. + * lexsup.c (S_ISDIR): Define if not already defined. + (parse_args): Add support for -rpath. If -R is used to name a + directory, treat it as -rpath for Solaris compatibility. + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): + Pass command_line.rpath to bfd_elf32_size_dynamic_sections. + * ldmain.c (main): Initialize command_line.rpath to NULL. + * ld.texinfo: Document -rpath option. + +Sun Jul 10 00:33:24 1994 Ian Dall (dall@hfrd.dsto.gov.au) + + * emulparams/pc532machaout.sh: New file. Pc532 mach script + parameters. + + * emulparams/netbsd532.sh: New file. Netbsd 532 script parameters. + + * config/pc532mach.mt: New file. Pc532 mach target support. + + * config/pc532mach.mh: New file. Pc532 mach host support. + + * config/netbsd532.mt: New file. Netbsd 532 target support. + + * configure.in: Add ns32k-pc532-mach and ns32k-pc532-netbsd support. + + * Makefile.in: Add epcmachaout.c dependency and enetbsd532.c + dependency. + +Fri Jul 8 10:57:02 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * emultempl/sunos.em (gld${EMULATION_NAME}_before_allocation): Use + bfd_abs_section_ptr, not &bfd_abs_section. + + * lexsup.c (parse_args): Changed "retain-symbols-file" from + no_argument to required_argument. From djm. + +Thu Jul 7 12:29:53 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * scripttempl/elf.sc: Explicitly mention .stab and .stabstr + sections to force a VMA of 0; needed for ELF backends which have + not been converted to the new linker style. + +Mon Jul 4 19:35:45 1994 Jeff Law (law@snake.cs.utah.edu) + + * scripttempl/hppaelf.sc (__stack_zero): Don't define this name, + it was for the HPUX dynamic loader's use and it creates problems + with ELF GDB. + +Fri Jul 1 12:53:47 1994 Jeff Law (law@snake.cs.utah.edu) + + * ldlang.c (lang_do_assignments): No longer static. Delete decl. + * ldlang.h (lang_do_assignments): Put external decl here. + * emultempl/hppaelf.em: Minor cleanups throughout file. + (hppa_elf_create_output_section_statements): Rewrite. + (hppaelf_finish): Rewrite. + +Wed Jun 29 16:50:00 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * config/solaris2.mh (NATIVE_LIB_DIRS): Define as /usr/ccs/lib. + + * lexsup.c (parse_args): Accept -Bstatic and -Bdynamic. Do not + accept plain -B. + * ld.texinfo: -Bstatic is not ignored. + +Tue Jun 28 12:13:34 1994 Stan Shebs (shebs@andros.cygnus.com) + + * ldlex.l: Recognize \r the same as \n. + +Thu Jun 23 17:53:04 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + Preliminary support for generating shared libraries, from Eric + Youngdale <ericy@cais.cais.com>. + * genscripts.sh: If the emulation parameter file sets + GENERATE_SHLIB_SCRIPT, generate a .xs script file with + CREATE_SHLIB defined. + * emultempl/elf32.em (gld${EMULATION_NAME}_get_script): If + link_info.shared is set, use the .xs script file. + * scripttempl/elf.sc: If CREATE_SHLIB is set, don't create a + .interp section, and don't include TEXT_START_ADDR in the starting + address of the first section. + * emulparams/elf_i386.sh (GENERATE_SHLIB_SCRIPT): Likewise. + * emulparams/elf32_sparc.sh (GENERATE_SHLIB_SCRIPT): Define. + +Thu Jun 23 12:52:22 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * configure.in: Change --with-targets to --enable-targets. + +Wed Jun 22 13:42:14 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * lexsup.c (parse_args): Add support for new options -( -) with + synonyms --start-group --end-group. + * ldlang.h (enum statement_enum): Add lang_group_statement_enum. + (lang_group_statement_type): Define new struct. + (lang_statement_union_type): Add group_statement field. + (lang_enter_group, lang_leave_group): Declare. + * ldlang.c (lang_for_each_statement_worker): Handle + lang_group_statement_enum. + (map_input_to_output_sections, print_statement): Likewise. + (lang_size_sections, lang_do_assignments): Likewise. + (open_input_bfds): Completely rewrite. Now does its own looping, + rather than using lang_for_each_statement. Handle groups. + (lang_process): Update call to open_input_bfds. + (print_group): New static function. + (lang_enter_group, lang_leave_group): New static functions. + * ldfile.c (ldfile_open_file): If the file has already been + opened, just return rather than taking an assertion failure. + * ldver.c (help): Mention new options. + * ld.texinfo: Document new options. + + * ldlang.c (end_of_data_section_statement_list): Don't define. + (lang_leave_output_section_statement): Don't set obsolete variable + end_of_data_section_statement_list. + + * scripttempl/go32coff.sc: Don't put ${DATA_ALIGNMENT} inside an + ALIGN. + + * ldlang.c (lang_size_sections): Adjust current region address + even for sections with an explicit address. From + ralphc@pyramid.com (Ralph Campbell). + + * emulparams/i386linux.sh (NONPAGED_TEXT_START_ADDR): Set to 0. + From jrs@world.std.com (Rick Sladkey). + + * scripttempl/mipsbsd.sc: Let sections align to their natural + boundaries. + +Tue Jun 21 11:27:04 1994 Ian Lance Taylor (ian@sanguine.cygnus.com) + + * ldlang.c (lang_init): Use new bfd_abs_section_ptr, not + &bfd_abs_section. + (lang_abs_symbol_at_beginning_of): Likewise. + (lang_abs_symbol_at_end_of): Likewise. + (lang_size_sections): Use bfd_is_abs_section to check for the + absolute section. Don't try to set the VMA or output_offset or + size of the absolute section. + * ldmain.c (notice_ysym): Use bfd_is_und_section to check for the + undefined section. + +Thu Jun 16 22:48:41 1994 Jeff Law (law@snake.cs.utah.edu) + + * scripttempl/hppaelf.sc: Place .data and .bss at 0x40000000 + when generating relocatable objects. + +Thu Jun 16 14:25:22 1994 Eric Youngdale (ericy@cais.cais.com) + + * emultempl/linux.em: New file providing support for linking + against Linux shared libraries. + * config/i386-linux.mt (ei386linux.c): Depend upon linux.em. + * emulparams/i386linux.sh (TEMPLATE_NAME): Define as linux. + +Thu Jun 16 12:22:01 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * lexsup.c (parse_args): Add -shared to longopts, and handle it. + * ldmain.c (main): Initialize link_info.shared to false. Give + error if link_info.relocateable and link_info.shared are both set. + + * configure.in: If EMUL_EXTRA* is defined in a config file, treat + it as naming an emulation to be added to EMULATION_OFILES. + * config/i386-linux.mt (EMUL_EXTRA1): Define as elf_i386. + + * Makefile.in: Rebuilt dependencies. + (ALL_EMULATIONS): Add ei386linux.o, eelf32_sparc.o, + eelf64_sparc.o. Remove $(OTHER_EMULATIONS). + (ei386linux.c, eelf32_sparc.c, eelf64_sparc.c): New targets. + * config/i386-linux.mt (OTHER_EMULATIONS): Don't define. + (ei386linux.c): Remove; now in Makefile.in. + * config/i386-lynx.mt (OTHER_EMULATIONS): Don't define. + * config/m68k-lynx.mt (OTHER_EMULATIONS): Don't define. + * config/sparc-lynx.mt (OTHER_EMULATIONS): Don't define. + * config/sparc64-elf.mt (OTHER_EMULATIONS): Don't define. + (eelf64_sparc.c): Remove; now in Makefile.in. + * config/sun4sol2.mt (OTHER_EMULATIONS): Don't define. + (eelf32_sparc.c): Remove; now in Makefile.in. + + * ldexp.c (exp_print_tree): Don't crash if etree_rel section has + no owner--it might be bfd_abs_section. From Eric Youngdale + <ericy@cais.cais.com>. + + * scripttempl/aout.sc: Let sections align to their natural + boundaries. + +Wed Jun 15 01:54:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldemul.h (ldemul_open_dynamic_archive): Declare. + (ld_emulation_xfer_type): Add new field open_dynamic_archive. + * ldemul.c: Include ldexp.h and ldlang.h. + (ldemul_open_dynamic_archive): New function. + * ldfile.h (ldfile_open_file_search): Declare. + * ldfile.c: Include ldemul.h. + (try_open_bfd): Rename from cache_bfd_openr. Return boolean + argument, not bfd *. Change all callers. + (ldfile_open_file_search): Rename from open_a. Return boolean + argument, not bfd *. Clean up. Change all callers. + (ldfile_open_file): If doing a dynamic link, call + ldemul_open_dynamic_archive rather than assuming the extension of + a dynamic object is ".so". + * emultempl/elf32.em (gld${EMULATION_NAME}_open_dynamic_archive): + New function. + (ld_${EMULATION_NAME}_emulation): Initialize open_dynamic_archive + field. + * emultempl/sunos.em (ld_${EMULATION_NAME}_emulation): Likewise. + + * ldmain.c (get_emulation): Ignore -m486 for Linux compatibility. + * lexsup.c (parse_args): Ignore -qmagic for Linux compatibility. + Accept -static as a synonym for -non_shared. + + Let the user change the dynamic linker used by ELF code. + * ld.h (args_type): Add new field interpreter. + * lexsup.c (parse_args): Add dynamic-linker to longopts, and + handle it. + * ldmain.c (main): Initialize command_line.interpreter to NULL. + * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Get + the ELF backend to return the .interp section. If + command_line.interpreter is not NULL, set the contents of .interp + to it. + * ld.texinfo: Mention -dynamic-linker. + + * config/sun4sol2.mt (eelf32_sparc.c): Depend upon elf32.em, not + generic.em. + + * lexsup.c (parse_args): Sort out the option macros and change the + definitions to make it easier to add a new option. + + * scripttempl/aout.sc: Define __etext and __edata to go along with + _etext and _edata. + + * ld.h (ld_config_type): Add new field traditional_format. + * lexsup.c (parse_args): Add traditional-format to longopts, and + handle it. + * ldmain.c (main): Initialize config.traditional_format to false. + * ldlang.c (ldlang_open_output): Set BFD_TRADITIONAL_FORMAT in BFD + flags of output_bfd according to config.traditional_format. + * ldver.c (help): Mention -traditional-format. + * ld.texinfo: Document -traditional-format. + +Tue Jun 14 23:10:07 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldctor.c (ldctor_add_entry): Add entries to a set in the order + they are encountered. + +Tue Jun 14 18:05:09 1994 Eric Youngdale (ericy@cais.cais.com) + + * emulparams/i386linux.sh (TEXT_START_ADDR): Define as 0x1000. + (NONPAGED_TEXT_START_ADDR): Define as 0x20. + +Mon Jun 13 15:46:09 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * scripttempl/alpha.sc: Define _ftext, _etext and _fdata insted of + _FTEXT, _ETEXT and _FDATA. Dont define _END. + + * ldfile.c (open_a): If this is not an archive, try to open it in + the current directory before searching for it. + + * lexsup.c (parse_args): Treat -i as a synonym for -r. + + * ldgram.y (exp): Treat BLOCK as a synonym for ALIGN, so that + BLOCK works in a section address as documented. + + * ldgram.y (YYDEBUG): Don't define. + +Fri Jun 10 16:45:39 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * emultempl/gld960.em: Pass false for new argument to + ldfile_add_library_path. + * emultempl/gld960c.em, emultempl/lnk960.em: Likewise. + + * emultempl/sunos.em: Only look for .so files if doing a dynamic + link. + +Thu Jun 9 08:35:17 1994 Ian Lance Taylor (ian@cygnus.com) + + * scripttempl/i960.sc: Add CONSTRUCTORS to .data. + +Thu Jun 9 06:52:29 1994 Bill Cox (bill@rtl.cygnus.com) + + * Makefile.in (check): Delete ld.new dependency so that a regression + test doesn't trigger a rebuild of the linker. + +Thu Jun 9 00:17:20 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (map_input_to_output_sections): For lang_address, call + init_os if it hasn't already been called. + +Thu Jun 2 17:24:08 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Add support for SunOS shared libraries. + * aout.sc: Don't define __DYNAMIC here. Add new sections used by + shared library support code. + * emultempl/sunos.em: New file. + * emulparams/sun4.sh (TEMPLATE_NAME): Define as sunos. + * emulparams/sun3.sh (TEMPLATE_NAME): Likewise. + * Makefile.in (esun4.c): Depend upon sunos.em, not generic.em. + (esun3.c): Likewise. + + * ldlang.c: Minor formatting cleanups. + (lang_for_each_input_file): New function. + * ldlang.h (lang_for_each_input_file): Declare. + + * ldfile.h (search_dirs_type): Move from ldfile.c, and add cmdline + field. + (search_head): Declare. + (ldfile_add_library_path): Add new cmdline argument in prototype. + * ldfile.c (search_head): Make non-static. + (search_dirs_type): Move to ldfile.h. + (ldfile_add_library_path): Accept cmdline argument, and save it. + * lexsup.c (parse_args): Pass true for new cmdline argument of + ldfile_add_library_path. + (set_default_dirlist): Likewise. + * ldmain.c (check_for_scripts_dir): Pass false for new cmdline + argument of ldfile_add_library_path. + * ldgram.y (ifile_p1): Likewise. + +Wed Jun 1 14:24:08 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.h (lang_input_statement_type): Remove fields subfiles, + total_size, superfile and chain. + * ldfile.c (open_a): Don't clear search_dirs_flag. + (ldfile_open_file): Don't try to open superfile. Assert that file + has not already been opened. + * ldlang.c (new_afile): Don't initialize superfile. + * ldmain.c (add_archive_element): Don't initialize subfiles or + chain or superfile. Initialize search_dirs_flag to false. + +Fri May 27 12:25:33 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * ldver.c (ldversion): Changed version to "cygnus-2.4.1". + + Changes from binutils-2.4 release: + + * genscripts.sh (RELOCATING, CONSTRUCTING): When setting + variables, use whitespace, so scripts don't break. + + * config/alphaosf.mh (HDEFINES, CFLAGS): Deleted. + + * emultempl/generic.em: Find emultempl/stringify.sed in ${srcdir}. + + * cdtest-bar.cc: Renamed from cdtest-func.cc. + * Makefile.in: Noted change. + + * scripttempl/a29k.sc: Don't include /lab3/u3/..../segments.o; I + don't know where that's supposed to come from, or why it's + necessary. + + Wed May 11 22:32:00 1994 DJ Delorie (dj@ctron.com) + + * configure.bat: update to latest makefile.in + * emulpara/go32.sh: set to coff-go32 not aout + * emultemp/generic.em: strength-reduce the structure of + this shell script, since the only available shell for + DOS can't handle complex syntax. + * emultemp/stringify.sed: for "sed -f" instead of inline. + * makefile.in: depend on stringify.sed as well as genscripts.sh + * scripttemp/go32coff.sc: correct for djgpp 1.11's COFF format + * genscripts.sh: empty variables aren't always considered "set", + so set them to "y" instead. + +Fri May 27 01:08:14 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (entry_symbol): Make static. + (lang_add_entry): Add cmdline argument. + * ldlang.h (lang_add_entry): Change prototype. + * ldgram.y (statement_anywhere): Change lang_add_entry call. + * lexsup.c (parse_args): Likewise. + +Tue May 24 16:13:43 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * emulparams/elf32mipb.sh (OTHER_READONLY_SECTIONS): Don't give + .reginfo an address. + (OTHER_READWRITE_SECTIONS): Don't give .lit4 or .lit8 an address. + (OTHER_SECTIONS): Define for .gptab.sdata and .gptab.sbss. + * scripttempl/elf.sc: Use OTHER_SECTIONS at end of script. + +Thu May 19 13:31:33 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Add support for ELF shared libraries. + * ld.h (ld_config_type): Add field dynamic_link. + * ldmain.c (main): Initialize config.dynamic_link to false. Warn + on attempts to use -r with -relax, -call_shared or -s. + * lexsup.c (longopts): Separate OPTION_CALL_SHARED from + OPTION_NON_SHARED. Add OPTION_IGNORE. Adjust macro values + accordingly. Add "dy" and "non_shared" options. Change "Qy" to + OPTION_IGNORE for now. Handle OPTION_CALL_SHARED and + OPTION_NON_SHARED by setting dynamic_link field accordingly. + Handle OPTION_IGNORE by ignoring it. Clear dynamic_link field for + -r and -Ur. + * ldfile.c (ldfile_open_file): If config.dynamic_link is true, try + opening a file with a .so extension first. + * emultempl/elf32.em: New file. + * emulparams/elf32_sparc.sh (TEXT_START_ADDR): Change to 0x10000. + (NONPAGED_TEXT_START_ADDR): Likewise. + (TEMPLATE_NAME): Define as elf32. + (DATA_PLT): Define. + * emulparams/elf_i386.sh (TEMPLATE_NAME): Define as elf32. + * scripttempl/elf.sc: Add placement for new dynamic sections. + Don't use CREATE_OBJECT_SYMBOLS. Define _etext, _edata and _end + outside of any section. Don't use ALIGN(8); just let one section + VMA follow another. Put .dynbss in .bss. Don't mention debugging + sections; they'll be handled correctly anyhow. + * Makefile.in (eelf_i386.c): Depend upon elf32.em, not generic.em. + +Wed May 18 10:15:39 1994 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (install): Redirect output of ln to /dev/null. + +Mon May 16 13:35:08 1994 Jeff Law (law@snake.cs.utah.edu) + + * emultempl/hppaelf.em: Change all references of + .hppa_linker_stubs to .PARISC.stubs. + * scripttempl/hppaelf.sc: Likewise. + +Fri May 13 13:00:38 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (print_output_section_statement): Change ``no attached + output section'' message slightly. + (lang_do_assignments): Don't recurse down if there is no real + section. + + * config/i386-linux.mt (OTHER_EMULATIONS): Change em_ to e to + match corresponding change in emulation templates. + * config/i386-lynx.mt, config/m68k-lynx.mt: Likewise. + * config/sparc-lynx.mt, config/sun4sol2.mt: Likewise. + +Wed May 11 18:16:46 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * ldver.c (ldversion): Updated version number. + + * cdtest-foo.cc: Use explicit "#pragma implementation". + * cdtest-bar.cc: Renamed from cdtest-func.cc. + * Makefile.in: References to cdtest-func.o changed to + cdtest-bar.o. + +Wed May 11 16:24:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Don't create unnecessary output sections. + * ldlang.c (out_bfd_get_section_by_name): Remove. + (wild_section): Call bfd_get_section_by_name rather than + our_bfd_get_section_by_name. Don't call wild_doit if there is no + section. + (lang_create_output_section_statements): Remove. + (map_input_to_output_sections): For several cases, call init_os if + it has not already been called. + (lang_size_sections): If output section was not created, skip it. + (lang_process): Don't call lan_create_output_section_statements. + (lang_place_orphans): Skip files with just_syms_flags set to true. + * ld.texinfo: Document change. + +Tue May 10 14:31:16 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (wild_doit): Don't bother initializing the vma and + section size. Don't special case SEC_SHARED_LIBRARY. + (lang_size_sections): Handle SEC_COFF_SHARED_LIBRARY sections + specially. + +Fri May 6 12:24:27 1994 Steve Chamberlain (sac@cygnus.com) + + * config/go32.mh : New file for Xgo32X. + +Fri May 6 15:15:35 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldfile.c (ldfile_open_command_file): Set bfd_error_system_call + before calling einfo, since we are reporting an fopen failure. + From jrs@world.std.com (Rick Sladkey). + + * configure.in: Use "e" rather than "em_" as prefix for + emulations. + +Fri May 6 01:08:14 1994 Ken Raeburn (raeburn@kr-pc.cygnus.com) + + * emultempl/generic.em: Use "e" rather than "em_" as prefix for + filename. + * emultempl/gld960.em, emultempl/gld960c.em, emultempl/lnk960.em, + emultempl/hppaelf.em, emultempl/m88kbcs.em, emultempl/vanilla.em: + Ditto. + * Makefile.in: Changed all generated file names. + (ldemul-list.h): Depend on Makefile, not config.status. Changed + sed patterns to handle new filenames. + + * config/mipsl-idt.mt: Renamed from mips-idtl.mt. + * configure.in: Adjusted. + +Thu May 5 15:07:32 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * Makefile.in (install-info): Don't use "$<*", it doesn't always + work. Instead, check build dir and $srcdir explicitly, and use + `echo' to get all the filenames. + + * configure.in (h8300h-*-hms): Changed ld_target name to + cf-h8300h. + * config/cf-h8300h.mt: Renamed from coff-h8300h.mt, to make it + unique in 8.3. + + * config/i960coff.mt: New file. + * emulparams/gld960coff.sh: New file. + * emultempl/gld960c.em: New file. + * configure.in (i960-*-vxworks5* except -vxworks5.0*): Use + i960coff configuration. + * Makefile.in (em_gld960coff.c): Added dependencies, build rule. + + * Makefile.in (ALL_EMULATIONS): Remove em_delta68.o, since the + code isn't included in FSF releases, and it can still be + explicitly selected. + (distclean): Remove site.bak and tmpdir. + (STAGESTUFF): Removed $(GENERATED_CFILES) $(GENERATED_HFILES). + (mostlyclean): Delete them explicitly here. Also remove tmpdir. + + Patches from Ralph Campbell: + * config/mipsbsd.mh: New file. + * Makefile.in (em_mipsbsd.c): Use mipsbsd.sc, not aout.sc. + * scripttempl/mipsbsd.sc: Don't define __DYNAMIC. + * emulparams/mipsbsd.sh (OUTPUT_FORMAT): Fix name to have `a.out' + instead of `aout'. + + * configure.in (i386-*-gnu*): Treat like i386-*-mach*. + +Wed May 4 11:59:40 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * config/m68k.mt (EMUL): Set to m68kaout. + * emulparams/m68kaout.sh: New file. + * Makefile.in (ALL_EMULATIONS): Add em_m68kaout.o. + (em_m68kaout.c): New target. + + * ldlang.c (lang_size_sections): If dot moves because of an + assignment, don't try to insert a pad into the absolute output + section, just change the address of the default memory region + instead. + + * Makefile.in (mostlyclean): Remove cdtest.tmp, cdtest-ur, + cdtest-ur.out, and cdtest-ur.tmp. + +Wed Apr 27 16:03:37 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * scripttempl/sa29200.sc: Align all sections to four byte + boundaries. + +Wed Apr 27 10:48:03 1994 Steve Chamberlain (sac@cygnus.com) + + * Makefile.in, configure.in: Support for go32 coff. + * config/i386-go32.mt: New file + * emulparams/i386go32.sh: New file + * scripttempl/i386go32.sc: New file + +Tue Apr 26 17:20:03 1994 Stan Shebs (shebs@andros.cygnus.com) + + * Makefile.in (em_m68klynx.c, em_i386lynx.c, em_sparclynx.c): Use + Lynx-specific script templates. + * configure.in (sparclite*-*-coff): Use coff-sparc. + * emulparams/i386lynx.sh (SCRIPT_NAME): Set to i386lynx. + * emulparams/sparclynx.sh (SCRIPT_NAME): Set to sparclynx. + (ENTRY): Set to __main. + * scripttempl/i386lynx.sc: New file, script for I386 Lynx. + * scripttempl/m68klynx.sc: Add insertion of ctor/dtor sections. + * scripttempl/sparclynx.sc: New file, script for uSparc Lynx. + +Tue Apr 26 12:41:03 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * scripttempl/mips.sc: Force _gp and .lit8 to be aligned to a 16 + byte boundary, in case the global constructors do not take up an + even 16 bytes. + + * config/i386v4.mh (HOSTING_CRT0): If ../gcc/crtbegin.o does not + exist, get crtbegin based on gcc -print-libgcc-file-name. + (HOSTING_LIBS): Similar change for ../gcc/crtend.o. + +Mon Apr 25 15:27:52 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (lang_size_sections): When no address is given for a + section, align it according to its requirements. + +Thu Apr 21 17:24:24 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in (clean, distclean): Remove configdoc.texi. + +Tue Apr 19 12:12:15 1994 Bill Cox (bill@rtl.cygnus.com) + + * configure.in: Add i[34]86-*-bsd386 to the patterns recognized. + +Fri Apr 15 14:35:42 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (lang_size_sections): When relaxing, adjust the + position of a padding statement, and adjust dot accordingly. + +Mon Apr 11 17:37:09 1994 Bill Cox (bill@rtl.cygnus.com) + + * Makefile.in (EXPECT, RUNTEST): Set these for the check goal. + +Mon Apr 11 12:32:57 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * scripttempl/i386coff.sc: If relocating, don't put .init and + .fini sections into .text; keep them separate. + * config/i386sco.mh (HOSTING_CRT0): If ../gcc/crtbegin.o does not + exist, get crtbegin based on gcc -print-libgcc-file-name. + (HOSTING_LIBS): Similar change for ../gcc/crtend.o. + +Mon Apr 11 10:31:00 1994 Bill Cox (bill@rtl.cygnus.com) + + * Makefile.in (check): Set TCL_LIBRARY for runtest. + +Wed Apr 6 00:09:37 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * configure.in (hppa*-*-*elf*): Don't require "-hp-" for the + manufacturer. + + * emultempl/hppaelf.em (hppaelf_finish): Only resize sections + if building a final executable. + +Tue Apr 5 12:17:30 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldmain.c (main): Check the return value of bfd_close. + +Thu Mar 31 18:07:06 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * scripttempl/alpha.sc: Clean up section alignment to ensure that + sections never overlap when using -r. + +Wed Mar 30 15:51:15 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldmisc.c (vfinfo): Change symbol reading slightly for recent BFD + changes: get_symtab_upper_bound renamed and returns long, + bfd_canonicalize_symtab returns long, check for error indications. + +Fri Mar 25 17:20:01 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (print_input_section): For section size, use + _cooked_size if it is non-zero, size otherwise. + (size_input_section): Likewise. + (lang_do_assignments): Likewise (case lang_input_section_enum). + +Thu Mar 24 15:20:47 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (new_afile): Add new argument add_to_list. Don't set + real to true for lang_input_file_is_marker_enum. Clear the_bfd. + (lang_add_input_file): Pass true to new_afile for add_to_list. + (lookup_name): Remove force_load argument. Changed all callers. + Pass false to new_afile for add_to_list. Split loading of symbols + out into separate function. + (load_symbols): New function split out of lookup_name. Don't load + the symbols if they are already loaded. + (open_input_bfds): For lang_input_statement_enum call load_symbols + rather than lookup_name. + (lang_process): Pass abs_output_section rather than NULL to + lang_size_sections. + (lang_startup): Set real field of first_file to true. + +Wed Mar 23 14:15:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (had_relax): Removed. + (relax_again): New static variable. + (lang_size_sections): Change call to bfd_relax_section to + correspond to BFD changes. Set relax_again appropriately. + (lang_process): Remove #if 0 code. When relaxing, keep calling + lang_do_assignments and lang_size_sections until relax_again + becomes false. + + * emultemp/gld960.em: Include libiberty.h + (gld960_before_parse): Pass NULL as final argument to concat. + +Tue Mar 22 13:08:28 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * scripttempl/aout.sc: Force _end and __end to be aligned to a + four byte boundary. + + * ldwrite.c (build_link_order): Handle lang_data_statement_enum by + building a bfd_data_link_order, rather than by setting the section + contents immediately. + +Mon Mar 21 18:28:37 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Changes to make -Ur work again. + * ldmain.c (add_to_set): Now takes reloc argument rather than + bitsize. Check config.build_constructors here. If an new hash + table entry is created, mark it as undefined. + (constructor_callback): No longer takes bitsize argument. Pass + BFD_RELOC_CTOR to ldctor_add_set_entry, but first make sure the + BFD backend supports it. + (reloc_overflow): Handle a NULL abfd argument. + (reloc_dangerous, unattached_reloc): Likewise. + * ldctor.c: Include ldmain.h. + (struct set_info): Change bitsize field to reloc. + (ldctor_add_set_entry): Now takes reloc argument rather than + bitsize. Don't bother to check config.build_constructors here. + (ldctor_build_sets): Get the size from the reloc howto. If + generating relocateable output, call lang_add_reloc rather than + lang_add_data. + * ldctor.h (ldctor_add_set_entry): Change declaration to use reloc + instead of bitsize. + * ldlang.h (statement_enum): Add lang_reloc_statement_enum. + (lang_reloc_statement_type): New structure. + (lang_statement_union_type): Add reloc_statement field. + (lang_add_reloc): Declare new function. + * ldlang.c (lang_for_each_statement_worker): Handle + lang_reloc_statement_enum. + (map_input_to_output_sections, print_statement): Likewise. + (lang_size_sections, lang_do_assignments): Likewise. + (print_reloc_statement): New function. + (lang_add_reloc): New function. + * ldwrite.c (build_link_order): Handle lang_reloc_statement_enum. + + * Makefile.in (cdtest.out, cdtest-ur.o): New targets. + (cdtest-ur, cdtest-ur.out): New targets. + (check-cdtest): Now also check that -Ur works correctly. + + * scripttemp/alpha.sc: Align all sections to 16 byte boundaries. + +Thu Mar 17 12:45:41 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (lang_process): Move lang_common call before + map_input_to_output_sections, to ensure that any alignment + constraints set by common symbols are copied over to the output + sections. + +Fri Mar 11 22:17:34 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * emulparams/elf32ppc.sh (TEMPLATE_NAME): Don't define. + (OTHER_READWRITE_SECTIONS): Rename .toc to .got. + * Makefile.in (em_elf32ppc.c): Depend upon generic.em, not ppc.em. + * emultempl/ppc.em: Remove ugly stub code; turns out not to be + needed for ELF. + +Tue Mar 8 04:22:27 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * config/i386bsd.mh: New file. + +Mon Mar 7 15:23:24 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * elf.sc: Permit TEXT_START_SYMBOLS and DATA_START_SYMBOLS to be + defined. + * emulparams/elf32mipb.s (TEXT_START_SYMBOLS): Define _ftext. + (DATA_START_SYMBOLS): Define _fdata. + +Mon Feb 28 10:59:14 1994 Stan Shebs (shebs@andros.cygnus.com) + + * ldlang.c (cat): Define using ANSI style if ALMOST_STDC defined. + +Sun Feb 27 16:29:38 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * emultempl/hppaelf.em (hppaelf_finish): Update comments. This + works again. Attach some output symbols to the stub file bfd. + + * emultempl/hppaelf.em: Include elf32-hppa.h. + (file_chain): Add decl. + (hppa_look_for_stubs_in_section): Delete decl. + (hppaelf_finish): Reenable code. Do not pass symbols + down to hppa_look_for_stubs_in_section. + +Sat Feb 26 10:58:25 1994 Ian Lance Taylor (ian@cygnus.com) + + * ldmain.c (write_map): Don't define. Removed all references. + Just use map_file or map_filename instead. + (add_archive_element): Use minfo to write map information, not + info_msg. + (constructor_callback): Use fprintf to write map information, not + info_msg. + * ldmain.h (write_map): Don't declare. + * ldgram.y (mri_script_command): Removed reference to write_map. + * ldlang.c (lang_one_common): Likewise. + * lexsup.c (parse_args): Likewise. + +Fri Feb 25 19:12:03 1994 Ian Lance Taylor (ian@cygnus.com) + + * scripttempl/elf.sc: Force all sections to be aligned. + + * ldgram.y (section): Reverse the order of memspec_opt and + fill_opt to avoid an ambiguity when both are used. + * ld.texinfo: Changed accordingly. + + * ldgram.y: Move include of ldlex.h back with other includes. + * ldlex.h (input_type): Don't initialize enum constants to + particular values. + * ldlex.l: Use a switch to return the right token based on + input_type, rather than knowing that input_type has a value based + on a token type. + + * ldgram.y (dirlist_ptr): Removed; not used. + * lexsup.c: Include ldver.h. + * Makefile.in: Rebuilt dependencies. + +Fri Feb 25 18:55:54 1994 Ted Lemon (mellon@pepper.ncd.com) + + * ldlang.c (lookup_name): don't call bfd_set_gp_size. + (ldlang_add_file): call it here instead. + +Fri Feb 25 18:13:46 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * ldgram.y: Include ldlex.h after %token decls, for byacc. + +Fri Feb 25 10:47:25 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * emultempl/hppaelf.em: First attempt to clean this file up. + Add comments in several functions as to their purpose and + how they function (or my current best guess). Clean up horrible + spacing and indention that never should have been accepted in the + first place. Add FIXMEs for issues which need to be resolved. + Disable linker-stub generation until it gets fixed. This allows + the linker to at least work on simple code for testing purposes. + + * ldlang.c (lang_size_sections): No longer static (PA ELF calls + it via hppaelf_finish). Prototype moved into ldlang.h. + (lang_process): Move problematic extra call to lang_size_sections + into the PA ELF specific code. + * emultempl/hppaelf.em (hppaelf_finish): Extra call to + lang_size_sections moved here. + +Thu Feb 24 16:47:33 1994 Ian Lance Taylor (ian@cygnus.com) + + * configure.in (powerpc-*-elf*): New target; use ppc-elf32. + * config/ppc-elf32.mt: New file. + * emulparams/elf32ppc.sh: New file. + * emultempl/ppc.em: New file. + * Makefile.in (ALL_EMULATIONS): Added em_elf32ppc.o. + (em_elf32ppc.c): New target; uses elf32ppc.sh, ppc.em and elf.sc. + (EMULATION_OFILES): Added dependencies on ldexp.h and ldlang.h. + +Thu Feb 24 12:27:07 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * lexsup.c (parse_args): Use symbolic numbers for long options. + Fix misunderstanding in -Y and -call_shared et al. + + Use getopt instead of lex and yacc to parse the command line. + + * ld.texinfo (Options): Document changes to option syntax. + * Makefile.in: Update dependencies. + * ldver.c (help): Tweak dashes in usage message. + * ldgram.y (%union): Remove unused members. + Remove %tokens for command line options; add ones for input types. + (command_line): Rules removed. + (file): Instead of command line, recognize an + input type indicator, then use the nonterminal for that type. + (defsym_expr): New nonterminal from code formerly in command_line. + * ldlex.h: Declare parser input type enum and variable. + Don't declare parse_line. + * ldlex.l: Remove unused variables. Make some used ones static + and comment them. + (COMMAND): Start state and its rules removed. + At start of yylex, return input state token if at start of input. + (lex_redirect): Don't need to set yyout. + (ldlex_command): Function removed. + * ldmain.c (main): Instead of calling parse_line, set up the + redirections and call yyparse directly. + * ldmisc.c (vfinfo): If there's no input filename, print nothing, not + "command line". + * lexsup.c: Remove #if 0'd code. + (parse_line): Function removed. + (parse_args): Rewrite to use getopt_long_only. + (set_default_dirlist): New function from code formerly in + ldgram.y:command_line. + (set_section_start): New function. + * emultempl/generic.em, emultempl/gld960.em, emultempl/hppaelf.em, + emultempl/lnk960.em, emultempl/m88kbcs.em: Don't enclose + compiled-in link scripts in "{" and "}", as the grammar no longer + wants them to be. + +Thu Feb 24 08:43:26 1994 Ken Raeburn (raeburn@rtl.cygnus.com) + + * Makefile.in (ld.dvi): Depend on configdoc.texi, but don't + require that it be in $(srcdir). + +Tue Feb 22 09:21:18 1994 Ian Lance Taylor (ian@cygnus.com) + + * ldlang.c (lang_size_sections): Only align section to alignment + required by linker script, not to maximum alignment of input + sections. + + * ldlang.h (largest_section): Don't declare. + * ldlang.c (largest_section): Don't define. + (size_input_section): Don't set largest_section; not used. + +Mon Feb 21 15:15:29 1994 Ian Lance Taylor (ian@cygnus.com) + + * ldlang.c (new_afile): Pass NULL as last argument to concat. + +Thu Feb 17 15:51:23 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c, ldmain.c: Include libiberty.h. + + * ldmisc.h (concat): Don't declare. + * ldmisc.c (concat): Don't define; just use the one in libiberty. + + * ld.h (as_output_section_statement): Removed; not used. + +Thu Feb 17 09:32:14 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldlang.c, ldmain.c, ldmisc.c: Use bfd_get_error and + bfd_set_error and new error names. + +Tue Feb 15 20:14:53 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * ldwrite.c (build_link_order): If the cooked size of the section + has been set, use it, for determining link_order size. + (ldwrite): In the error message displayed if bfd_final_link fails, + indicate that it was in fact the final link step that failed. + + * ldlang.c (lang_size_sections): Clear bfd_error before calling + bfd_relax_section, in case it returns false but doesn't flag an + error. If an error is returned, indicate which one it is in the + error message. + + * Makefile.in (install-info): Depend on ld.info, and use "$<*" so + it'll get picked up from $(srcdir) if appropriate. + +Tue Feb 15 16:32:04 1994 David J. Mackenzie (djm@rtl.cygnus.com) + + * scripttempl/aout.sc: Only pad .text if PAD_TEXT is set. + * emulparams/i386mach.sh (PAD_TEXT): Set PAD_TEXT. + +Fri Feb 11 17:02:49 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldlex.l (comment): Increment line number when newline is read. + +Fri Feb 11 17:36:20 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (lookup_name): Take new argument, force_load. If true, + reload the file even if it is already loaded. + (wild): Call lookup_name with force_load argument of 0. + (open_input_bfds): Call lookup_name with force_load argument of 1. + (print_symbol): Remove declaration of non-existent function. + (print_one_symbol): Return true rather than falling off end. + +Thu Feb 10 11:52:38 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldmain.c (main): Use %ld when printing long values. + + * scripttempl/elf.sc: Move _edata after the .sdata section. + Permit OTHER_BSS_SYMBOLS to be defined. + * emulparams/elf32mipb.s (OTHER_BSS_SYMBOLS): Define _fbss. + +Mon Feb 7 16:31:15 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * Rename all "hppaosf" files to "hppaelf". + * Change all "osf" references to "elf" in hppaelf files. + * Makefile.in: Likewise. + * configure.in: Likewise. + +Sun Feb 6 20:31:56 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldmain.c (main): Call xatexit, not atexit. + Call xmalloc_set_program_name. + + * ldlang.c (lang_size_sections): Check if bfd_relax_section set + bfd_errno. + +Sat Feb 5 03:54:34 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * emultempl/lnk960.em (append), emultempl/hppaosf.em + (hppaosf_finish): Call xmalloc, not ldmalloc. + * ldmain.c (preserve_output): Function removed. + (main): Do it here instead. + +Fri Feb 4 23:02:19 1994 Jeffrey A. Law (law@snake.cs.utah.edu) + + * ldlang.h (LANG_FOR_EACH_{INPUT,OUTPUT}_SECTION): Delete (unused) + GNU C specific macros. + + * emultempl/hppaosf.em (hppaosf_finish): Expand the only remaining + call to LANG_FOR_EACH_INPUT_SECTION. + +Fri Feb 4 16:26:08 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldmisc.c (ldmalloc, xmalloc, ldrealloc, xrealloc): Functions + deleted; will use libiberty versions instead. + * ldctor.c ldfile.c ldlang.c ldmain.c ldmisc.c ldmisc.h lexsup.c + mri.c Makefile.in: Change callers. + + * ldmisc.c (vfinfo): Remove cleanup code. + * ldmain.c (remove_output): Put it here (new function). + (preserve_output): New function. + (main): Register remove_output and preserve_output with atexit. + * ldmain.c ldgram.y: Call xexit instead of exit. + * ldmisc.h: Declare xexit. + +Fri Feb 4 15:19:01 1994 Steve Chamberlain (sac@cygnus.com) + + * Makefile.in: Lots of new H8/500 memory models. + +Sun Jan 30 14:33:40 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * ldlex.l: Removed duplicate rules. + (yywrap): Provide default definition, needed with some versions of + flex. + +Fri Jan 28 09:12:56 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldmisc.c (vfinfo): For `%I', if the file is in an archive, print + the archive filename too. + + * ldlex.l: Add rule to catch invalid input characters instead of + printing them. Include "ldmain.h" for program_name decl. + (lex_warn_invalid): New function. + * Makefile.in: Add dependency. + +Fri Jan 28 12:58:45 1994 Ken Raeburn (raeburn@cujo.cygnus.com) + + * Makefile.in (check): Don't bother running any tests of + cross-linker until the test suite no longer assumes native mode. + +Thu Jan 27 17:19:54 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * ldlang.c (print_one_symbol, print_input_section): Print + global symbols in symbol table again. + +Thu Jan 27 12:35:01 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldmain.c ldmain.h ldgram.y: If -v -V or --version was given, + exit successfully instead of complaining if no input files are + given. + +Tue Jan 25 13:19:41 1994 Stan Shebs (shebs@andros.cygnus.com) + + * Makefile.in: Format variable definitions consistently. + (LD_PROG): Remove unnecessary variables from link command, + change variable LOADLIBES to EXTRALIBS. + + * ldmain.c (main): Compute and display total execution time. + * ld.texinfo (-stats): Document the option. + +Mon Jan 24 12:56:37 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldmain.c (reloc_overflow): Added name, reloc_name and addend + arguments. + + * ldlang.c (lookup_name): Set BFD GP size to -G argument value + after opening BFD. + + * ldlang.c (relaxing): Removed global variable. + (lang_size_sections): If the canonical symbols have not already + been read in, read them in before relaxing. + * ldlang.h (relaxing): Removed declaration. + +Fri Jan 21 00:44:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (new_afile): Initialize loaded field to false. + (lookup_name): If file was already loaded, don't call the + add_symbols entry point again. + +Wed Jan 19 13:57:00 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ld.texinfo: Clarify what -T option does. + +Tue Jan 18 16:18:15 1994 Steve Chamberlain (sac@jonny.cygnus.com) + + * scripttempl/m88kbcs.sc: Don't use CREATE_OBJECT_SYMBOLS, that's + for a.out. + +Tue Jan 11 13:22:04 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldmain.c (add_archive_element): If trace_files or + trace_file_tries, print file name. + * ldlang.c (lookup_name): Likewise. + (ldlang_add_file): Don't put files on input_bfds list in reverse + order. + + * scripttempl/elf.sc: Correct typo. + +Mon Jan 10 19:49:05 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldgram.y, ldlex.l: Make the space between -e, -u, and -y and + their arguments optional, for compatibility with the old GNU ld. + +Fri Jan 7 20:00:24 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * scripttempl/elf.c: Define __bss_start before the .sbss section. + +Thu Jan 6 00:13:10 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldmain.c (add_to_set): Add bitsize argument. + (constructor_callback): New function. + (link_callbacks): Add constructor_callback. + * ldctor.c (struct set_info): Add bitsize field. + (ldctor_add_set_entry): Add bitsize argument. + (ldctor_build_sets): Base the size of the elements of the set on + the bitsize, rather than always using LONG. + * ldctor.h (ldctor_add_set_entry): Add bitsize to declaration. + + * ld.h (QUAD_SIZE): Define. + * ldgram.y (QUAD): New token. + (length): Handle it. + * ldlex.l: Return QUAD. + * lexsup.c (keywords): Add QUAD. + * ldwrite.c (build_link_order): Handle QUAD. + * ldlang.c (print_data_statement): Handle QUAD. + (lang_size_sections): Likewise. + (lang_do_assignments): Likewise. + * ldexp.c (exp_print_token): Add QUAD to table. + * ld.texinfo: Describe QUAD. + + * scripttempl/alpha.sc: Don't create .lit4 or .sdata sections, + since the Alpha doesn't use them. + +Wed Jan 5 17:42:16 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldemul.h (ld_emulation_xfer_struct): Comment the members. + +Sat Jan 1 13:39:31 1994 Rob Savoye (rob@darkstar.cygnus.com) + + * Makefile.in, configure.in: Add support for VSTa micro-kernel. + * config/vsta.mt, emulparams/vsta.sh: New files for VSTa. + +Sat Jan 1 10:53:35 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * scripttempl/aout.sc: Pad .text to DATA_ALIGNMENT if relocating; + needed for i386mach. (Should be a no-op on other systems.) + + * emulparams/i386mach.sh (SEGMENT_SIZE): Fix again. + (PAGE_SIZE): Don't define; not used. + +Fri Dec 31 16:12:06 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldgram.y (yyerror): Make argument const char *, and actually + print it out rather than assuming it is a syntax error. + * ldmisc.h: Change declaration of yyerror. + * ldemul.c, ldwrite.c: Add /*ARGSUSED*/ as appropriate. + +Fri Dec 31 11:37:28 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * emulparams/i386mach.sh (NONPAGED_TEXT_START_ADDR): Don't include + exec header offset, since the exec header isn't loaded. + (PAGE_SIZE, SEGMENT_SIZE): Agree with bfd/i386mach3.c. + +Thu Dec 30 13:01:43 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + A major rewrite to move the bulk of the linker into BFD so that + more efficient backend code can be written for specific object + files. + * lderror.c, lderror.h, ldindr.c, ldindr.h, ldsym.c, ldsym.h, + ldwarn.c, ldwarn.h, relax.c, relax.h: Removed. + * ldctor.c, ldctor.h: Complete rewrite. + * ldwrite.c, ldwrite.h: Complete rewrite. + * ld.h (strip_symbols_type, strip_symbols): Removed. Use + link_info.strip instead. Changed all uses. + (discard_locals_type, discard_locals): Removed. Use + link_info.discard instead. Changed all uses. + (ld_config_type): Removed relocateable_output field; use + link_info.relocateable instead; changed all uses. Added stats + field. + (set_asymbol_chain, get_asymbol_chain, get_loader_symbol, + set_loader_symbol): Removed. + * ldexp.h (node_class): Added etree_rel. + (etree_type): Added rel field. + * ldexp.c (exp_print_token): Bracketed table initialization. + (exp_relop): New function. + (fold_name): Use linker hash table rather than ldsym functions. + (exp_fold_tree): Likewise. Also, handle etree_rel case. + (exp_print_tree): Handle etree_rel. + * ldgram.y (strip_symbols, discard_locals): Removed. + (OPTION_stats, OPTION_no_keep_memory): New tokens. Handle them. + (REL): New token. Does not appear in grammar, but needed for + expression code. + (file): Don't call lang_final; it's called by main anyhow. + * ldlex.l: Accept -stats and -no-keep-memory options. + * ldlang.h (fill_type): Make unsigned int, not unsigned short. + * ldlang.c: Consistently use fill_type for fill argument. + (lang_init_script_file, script_file): Removed. + (create_object_symbols): Removed. Use + link_info.create_object_symbols_section instead. Changed all + uses. + (lang_add_keepsyms_file): Removed. + (lookup_name): Call bfd_link_add_symbols instead of + ldmain_open_file_read_symbol. + (wild): Don't iterate over script_file. + (open_output): Create link hash table. + (lang_place_undefineds): Rewrote. + (lang_size_sections): Handle relaxing (doesn't work yet). + (lang_relocate_globals): Removed. + (lang_finish): Use link hash table rather than ldsym functions. + (lang_common): Rewrote. + (lang_one_common): New function. + (ldlang_add_file): Add file to link_info.input_bfds list. Set + usrdata. + (create_symbol): Removed. + (lang_process): Don't call lang_init_script_file. Call + ldctor_build_sets rather than find_constructors. Don't call + lang_relocate_globals. + (lang_abs_symbol_at_beginning_of): Rewrote. + (lang_abs_symbol_at_end_of): Rewrote. + * ldmain.c (had_y): Removed. + (lprefix, lprefix_len): Removed; use link_info fields instead. + Changed all uses. + (multiple_def_count, commons_pending, undefined_global_sym_count, + total_symbols_seen, total_files_seen): Removed. + (link_callbacks, link_info): New variables. + (main): Initialize link_info. Don't call init_bfd_error_vector or + ldsym_init. Don't set now unused variables. Handle -stats. + (get_emulation): Removed obsolete and nonfunctional GNU960 code. + (add_ysym): Rewrote. + (read_entry_symbols, refize, enter_global_ref, enter_file_symbols, + search_library, gnu960_check_format, decode_library_subfile, + linear_library, symdef_library, clear_syms, subfile_wanted_p): + Removed. + (add_keepsyms_file, add_archive_element, multiple_definition, + multiple_common, add_to_set, warning_callback, undefined_symbol, + reloc_overflow, reloc_dangerous, unattached_reloc, notice_ysym): + New functions. + * ldmisc.c (vfinfo): Accept a string for %T, not a symbol. Don't + require symbols for %C; look them up instead. + * emultempl/hppaosf.em: Pass link_info to + hppa_look_for_stubs_in_section. + * Makefile.in: Rebuilt dependencies. + (CFILES): Removed lderror.c, ldindr.c, ldsym.c, ldwarn.c, and + relax.c. + (HFILES): Removed lderror.h, ldindr.h, ldsym.h, ldwarn.h, and + relax.h. + (EMULATION_OFILES): Depend on bfdlink.h, ldmain.h, ldexp.h, + ldlang.h and ldctor.h. + + * Makefile.in (ldlex.c): Don't depend on ldgram.h. Remove + declarations of free and malloc from flex output. Change malloc + to ldmalloc in flex output. + +Thu Dec 16 21:19:57 1993 Jeffrey A. Law (law@snake.cs.utah.edu) + + * ldmain.c (lprefix): Change default from a char to a string + with only one character. + (lprefix_len): Set default to one. + + * ldmain.h (lprefix_len): Declare. + + * ldsym.c (write_file_locals): Use strncmp rather than a character + comparison for lprefix. + + * emultmpl/m88kbcs.em (before_parse): Set lprefix and lprefix_len + correctly. + + * emultmpl/hppaosf.em: Include ldexp.h. + (before_parse): Set lprefix and lprefix_len correctly. + +Tue Dec 14 17:19:03 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlex.h: Don't declare yywrap if it is a macro. + * ldlex.l: Include sysdep.h. + * ldlang.c (lang_for_each_statement_worker, + lang_for_each_statement): Forgot to use PARAMS. + +Mon Dec 13 14:30:03 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in: Added .PHONY targets where appropriate. Added some + comments. Also: + (gcclibdir, version): Removed unused variables. + (DEP): New variable, set to mkdep. + (ALL_CFLAGS): New variable. Used in .c.o target. + (CFILES, HFILES, GENERATED_CFILES, GENERATED_HFILES): New + variables. + (HEADERS, MANSOURCES, LDCSOURCES, GENERATED_SOURCES, + GENERATED_HEADERS, LDSOURCES, BFD_SOURCES, SOURCES): Removed + mostly obsolete variables. Adjusted remaining uses. + (DEF_EMUL): Removed variable. + (ldmain.o): Handle undefined EMUL error correctly. + (ldemul-list.h): Depend on config.status rather than Makefile. + Create via temporary file. + (ver960.c, roll, make): Removed obsolete targets. + (.dep, .dep1, dep.sed, dep, dep-in): New targets. Used to rebuild + dependencies. + * dep-in.sed: New file, used when rebuilding dependencies. + +Sat Dec 11 14:43:44 1993 Ian Lance Taylor (ian@deneb.cygnus.com) + + Made many changes to eliminate gcc warnings. Made various + cosmetic changes, declared various things in header files, removed + various extern declarations from .c files. No substantive + changes. + + * ldlang.c (lang_process): Ifdef out final call to + lang_size_sections again (reverting change of Nove 2), since it + breaks the Sun4 linker. + +Thu Dec 2 16:31:47 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in (alpha-*-netware*): New target; use alpha. + +Wed Dec 1 14:04:20 1993 Ken Raeburn (raeburn@cygnus.com) + + * configure.in: Group targets by CPU. Merge some m68k target + entries with different CPU specs that use the same ld_target + values. + + * configure.in: Add sparc*-*-coff. + * config/coff-sparc.mt, emulparams/coff_sparc.sh: New files. + * Makefile.in (ALL_EMULATIONS): Add em_coff_sparc.o. + (em_coff_sparc.c): Add dependencies and build rules. + + * ldmisc.c (errno, sys_nerr, sys_errlist): Don't declare. + +Wed Dec 1 12:19:55 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldgram.y (OPTION_call_shared, OPTION_non_shared, OPTION_Oval): + New tokens. + (command_line_option): Accept and ignore them (for now). + * ldlex.l (<COMMAND>): Handle -non_shared, -call_shared, and -On + where n is a number. + +Mon Nov 22 14:14:29 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldmain.c (subfile_wanted_p): If merging a common symbol which is + not in bfd_com_section, create the section in the BFD so that it + can be placed in the right output section. + +Fri Nov 19 14:12:39 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in (mips*-sgi-irix5*): New target. Use mipsb-elf32. + * emulparams/elf32mipsb.sh (DATA_ADDR): Define. + (OTHER_READONLY_SECTIONS): Define for .reginfo. + (EXECUTABLE_SYMBOLS): Define for _DYNAMIC_LINK. + * scripttempl/elf.sc: Use EXECUTABLE_SYMBOLS when not relocating. + Move OTHER_READONLY_SECTIONS after all the other readonly + sections. Don't use DATA_ADDR twice. + + * ldmain.c (enter_file_symbols): Removed duplicate tests of p. If + p is in a common section, make sure the BFD has a section of that + name. + + * ldlang.c (lang_common): Add newline to error message. + +Thu Nov 11 15:54:41 1993 Stan Shebs (shebs@rtl.cygnus.com) + + * emulparams/m68klynx.sh (SCRIPT_NAME): Define to use a + Lynx-specific script instead of m68kcoff. + (OUTPUT_FORMAT): Define as "coff-m68k-lynx". + (ENTRY): Define as __main. + (TEXT_START_ADDR): Define as 0. + (PAGE_SIZE): Define as 0x1000. + * emulparams/i386lynx.sh, emulparams/sparclynx.sh: Fix comment. + * scripttempl/m68klynx.sc: New file. + +Mon Nov 8 12:00:16 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldmain.c (get_emulation): Ignore -mips1, -mips2 and -mips3 + arguments rather than treating them as emulation names. + +Fri Nov 5 09:02:52 1993 D. V. Henkel-Wallace (gumby@blues.cygnus.com) + + * configure.in: Support x86 unixware and netware plus generic netware. + +Fri Nov 5 21:47:55 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * emulparams/i386mach.sh (TEXT_START_ADDR, NONPAGED_TEXT_START_ADDR): + Correct values (?). + +Wed Nov 3 15:10:15 1993 Ken Raeburn (raeburn@rover.cygnus.com) + + * Makefile.in (distclean): Don't delete dvi or info files. + (ld.info): Update dependency list. + (ld.dvi): Ditto. Extend TEXINPUTS to get bfdsumm.texi. + +Wed Nov 3 12:07:39 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldlang.c (lang_add_output): Take new arg, FROM_SCRIPT. + Set output_filename instead of creating a new node. + (open_output): Don't set output_filename. + (lang_final): Create the new node here. + * ldlang.c, ldlang.h, ldgram.y, mri.c: pass FROM_SCRIPT. + +Tue Nov 2 15:45:51 1993 Jeffrey A. Law (law@snake.cs.utah.edu) + + From Pete Hoogenboom (hoogen@cs.utah.edu): + + * scripttempl/hppaosf.sc: (___stack_zero, etext, _etext, + edata, _edata, end): Add definitions of these symbols. + (__end): Remove definition of this symbol. + (__data_start): Move definition of this symbol. + + * emultempl/hppaosf.em: Various fixes and support for linker stub + generation. + (hppaosf_finish, hppaosf_search_for_padding_statements, + hppaosf_create_output_section_statements): New functions in + support of linker stub generation. + (ld_hppaosf_emulation): Redefine to include new + emulation-specific routines. + + * ldlang.c (lang_process): Re-enable last call lang_size_sections. + Pass abs_output_section rather than NULL to avoid invalidating + absolute symbols. + +Thu Oct 28 21:16:42 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * Makefile.in (ALL_EMULATIONS): Add em_i386mach.o. + (em_i386mach.c): New rule. + * configure.in (i[34]86-*-mach*): New case. + * config/i386-mach.mt: New file. + * emulparams/i386mach.sh: New file. + +Fri Oct 29 14:55:05 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ld.h (flag_is_*): Removed macros. + * ldmain.c (enter_global_ref), ldsym.c (write_file_locals): + Consistently check the BFD symbol flags directly, rather than + using file_is_* macros. + +Thu Oct 28 19:08:42 1993 Stan Shebs (shebs@rtl.cygnus.com) + + * configure.in (sparc*-*-lynxos*): New target. + * Makefile.in: Add rule for em_sparclynx.c. + (ALL_EMULATIONS): Add Lynx emulations. + * config/sparc-lynx.mt: New file. + * emulparams/sparclynx.sh: New file. + * scripttempl/sparccoff.sc: New file. + +Thu Oct 28 13:50:25 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * Makefile.in: Add dependency for $(EMULATION_OFILES). + +Mon Oct 25 16:09:24 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * relax.c (write_relax): Check return value of bfd_seclet_link. + +Mon Oct 25 09:31:21 1993 Ken Raeburn (raeburn@cygnus.com) + + * ldlang.c (delete_output_file_on_failure): New variable. + (open_output): Set it after bfd open succeeds. + * ldmisc.c (vfinfo): Test it. + + Changes from Peter Hoogenboom, hoogen@cs.utah.edu: + + * ldsym.c (write_file_locals): Set the BSF_FILE flag for object + symbols. + + * ldemul.c: Support was added to allow emulation-specific + processing to occur. This support was added primarily for linker + stub generation in the elf32-hppa gld. + (ldemul_finish, ldemul_create_output_section_statements): New + functions. + * ldemul.h: Support was added to allow emulation-specific + processing to occur. (As described above.) Added finish and + create_output_section_statements fields to + ld_emulation_xfer_struct structure. + * ldlang.c: Add calls to emulation-specific routines. + (lang_process): Add call to + ldemul_create_output_section_statements function. + (lang_process): Add call to a emulation-specific routine (and + some processing after the call). + +Fri Oct 22 20:54:13 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in: mips*- instead of mips-, mips*el changes + +Tue Oct 19 15:46:28 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in (alpha-*-osf*): New target; use alpha.mt. + * Makefile.in (ALL_EMULATIONS): Added em_alpha.o. + (em_alpha.c): New target; use alpha.sh and alpha.sc. + * config/alphaosf.mh (NATIVE_LIB_DIRS, HOSTING_CRT0): Define. + * config/alpha.mt: New file. + * emulparams/alpha.sh: New file. + * scripttempl/alpha.sc: New file. + +Fri Oct 15 02:20:04 1993 Doug Evans (dje@canuck.cygnus.com) + + * ldlang.c (lang_size_sections, lang_common): ALIGN_N can't handle + types of different sizes (eg: 64 and 32 bits), so coerce. + * ld.h (ALIGN_N): Add warning about usage. + +Wed Oct 13 16:02:39 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldmain.c (enter_global_ref): Just ignore any weak symbol for + which we already have a definition, rather than checking in + several different places whether the symbol is weak. + +Tue Oct 12 17:30:51 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * configure.in (mips-*-elf*): New target; use mipsb-elf32. + * scripttempl/elf.sc: Only use OTHER_READONLY_SECTIONS and + OTHER_READWRITE_SECTIONS if relocating. Shell variables are not + expanded within them. + * config/mipsb-elf32.mt: New file. + * emulparams/elf32mipb.sh: New file. + * Makefile.in (em_elf32mipb.c): New target. + +Thu Sep 30 17:00:36 1993 Rob Savoye (rob@darkstar.cygnus.com) + + * ldgram.y: In input_list, change lang_input_file_is_file_enum to + lang_input_file_is_search_file_enum so objects brought in using + INPUT() do a path lookup. + +Tue Sep 28 13:31:23 1993 Stan Shebs (shebs@rtl.cygnus.com) + + * configure.in: Change Lynx ld_target to be {i386,m68k}-lynx + instead of {i386,m68k}-coff. + * Makefile.in (em_i386lynx.c, em_m68klynx.c): New targets. + * config/i386-lynx.mt: New file. + * config/m68k-lynx.mt: New file. + * emulparams/i386lynx.sh: New file. + * emulparams/m68klynx.sh: New file. + + * scripttempl/i386coff.sc: Make ENTRY get its value from ${ENTRY}, + but defaulting to _start. + + * ldemul.c, ldfile.c, ldlang.c, ldmain.c, ldmisc.c, ldmisc.h, + ldsym.c, ldwarn.c: Rename info to info_msg, to avoid conflict with + LynxOS libc. + +Thu Sep 23 14:51:03 1993 Ian Lance Taylor (ian@cygnus.com) + + * config/solaris2.mh: New file. Define HOSTING_CRT0 and + HOSTING_LIBS for testing. + +Fri Sep 17 17:52:24 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + Finish up support for i386-sysv4 (without shared libraries): + * ld.h (flag_is_weak): Define. + * ldlang.c (print_symbol): Mention whether symbol is weak. + (print_input_section): Print weak symbols as globals. + * ldmain.c (refize): Do not zero out BSF_WEAK flag. + (enter_global_ref): Do not warn if a weak symbol redefines a + global symbol. Do not let a weak symbol redefine a common symbol. + (enter_file_symbols): Treat weak symbols as global symbols. + (subfile_wanted_p): Do not pull in an object file from a archive + just to resolve an undefined weak symbol. + * ldmisc.c (vfinfo): Don't needlessly malloc space after a fatal + error; the error might be that malloc has run out of space. + * ldsym.c (write_file_locals): Treat weak symbols as global. + * configure.in (i[34]86-*-sysv4*, i[34]86-*-elf*): New targets; + use i386-elf. + * config/i386v4.mh: New file; set NATIVE_LIB_DIRS to /usr/ccs/lib. + * config/i386-elf.mt: New file; set EMUL to elf_i386. + * emulparams/elf_i386.sh: New file. + * scripttempl/elf.sc: Use ${NOP} as filler (defaults to 0). + * Makefile.in (NATIVE_LIB_DIRS): Define to be empty. + (ALL_EMULATIONS): Add em_elf_i386.o. + (GENSCRIPTS): Pass NATIVE_LIB_DIRS as sixth argument. + (em_elf_i386.c): New target, like other em_*.c targets. + ($(LD_PROG)): Pass $(CFLAGS) to $(CC). + * genscripts.sh: Accept NATIVE_LIB_DIRS as sixth argument. If + nonempty, and configured for native, add it to LIB_PATH. + +Fri Sep 17 13:07:39 1993 Stan Shebs (shebs@rtl.cygnus.com) + + * scripttempl/{h8300.sc,h8500.sc,i386coff.sc,m68kcoff.sc,sh.sc}: + Added statements to pass stab and stabstr sections through and + mark them as NOLOAD, which makes GDB happier. + +Wed Sep 15 16:02:29 1993 Stan Shebs (shebs@rtl.cygnus.com) + + * configure.in: Accept m68k-lynx-lynxos config. + + * Makefile.in: Use $(SHELL) to run genscripts.sh. + +Sun Sep 12 16:04:40 1993 Doug Evans (dje@cygnus.com) + + * config/coff-h8300.mt: Add EMUL=h8300h. + + * ldmain.c (main): Call set_scripts_dir after argv has been processed. + +Fri Sep 10 09:36:29 1993 Jeffrey Wheat (cassidy@cygnus.com) + + * Makefile.in: Changed CXX back to g++. + +Fri Sep 10 09:34:29 1993 Jeffrey Wheat (cassidy@cygnus.com) + + * Makefile.in: Fixed RUNTEST* CXX CXXFLAGS macros and check rule. + +Fri Sep 10 07:26:57 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * Makefile.in (TAGS): Use shell wildcards. + +Tue Sep 7 18:04:54 1993 Jeffrey Osier (jeffrey@cygnus.com) + + * Makefile.in: add TEXINPUTS variable and use it in ld.dvi target + +Fri Sep 3 16:46:41 1993 Roland H. Pesch (pesch@fowanton.cygnus.com) + + * ld.texinfo: re-enable included config file; conditionalize doc + for -oformat to interact properly with SingleFormat doc config + var; rename @up/@down to @raisesections/@lowersections. + +Wed Aug 25 16:29:56 1993 K. Richard Pixley (rich@sendai.cygnus.com) + + * configure.in: recognize m88110. + +Tue Aug 24 18:49:40 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + From Peter Hoogenboom <hoogen@shafer.cs.utah.edu>: + * emultempl/hppaosf.em (ld_hppaosf_emulation): Correct name for PA + ELF emulation is "elf32-hppa" not "elf-big". + (hppaosf_before_parse): Remove unneeded processing of environment + variables. + * scripttempl/hppaosf.sc: Include .hppa_linker_stubs sections in + .text segment of output file. + * emulparams/hppaosf.sh (OUTPUT_FORMAT): Use elf32-hppa. + +Tue Aug 24 16:17:00 1993 K. Richard Pixley (rich@sendai.cygnus.com) + + * ld.h: define BYTE_SIZE, SHORT_SIZE, and LONG_SIZE which are no + longer in bfd.h. + + * ldlang.c, ld.h: updated copyright. + +Tue Aug 17 15:22:03 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldlang.c (open_output, lang_check): Check return value of + bfd_set_arch_mach. + +Tue Aug 17 07:02:19 1993 Steve Chamberlain (sac@phydeaux.cygnus.com) + + * scripttempl/h8500.sc: Start all sections in a different segment. + * scripttempl/z8ksim.sc: Handle constructors + +Thu Aug 12 16:05:37 1993 Jeffrey Wheat (cassidy@cygnus.com) + + * Makefile.in: revert earlier changes back to execute runtest + with make check. cdtest and bootstrap now function as they + did within the Makefile. + +Thu Aug 12 10:20:05 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * Makefile.in: Update dependencies. + + * configure.in: Set EMULATION_OFILES in Makefile based on + --with-targets option. + +Thu Aug 12 08:52:29 1993 Jeffrey Wheat (cassidy@cygnus.com) + + * Makefile.in: check targets reimplemented to old way. + +Wed Aug 11 08:26:11 1993 Ian Lance Taylor (ian@cygnus.com) + + * config/i386v.mh, config/irix4.mh: Use gcc + -print-libgcc-file-name rather than $(libdir)/libgcc.a. + * config/i386sco.mh: New file; copy of i386v.mh to correspond to + bfd/configure.host change. + +Mon Aug 9 14:25:35 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * scripttempl/elf.sc: Handle .line and .debug* sections. + + * ldlex.l: Use bfd_scan_vma, not strtoul. + +Fri Aug 6 08:57:39 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldexp.c, ldfile.c, ldlang.c, lexsup.c, ldmain.c, ldemul.c: + Remove inital caps in some error messages, change "can't" to + "cannot", add missing colons. + * ldmisc.c (vfinfo): Print "%%" as a single %. + For '%' followed by unrecognized character, print them both + verbatim instead of expecting a char * arg. + For '%C', don't put the function name in parens. + + * ldexp.c (invalid): Pass "%%", not "% ". + +Fri Aug 6 14:31:22 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * scripttempl/mips.sc: Always define _ftext, _fdata, _fbss. + (BSS_VAR): Removed; now always define _fbss. + * emulparams/mipsidt.sh, emulparams/mipsidtl.sh (BSS_VAR): + Removed. + +Thu Aug 5 15:55:19 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com) + + * configure.in: z8k-coff is the same as z8k-sim + +Wed Aug 4 21:00:18 1993 Jeffrey Wheat (cassidy@cygnus.com) + + * testsuite/lib/ld.exp: new file + * testsuite/config/unix-ld.exp: new file + * testsuite/ld.bootstrap/bootstrap.exp: new file + * Makefile.in: add dejagnu support for make check + +Wed Aug 4 17:52:32 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldlex.l (comment): Add missing newline in message. + * ldindr.c (add_indirect): Ditto. + * ldexp.c (exp_fold_tree): Ditto. + +Tue Aug 3 10:57:41 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldgram.y, ldlex.l, mri.c, ldwrite.c: Change multiple commons + into externs. + + * ldmisc.c (multiple_warn): New function. + * ldmisc.h: Declare it. + * ldmain.c (enter_global_ref): Call it. + * ld.h (ld_config_type): Add warn_common. + * ldlex.l, ldgram.y: Set it with -warn-common option. + * ldver.c (help): Document it. + +Mon Aug 2 12:04:36 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * scripttempl/elf.sc: Add hooks for .sdata, .sbss, and + target-specific sections, and for changing data section vma. + +Mon Jul 26 14:00:02 1993 Ken Raeburn (raeburn@deneb.cygnus.com) + + * ldgram.y (OPTION_Qy, OPTION_Y, OPTION_dn, OPTION_YP): New + terminals, for Solaris. + (dirlist_ptr): New static variable. + (command_line_option): Accept new options. + + * ldlex.l: Accept command-line options "-Qy", "-dn", "-Y", and + "-YP,...". + + * config/sun4sol2.mt: Pass emulation name without ".sh". + + * emulparams/elf32_sparc.c: Renamed from elf32-sparc.c. + * config/sun4sol2.mt (em_elf32_sparc.c): Adjusted accordingly. + +Fri Jul 23 13:51:09 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * scripttempl/elf.sc: Add support for .init, .fini, .ctors, + .dtors, .data1, .rodata1 sections, instead of combining them into + other sections. For `-r', set all section start addresses to + zero. + + * emulparams/elf32-sparc.sh (TEXT_START_ADDR, + NONPAGED_TEXT_START_ADDR): Value should be 0x10100. + (MAXPAGESIZE): Renamed from PAGE_SIZE. + +Wed Jul 21 14:28:42 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * genscripts.sh: If this is the default emulation, set + COMPILE_IN. + * emultempl/*.em: Use it to determine whether to compile in the + scripts. + + * Makefile.in (GENSCRIPTS): Pass the default emulation name to + genscripts.sh. Pass the current emulation name without ".sh" on + the end. + * genscripts.sh: Take an default emulation arg. + Use the current emulation name as EMULATION_NAME. + Make default lib path for cross-compiling ':', not null. + * emulparams/*.sh: Don't set EMULATION_NAME. + * ldemul.c (ldemul_get_script): Take isfile arg. + Pass it to emulation's get_script function. + * ldemul.h: Adjust get_script prototypes. + * ldfile.c (ldfile_find_command_file): Renamed from find_a_name. + No longer static. + * ldfile.h: Declare it. + * ldgram.y: Accept a script on the command line again, + for parsing compiled-in scripts. + * ldmain.c (main): If ld script is a file, parse it as a -T + option, otherwise parse it directly. + * emultempl/*.em (*get_script): Return the scripts themselves if + this is the default emulation; otherwise return their file names. + * emultempl/m88kbcs.em: New file, to take m88kbcs #ifdef out of + generic.em. + * emulparams/m88kbcs.sh: Use it. + + * ld.h (ld_config_type::unix_relocate): Remove unused element. + +Tue Jul 20 12:01:49 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * Makefile.in (ALL_EMULATIONS): Delete em_i386linux.o (for which + there's no change log entry yet, tsk tsk) from the list of + emulations compiled in until Mark gets around to checking in + emulparams/i386linux.sh. + (ldemul-list.h): Depend on Makefile, so if EMULATION_OFILES is + changed, this file gets updated. + +Fri Jul 16 14:14:32 1993 Ian Lance Taylor (ian@cygnus.com) + + * ldgram.y (OPTION_Lfile): New token. + (command_line_option): Accept OPTION_L NAME (whitespace after -L). + * ldlex.l (<COMMAND>): Accept -L without FILENAME. + +Fri Jul 16 13:44:26 1993 Doug Evans (dje@canuck.cygnus.com) + + * configure.in: h8/300h support needs own .mt file. + config/coff-h8300h.mt: New file. + +Thu Jul 15 12:44:35 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldmain.c: Don't include sys/stat.h; it already got included + somewhere along the way. + +Thu Jul 15 14:43:34 1993 Doug Evans (dje@canuck.cygnus.com) + + * Makefile.in: Add h8300h support. + emulparams/h8300h.sh: New file. + scripttempl/h8300h.sc: New file. + +Thu Jul 15 12:44:35 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldfile.c (ldfile_open_file): In error message, use the name the + user gave (e.g., "-lc"), rather than the base file name. + + * ldexp.c (exp_fold_tree): Don't assign an int to an enum. + + * ldmain.[ch]: Remove initial Q_ from function names. + * ldexp.c, ldindr.c, ldlang.c: Change callers. + + * ldfile.c, ldmain.c, ldgram.y: Rename option_v to trace_file_tries. + + * ldlang.c (lang_process): Move loading of default script from + here to main. Add a "/" to start of script name to prevent + finding it in "." first. + + * ldmain.c (set_scripts_dir): Don't look in "." first. + + * ldgram.y, ldlang.c, ldsym.c: Remove traces of unused var + option_longmap. + +Thu Jul 15 10:55:59 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (em_m88kbcs.c): Correct dependency. + * scripttempl/m88kbcs.sc: It's ARCH, not arch. Removed TARGET + statement. Changed OUTPUT_FORMAT to use ${OUTPUT_FORMAT}. + * emulparams/m88kbcs.sh: It's coff-m88kbcs, not m88kbcs. + +Wed Jul 14 21:42:53 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldfile.c (ldlang_open_file, ldfile_open_command_file), + main.c (main): Print the errno string in the error message. + +Tue Jul 13 20:00:30 1993 Doug Evans (dje@canuck.cygnus.com) + + * configure.in: Accept h8300h for target cpu. + + * ldmisc.c (vfinfo): Have demangle remove leading underscore if + present (demangle is smart enough to know whether to do it or not). + +Mon Jul 12 11:45:48 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldmain.c (set_scripts_dir): Check . and <ld bin dir>/../lib for + ldscripts, as well as <ld bin dir> and SCRIPTDIR. + + * ldlang.c (lang_process): Use sizeof instead of magic constant. + + * ldmain.c (get_emulation, check_for_scripts_dir, + set_scripts_dir): New functions. + (main): Call them. + +Mon Jul 12 10:57:03 1993 Ken Raeburn (raeburn@deneb.cygnus.com) + + * scripttempl/elf.sc: Include .init, .fini, .rodata sections. + Create symbol "end" instead of "__end". Comment out some parts + that may not be needed (yet) for elf. + + * configure.in: Accept sparc-elf and sparc-solaris2 configs. + +Thu Jul 8 15:33:32 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * Makefile.in (ALL_EMULATIONS): Include $(OTHER_EMULATIONS). + + * ldmisc.h (einfo, minfo, info): Don't bother with PARAMS macro + when no prototype is being supplied. + (ldmalloc, ldrealloc): Size argument is now size_t. + + * ldmisc.c (finfo): New function, accepts FILE* argument. + (vfinfo, case 'v'): New format character; displays bfd_vma in hex + without leading zeros. + (vfinfo, cases 'R' and 'C'): Use finfo(%v) when displaying a + bfd_vma value, instead of fprintf(%x) which won't hold a long long + value. + (concat, buystring): String lengths are size_t. + (ldmalloc, ldrealloc, xrealloc): Size argument is now size_t. + + * ldlang.c (new_statement): Size argument is now size_t. Added + forward declaration with prototype. + +Thu Jul 8 10:53:47 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldgram.y (OPTION_v): Don't turn on verbose output. + +Wed Jul 7 17:10:45 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * ldlex.l: Get rid of local typedef for bfd_vma! Get it from + bfd.h instead. + +Wed Jul 7 11:33:12 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (install): Don't install as $(tooldir)/bin/gld; + collect2 doesn't look for gld any more anyhow. + +Mon Jul 5 14:29:48 1993 Ian Lance Taylor (ian@cygnus.com) + + * ldlang.c (lang_relocate_globals): Skip indirect symbols, which + now have a non NULL srefs_chain. + + * config/hp300hpux.mt: Use emulation hp3hpux rather than + hp300hpux, since the latter does not exist. + +Fri Jul 2 18:06:05 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * genscripts.sh: Put the scripts in the ldscripts directory, not + emulations. + * configure.in (ldscripts): Make, instead of emulations. + * Makefile.in (scriptdir): Take off the "ld" part. + (install, clean, distclean): Use ldscripts, not emulations. + In tests, don't pass -Lemulations. + Don't pass tooldir/lib to genscripts.sh. + * genscripts.sh: Don't take tooldir/lib arg. + * ldlang.c (lang_process): Add "ldscripts/" to the name of the + default script file. + +Fri Jul 2 17:13:35 1993 Doug Evans (dje@canuck.cygnus.com) + + * scripttempl/h8300.sc: Add .tors section for constructor/destructors. + +Thu Jul 1 16:38:45 1993 Doug Evans (dje@canuck.cygnus.com) + + * config/coff-h8300.mt: EMUL=h8300hms -> h8300. + +Wed Jun 30 15:45:55 1993 K. Richard Pixley (rich@sendai.cygnus.com) + + * Makefile.in (.y.c): skip default .y.c rules. gnu make can now + run in parallel without colliding on yacc's static file names. + Without the stub rule, make will try to start two yacc's + concurrently which fails because of yacc's static file names. + +Tue Jun 29 12:20:36 1993 Ian Lance Taylor (ian@cygnus.com) + + * ldmain.c (subfile_wanted_p): Don't dump core if there are no + symbols. + +Mon Jun 28 12:22:11 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * genscripts.sh (LIB_PATH): Only add /usr/local/lib if it's + different from libdir. + + * Makefile.in (scriptdir): Base on tooldir, not datadir. + +Sat Jun 26 12:03:57 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldver.c (help): New function. + * ldver.h: Declare it. + * ldlex.l, ldgram.y: Recognize new options --help and --version. + +Mon Jun 21 20:39:48 1993 Ken Raeburn (raeburn@poseidon.cygnus.com) + + * Makefile.in (INCLUDES): Don't need ../include any more. + +Mon Jun 21 16:38:35 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldlex.l, ldgram.y: Support new -oformat option. + Remove attempt at supporting script fragments on the command line. + * ldlang.c (lang_add_output_format): Take new arg, FROM_SCRIPT. + * mri.c (mri_format), ldgram.y: Change callers. + * ldlang.h: Change prototype. + +Thu Jun 17 16:53:56 1993 david d `zoo' zuhn (zoo@cygnus.com) + + * Makefile.in: canonicalize install.sh; for use within + this directory (and subdirs) + +Thu Jun 17 14:33:09 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldgram.y: Tweak grammar to make reporting of invalid options work. + + * Makefile.in (.cc.o): Restore .SUFFIXES entry for .cc + and .cc.o rule. + +Wed Jun 16 11:45:32 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldfile.c (ldfile_open_command): Don't try .ld extension. + It wasn't documented (or likely used) and wastes time. + (try_open): If EXTEN is empty, don't try it. + + * ldctor.c, lderror.c, ldexp.c, ldfile.c, ldindr.c, ldlang.c, + ldlex.l, ldmain.c, ldmisc.c, ldsym.c, ldver.c, ldwarn.c, + ldwrite.c, lexsup.c, mri.c, relax.c: Replace DEFUN macro calls + with normal function declarations. + + * Move *.em to emultempl/*.em. Move *.sh to emulparams/*.sh. + Move *.sc-sh to scripttempl/*.sc. + * {emultempl,emulparams,scripttempl}/README: New files. + * sh.em, st2000.em, z8ksim.em, h8300hms.em, h8500hms.em: Files + removed, replaced with generic.em. + * h8300.sh, h8500.sh, h8300.sc, h8500.sc: Renamed from + h8[35]00hms.s[ch]. Change their contents to omit the "hms". + + * *.em (*_get_script): Return script name instead of script contents. + * ldlang.c (lang_process): Change caller. + + * ldlex.l, ldgram.y: Recognize -m option. + Check for input files after *all* options in grammar. + * ldmain.c (main): Check for -m options. Add default directory + for -m. + + * mkscript.c: File removed. + * genscripts.sh: Take two more parameters, tooldirlib and libdir, + to add to the default LIB_PATH. + Look for input files in the new subdirectories. + Create the scripts in emulations subdirectory and don't filter + them through mkscript. + * configure.in: Make the emulations subdirectory. + + * Makefile.in: Account for all of the above changes. + Remove unused .SUFFIXES. Get libgcc.a path with gcc + -print-libgcc-file-name instead of $(libdir)/libgcc.a. + Put CFLAGS last in the compilation rules. + Add -I../bfd to INCLUDES so sysdep.h is found. + +Tue Jun 15 23:04:46 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * Makefile.in (INCLUDES): Look in ../include, not ../bfd. + + * aout.sc-sh: Add SHLIB_PATH like STACKZERO. Make STACKZERO + dependent on RELOCATING, not RELOCATION. + * hp3hpux.sh (SHLIB_PATH): Define it. + +Mon Jun 14 19:06:15 1993 David J. Mackenzie (djm@thepub.cygnus.com) + + * ldfile.c (try_open): If opening without the extension fails, + try with the extension even if -v or -V was given. + had_script is imported (from ldgram.y), not exported. + +Mon Jun 14 16:26:10 1993 david d `zoo' zuhn (zoo at rtl.cygnus.com) + + * Makefile.in: remove parentdir support, use INSTALL_XFORM + +Thu Jun 10 14:00:06 1993 Ian Lance Taylor (ian@cygnus.com) + + * ldexp.c (exp_fold_tree): Don't lose the old flag bits. + * ldgram.y (statement_list_opt): New nonterminal, either empty or + statement_list. + (section): Use statement_list_opt, not statement_list. + * m68kcoff.sc-sh: Gather constructors and destructors and define + __CTOR_LIST__ and __DTOR_LIST__ appropriately. + * sa29200.sc-sh: Gather constructors and destructors and define + ___CTOR_LIST__ and ___DTOR_LIST__ appropriately. + +Mon Jun 7 12:53:28 1993 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in (INCLUDES): Add -I../bfd for sysdep.h and bfd.h. + * configure.in: No longer need to configure to get sysdep.h. + +Fri Jun 4 16:18:24 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: remove install:all and install-info:info + dependencies (these cause some spurious rebuilds at 'make install' + time) + +Fri Jun 4 08:50:14 1993 Ian Lance Taylor (ian@cygnus.com) + + * configure.in (mips-idt-ecoffl*): New target; use mips-idtl. + (mips-idt-ecoff*): Added trailing '*'. + * config/mips-idtl.mt: New file; use EMUL of mipsidtl. + * mipsidtl.sh: New file; like mipsidt.sh, but little endian. + * Makefile.in (ALL_EMULATIONS): Added em_mipsidtl.o. + + * config/sun3.mh (HOSTING_LIBS, HOSTING_EMU): Removed obsolete and + incorrect definitions. + +Tue Jun 1 14:56:10 1993 Per Bothner (bothner@rtl.cygnus.com) + + * ldsym.c (write_file_locals): Write BSF_CONSTRUCTOR + symbols, unless stripping. + +Tue May 25 15:34:25 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: configure looks for ####, so remove lines with many + '#' characters. + * config/irix4.mh, config/i386v.mh: New files; set HOSTING_CRT0 + and HOSTING_LIBS correctly so that ``make check'' will work. + +Thu May 20 13:56:16 1993 Per Bothner (bothner@deneb.cygnus.com) + + * mips.sc-sh: Define _etext, _edata, and _end, in addition + to etext, edata, and end. Needed for IRIX 4.0.5F. + Patch from mwp@iconix.oz.au (Michael Paddon). + + * Version 2.2.1 released. + +Thu May 20 11:42:06 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * mipsbsd.sc-sh: Renamed from aout-mipsbsd.sc-sh. + * mipsbsd.sh (EMULATION_NAME): Use new file name. + +Tue May 18 17:10:24 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * Makefile.in (LDDISTSTUFF): Remove ld.mm since we can't build it + properly right now. + + * Version 2.2 released. + +Mon May 17 15:37:28 1993 Ken Raeburn (raeburn@deneb.cygnus.com) + + * ldver.c (ldversion): Bump version number to 2.2. + +Mon May 17 12:44:31 1993 Per Bothner (bothner@cygnus.com) + + * NEWS: New file. + +Fri May 14 11:26:24 1993 Ian Lance Taylor (ian@cygnus.com) + + * mips.sc-sh: Don't define BSS_VAR unless relocating. + +Wed May 12 13:33:29 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (mkscript.o, mkscript): Build mkscript via + mkscript.o, rather than directly from mkscript.c. + +Tue May 4 21:58:56 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * configure.in: Look for ${target_makefile_frag} relative to + ${srcdir}, not relative to build directory. + + * hppaosf.em, hppaosf.sc-sh, hppaosf.sh: New files. + * configure.in: Recognize hppa*-hp-osf. + * Makefile.in (ALL_EMULATIONS): Include hppaosf emulation. + (em_hppaosf.c): Build it. + * config/hppaosf.mh, hppaosf.mt: New files. + + * ld.h (ALIGN_N): Renamed from ALIGN, because that conflicted with + some system header files. All uses changed. + + * configure.in: Recognize i386-aix configurations as i386-coff + targets. + + * configure.in: Recognize m68*-*-hpux. + * aout.sc-sh: If STACKZERO and RELOCATING are both defined, output + the value of STACKZERO. + * Makefile.in (ALL_EMULATIONS): Include hp300-hpux emulation. + (em_hp3hpux.c): Build it. + * hp3hpux.sh, config/hp300hpux.mt: New files. + +Tue May 4 12:37:35 1993 Ian Lance Taylor (ian@cygnus.com) + + * mips.sc-sh: Put constructors in the .data section. + * Makefile.in (cdtest): Added dependency on ld.new. + +Mon May 3 19:43:39 1993 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Change definition of $(tooldir) to match FSF. + * vax.sh, config/vax.mt, configure.in, Makefile.in: + Support VAX Ultrix and BSD. + +Mon Apr 26 18:35:47 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * sh.em, sh.sh, sh.sc-sh: New files supporting Hitachi SH. + +Wed Apr 14 21:01:51 1993 John Gilmore (gnu@cygnus.com) + + * ldlang.h (struct memory_region): Change `length' and + `old_length' fields to bfd_size_type. Eliminate use of bfd_offset. + * ldlang.c, mri.c: Corresponding changes, plus lint. + +Thu Apr 8 22:08:18 1993 Ian Lance Taylor (ian@cygnus.com) + + * configure.in: For all i386 targets, accept i486 as well. + +Mon Apr 5 17:33:39 1993 Ian Lance Taylor (ian@cygnus.com) + + * ldlang.c (wild_doit): Preserve all flags for a + SEC_SHARED_LIBRARY section. + (size_input_section): Consider any SEC_HAS_CONTENTS section when + computing largest_section. + +Fri Apr 2 14:33:52 1993 Ian Lance Taylor (ian@cygnus.com) + + * ldlang.c (lang_output_section_statement_lookup): Initialize all + fields of newly created structure. + +Wed Mar 31 18:19:15 1993 Ian Lance Taylor (ian@cygnus.com) + + * ldmain.c (g_switch_value): New variable. + * ldgram.y (OPTION_G, OPTION_Gval): New tokens. + (command_line_option): Accept -G and set g_switch_value. + * ldlex.l (COMMAND): Accept -G. + * ldlang.c (open_output): Call bfd_set_gp_size on new BFD. + +Tue Mar 30 09:40:25 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + Support for linking and loading at different places: + + * ldlex.l: Add "AT" keyword. + * ldgram.y: Cleanup, and parse AT. + * ldlang.c (print_output_section_statement): Print output address + of section in map. (lang_size_sections): Fill sections' lma with + load address. + * ldlang.h (lang_output_section_statement_type): Add load_base + information. + + * ldindr.c (add_indirect): Keep more information in the alias + symbol chain. + * ldlang.c (wild_doit): Don't inherit NEVER_LOAD section + attribute from an input section. + * ldmain.c (Q_enter_file_symbols): Common section is NEVER_LOAD by + default. (Q_enter_file_symbos): Indirect symbols now are known by + their section, not a special symbol flag. + * ldsym.c (write_file_locals): Indirect symbols aren't local. + (write_file_globals): Write the mapping for an indirect symbol. + * relax.c (build_it): When forced to write a NEVER_LOAD section, + fill it with zeros. + +Tue Mar 23 13:24:10 1993 Jeffrey Osier (jeffrey@fowanton.cygnus.com) + + * ld.texinfo: changes for q1 + +Tue Mar 23 00:13:29 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: add dvi target, define & use TEXI2DVI, add installcheck + +Mon Mar 8 20:30:35 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: rename HOST_CC to CC_FOR_BUILD + +Thu Mar 4 12:44:33 1993 Ian Lance Taylor (ian@cygnus.com) + + * mips.sc-sh: Added variables which may be overridden by a + specific emulation. + * mipsidt.sh: New file; emulation for IDT MIPS board. + * Makefile.in (ALL_EMULATIONS): Added em_mipsidt.o. + (em_mipsidt.c): New target. Uses mipsidt.sh and mips.sc-sh. + * config/mips-idt.mt: New file; sets EMUL to mipsidt. + * configure.in (mips-idt-ecoff): New target; uses mips-idt. + +Sat Feb 27 00:00:14 1993 Ken Raeburn (raeburn@cambridge.cygnus.com) + + * aout-mipsbsd.sc-sh, mipsbsd.sh: New files from Ralph Campbell, + ralphc@pyramid.com. + * i386bsd.sh, config/i386bsd.mt: New files. + * configure.in, Makefile.in: Added support for mipsbsd and 386bsd. + +Thu Feb 25 15:33:10 1993 Per Bothner (bothner@rtl.cygnus.com) + + * mri.c: Add extern declaration of strdup. + * ldsym.c (KEEP macro): Add spaces around '=' for the + sake of old (e.g. PCC) compilers. + +Wed Feb 24 19:49:31 1993 Per Bothner (bothner@rtl.cygnus.com) + + * ldver.c: Bump to version 2.1. + +Fri Feb 12 08:09:11 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldgram.y: allow section types without address expressions. + * ldlang.c (lang_relocate_globals): avoid possible hang with + undefined but unreferenced symbols. + * relax.c (relax_section): don't complain if the script file isn't + relaxable but -relax is set + +Thu Feb 18 17:58:45 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: go32 is the 3rd part of the triple, not the 2nd + +Wed Feb 3 09:05:56 1993 Ian Lance Taylor (ian@cygnus.com) + + * mipsbig.sh: New file. Big endian MIPS emulation. + * config/mips-big.mt: New file. Use mipsbig emulation. + * configure.in (mips-sgi-irix*): Use target mips-big. + * Makefile.in (ALL_EMULATIONS): Added em_mipsbig.o. + (em_mipsbig.c): New target. Uses mipsbig.sh. + +Tue Feb 2 11:32:27 1993 Ian Lance Taylor (ian@cygnus.com) + + * mips.sc-sh: Put .scommon sections into .sbss section. + + * ldmain.c (subfile_wanted_p): Preserve section of common symbols, + rather than always putting them in bfd_com_section. + * ldlang.c (lang_common): If a common symbol is not in + bfd_com_section, put in a section of the same name, rather than + always putting it in section COMMON. + +Fri Jan 29 09:57:58 1993 Ian Lance Taylor (ian@cygnus.com) + + * ldmain.c (subfile_wanted_p): If we already have a common + definition of a symbol, don't necessarily pull in an object file + that provides a non-common definition. + + * ldlex.l (COMMAND): Accept -EB and -EL command line arguments, + returning OPTION_EB and OPTION_EL. gcc passes these to a MIPS + linker. + * ldgram.y (OPTION_EB, OPTION_EL): New tokens. + (command_line_option): Accept and ignore OPTION_EB and OPTION_EL. + +Thu Jan 28 15:12:04 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (install): Remove $(tooldir)/bin/gld before creating + the link to it. + +Tue Jan 26 11:49:50 1993 Ian Lance Taylor (ian@cygnus.com) + + * ldmain.c, ldsym.c: Use new bfd_is_com_section macro rather than + checking for equality to bfd_com_section. + +Fri Jan 22 14:22:44 1993 Ian Lance Taylor (ian@cygnus.com) + + * mips.sc-sh: New file. Ultrix, and hopefully other MIPS ECOFF + targets, linker script. + * mipslit.sh: New file. Little endian MIPS emulation. + * config/mips-lit.mt: New file. Use mipslit emulation. + * configure.in (mips-dec-ultrix*): Use target mips-lit. + * Makefile.in (ALL_EMULATIONS): Added em_mipslit.o. + (em_mipslit.c): New target. Uses mipslit.sh. + +Thu Jan 14 15:30:27 1993 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (install): Install ld as both $(tooldir)/bin/ld and + $(tooldir)/bin/gld, so that gcc can find it with or without + collect2. + +Mon Jan 11 18:50:07 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * ldwrite.c: Removed perform_relocation, copy_and_relocate, and + write_norel. All linking is now done via write_relax. Call + ldsym_write before calling write_relax. + * relax.c: Added copyright. + (write_relax): Renamed from write_relaxnorel. Added relocateable + argument. seclet_dump renamed to bfd_seclet_link. + * relax.h: Added copyright. + +Mon Jan 11 15:41:56 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldmain.c (decode_library_subfile): Patch from + hoogen@shafer.cs.utah.edu, don't reread library symbol tables. + +Fri Jan 8 18:04:33 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * config/vxworks960.mt renamed to config/i960.mt + + * configure.in: sparc-aout emulates a sun4, as does + sparc*-vxworks, i960-nindy uses gld960 emulation + +Fri Jan 8 14:39:07 1993 Steve Chamberlain (sac@thepub.cygnus.com) + + Fix support for NOLOAD, add INCLUDE + * ldfile.c (ldfile_open_command_file): pass file name to + lex_push_file. + * ldlex.l, ldgram.y: tidy up, parse INCLUDE and NOLOAD + * ldlang.c (wild_doit): make output sections inherit NEVER_LOAD + attribute. + +Thu Jan 7 10:22:19 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in, config.h: no more default emulation. Make the lack + of emulation a compile time error + +Wed Jan 6 01:08:37 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: recognise all sparclite variants, not just 'sparclite' + +Mon Dec 28 11:15:35 1992 Ian Lance Taylor (ian@cygnus.com) + + * m68kcoff.sc-sh: define _end as well as end, for consistency with + aout.sc-sh. + + * configure.in: accept *-ericsson-ose for any m68k CPU. + + * ldwrite.c (write_rel): don't always set SEC_HAS_CONTENTS flag + for each output section. + +Mon Dec 21 16:06:59 1992 Per Bothner (bothner@rtl.cygnus.com) + + * ldexp.c, ldlang.c, ldmain.c, ldsym.c, ldwarn.c: Use new + macro bfd_asymbol_bfd as appropriate. + * Makefile.in: Un-duplicate ldlex.c dependency. + * condigure.in: Replace my_host case table by sourcing + ../bfd/configure.host. Allow std-host as the default. + * ldmisc.c: Change logic for C++ name demangling: There is + no initial '_' to remove from stab-derived function names. + +Sun Dec 13 16:31:26 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldlang.c (lang_init_script_file): don't attach the output file + sections to the script file. + +Wed Dec 9 08:38:05 1992 Steve Chamberlain (sac@thepub.cygnus.com) + * ldlang.c (wild): run expansion loop over command line bfd too. + (lang_ini_script_file): initialize more parts of the command line + bfd. + * ldlex.l: fix DEFINED start states. + +Mon Dec 7 08:43:41 1992 Steve Chamberlain (sac@thepub.cygnus.com) + -y support + * ld.texinfo: new doc. + * ldgram.y, ldlex.l: understand -y<symbol> + * ldmain.c (Q_enter_file_symbols): if had -y, lookup symbol and + print info. (add_ysym): new function. + * ldsym.h: (ldsym_type): new define SYM_Y. + +Sat Nov 21 03:15:27 1992 John Gilmore (gnu@cygnus.com) + + * ldctor.h, lderror.h, ldexp.h, ldfile.h, ldindr.h, ldlang.c, + ldlang.h, ldlex.h, ldmain.h, ldmisc.h, ldsym.h, ldver.h, ldwarn.h, + ldwrite.h, relax.h: Replace all uses of EXFUN and PROTO ansi-glue + macros with PARAMS. Recreational cleanup. Update copyrights. + +Tue Nov 10 00:23:37 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: pass down the bfd source directory for includes + +Thu Nov 5 15:41:55 1992 Ian Lance Taylor (ian@cygnus.com) + + * ldlang.c (lang_size_sections): don't change size and address for + SEC_SHARED_LIBRARY sections rather than for SEC_NEVER_LOAD + sections. + +Thu Nov 5 11:33:57 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * relax.c (build_it): re-enable the processing of data_statements + in scripts, makes counted contructor lists work again. + +Thu Nov 5 05:43:01 1992 John Gilmore (gnu@cygnus.com) + + * ldemul.h: Remove uses of SDEF and PROTO macros (use PARAMS). + +Tue Oct 20 10:56:06 1992 Ian Lance Taylor (ian@cygnus.com) + + * m68kcoff.sc-sh: don't use initial underscores for etext, edata + and end. + +Mon Oct 19 09:45:38 1992 Ian Lance Taylor (ian@cygnus.com) + + * Support for i386-sysv. + configure.in: check for i386-*-sysv* and i386-*-sco*. + i386coff.sc-sh: rewrote to support SVR3 by default. + ldctor.c (find_constructors): preserve stat_ptr. + ldlang.c (wild_doit): initialize vma and size of new output + section to corresponding input section. This is required for + shared library support. + (lang_size_sections): don't modify vma and size of sections which + are never loaded (for shared libraries). + ldwrite.c (copy_and_relocate): copy the contents of any section + which has contents, not just sections which are loaded (for shared + libraries). + +Thu Oct 15 15:20:26 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldlang.c (size_input_section): count the sizes of all sections + we allocate. + +Thu Oct 8 09:05:25 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldmisc.c (demangle,vfinfo): use the new underscore in bfd to + to demangle symbols better + +Tue Oct 6 13:08:54 1992 Ian Lance Taylor (ian@cygnus.com) + + * ldlang.c (lang_finish): don't warn if -e start symbol does not + exist when linking with -r. + +Mon Oct 5 14:07:37 1992 Ian Lance Taylor (ian@cygnus.com) + + * aout.sc-sh, m68kcoff.sc-sh: set __bss_start to the start of the + .bss segment. + +Mon Oct 5 08:55:14 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldmain.c (linear_library): don't even think about processing + an object file if it's already been done + +Thu Oct 1 23:14:59 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: the hp9000/300 config file is now hp300 + +Wed Sep 30 07:34:09 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * config/z8ksim.mt: new file + +Fri Sep 25 13:49:52 1992 Ken Raeburn (raeburn@kyriath.cygnus.com) + + * Makefile.in (ldexp.o, ldctor.o, ldlang.o, ldmain.o, ldwrite.o, + lexsup.o, mri.o, relax.o): Indicate dependence on ldgram.h. + + * ld.h (strip_symbols_type): Add value STRIP_SOME. + * ldgram.y (OPTION_RETAIN_SYMBOLS_FILE): New terminal token. + * ldlang.c (lang_add_keepsyms_file): New function. + * ldlex.l: Handle "-retain-symbols-file". + * ldsym.c (keepsyms_file, kept_syms): New vars. + (process_keepsyms): New functihon; reads file, marks symbols for + saving. + (write_file_locals): File symbols should always be kept. + (ldsym_write): Warn about "-retain-symbols-file" overriding "-S" + and "-s". Process retain-symbols file before setting symtab. + * ldsym.h (SYM_KEEP): New flag for ldsym_type flags. + (keepsyms_file, kept_syms): Declare them. + + * ldmain.c (main): Non-fatal errors should still cause non-zero + exit status even with -r. + +Fri Sep 25 11:08:01 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + Added initial support for the z8k + * z8ksim.em, z8ksim.sc-sh, z8ksim.sh: new files + * configure.in, Makefile.in: modified to reflect above + + * ldlang.c (lang_check): when linking conflicting architectures, + make the output file reflect at least one of the bad inputs. + +Tue Sep 15 15:35:38 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in (install): if $(tooldir) exists, install ld in + $(tooldir)/bin. + +Fri Sep 11 10:24:22 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * Makefile.in, configure.in: modified to support i386-coff + * i386coff.sh: new file + +Wed Sep 9 11:52:58 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in, m68kcoff.sh, m68kcoff.sc-sh, config/m68k-coff.mt: + added m68k-coff emulation mode, stolen from a29k emulation. + Almost certainly wrong, but perhaps better than sun3. + +Thu Sep 3 14:19:30 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in, Makefile.dos, generic.em, genscripts.sh, + gld960.em, h8300hms.em, h8300xray.em, lnk960.em, st2000.em, + vanilla.em: Rename all (generated) ld__*.c files to em_.c. + This is one character shorter, and lets people build on + SVR3 system. (ld__h8300xray.[co] was the killer there; + h8300xray.sc-sh is also overlong, but seems harmless.) + Based on a patch from Jonathan Ryshpan <hitachi!amito!jon>. + * Makefile.in (clean): Fix typo mostclean -> mostlyclean. + * configure.in: Add host isc. + + * ldver.c: Call it version 2.0. + +Wed Sep 2 00:21:33 1992 Per Bothner (bothner@rtl.cygnus.com) + + * ldver.c: Bump to version 0.98. + * TODO: New file. + + * Makefile.in: Added mostlyclean, distclean, realclean rules. + +Tue Sep 1 23:42:16 1992 Per Bothner (bothner@rtl.cygnus.com) + + * ldmisc.c (xrealloc): New (needed by ../libiberty/cplus.dem.c). + * ldlex.l: Moved comment() to end, since some compilers + otherwise have problems with input() used before it is defined. + +Tue Sep 1 17:45:51 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: added Solaris 2 and Irix 4 host support. + +Mon Aug 31 19:27:11 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in: remove -S flag from the FLEX definition + + * configure.in: rewrote, using new style case statement. use + m68k.mt for m68k-aout systems + +Sun Aug 30 21:38:53 1992 Ian Lance Taylor (ian@cygnus.com) + + * Makefile.in: map "ld" through program_transform_name when + installing. + +Sun Aug 30 18:12:13 1992 Per Bothner (bothner@rtl.cygnus.com) + + * cplus-dem.c: Removed. Use the version in libiberty now. + * ldmisc.c: Use new libiberty version of cplus_demangle(). + +Thu Aug 27 16:38:42 1992 Ian Lance Taylor (ian@cygnus.com) + + * gld960.em (gld960_choose_target): default to little endian, not + big endian. + +Wed Aug 26 17:28:51 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldlang.c (lang_process): don't pass null pointers when + abs_output_section is what is required. + * ldwrite.c (ldwrite): use malloc to allocate the largest space + used, and pass that down. + * relax.c,relax.h (write_relaxnorel): use the passed malloc area rather + than alloca. + +Mon Aug 24 14:42:06 1992 Ian Lance Taylor (ian@cygnus.com) + + * configure.in, config/ose68.mt: renamed OSE to ose. + +Thu Aug 20 19:55:22 1992 Ken Raeburn (raeburn@cygnus.com) + + * ldsym.c (write_file_locals): Reorder check for common or + undefined symbols so that it works. + +Tue Aug 18 13:41:36 1992 Ian Lance Taylor (ian@cygnus.com) + + * configure.in: accept all m68K family members. + + * Makefile.in: always create installation directories. + +Thu Aug 13 11:49:34 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldlex.l: now parses comment correctly, added ~ to acceptable + chars in filenames + + * ldexp.c (exp_unop): pass down abs_output_section - now can have + unary -ve constants. + + * ldlang.c (lang_finish): warn when an entry symbol supplied on + the command line can't be found. + +Fri Aug 7 12:31:10 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldlang.h: add new field "loadable" to output_section_statement. + * ldlang.c (lang_output_section_statement_lookup): initilize new + field. (wild_doit): if new field is not set, then stop output + section from being loadable. + (lang_enter_output_section_statement): set the field from the + NOLOAD keyword + * ldgram.y: new synax for NOLOAD. Removes a shift/reduce too. + * h8300hms.sc-sh, h8300hms.em: get -r right. + +Thu Aug 6 18:35:21 1992 Per Bothner (bothner@rtl.cygnus.com) + + * ldint.texinfo: New internals manual (beginnings thereof). + * PORTING: Removed, merged into ldint.texinfo. + +Tue Aug 4 21:12:29 1992 Per Bothner (bothner@rtl.cygnus.com) + + * cdtest-main.cc, cdtest-func.cc, cdtest-foo.h, cdtest-foo.cc, + cdtest.exp: A test program (copied from libg++/test-install) + that tests that constructor and destructors are handled + corrrectly. + +Mon Aug 3 14:58:19 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * Makefile.in (install): install from ld.new, renaming during the + copy, or else the next 'make install' needs to re-link ld. + +Mon Jul 20 03:37:06 1992 D. V. Henkel-Wallace (gumby@cygnus.com) + + * configure.in: generalise hp recognition (from sef). + +Sat Jul 18 14:46:04 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com) + + * configure.in: recognize bsd and hpux hppa configurations. + error messages echo to stderr, not stdout + +Fri Jul 17 22:06:11 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.dos, gld.1, ld.texinfo, ldemul.c, ldfile.c, ldlang.c, + ldmisc.c: removed rcsid's. + +Tue Jul 14 08:34:34 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldlang.c (lang_map): print changes in sizes due to relaxing + (size_input_section): maintain the delta information. + * ldlang.h: add new field to struct to contain delta info. + * relax.c (relax_section): complain if input not relaxable. + * ldlex.l : add '_', ',' and '$' to chars which can appear at the + start of a filename + +Mon Jul 13 17:33:00 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldmain.c(main): prevent -r and -relax from being on at the same + time. + +Wed Jul 1 17:51:19 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldmain.c (Q_enter_global_ref), ldindr.c (add_indirect): fix for + aliasing problems + + +Thu Jun 18 09:38:56 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * h8300hms.em, h8300hms.sc-sh: do the right thing for -r + * ldexp.c: lint + * ldlang.c(open_output): set the target arch and machine as soon + as we can. (lang_size_sections): use new macros for setting vma + * ldwrite.c: lint + +Mon Jun 15 08:47:43 1992 Michael Tiemann (tiemann@rtl.cygnus.com) + + * configure.in (my_target): Accept m680?0 for wrs as vxworks68. + Also deleted an unreachable path to wrs. + +Wed May 27 23:24:19 1992 Michael Tiemann (tiemann@rtl.cygnus.com) + + * Makefile.in (install): use -d test for $tooldir before + installing ld there so that $tooldir can be inherited from + top-level Makefile. + +Wed May 27 16:56:48 1992 Per Bothner (bothner@rtl.cygnus.com) + + * ldlang.c: Two non-substantial changes for the sake of + the old Portable C Compiler. + +Wed May 27 15:15:58 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldgram.y, ldlex.l: parse ABSOLUTE + * ldexp.c: add support for ABSOLUTE + +Wed May 27 13:07:20 1992 Per Bothner (bothner@rtl.cygnus.com) + + * Makefile.in: Added default definitions for HOSTING_CRT0, + HOSTING_LIBS, and HOSTING_EMU, based on those in config/*.mh. + * config/*.mh: Miscellaneous clean-up: Removed definitions + of YACC (since it is not longer used in the Makefile). + Remove HOSTING_* definitions that are subsumed by the + ones added to Makefile.in. Removed most definitions of CC. + * config/{sparc,news,hp300bsd,decstation}.mh: Removed; + These are no longer needed. + +Fri May 22 13:47:19 1992 Per Bothner (bothner@cygnus.com) + + * Makefile.in: Use srcdir instead of VPATH in ldgram/ldlex + rules, since these are used when building a distribution. + * Makefile.in (ldlex.c): Don't re-direct output, since that + leaves a bogus output files if it fails. + + * config/sparc.mh: Fix HOSTING_LIBS so it has a chance of working. + * ldlex.c: Fix some unnecessary flex-specific-isms. + +Fri May 8 11:49:43 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldgram.y: move spurious semicolon + * ldexp.h: fix prototype + +Thu May 7 17:01:12 1992 Roland H. Pesch (pesch@fowanton.cygnus.com) + + * ld.texinfo: references to linker now say "ld" not "gld". + +Wed May 6 13:26:19 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + changed calling convention for Q_enter_global_ref + * ldexp.c, ldlang.c, ldmain.c: reflect this + * ldver.c: bump version to 1.97.1 + * ldindr.c (add_indirect): when an edict declaring an indirect + symbol is found, make sure that any ideas about the symbol being + common are changed if it now known to be defined. + * ldmain.c (linear_library): complain once if archive isn't + ranlibbed. + * ldlang.h, ldlang.c: make room for and initialize the complain + once field. + +Wed May 6 11:07:35 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: use flex & bison from ../ if they exist. + +Tue May 5 17:47:33 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * relax.c (build_it): don't allocate space in the output file for + stuff if -R flag applys to it. + * ldfile.c: merge in VMS filename support + * ldmain.c (main): take out ./ from library path, and close file + before unlinking. Make multiple defs of a symbol create an + unexecable file. + * ldmisc.c: fatal errosrs delete output file + +Tue May 5 14:05:05 1992 Per Bothner (bothner@rtl.cygnus.com) + + * ldver.c: Increase version number to 1.97, for consistency + with ../binutils. + +Tue May 5 12:12:24 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: FLEX -> LEX. + + * ld.texinfo: {} -> @{@}. + +Mon May 4 17:52:41 1992 Roland H. Pesch (pesch@fowanton.cygnus.com) + + * ld.texinfo: describe alternate, MRI-compatible linker scripts + (and associated change in -c option, now used for these scripts) + +Mon May 4 16:10:10 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldver.c: Bumped version to 1.96 - new release, resync with the + bfd too #. + * ldexp.c, ldlang.c: now build memory shape tree in obstacks + rather than with raw malloc, makes it easier to track where memory + is going. + * ldsym.h, ldsym.c: create obstack for all global symbols too. + * ldwrite.c (ldwrite): moved malloc so only used when needed. + * sa29200-sc.sh: added support for .lit, data1 and data2 sections. + + +Fri May 1 18:17:52 1992 K. Richard Pixley (rich@cygnus.com) + + * config/sparc.mh: use ../gcc/libgcc.a on check if it exists. + + * Makefile.in: use bootstrap for check. + +Fri May 1 13:03:41 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldgram.y, ldlex.c, mri.c: added more compatible words; BASE, ALIAS and + PUBLIC. + * Makefile.in: now use flex, not lex + * ldlex.l, ldlang.c, ldctor.c: lint + +Wed Apr 22 12:48:42 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldlex.l: added CMDFILENAMECHAR state so that you can lex + different sorts of filenames on the command line than in a script. + +Mon Apr 20 22:37:04 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: rework CFLAGS so that they can be passed on the + make command line. Remove MINUS_G. Default CFLAGS to -g. + +Fri Apr 17 08:57:17 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * relax.c: added handling for new "padding" seclet type, used to + fill out gaps between section. + * ldgram.y, ldlex.l: now -defsym on the command line is done + properly. + +Wed Apr 15 21:20:07 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: the tooldir copy of ld goes directly in tooldir. + +Wed Apr 15 16:09:33 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * mri.c, ldgram.y, ldlex.l: added support for minimal strange link + scripts. + +Thu Apr 9 05:52:02 1992 Ken Raeburn (Raeburn@Cygnus.COM) + + * Makefile.in (install): Install second copy in $(tooldir)/bin + without $(program_prefix), since that's what gcc expects. + +Sat Apr 4 17:44:06 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldlex.l, ldgram.y, ldlex.h: Rewrote lexer. Now it's much nicer. + * h8300*: fix bit rot and add support for h8300xray target + * go32.sh: target emulation for go32. + +Mon Mar 16 14:53:29 1992 Steve Chamberlain (sac@rtl.cygnus.com) + + * gld960.em, i960.sc-sh. Fix i960 bit rot + +Fri Mar 13 19:47:22 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: install man page. + +Fri Mar 13 08:23:59 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * config/mt-<foo> renamed to <foo>.mt + * config/mh-<foo> renamed to <foo>.mt + * configure.in changed to reflect this + * genscripts.sh now make .xbn files rather than .xN files + +Sat Mar 7 03:40:40 1992 K. Richard Pixley (rich@cygnus.com) + + * ldver.h: fix decl of ldversion. + +Fri Mar 6 22:00:35 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: added check target. + +Fri Mar 6 06:59:04 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldmain.c (Q_enter_file_symbols): now aliases work again + +Thu Mar 5 21:39:29 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in: added clean-info target. + +Thu Mar 5 16:55:56 1992 Steve Chamberlain (sac@thepub.cygnus.com) + + * ldexp.c (exp_print_tree): don't try and follow null pointers + around. + * ldgram.y: remove 11 shift reduce errors + +Tue Mar 3 15:46:39 1992 K. Richard Pixley (rich@rtl.cygnus.com) + + * Makefile.in: added tooldir and program_prefix. + +Fri Feb 28 08:17:45 1992 Steve Chamberlain (sac at thepub.cygnus.com) + + * ldlang.c (size_input_section): don't move absolute sections + around! + + +Thu Feb 27 09:20:41 1992 Steve Chamberlain (sac at thepub.cygnus.com) + + * cplus-dem.c: yet another copy of this - maybe it should go into + libiberty ? + * ldgram.y: now -V and -v have different actions + * ldver.c: if -V, prints list of emulations compiled in + * ldmisc.c: support for cplus demangling + + +Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com) + + * Makefile.in, configure.in: removed traces of namesubdir, + -subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced + copyrights to '92, changed some from Cygnus to FSF. + +Thu Feb 20 17:43:46 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Change mkscript rule into one for ./mkscript + (for the sake of makes that don't realize they're the same). + * PORTING: Add more details. + * genscripts.sh: Add more tailorability of DATA_ALIGNMENT. + +Mon Feb 17 12:04:36 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in, and new files hp300bsd.sh, config/mh-hp300bsd, + config/mt-hp300bsd: New port to hp300 running BSD. + +Sat Feb 15 13:59:54 1992 Per Bothner (bothner at cygnus.com) + + Major rewrite of how ld is configured. The major idea + is to use shell scripts to generate everything. + * generic.em replaces ldtemplate. + * Other *.em files replace various *.c files. + A *.em file is a shell script that generates the corresponding + ld__*.c file that implements an emulation. This is usually + a straight 'cat' of a here-document, possibly with substitutions. + * Script files (*.sc) are places by *.sc-sh scripts. + Again, these are simple shell scripts that 'cat' + here-documents, usually with some substitutions. + The output a *.sc-sh is a script file. + * Each emulation is defined by a short shell script with + extension *.sh that specifies the emulation-specific + parameters (such as the name of the *.sh-sc and *.em + files to use). + * genscript.sh is the master shell script used to generate + an emulation. It is passed various argument, including + the name a the emulation-speciic *.sh file that it + "sources" to set variables to emulation-specifc parameters. + * config/mt-foo: Changed EMUL=GLDFOO_EMULATION_NAME + to EMUL=foo. (The GLDFOO_EMULATION_NAMEs have bee removed.) + * config/mh-foo: Rename LDEMULATION names as appropriate + (usually 'gldfoo' -> plain 'foo'). + * ldwrite.c: Fixed a typo in a comment. + * Makefile.in: Major changes. Removed some the sed + magic to converts scripts, since that is now handled + by genscripts.sh and the *.sc-sh scipt generators. + * config.h: Remove a bunch of macros defining emulations + and targets. This becomes one less file to edit when + adding emulations or targets. + * ldemul.h (struct ld_emulation_xfer_struct): Add + emulation_name and target_name fields. + * ldemul.c, ldemul.h: Define some default functions used + by most emulations (and remove from the *.em scripts). + * ldemul.c (ldemul_choose_target): Search the new + ld_emulations array using a loop (instead of a hardwired + nested if statement). + Define the ld_emulation from the automatically-geenrated + ldemul-list.h. This means you no longer have to edit ldemul.c + to add a new emulation. + * ldmain.c: Replace {GLD,LNK}960_EMULATION_NAME by + their expansions, since the former no longer exist. + * PORTING: A very rough first draft of a porting guide. + + * ldgram.y, ldlex.l, lexsup.c: Changes to allow an assignment + to be terminated by a new-line (instead of requiring a semicolon). + +Mon Feb 10 16:21:02 1992 Steve Chamberlain (sac at rtl.cygnus.com) + + * ldexp.c, ldlang.c: added new idea "abs_output_section", removes + tests for NULL pointers all over the place. + * ldlang.c (lang_process): remember to relocate global symbols + *after* relaxing has done it stuff. + +Thu Feb 6 11:40:15 1992 Steve Chamberlain (sac at rtl.cygnus.com) + + * config/mt-coff-h8300: use EMUL like everything else + * ldlang.c: (print_padding_statement): print the right address. + * Makefile.in, config.h, ldemul.c: renamed h8300hds to h8300hms + + +Tue Feb 4 15:28:01 1992 Steve Chamberlain (sac at rtl.cygnus.com) + + * ldlex.l: Put pack -noinhibit-exec and -sort-common + * ldlang.c (print_data_statement): print the right address. + +Thu Jan 30 17:51:53 1992 Per Bothner (bothner at cygnus.com) + + * Makefile.in: The rule for testing ld by re-linking itself + via an intermediate -r link was moved to the ld1 rule + instead of the ld2 rule. This allows ld2 and ld3 to be identical, + which allows the bootstrap rule to work. + * ldctor.c (find_constructors): Don't create a constructor + list if it is already defined (as would happen if ld is + invoked by collect). + +Wed Jan 29 08:35:39 1992 Steve Chamberlain (sac at rtl.cygnus.com) + + * config/mh-sparc.h: now uses libgcc.a + * ldmain.c: quit using exit + * *sc: use *(COMMON) rather than [COMMON] + * ldlex.l, lexsup.c: much thinking moved from .l and put into .c, + to allow preprocessing of .l file. + * Makefile.in: New ldlex.l mangling + * ldexp.c (fold_binary): perform expressions with % and / in + integer. + * ldfile.c (open_a): open archives on VMS in a special way + + +Tue Jan 28 10:18:16 1992 Steve Chamberlain (sac at rtl.cygnus.com) + + * ldgram.y: map -M behave in the same way as -Map (sets file name + to be "-". + * ldsym.c, ldlang.c: remember that size of a section is dependent on + whether or not relaxing has been done. + * ldmain.c: don't open a map file if it doesn't have a name + * relax.c: all the brains have moved into bfd. + * ldwrite.c: ammend comment + +Fri Jan 24 14:23:46 1992 Steve Chamberlain (sac at rtl.cygnus.com) + + * Makefile.in: added relax, also made three stage go through a + partial link stage. + * relax.c : added + * config.h: if GNU960 defined, then default emulation mode is + GLD960 + * ldexp.h, ldexp.c: map to file hooks + * ldlang.c: map to file hooks + * ldgram.y: added -Map -relax + * ldlex.l: added -relax, -Map + * ldmain.c: open map file + * ldmisc.c: support for map file + * ldwrite.c: new relax magic + +Thu Dec 19 18:49:51 1991 John Gilmore (gnu at cygnus.com) + + * Makefile.in, config/tm-*.h: Clean up make output, only + pass DEFAULT_EMULATION to ldmain.c. + +Wed Dec 18 15:02:47 1991 Per Bothner (bothner at cygnus.com) + + * ldver.c: Bump to version 1.94. + +Tue Dec 10 04:07:23 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Makefile.in: infodir belongs in datadir. + +Mon Dec 9 16:26:43 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Pass -y to bison. (Again; + accidentally deleted by Rich.) + * news.sc, ldgld68k.sc: Define __end as well as _end. + +Sat Dec 7 17:19:26 1991 Steve Chamberlain (sac at rtl.cygnus.com) + + * ldindr.h: added to contain prototypes of ldindr.c + * ldfile.c: include ctype.h + * ldmain.c: include the requried prototype headers + * ldwrite.c: get_reloc_upper_bound has been renamed + bfd_get_reloc_upper_bound + +Fri Dec 6 23:29:26 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Makefile.in: punt "fundamental" mode because it breaks my emacs + macros. install using INSTALL_PROGRAM and INSTALL_DATA. remove + spaces following hyphens, bsd make can't cope. added + standards.text support and made it look like all the other + makefiles. + + * configure.in: configure now runs entirely in objdir so make file + existence checks against ${srcdir}. Mark this directory as + target dependent. + +Thu Dec 5 22:46:16 1991 K. Richard Pixley (rich at rtl.cygnus.com) + + * Makefile.in: idestdir and ddestdir go away. Added copyrights + and shift gpl to v2. Added ChangeLog if it didn't exist. docdir + and mandir now keyed off datadir by default. + +Wed Dec 4 23:36:55 1991 Per Bothner (bothner at cygnus.com) + + * ldver.c: Bumped version to 1.93. + * Makefile.in: Pass -y to bison. + +Mon Nov 25 18:28:40 1991 Steve Chamberlain (sac at cygnus.com) + + * config.h: h8 is now coff, not ieee + * h8300hds.sc: reflect the same + +Thu Nov 14 19:55:09 1991 Per Bothner (bothner at cygnus.com) + + * ldver.c (ldversion()): Update to 1.92. + * ldctor.c: There are two places constructor sets + can be defined. One of them checked for an existing + duplicate, the other didn't. Unfortunately, the latter + was called after the former ... + So, factor out code for inserting a new element into + constructor_name_list (after checking for a duplicate) + into a new function add_constructor_name, and call + it from both aforementioned places (ldlang_add_constructor + and ldlang_check_for_constructors). + +Wed Nov 13 15:17:43 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in: Rename .c files generated from ldtemplate + to have names starting with ld__. This helps 'make clean'. + +Tue Nov 12 18:36:50 1991 Steve Chamberlain (sac at cygnus.com) + + * Makefile.in: Take out the version number for install + * m88kbcs.sc: put in contructor blocks. + +Mon Nov 11 18:47:33 1991 Per Bothner (bothner at cygnus.com) + + * ldmisc.c, ldmisc.h: Re-write info() to take a filename + parameter, a format, and an arg pointer, and rename it to + vfinfo(). Write info() in terms of new vfinfo(). + New einfo() is the same as info(), except it writes to stderr. + * ldemul.c, ldexp.c, ldlang.c, ldlnk960.c, ldmain.c, ldwrite.c, + ldmisc.c: Replace "error" calls to info() by new einfo(). + +Mon Nov 11 09:57:32 1991 Steve Chamberlain (steve at cygnus.com) + + * ldlex.l ldgram.y: made -V option do same as -v + * Makefile.in: Added $(MINUS_G) flag so debugging can be + turned off + +Sun Nov 3 16:37:37 1991 Steve Chamberlain (steve at cygnus.com) + i386 aout changes from Bob Kukura + * Makefile.in, config.h: added i386aout support + * configure.in: fixed /h-{myhost} typo + * ldgram.y: -MM now gives more boring map. + * ldlang.c: now does D_PAGED flag the right way. + * ldsym.c: -MM flags does the right thing. + +Sun Nov 3 15:00:03 1991 Per Bothner (bothner at cygnus.com) + + * configure.in: Fixed typo. Also, a fix for hp300bsd. + * ldlang.c (init_os): Compensate for BFD change, + where bfd_make_section now returns NULL for a duplicate + section request, instead of the old section. + +Thu Oct 17 15:27:13 1991 Per Bothner (bothner at cygnus.com) + + * ldver.c: Bump to version 1.91 (consistent with binutils). + +Wed Oct 16 12:27:08 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in, config.h, ld.h, ldemul.c, ldexp.c, ldexp.h, + ldgram.y, ldlex.l, ldlnk960.c, ldmain.c, ldmisc.c, ldmisc.h, + ldsym.c, ldsym.h, ldtemplate, ldvanilla.c, ldver.c, ldver.h, + ldwarn.c, ldwarn.h, ldwrite.c, ldwrite.h, mkscript.c: + Add or update copyright notices. + +Mon Oct 14 23:55:27 1991 Per Bothner (bothner at cygnus.com) + + * README: New file. + * Makefile.in: Changed installation directory name scheme + to be consistent with gcc. Also changed 'install'. + +Mon Oct 14 17:30:02 1991 Roland H. Pesch (pesch at cygnus.com) + + * Makefile.in: new targets ld.mm, ld.me + +Mon Oct 14 17:27:24 1991 Per Bothner (bothner at cygnus.com) + + * Makefile.in, ldtemplate: Need to use separate scripts + for -n and -N options. Yet more complication. + +Fri Oct 11 22:40:46 1991 John Gilmore (gnu at cygnus.com) + + * Makefile.in: Avoid using $< in explicit Make rules (it doesn't + work). Add some lines to avoid Sun Make VPATH bugs. + +Fri Oct 11 16:42:22 1991 Per Bothner (bothner at cygnus.com) + + * news.sc: Add alignment for data segment. + * ldtemplate: Add (yet another) script to get for -n or -N + options. (These need different alignment than ZMAGIC files.) + * Makefile.in: Add stuff for new foo.xn scripts. + These are generated by replacing "ALIGN(0x...00)" by ".". + +Fri Oct 11 15:43:04 1991 Roland H. Pesch (pesch at cygnus.com) + + * Makefile.in: new targets ld.ms, ld-index.ms + ld.texinfo: remove tabs, other cleanups for texi2roff + +Fri Oct 11 13:51:54 1991 Per Bothner (bothner at cygnus.com) + + * ldmain.c (main): Make config.magic_demand_paged be true + by default. Don't the WP_TEXT and D_PAGED flags of + output_bfd here; it's too late, so set it when output_bfd + is created (in ldlang.c). Also fix setting of EXEC_P flag + * ldlang.c (ldlang_open_output): Set output_bfd->flags here. + * ldlang.c: Remove some duplicate extern declarations. + * ldgram.y: Fixes to -N and -n options. + * Makefile.in: Recognize upper case letters in sed script + to remove assignments from script files. + * ldtemplate: Don't assukme that -N or -n options + imply use of -r script. + * mkscript.c: Tweaking to correctly handle \n and \\ in input. + +Fri Oct 11 10:29:27 1991 Steve Chamberlain (steve at cygnus.com) + + * ldtemplate: include bfd.h before sysdep.h. + +Fri Oct 11 04:24:45 1991 John Gilmore (gnu at cygnus.com) + + Restructure configuration scheme for bfd, binutils, ld. + + * include/sys/h-*.h: Move to bfd/hosts/h-*.h. + * configure.in: Revise to symlink sysdep.h to ../bfd/hosts/h-xxx.h. + Change some config names to match other dirs. + * *.c: Include bfd.h before sysdep.h, so ansidecl and PROTO() + get defined first. + * config/: Rename some config files to match up h-*.h names. + Remove all the HOST_SYS definitions from the config files. + +Tue Oct 8 16:00:57 1991 Per Bothner (bothner at cygnus.com) + + * ldexp.h, ldlang.h: Change enum boolean -> enum bfd_boolean. + * ldtemplate: Remove ldfile_add_library_path calls; + just use the SEARCH_DIR commands in the script files. + * Makefile.in: Add LIB_PATH macro, which if set is used to replace + the SEARCH_DIR commands in the scripts (using ugly sed magic). + This is primarily intended for cross-linking, where you would + place libaries in a different place than native libraries. + Also, emulations made from ldtemplate now use $(srcdir). + * ldglda29k.sc: Change SEARCH_DIR commands to a conventional + form; people can use the Makefile's LIB_PATH to override. + +Tue Oct 8 14:51:21 1991 Roland H. Pesch (pesch at cygnus.com) + + * Makefile.in: fix target ld.dvi, add target ld.info + ld.texinfo: make info filename ld.info + +Fri Oct 4 21:51:58 1991 John Gilmore (gnu at cygnus.com) + + * Makefile.in: Avoid using $< in non-suffix rules (breaks on Sun + Make). + * ldfile.c, ldlang.c, ldmain.c, ldwrite.c: Cope with renames of a + few BFD types & enums. + + +Local Variables: +mode: change-log +left-margin: 8 +fill-column: 74 +version-control: never +End: diff --git a/contrib/binutils/ld/Makefile.in b/contrib/binutils/ld/Makefile.in new file mode 100644 index 0000000..d327206 --- /dev/null +++ b/contrib/binutils/ld/Makefile.in @@ -0,0 +1,1074 @@ +# Makefile for the GNU linker ld (version 2) +# Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 96, 1997 +# Free Software Foundation, Inc. + +# This file is part of GNU ld. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +VPATH = @srcdir@ +srcdir = @srcdir@ +objdir = . + +target_alias = @target_alias@ +prefix = @prefix@ + +program_transform_name = @program_transform_name@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +tooldir = $(exec_prefix)/$(target_alias) +datadir = @datadir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 +man2dir = $(mandir)/man2 +man3dir = $(mandir)/man3 +man4dir = $(mandir)/man4 +man5dir = $(mandir)/man5 +man6dir = $(mandir)/man6 +man7dir = $(mandir)/man7 +man8dir = $(mandir)/man8 +man9dir = $(mandir)/man9 +infodir = @infodir@ +includedir = @includedir@ + +# We put the scripts in the directory $(scriptdir)/ldscripts. +# We can't put the scripts in $(datadir) because the SEARCH_DIR +# directives need to be different for native and cross linkers. +scriptdir = $(tooldir)/lib + +SHELL = /bin/sh + +INSTALL = `cd $(srcdir); pwd`/../install.sh -c +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_XFORM = $(INSTALL) -t='$(program_transform_name)' +INSTALL_XFORM1 = $(INSTALL_XFORM) -b=.1 + +AR = ar +AR_FLAGS = qv +CC = @CC@ +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ +HLDFLAGS = @HLDFLAGS@ +HLDENV = @HLDENV@ +RPATH_ENVVAR = @RPATH_ENVVAR@ +MAKEINFO = makeinfo +TEXI2DVI = texi2dvi +RANLIB = ranlib +BISON = bison -y +LEX = `if [ -f ../flex/flex ] ; then echo ../flex/flex ; else echo flex ; fi` + +EMUL = @EMUL@ +EMULATION_OFILES = @EMULATION_OFILES@ + +# Search path to override the default search path for -lfoo libraries. +# If LIB_PATH is empty, the ones in the script (if any) are left alone. +# (The default is usually /lib:/usr/lib:/usr/local/lib, unless building +# a cross-linker, in which case the default is empty. See genscripts.sh.) +# Otherwise, they are replaced with the ones given in LIB_PATH, +# which may have the form: LIB_PATH=/lib:/usr/local/lib +LIB_PATH = + +BASEDIR = $(srcdir)/.. +BFDDIR = $(BASEDIR)/bfd +INCDIR = $(BASEDIR)/include +INCLUDES = -I. -I$(srcdir) -I../bfd -I$(BFDDIR) -I$(INCDIR) +DEP = mkdep + +# What version of the manual to build +DOCVER = gen + +# Where to find texinfo.tex to format docn with TeX +TEXIDIR = $(srcdir)/../texinfo + +# Where to find other docs needed to format with TeX +TEXINPUTS = $(TEXIDIR):$(BFDDIR)/doc:$(srcdir) + +# Whether to get roff to put indexing entries on stderr +TEXI2OPT = +# You neeed this to generate ld-index.ms (or .mm or .me) +# TEXI2OPT = -i + +TEXI2ROFF=texi2roff + +# Which roff program to use to generate index for texi2roff'd doc +ROFF = groff + +#stuff for self hosting (can be overridden in config file). +HOSTING_CRT0 = @HOSTING_CRT0@ +HOSTING_LIBS = @HOSTING_LIBS@ +HOSTING_EMU = -m $(EMUL) + +# These were used by `make check-cdtest' +# +#CXX = `if [ -f ../gcc/xgcc ] ; then \ +# echo ../gcc/xgcc -B../gcc/; \ +# else echo gcc; \ +# fi` +#CXXFLAGS = -fgnu-linker +# +# FIX_ME: using ../gcc/xgcc breaks the cdtest. +#CXX = g++ + +# Setup the testing framework, if you have one +EXPECT = `if [ -f $$r/../expect/expect ] ; \ + then echo $$r/../expect/expect ; \ + else echo expect ; fi` + +RUNTEST = `if [ -f $${srcroot}/../dejagnu/runtest ] ; \ + then echo $${srcroot}/../dejagnu/runtest ; \ + else echo runtest ; fi` + +RUNTESTFLAGS = + +CC_FOR_TARGET = ` \ + if [ -f $$r/../gcc/xgcc ] ; then \ + if [ -f $$r/../newlib/Makefile ] ; then \ + echo $$r/../gcc/xgcc -B$$r/../gcc/ -idirafter $$r/../newlib/targ-include -idirafter $${srcroot}/../newlib/libc/include -nostdinc; \ + else \ + echo $$r/../gcc/xgcc -B$$r/../gcc/; \ + fi; \ + else \ + if [ "@host@" = "@target@" ] ; then \ + echo $(CC); \ + else \ + echo gcc | sed '$(program_transform_name)'; \ + fi; \ + fi` + +CXX = gcc +CXX_FOR_TARGET = ` \ + if [ -f $$r/../gcc/xgcc ] ; then \ + if [ -f $$r/../newlib/Makefile ] ; then \ + echo $$r/../gcc/xgcc -B$$r/../gcc/ -idirafter $$r/../newlib/targ-include -idirafter $${srcroot}/../newlib/libc/include -nostdinc; \ + else \ + echo $$r/../gcc/xgcc -B$$r/../gcc/; \ + fi; \ + else \ + if [ "@host@" = "@target@" ] ; then \ + echo $(CXX); \ + else \ + echo gcc | sed '$(program_transform_name)'; \ + fi; \ + fi` + +# go directly to ld.new in case this ld isn't capable of +# linking native object on this host. It can be renamed on +# install. +LD_PROG = ld.new + +all: $(LD_PROG) +.PHONY: all + +LINTFLAGS = $(INCLUDES) $(EXTRA_DEF) + +# The .cc suffix was used by `make check-cdtest'. + +.SUFFIXES: .y $(SUFFIXES) .cc + +# Suppress smart makes who think they know how to automake Yacc files +.y.c: + +# This rule was used for the check-cdtest target. +#.cc.o: +# $(CXX) -c -I$(srcdir) $(CXXFLAGS) $(CFLAGS) $< + +ALL_CFLAGS = -D_GNU_SOURCE $(INCLUDES) @HDEFINES@ $(CFLAGS) +.c.o: + $(CC) -c $(ALL_CFLAGS) $< + +BFDDEP = ../bfd/libbfd.a +BFDLIB = @BFDLIB@ +LIBIBERTY = ../libiberty/libiberty.a + +ALL_EMULATIONS = \ + ea29k.o \ + eaixppc.o \ + eaixrs6.o \ + ealpha.o \ + earmaoutb.o \ + earmaoutl.o \ + earmcoff.o \ + earmpe.o \ + ecoff_sparc.o \ + edelta68.o \ + eebmon29k.o \ + eelf32_sparc.o \ + eelf32b4300.o \ + eelf32bmip.o \ + eelf32ebmip.o \ + eelf32elmip.o \ + eelf32l4300.o \ + eelf32lmip.o \ + eelf32lppc.o \ + eelf32ppc.o \ + eelf64_sparc.o \ + eelf_i386.o \ + egld960.o \ + egld960coff.o \ + ego32.o \ + eh8300.o \ + eh8300h.o \ + eh8300s.o \ + eh8500.o \ + eh8500b.o \ + eh8500c.o \ + eh8500m.o \ + eh8500s.o \ + ehp300bsd.o \ + ehp3hpux.o \ + ehppaelf.o \ + ei386aout.o \ + ei386bsd.o \ + ei386coff.o \ + ei386go32.o \ + ei386linux.o \ + ei386lynx.o \ + ei386mach.o \ + ei386moss.o \ + ei386msdos.o \ + ei386nbsd.o \ + ei386nw.o \ + ei386pe.o \ + elnk960.o \ + em68k4knbsd.o \ + em68kaout.o \ + em68kaux.o \ + em68kcoff.o \ + em68kelf.o \ + em68klinux.o \ + em68klynx.o \ + em68knbsd.o \ + em68kpsos.o \ + em88kbcs.o \ + emipsbig.o \ + emipsbsd.o \ + emipsidt.o \ + emipsidtl.o \ + emipslit.o \ + emipslnews.o \ + enews.o \ + ens32knbsd.o \ + epc532macha.o \ + eppcmacos.o \ + eppcnw.o \ + eppcpe.o \ + eriscix.o \ + esa29200.o \ + esh.o \ + eshelf.o \ + eshlelf.o \ + eshl.o \ + esparcaout.o \ + esparclinux.o \ + esparclynx.o \ + esparcnbsd.o \ + est2000.o \ + esun3.o \ + esun4.o \ + evanilla.o \ + evax.o \ + evsta.o \ + ew65.o \ + ez8001.o \ + ez8002.o + +ALL_64_EMULATIONS = \ + eelf64alpha.o + +CFILES = ldctor.c ldemul.c ldexp.c ldfile.c ldlang.c \ + ldmain.c ldmisc.c ldver.c ldwrite.c lexsup.c \ + mri.c ldcref.c + +HFILES = config.h ld.h ldctor.h ldemul.h ldexp.h ldfile.h \ + ldlang.h ldlex.h ldmain.h ldmisc.h ldver.h \ + ldwrite.h mri.h + +GENERATED_CFILES = ldgram.c ldlex.c +GENERATED_HFILES = ldgram.h ldemul-list.h + +OFILES = ldgram.o ldlex.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o \ + ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o \ + ldfile.o ldcref.o ${EMULATION_OFILES} + +LINTSOURCES = $(CFILES) $(GENERATED_CFILES) e*.c + +STAGESTUFF = *.o ldscripts/* e*.c + +info: ld.info +.PHONY: info + +ldgram.c: ldgram.y + $(BISON) $(BISONFLAGS) -d $(srcdir)/ldgram.y + mv -f y.tab.c ldgram.c + mv -f y.tab.h ldgram.h + +# Separate from ldgram.c so that a parallel make doesn't try to build +# both ldgram.c and ldgram.h simultaneously. +ldgram.h: ldgram.c + +ldmain.o: ldmain.c config.status + $(CC) -c -DDEFAULT_EMULATION='"$(EMUL)"' -DSCRIPTDIR='"$(scriptdir)"' -DTARGET='"@target@"' $(ALL_CFLAGS) $< + +ldemul-list.h: Makefile + (echo "/* This file is automatically generated. DO NOT EDIT! */";\ + for f in `echo " " ${EMULATION_OFILES} "" \ + | sed -e 's/ e/ ld/g' -e 's/ ld/ /g' -e 's/[.]o//g'`; do \ + echo "extern ld_emulation_xfer_type ld_$${f}_emulation;"; \ + done;\ + echo "";\ + echo "#define EMULATION_LIST \\";\ + for f in `echo " " ${EMULATION_OFILES} "" \ + | sed -e 's/ e/ ld/g' -e 's/ ld/ /g' -e 's/[.]o//g'`; do \ + echo " &ld_$${f}_emulation, \\"; \ + done;\ + echo " 0") >ldemul-tmp.h + mv ldemul-tmp.h ldemul-list.h + +ldlex.c: ldlex.l + $(LEX) $(srcdir)/ldlex.l + -sed -e '/^int.*free();/d' \ + -e '/^char.*malloc();/d' \ + -e 's/malloc/xmalloc/g' \ + < lex.yy.c > ldlex.c.new + -rm lex.yy.c + mv ldlex.c.new ./ldlex.c + +# These all start with e so 'make clean' can find them. + +GENSCRIPTS = $(SHELL) $(srcdir)/genscripts.sh ${srcdir} ${libdir} @host@ @target@ @target_alias@ ${EMUL} "@NATIVE_LIB_DIRS@" +GEN_DEPENDS = $(srcdir)/genscripts.sh $(srcdir)/emultempl/stringify.sed +@TDIRS@ + +ea29k.c: $(srcdir)/emulparams/a29k.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/a29k.sc ${GEN_DEPENDS} + ${GENSCRIPTS} a29k "$(tdir_a29k)" +eaixppc.c: $(srcdir)/emulparams/aixppc.sh \ + $(srcdir)/emultempl/aix.em $(srcdir)/scripttempl/aix.sc ${GEN_DEPENDS} + ${GENSCRIPTS} aixppc "$(tdir_aixppc)" +eaixrs6.c: $(srcdir)/emulparams/aixrs6.sh \ + $(srcdir)/emultempl/aix.em $(srcdir)/scripttempl/aix.sc ${GEN_DEPENDS} + ${GENSCRIPTS} aixrs6 "$(tdir_aixrs6)" +ealpha.c: $(srcdir)/emulparams/alpha.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/alpha.sc ${GEN_DEPENDS} + ${GENSCRIPTS} alpha "$(tdir_alpha)" +earmaoutb.c: $(srcdir)/emulparams/armaoutb.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/armaout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} armaoutb "$(tdir_armaoutb)" +earmaoutl.c: $(srcdir)/emulparams/armaoutl.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/armaout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} armaoutl "$(tdir_armaoutl)" +earmcoff.c: $(srcdir)/emulparams/armcoff.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/armcoff.sc ${GEN_DEPENDS} + ${GENSCRIPTS} armcoff "$(tdir_armcoff)" +earmpe.c: $(srcdir)/emulparams/armpe.sh \ + $(srcdir)/emultempl/pe.em $(srcdir)/scripttempl/pe.sc ${GEN_DEPENDS} + ${GENSCRIPTS} armpe "$(tdir_armpe)" +ecoff_sparc.c: $(srcdir)/emulparams/coff_sparc.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sparccoff.sc ${GEN_DEPENDS} + ${GENSCRIPTS} coff_sparc "$(tdir_coff_sparc)" +ed10velf.c: $(srcdir)/emulparams/d10velf.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/elfd10v.sc ${GEN_DEPENDS} + ${GENSCRIPTS} d10velf "$(tdir_d10v)" +edelta68.c: $(srcdir)/emulparams/delta68.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/delta68.sc ${GEN_DEPENDS} + ${GENSCRIPTS} delta68 "$(tdir_delta68)" +eebmon29k.c: $(srcdir)/emulparams/ebmon29k.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/ebmon29k.sc ${GEN_DEPENDS} + ${GENSCRIPTS} ebmon29k "$(tdir_ebmon29k)" +em32relf.c: $(srcdir)/emulparams/m32relf.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m32relf "$(tdir_m32r)" +eelf32_sparc.c: $(srcdir)/emulparams/elf32_sparc.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32_sparc "$(tdir_elf32_sparc)" +eelf32b4300.c: $(srcdir)/emulparams/elf32b4300.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32b4300 "$(tdir_elf32b4300)" +eelf32bmip.c: $(srcdir)/emulparams/elf32bmip.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elfmips.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32bmip "$(tdir_elf32bmip)" +eelf32ebmip.c: $(srcdir)/emulparams/elf32ebmip.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elfmips.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32ebmip "$(tdir_elf32ebmip)" +eelf32elmip.c: $(srcdir)/emulparams/elf32elmip.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elfmips.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32elmip "$(tdir_elf32elmip)" +eelf32l4300.c: $(srcdir)/emulparams/elf32l4300.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32l4300 "$(tdir_elf32l4300)" +eelf32lmip.c: $(srcdir)/emulparams/elf32lmip.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elfmips.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32lmip "$(tdir_elf32lmip)" +eelf32lppc.c: $(srcdir)/emulparams/elf32lppc.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elfppc.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32lppc "$(tdir_elf32lppc)" +eelf32ppc.c: $(srcdir)/emulparams/elf32ppc.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elfppc.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32ppc "$(tdir_elf32ppc)" +eelf64alpha.c: $(srcdir)/emulparams/elf64alpha.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf64alpha "$(tdir_elf64alpha)" +eelf64_sparc.c: $(srcdir)/emulparams/elf64_sparc.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf64_sparc "$(tdir_elf64_sparc)" +eelf_i386.c: $(srcdir)/emulparams/elf_i386.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf_i386 "$(tdir_elf_i386)" +egld960.c: $(srcdir)/emulparams/gld960.sh \ + $(srcdir)/emultempl/gld960.em $(srcdir)/scripttempl/i960.sc ${GEN_DEPENDS} + ${GENSCRIPTS} gld960 "$(tdir_gld960)" +egld960coff.c: $(srcdir)/emulparams/gld960coff.sh \ + $(srcdir)/emultempl/gld960c.em $(srcdir)/scripttempl/i960.sc ${GEN_DEPENDS} + ${GENSCRIPTS} gld960coff "$(tdir_gld960coff)" +ego32.c: $(srcdir)/emulparams/go32.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} go32 "$(tdir_go32)" +eh8300.c: $(srcdir)/emulparams/h8300.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8300.sc ${GEN_DEPENDS} + ${GENSCRIPTS} h8300 "$(tdir_h8300)" +eh8300h.c: $(srcdir)/emulparams/h8300h.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8300h.sc ${GEN_DEPENDS} + ${GENSCRIPTS} h8300h "$(tdir_h8300h)" +eh8300s.c: $(srcdir)/emulparams/h8300s.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8300s.sc ${GEN_DEPENDS} + ${GENSCRIPTS} h8300s "$(tdir_h8300s)" +eh8500.c: $(srcdir)/emulparams/h8500.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8500.sc ${GEN_DEPENDS} + ${GENSCRIPTS} h8500 "$(tdir_h8500)" +eh8500b.c: $(srcdir)/emulparams/h8500b.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8500b.sc ${GEN_DEPENDS} + ${GENSCRIPTS} h8500b "$(tdir_h8500b)" +eh8500c.c: $(srcdir)/emulparams/h8500c.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8500c.sc ${GEN_DEPENDS} + ${GENSCRIPTS} h8500c "$(tdir_h8500c)" +eh8500m.c: $(srcdir)/emulparams/h8500m.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8500m.sc ${GEN_DEPENDS} + ${GENSCRIPTS} h8500m "$(tdir_h8500m)" +eh8500s.c: $(srcdir)/emulparams/h8500s.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/h8500s.sc ${GEN_DEPENDS} + ${GENSCRIPTS} h8500s "$(tdir_h8500s)" +ehp300bsd.c: $(srcdir)/emulparams/hp300bsd.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} hp300bsd "$(tdir_hp300bsd)" +ehp3hpux.c: $(srcdir)/emulparams/hp3hpux.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} hp3hpux "$(tdir_hp3hpux)" +ehppaelf.c: $(srcdir)/emulparams/hppaelf.sh \ + $(srcdir)/emultempl/hppaelf.em $(srcdir)/scripttempl/hppaelf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} hppaelf "$(tdir_hppaelf)" +ei386aout.c: $(srcdir)/emulparams/i386aout.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386aout "$(tdir_i386aout)" +ei386bsd.c: $(srcdir)/emulparams/i386bsd.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386bsd "$(tdir_i386bsd)" +ei386coff.c: $(srcdir)/emulparams/i386coff.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386coff.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386coff "$(tdir_i386coff)" +ei386go32.c: $(srcdir)/emulparams/i386go32.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386go32.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386go32 "$(tdir_i386go32)" +ei386linux.c: $(srcdir)/emulparams/i386linux.sh \ + $(srcdir)/emultempl/linux.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386linux "$(tdir_i386linux)" +ei386lynx.c: $(srcdir)/emulparams/i386lynx.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386lynx.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386lynx "$(tdir_i386lynx)" +ei386mach.c: $(srcdir)/emulparams/i386mach.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386mach "$(tdir_i386mach)" +ei386moss.c: $(srcdir)/emulparams/i386moss.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386moss "$(tdir_i386moss)" +ei386msdos.c: $(srcdir)/emulparams/i386msdos.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/i386msdos.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386msdos "$(tdir_i386msdos)" +ei386nbsd.c: $(srcdir)/emulparams/i386nbsd.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386nbsd "$(tdir_i386nbsd)" +ei386nw.c: $(srcdir)/emulparams/i386nw.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/nw.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386nw "$(tdir_i386nw)" +ei386pe.c: $(srcdir)/emulparams/i386pe.sh \ + $(srcdir)/emultempl/pe.em $(srcdir)/scripttempl/pe.sc ${GEN_DEPENDS} + ${GENSCRIPTS} i386pe "$(tdir_i386pe)" +elnk960.c: $(srcdir)/emulparams/lnk960.sh \ + $(srcdir)/emultempl/lnk960.em $(srcdir)/scripttempl/i960.sc ${GEN_DEPENDS} + ${GENSCRIPTS} lnk960 "$(tdir_lnk960)" +em68k4knbsd.c: $(srcdir)/emulparams/m68k4knbsd.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m68k4knbsd "$(tdir_m68k4knbsd)" +em68kaout.c: $(srcdir)/emulparams/m68kaout.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m68kaout "$(tdir_m68kaout)" +em68kaux.c: $(srcdir)/emulparams/m68kaux.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/m68kaux.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m68kaux "$(tdir_m68kaux)" +em68kcoff.c: $(srcdir)/emulparams/m68kcoff.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/m68kcoff.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m68kcoff "$(tdir_m68kcoff)" +em68kelf.c: $(srcdir)/emulparams/m68kelf.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m68kelf "$(tdir_m68kelf)" +em68klinux.c: $(srcdir)/emulparams/m68klinux.sh \ + $(srcdir)/emultempl/linux.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m68klinux "$(tdir_m68klinux)" +em68klynx.c: $(srcdir)/emulparams/m68klynx.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/m68klynx.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m68klynx "$(tdir_m68klynx)" +em68knbsd.c: $(srcdir)/emulparams/m68knbsd.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m68knbsd "$(tdir_m68knbsd)" +em68kpsos.c: $(srcdir)/emulparams/m68kpsos.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/psos.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m68kpsos "$(tdir_m68kpsos)" +em88kbcs.c: $(srcdir)/emulparams/m88kbcs.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/m88kbcs.sc ${GEN_DEPENDS} + ${GENSCRIPTS} m88kbcs "$(tdir_m88kbcs)" +emipsbig.c: $(srcdir)/emulparams/mipsbig.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/mips.sc ${GEN_DEPENDS} + ${GENSCRIPTS} mipsbig +emipsbsd.c: $(srcdir)/emulparams/mipsbsd.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/mipsbsd.sc ${GEN_DEPENDS} + ${GENSCRIPTS} mipsbsd +emipsidt.c: $(srcdir)/emulparams/mipsidt.sh \ + $(srcdir)/emultempl/mipsecoff.em $(srcdir)/scripttempl/mips.sc ${GEN_DEPENDS} + ${GENSCRIPTS} mipsidt "$(tdir_mipsidt)" +emipsidtl.c: $(srcdir)/emulparams/mipsidtl.sh \ + $(srcdir)/emultempl/mipsecoff.em $(srcdir)/scripttempl/mips.sc ${GEN_DEPENDS} + ${GENSCRIPTS} mipsidtl "$(tdir_mipsidtl)" +emipslit.c: $(srcdir)/emulparams/mipslit.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/mips.sc ${GEN_DEPENDS} + ${GENSCRIPTS} mipslit "$(tdir_mipslit)" +emipslnews.c: $(srcdir)/emulparams/mipslnews.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/mips.sc ${GEN_DEPENDS} + ${GENSCRIPTS} mipslnews +emn10300.c: $(srcdir)/emulparams/mn10300.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} mn10300 "$(tdir_mn10300)" +emn10200.c: $(srcdir)/emulparams/mn10200.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} mn10200 "$(tdir_mn10200)" +enews.c: $(srcdir)/emulparams/news.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} news "$(tdir_news)" +ens32knbsd.c: $(srcdir)/emulparams/ns32knbsd.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} ns32knbsd "$(tdir_ns32knbsd)" +epc532macha.c: $(srcdir)/emulparams/pc532macha.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} pc532macha "$(tdir_pc532macha)" +eppcmacos.c: $(srcdir)/emulparams/ppcmacos.sh \ + $(srcdir)/emultempl/aix.em $(srcdir)/scripttempl/aix.sc ${GEN_DEPENDS} + ${GENSCRIPTS} ppcmacos "$(tdir_ppcmacos)" +eppcnw.c: $(srcdir)/emulparams/ppcnw.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/nw.sc ${GEN_DEPENDS} + ${GENSCRIPTS} ppcnw "$(tdir_ppcnw)" +eppcpe.c: $(srcdir)/emulparams/ppcpe.sh \ + $(srcdir)/emultempl/pe.em $(srcdir)/scripttempl/ppcpe.sc ${GEN_DEPENDS} + ${GENSCRIPTS} ppcpe "$(tdir_ppcpe)" +eriscix.c: $(srcdir)/emulparams/riscix.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} riscix "$(tdir_riscix)" +esa29200.c: $(srcdir)/emulparams/sa29200.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sa29200.sc ${GEN_DEPENDS} + ${GENSCRIPTS} sa29200 "$(tdir_sa29200)" +esh.c: $(srcdir)/emulparams/sh.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS} + ${GENSCRIPTS} sh "$(tdir_sh)" +eshelf.c: $(srcdir)/emulparams/shelf.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} shelf "$(tdir_shelf)" +eshlelf.c: $(srcdir)/emulparams/shlelf.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} shlelf "$(tdir_shlelf)" +eshl.c: $(srcdir)/emulparams/shl.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sh.sc ${GEN_DEPENDS} + ${GENSCRIPTS} shl "$(tdir_shl)" +esparcaout.c: $(srcdir)/emulparams/sparcaout.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} sparcaout "$(tdir_sparcaout)" +esparclinux.c: $(srcdir)/emulparams/sparclinux.sh \ + $(srcdir)/emultempl/linux.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} sparclinux "$(tdir_sparclinux)" +esparclynx.c: $(srcdir)/emulparams/sparclynx.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/sparclynx.sc ${GEN_DEPENDS} + ${GENSCRIPTS} sparclynx "$(tdir_sparclynx)" +esparcnbsd.c: $(srcdir)/emulparams/sparcnbsd.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} sparcnbsd "$(tdir_sparcnbsd)" +est2000.c: $(srcdir)/emulparams/st2000.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/st2000.sc ${GEN_DEPENDS} + ${GENSCRIPTS} st2000 "$(tdir_st2000)" +esun3.c: $(srcdir)/emulparams/sun3.sh \ + $(srcdir)/emultempl/sunos.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} sun3 "$(tdir_sun3)" +esun4.c: $(srcdir)/emulparams/sun4.sh \ + $(srcdir)/emultempl/sunos.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} sun4 "$(tdir_sun4)" +evanilla.c: $(srcdir)/emulparams/vanilla.sh \ + $(srcdir)/emultempl/vanilla.em $(srcdir)/scripttempl/vanilla.sc ${GEN_DEPENDS} + ${GENSCRIPTS} vanilla "$(tdir_vanilla)" +evax.c: $(srcdir)/emulparams/vax.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} vax "$(tdir_vax)" +evsta.c: $(srcdir)/emulparams/vsta.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} + ${GENSCRIPTS} vsta "$(tdir_vsta)" +ew65.c: $(srcdir)/emulparams/w65.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/w65.sc ${GEN_DEPENDS} + ${GENSCRIPTS} w65 "$(tdir_w65)" +ez8001.c: $(srcdir)/emulparams/z8001.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/z8000.sc ${GEN_DEPENDS} + ${GENSCRIPTS} z8001 "$(tdir_z8001)" +ez8002.c: $(srcdir)/emulparams/z8002.sh \ + $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/z8000.sc ${GEN_DEPENDS} + ${GENSCRIPTS} z8002 "$(tdir_z8002)" + +$(LD_PROG): $(OFILES) $(BFDDEP) $(LIBIBERTY) + $(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(LD_PROG) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(EXTRALIBS) + +# The generated emulation files mostly have the same dependencies. +$(EMULATION_OFILES): ../bfd/bfd.h sysdep.h config.h $(INCDIR)/bfdlink.h \ + ld.h ldmain.h ldemul.h ldfile.h ldmisc.h ldexp.h ldlang.h \ + ldctor.h ldexp.h ldlang.h ldgram.h + +# These targets are for the dejagnu testsuites. The file site.exp +# contains global variables that all the testsuites will use. + +site.exp: ./config.status Makefile + @echo "Making a new config file..." + @rm -f ./tmp? + @touch site.exp + @mv site.exp site.bak + @echo "## variables are automatically generated by make ##" > ./tmp0 + @echo "# Do not edit here. If you wish to override these" >> ./tmp0 + @echo "# values, add them to the last section" >> ./tmp0 + @echo "# HOST AND TARGET INFO" >> ./tmp0 + @echo "set host_os @host_os@" >> ./tmp0 + @echo "set host_alias @host_alias@" >> ./tmp0 + @echo "set host_cpu @host_cpu@" >> ./tmp0 + @echo "set host_vendor @host_vendor@" >> ./tmp0 + @echo "set target_os @target_os@" >> ./tmp0 + @echo "set target_alias @target_alias@" >> ./tmp0 + @echo "set target_cpu @target_cpu@" >> ./tmp0 + @echo "set target_vendor @target_vendor@" >> ./tmp0 + @echo "set host_triplet @host@" >> ./tmp0 + @echo "set target_triplet @target@" >> ./tmp0 + @echo "# DIRECTORY INFO" >> ./tmp0 + @echo "set objdir `pwd`" >> ./tmp0 + @echo "" >> ./tmp0 + @echo "# LD DEPENDENCIES" >> ./tmp0 + @echo "set OFILES \"$(OFILES)\"" >> ./tmp0 + @echo "set BFDLIB \"$(BFDLIB)\"" >> ./tmp0 + @echo "set LIBIBERTY \"$(LIBIBERTY)\"" >> ./tmp0 + @echo "set HOSTING_EMU \"$(HOSTING_EMU)\"" >> ./tmp0 + @echo "set HOSTING_CRT0 \"$(HOSTING_CRT0)\"" >> ./tmp0 + @echo "set HOSTING_LIBS \"$(HOSTING_LIBS)\"" >> ./tmp0 + @echo "" >> ./tmp0 + @echo "## Variables generated by configure. Do Not Edit ##" >> ./tmp0 + @cat ./tmp0 > site.exp + @cat site.bak | sed \ + -e '1,/^## Variables generated by.*##/ d' >> site.exp + -@rm -f ./tmp? + +check: site.exp + r=`pwd`; export r; \ + srcroot=`cd ${srcdir}; pwd` ; export srcroot ; \ + EXPECT=${EXPECT} ; export EXPECT ; \ + $(RPATH_ENVVAR)=$$r/../bfd:$$r/../opcodes:$$$(RPATH_ENVVAR); \ + export $(RPATH_ENVVAR); \ + if [ -f $$r/../expect/expect ] ; then \ + TCL_LIBRARY=$${srcroot}/../tcl/library ; \ + export TCL_LIBRARY ; \ + else true ; fi ; \ + $(RUNTEST) --tool ld --srcdir $(srcdir)/testsuite $(RUNTESTFLAGS) \ + CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS)" \ + CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS)" \ + CC_FOR_HOST="$(CC)" CFLAGS_FOR_HOST="$(CFLAGS)" + +installcheck: +.PHONY: check installcheck + +# Rules for testing by relinking ld itself. +# A similar test is in the testsuite. This target is for ease of use +# when porting ld. + +ld-partial.o: ld.new + ./ld.new $(HOSTING_EMU) -o ld-partial.o -r $(OFILES) +ld1: ld-partial.o + ./ld.new $(HOSTING_EMU) -o ld1 $(HOSTING_CRT0) ld-partial.o $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) + +ld1-full: ld.new + ./ld.new $(HOSTING_EMU) -o ld1-full $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) + +ld2: ld1 + ./ld1 $(HOSTING_EMU) -o ld2 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) + +ld3: ld2 + ./ld2 $(HOSTING_EMU) -o ld3 $(HOSTING_CRT0) $(OFILES) $(BFDLIB) $(LIBIBERTY) $(HOSTING_LIBS) + +bootstrap: ld3 + cmp ld2 ld3 + +.PHONY: bootstrap + +# A test program for C++ constructors and destructors. +# This test is now in the testsuite. +# +#cdtest: cdtest-main.o cdtest-bar.o cdtest-foo.o ld.new +# ./ld.new $(HOSTING_EMU) -o cdtest $(HOSTING_CRT0) \ +# cdtest-main.o cdtest-bar.o cdtest-foo.o $(HOSTING_LIBS) +# +#cdtest.out: cdtest +# ./cdtest > cdtest.tmp +# mv cdtest.tmp cdtest.out +# +#cdtest-ur.o: cdtest-main.o cdtest-bar.o cdtest-foo.o ld.new +# ./ld.new $(HOSTING_EMU) -o cdtest-ur.o -Ur cdtest-main.o \ +# cdtest-bar.o cdtest-foo.o +# +#cdtest-ur: cdtest-ur.o +# ./ld.new $(HOSTING_EMU) -o cdtest-ur $(HOSTING_CRT0) cdtest-ur.o \ +# $(HOSTING_LIBS) +# +#cdtest-ur.out: cdtest-ur +# ./cdtest-ur > cdtest-ur.tmp +# mv cdtest-ur.tmp cdtest-ur.out +# +#check-cdtest: cdtest.out cdtest-ur.out $(srcdir)/cdtest.exp +# diff $(srcdir)/cdtest.exp cdtest.out +# diff $(srcdir)/cdtest.exp cdtest-ur.out +# +#.PHONY: check-cdtest + +# END OF CHECK TARGETS + +# DOCUMENTATION TARGETS +# Manual configuration file; not usually attached to normal configuration, +# because almost all configs use "gen" version of manual. +# Set DOCVER above to change. +configdoc.texi: ${DOCVER}-doc.texi + ln -s ${srcdir}/${DOCVER}-doc.texi ./configdoc.texi || \ + ln ${srcdir}/${DOCVER}-doc.texi ./configdoc.texi || \ + cp ${srcdir}/${DOCVER}-doc.texi ./configdoc.texi + +# TeX output +dvi: ld.dvi +ld.dvi: $(srcdir)/ld.texinfo configdoc.texi $(BFDDIR)/doc/bfdsumm.texi + TEXINPUTS=$(BFDDIR)/doc:$$TEXINPUTS MAKEINFO='$(MAKEINFO) -I$(BFDDIR)/doc -I$(srcdir)' \ + $(TEXI2DVI) $(srcdir)/ld.texinfo + +ldint.dvi: $(srcdir)/ldint.texinfo + $(TEXI2DVI) $(srcdir)/ldint.texinfo + +# info file for online browsing +ld.info: $(srcdir)/ld.texinfo configdoc.texi $(BFDDIR)/doc/bfdsumm.texi + $(MAKEINFO) -I$(BFDDIR)/doc -I$(srcdir) -o ld.info $(srcdir)/ld.texinfo + +ldint.info: $(srcdir)/ldint.texinfo + $(MAKEINFO) -o ldint.info $(srcdir)/ldint.texinfo + +.PHONY: dvi + +#separate targets for "ms", "me", and "mm" forms of roff doc +# Try to use a recent texi2roff. v2 was put on prep in jan91. +# If you want an index, see texi2roff doc for postprocessing +# and add -i to texi2roff invocations below. +# Workarounds for texi2roff-2 (probably fixed in later texi2roff's, delete +# correspondint -e lines when later texi2roff's are current) +# + @ifinfo's deleted explicitly due to texi2roff-2 bug w nested constructs. +# + @c's deleted explicitly because texi2roff sees texinfo commands in them +# + @ (that's at-BLANK) not recognized by texi2roff, turned into blank +# + @alphaenumerate is ridiculously new, turned into @enumerate + +ld.ms: $(srcdir)/ld.texinfo + sed -e '/\\input texinfo/d' \ + -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ + -e '/^@ifinfo/,/^@end ifinfo/d' \ + -e '/^@c/d' \ + -e 's/{.*,,/{/' \ + -e 's/@ / /g' \ + -e 's/^@alphaenumerate/@enumerate/g' \ + -e 's/^@end alphaenumerate/@end enumerate/g' \ + $(srcdir)/ld.texinfo | \ + $(TEXI2ROFF) $(TEXI2OPT) -ms | \ + sed -e 's/---/\\(em/g' \ + >>ld.ms + +# index for roff output +ld-index.ms: ld.ms + $(ROFF) -ms ld.ms 2>&1 1>/dev/null | \ + sed -e '/: warning:/d' | \ + texi2index >ld-index.ms + +# roff output (-mm) +ld.mm: $(srcdir)/ld.texinfo + sed -e '/\\input texinfo/d' \ + -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ + -e '/^@ifinfo/,/^@end ifinfo/d' \ + -e '/^@c/d' \ + -e 's/{.*,,/{/' \ + -e '/@noindent/d' \ + -e 's/@ / /g' \ + -e 's/^@alphaenumerate/@enumerate/g' \ + -e 's/^@end alphaenumerate/@end enumerate/g' \ + $(srcdir)/ld.texinfo | \ + $(TEXI2ROFF) $(TEXI2OPT) -mm | \ + sed -e 's/---/\\(em/g' \ + >ld.mm + +# index for roff output +ld-index.mm: ld.mm + $(ROFF) -mm ld.mm 2>&1 1>/dev/null | \ + sed -e '/: warning:/d' | \ + texi2index >ld-index.mm + +# roff output (-me) +ld.me: $(srcdir)/ld.texinfo + sed -e '/\\input texinfo/d' \ + -e '/@c TEXI2ROFF-KILL/,/@c END TEXI2ROFF-KILL/d' \ + -e '/^@ifinfo/,/^@end ifinfo/d' \ + -e '/^@c/d' \ + -e 's/{.*,,/{/' \ + -e 's/@ / /g' \ + -e 's/^@alphaenumerate/@enumerate/g' \ + -e 's/^@end alphaenumerate/@end enumerate/g' \ + $(srcdir)/ld.texinfo | \ + $(TEXI2ROFF) $(TEXI2OPT) -me | \ + sed -e 's/---/\\(em/g' \ + >>ld.me + +# index for roff output +ld-index.me: ld.me + $(ROFF) -me ld.me 2>&1 1>/dev/null | \ + sed -e '/: warning:/d' | \ + texi2index >ld-index.me + +stage1: force + -mkdir stage1 + -mv -f $(STAGESTUFF) $(LD_PROG) stage1 + -(cd stage1 ; ln -s $(LD_PROG) ld) + +stage2: force + -mkdir stage2 + -mv -f $(STAGESTUFF) $(LD_PROG) stage2 + -(cd stage2 ; ln -s $(LD_PROG) ld) + +stage3: force + -mkdir stage3 + -mv -f $(STAGESTUFF) $(LD_PROG) stage3 + -(cd stage3 ; ln -s $(LD_PROG) ld) + +against = stage2 + +comparison: force + for i in $(STAGESTUFF) $(LD_PROG) ; do cmp $$i $(against)/$$i ; done + +de-stage1: force + -(cd stage1 ; mv -f * ..) + -rm ld + -rmdir stage1 + +de-stage2: force + -(cd stage2 ; mv -f * ..) + -rm ld + -rmdir stage2 + +de-stage3: force + -(cd stage3 ; mv -f * ..) + -rm ld + -rmdir stage3 + +.PHONY: stage1 stage2 stage3 comparison de-stage1 de-stage2 de-stage3 + +# Stuff that should be included in a distribution: +LDDISTSTUFF = ldgram.c ldgram.h ldlex.c +diststuff: $(LDDISTSTUFF) info + +mostlyclean: + -rm -f $(STAGESTUFF) ld.?? ld.??? ldlex.[qp] + -rm -f ld ld1 ld2 ld3 *.o y.output cdtest cdtest.out cdtest.tmp + -rm -f cdtest-ur cdtest-ur.out cdtest-ur.tmp crtbegin.o crtend.o + -rm -f ldemul-list.h + -rm -fr tmpdir +clean: mostlyclean + -rm -f $(LD_PROG) +distclean: clean + -rm -f Makefile config.status TAGS site.exp site.bak config.cache + -rm -f config.h stamp-h config.log + -rm -rf ldscripts +maintainer-clean realclean: clean distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + -rm -f $(GENERATED_CFILES) $(GENERATED_HFILES) + -rm -f $(LDDISTSTUFF) *.info* configdoc.texi + +.PHONY: diststuff mostlyclean clean distclean realclean + +lintlog:$(LINTSOURCES) Makefile + $(LINT) -abhxzn $(LINTFLAGS) $(LINTSOURCES) \ +| grep -v "pointer casts may be troublesome" \ +| grep -v "possible pointer alignment problem" \ +| grep -v "ignore" \ +| grep -v "conversion from long may lose accuracy" \ +| grep -v "warning: constant argument to NOT" \ +| grep -v "enumeration type clash, operator CAST" \ +| grep -v "warning: constant in conditional context"\ +| grep -v "archive\.c" + + +TAGS: + etags -t $(srcdir)/*.[chly] *.[chly] + + +install: + $(INSTALL_XFORM) ld.new $(bindir)/ld + $(INSTALL_XFORM1) $(srcdir)/ld.1 $(man1dir)/ld.1 + for f in ldscripts/*; do \ + $(INSTALL_DATA) $$f $(scriptdir)/$$f ; \ + done + test -d $(tooldir) || mkdir $(tooldir) + test -d $(tooldir)/bin || mkdir $(tooldir)/bin + -n=`echo ld | sed '$(program_transform_name)'`; \ + rm -f $(tooldir)/bin/ld; \ + ln $(bindir)/$$n $(tooldir)/bin/ld >/dev/null 2>/dev/null \ + || $(INSTALL_PROGRAM) ld.new $(tooldir)/bin/ld + +install-info: ld.info + if [ -r ld.info ]; then \ + dir=. ; \ + else \ + dir=$(srcdir) ; \ + fi ; \ + for i in `cd $$dir ; echo ld.info*` ; do \ + $(INSTALL_DATA) $$dir/$$i $(infodir)/$$i ; \ + done + +clean-info: + -rm -rf *.info* + +.PHONY: install install-info clean-info + +# Targets to rebuild dependencies in this Makefile. +# Have to get rid of .dep1 here so that "$?" later includes all of $(CFILES). +.dep: dep.sed $(CFILES) $(HFILES) $(GENERATED_CFILES) $(GENERATED_HFILES) config.h + rm -f .dep1 + $(MAKE) DEP=$(DEP) .dep1 + sed -f dep.sed <.dep1 >.dep + +# This rule really wants a mkdep that runs "gcc -MM". +.dep1: $(CFILES) $(GENERATED_CFILES) + rm -f .dep2 + echo '# DO NOT DELETE THIS LINE -- mkdep uses it.' > .dep2 + $(DEP) -f .dep2 $(ALL_CFLAGS) $? + $(srcdir)/../move-if-change .dep2 .dep1 + +dep.sed: dep-in.sed config.status + sed <$(srcdir)/dep-in.sed >dep.sed \ + -e 's!@INCDIR@!$(INCDIR)!' \ + -e 's!@SRCDIR@!$(srcdir)!' + +dep: .dep + sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < Makefile > tmp-Makefile + cat .dep >> tmp-Makefile + $(srcdir)/../move-if-change tmp-Makefile Makefile + +dep-in: .dep + sed -e '/^..DO NOT DELETE THIS LINE/,$$d' < $(srcdir)/Makefile.in > tmp-Makefile.in + cat .dep >> tmp-Makefile.in + $(srcdir)/../move-if-change tmp-Makefile.in $(srcdir)/Makefile.in + +.PHONY: dep dep-in + +# Dummy target to force execution of dependent targets. +# +force: + +.PHONY: force + +Makefile: Makefile.in config.status + CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status + +config.h: stamp-h ; @true +stamp-h: config.in config.status + CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status + +config.status: configure configure.host configure.tgt + $(SHELL) ./config.status --recheck + +# What appears below is generated by a hacked mkdep using gcc -MM. + +# DO NOT DELETE THIS LINE -- mkdep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +ldctor.o: ldctor.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/bfdlink.h \ + ld.h ldexp.h ldlang.h ldmisc.h ldgram.h ldmain.h ldctor.h +ldemul.o: ldemul.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h ld.h ldemul.h \ + ldmisc.h ldexp.h ldlang.h ldfile.h ldmain.h ldemul-list.h +ldexp.o: ldexp.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/bfdlink.h \ + ld.h ldmain.h ldmisc.h ldexp.h ldgram.h ldlang.h +ldfile.o: ldfile.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/bfdlink.h \ + ld.h ldmisc.h ldexp.h ldlang.h ldfile.h ldmain.h ldgram.h \ + ldlex.h ldemul.h +ldlang.o: ldlang.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \ + $(INCDIR)/obstack.h $(INCDIR)/bfdlink.h ld.h ldmain.h \ + ldgram.h ldexp.h ldlang.h ldemul.h ldlex.h ldmisc.h \ + ldctor.h ldfile.h $(INCDIR)/fnmatch.h +ldmain.o: ldmain.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \ + $(INCDIR)/progress.h $(INCDIR)/bfdlink.h ld.h ldmain.h \ + ldmisc.h ldwrite.h ldgram.h ldexp.h ldlang.h ldemul.h \ + ldlex.h ldfile.h ldctor.h +ldmisc.o: ldmisc.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \ + $(INCDIR)/demangle.h ld.h ldmisc.h ldexp.h ldlang.h \ + ldgram.h ldlex.h ldmain.h ldfile.h +ldver.o: ldver.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h ld.h ldver.h \ + ldemul.h ldmain.h +ldwrite.o: ldwrite.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/libiberty.h ld.h ldexp.h ldlang.h ldwrite.h \ + ldmisc.h ldgram.h ldmain.h +lexsup.o: lexsup.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \ + $(INCDIR)/getopt.h $(INCDIR)/bfdlink.h ld.h ldmain.h \ + ldmisc.h ldexp.h ldlang.h ldgram.h ldlex.h ldfile.h \ + ldver.h ldemul.h +mri.o: mri.c ../bfd/bfd.h $(INCDIR)/ansidecl.h sysdep.h \ + config.h $(INCDIR)/fopen-same.h ld.h ldexp.h ldlang.h \ + ldmisc.h mri.h ldgram.h $(INCDIR)/libiberty.h +ldcref.o: ldcref.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/libiberty.h ld.h ldmain.h ldmisc.h ldexp.h \ + ldlang.h +ldgram.o: ldgram.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ + sysdep.h config.h $(INCDIR)/fopen-same.h $(INCDIR)/bfdlink.h \ + ld.h ldexp.h ldver.h ldlang.h ldemul.h ldfile.h ldmisc.h \ + ldmain.h mri.h ldlex.h +ldlex.o: ldlex.c ../bfd/bfd.h sysdep.h config.h $(INCDIR)/fopen-same.h \ + ld.h ldgram.h ldmisc.h ldexp.h ldlang.h ldfile.h ldlex.h \ + ldmain.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/contrib/binutils/ld/NEWS b/contrib/binutils/ld/NEWS new file mode 100644 index 0000000..b2449c4 --- /dev/null +++ b/contrib/binutils/ld/NEWS @@ -0,0 +1,160 @@ +-*- text -*- + +Changes in version 2.8: + +* Linker scripts may now contain shell wildcard characters for file and section + names. + +* The linker now supports symbol versions in ELF. + +* The NOCROSSREFS command was added to the linker script language. + +* The LOADADDR expression was added to the linker script language. + +* MAX and MIN functions were added to the linker script language. + +* The OVERLAY construct was added to the linker script language. + +* New option --warn-section-align to warn when the address of an output section + changes due to alignment of an input section. + +* New options --filter/-F and --auxiliary/-f. + +Changes in version 2.7: + +* New option --cref to print out a cross reference table. + +* New option --wrap SYMBOL. + +* New option --no-whole-archive, to turn off the effect of --whole-archive. + +* Input sections assigned to the output section /DISCARD/ in the linker script + are not included in the output file. + +* The SunOS and ELF linkers now merge stabs debugging information which uses + the N_BINCL and N_EINCL stab types. This reduces the amount of debugging + information generated. + +Changes in version 2.6: + +* When an ELF section name is representable as a C identifier (this is not true +of most ELF section names), the linker will automatically define symbols +__start_SECNAME and __stop_SECNAME, where SECNAME is the section name, at the +beginning and the end of the section. This is used by glibc. + +* When an ELF section named .gnu.warning is encountered in an input file, the +contents of the section are displayed as an error message, and the section is +not copied into the output file. This is used by glibc. + +* When an ELF section named .gnu.warning.SYMBOL is encountered in an input +file, and the symbol SYMBOL is referenced by some object file, the contents of +the section are displayed as an error message. The section is not copied into +the output file, unless doing a relocateable or shared link. This is used by +glibc. + +* New options -split-by-reloc and -split-by-file. + +* The linker now supports linking PIC compiled code on SPARC SunOS. It can +also create SPARC SunOS shared libraries, and, like the native SunOS linker, +will do so whenever there is an undefined symbol in the link and neither the -e +nor the -r option was used. + +* The -rpath option may be used on SunOS to set the list of directories to be +searched at run time. This overrides the default of building the list from the +-L options. + +* The COFF linker now combines debugging information for structs, unions, and +enums, so that even if the same type is defined in multiple input files it will +only be defined once in the output file. The --traditional-format switch will +prevent this optimization. + +Changes in version 2.5: + +* The linker now supports linking against SunOS shared libraries. It still can +not link SunOS PIC (Position Independent Code) files, so it can not be used to +generate shared libaries. + +* The linker now supports linking against ELF shared libraries for the i386 +(UnixWare) and SPARC (Solaris). It can also link ELF PIC files, and can be +used to generate shared libraries. Shared library generation is not well +tested; please report any problems encountered. The linker is now enabled for +Solaris again. + +* Eric Youngdale has contributed Linux support code, including linking against +Linux a.out shared libraries. The linker produces Linux QMAGIC binaries. + +* The ELF backend has been converted to the new linker code. To use the new +ELF linker, each particular target requires a relocation function. So far, +this function has been written for i386 (UnixWare), SPARC (Solaris) MIPS (Irix +5), and HPPA ELF targets. + +* The -( (--start-group) and -) (--end-group) options have been added to +support searching a group of archives as though they were a single archive. +This can also be used in a linker script, as GROUP ( files ). + +* When a file is named on the command line, and the linker does not recognize +it as an object file, the linker will now treat the file as a linker script +file. A linker script named in this way augments, but does not replace, the +default linker script. + +* The -warn-once option was added. It causes the linker to only warn once per +undefined symbol, rather than once per reference. + +* The COFF backend has been converted to the new linker code. As with ELF, to +use the new linker, each particular target requires a relocation function. So +far, this function has been written for the i386, m68k, a29k and SH targets. + +* The -V flag was made a synonym for -v, for SVR4 compatibility. The old -V +behaviour is available via --verbose. + +Changes in version 2.4: + +* New linker code, by Steve Chamberlain and Ian Taylor. For a.out and ecoff + formats (so far), this should result in considerable savings in time + and memory used while linking; slightly poorer performance than + before for formats not converted yet. + +* Command-line parsing is no longer done with flex. This means + oddball characters in filenames won't get treated as argument + separators. + +* HP-PA ELF support, by Jeff Law. (No SOM support yet.) + +* Mach i386 support, by David Mackenzie. + +* Irix 4 shared libraries are now supported (Irix 5 uses ELF, and ELF shared + libraries are not yet supported). + +* COFF shared libraries (as on SCO) should work as well. + +* The linker is disabled for Solaris. (Actually, it was in 2.3 also, I just + forgot to note it.) Some of their C library routines don't work when + statically linked, and the GNU linker doesn't support dynamic linking yet. + +Changes in version 2.3: + +* Weak symbols are now supported. + +* ELF support has been added. The linker has been bootstrapped on + UnixWare and Solaris. + +* Alpha OSF/1 support has been added (non dynamic linking only). + +Changes in version 2.2: + +* The `bfd' library has been updated to reduce a.out-format string + table size. The effect of this is that files linked from many input + files with duplicate symbols (`-g' debugging records, or identical + static symbols) should be much smaller. + +Changes in version 2.1: + +* The ld -ySYMBOL flag (to trace references to SYMBOL) is now implemented. + +* There is now support for writing ECOFF files, so ld and the + other utilities should work on Risc/Ultrix and Irix. + + +Local variables: +fill-column: 79 +End: diff --git a/contrib/binutils/ld/README b/contrib/binutils/ld/README new file mode 100644 index 0000000..4efa989 --- /dev/null +++ b/contrib/binutils/ld/README @@ -0,0 +1,54 @@ +This is a BETA release of a completely rewritten GNU linker. +It is distributed with other "binary utilities" which should +be in ../binutils. See ../binutils/README for more general notes, +including where to send bug reports. + +There are many new features of the linker: + +* The linker uses a Binary File Descriptor library (../bfd) + that it uses to read and write object files. This helps + insulate the linker itself from the format of object files. + +* The linker support a number of different object file + formats. It can even handle multiple formats at once: + Read two input formats and write a third. + +* The linker can be configured for cross-linking. + +* The linker contains a control language. + +* There is a user manual (ld.texinfo), as well as the + beginnings of an internals manual (ldint.texinfo). + +Installation +============ + +See ../binutils/README. + +If you want to make a cross-linker, you may want to specify +a different search path of -lfoo libraries than the default. +You can do this by setting the LIB_PATH variable in ./Makefile. + +To build just the linker, make the target all-ld. + +Porting to a new target +======================= + +See the ldint.texinfo manual. + +Reporting bugs etc +=========================== +See ../binutils/README. + +Known problems +============== + +HP/UX 9.01 has a shell bug that causes the linker scripts to be +generated incorrectly. The symptom of this appears to be "fatal error +- scanner input buffer overflow" error messages. There are various +workarounds to this: + * Build and install bash, and build with "make SHELL=bash". + * Update to a version of HP/UX with a working shell (e.g., 9.05). + * Replace "(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc)" in + genscripts.sh with "sh ${srcdir}..." (no parens) and make sure the + emulparams script used exports any shell variables it sets. diff --git a/contrib/binutils/ld/TODO b/contrib/binutils/ld/TODO new file mode 100644 index 0000000..31cd98b --- /dev/null +++ b/contrib/binutils/ld/TODO @@ -0,0 +1,9 @@ +Volunteers to tackle some of the following would be welcome: + +Support the "traditional" BSD -A flag (incremental loading). +(There is a -A flag in ld now, but it is used to specify the +architecture. That should probably be changed.) + +Support for dynamic loading (a la dld, but bfd-based) would be nice. + +Avoid re-open (and re-seeking) output bfd and archives. diff --git a/contrib/binutils/ld/acconfig.h b/contrib/binutils/ld/acconfig.h new file mode 100644 index 0000000..6034cad --- /dev/null +++ b/contrib/binutils/ld/acconfig.h @@ -0,0 +1,16 @@ + +/* Whether strstr must be declared even if <string.h> is included. */ +#undef NEED_DECLARATION_STRSTR + +/* Whether free must be declared even if <stdlib.h> is included. */ +#undef NEED_DECLARATION_FREE + +/* Whether sbrk must be declared even if <unistd.h> is included. */ +#undef NEED_DECLARATION_SBRK + +/* Whether getenv must be declared even if <stdlib.h> is included. */ +#undef NEED_DECLARATION_GETENV +@TOP@ + +/* Do we need to use the b modifier when opening binary files? */ +#undef USE_BINARY_FOPEN diff --git a/contrib/binutils/ld/aclocal.m4 b/contrib/binutils/ld/aclocal.m4 new file mode 100644 index 0000000..7adc004 --- /dev/null +++ b/contrib/binutils/ld/aclocal.m4 @@ -0,0 +1 @@ +sinclude(../bfd/aclocal.m4) diff --git a/contrib/binutils/ld/config.in b/contrib/binutils/ld/config.in new file mode 100644 index 0000000..4313165 --- /dev/null +++ b/contrib/binutils/ld/config.in @@ -0,0 +1,43 @@ +/* config.in. Generated automatically from configure.in by autoheader. */ + +/* Whether strstr must be declared even if <string.h> is included. */ +#undef NEED_DECLARATION_STRSTR + +/* Whether free must be declared even if <stdlib.h> is included. */ +#undef NEED_DECLARATION_FREE + +/* Whether sbrk must be declared even if <unistd.h> is included. */ +#undef NEED_DECLARATION_SBRK + +/* Whether getenv must be declared even if <stdlib.h> is included. */ +#undef NEED_DECLARATION_GETENV + +/* Do we need to use the b modifier when opening binary files? */ +#undef USE_BINARY_FOPEN + +/* Define if you have the sbrk function. */ +#undef HAVE_SBRK + +/* Define if you have the <dirent.h> header file. */ +#undef HAVE_DIRENT_H + +/* Define if you have the <ndir.h> header file. */ +#undef HAVE_NDIR_H + +/* Define if you have the <stdlib.h> header file. */ +#undef HAVE_STDLIB_H + +/* Define if you have the <string.h> header file. */ +#undef HAVE_STRING_H + +/* Define if you have the <strings.h> header file. */ +#undef HAVE_STRINGS_H + +/* Define if you have the <sys/dir.h> header file. */ +#undef HAVE_SYS_DIR_H + +/* Define if you have the <sys/ndir.h> header file. */ +#undef HAVE_SYS_NDIR_H + +/* Define if you have the <unistd.h> header file. */ +#undef HAVE_UNISTD_H diff --git a/contrib/binutils/ld/configdoc.texi b/contrib/binutils/ld/configdoc.texi new file mode 100644 index 0000000..3a36727 --- /dev/null +++ b/contrib/binutils/ld/configdoc.texi @@ -0,0 +1,13 @@ +@c ------------------------------ CONFIGURATION VARS: +@c 1. Inclusiveness of this manual +@set GENERIC + +@c 2. Specific target machines +@set H8300 +@set I960 + +@c 3. Properties of this configuration +@clear SingleFormat +@set UsesEnvVars +@c ------------------------------ end CONFIGURATION VARS + diff --git a/contrib/binutils/ld/configure b/contrib/binutils/ld/configure new file mode 100755 index 0000000..f0d151e --- /dev/null +++ b/contrib/binutils/ld/configure @@ -0,0 +1,1884 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.12 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --enable-targets alternative target configurations" +ac_help="$ac_help + --enable-shared build shared BFD library" +ac_help="$ac_help + --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.12" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=ldmain.c + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + +# Check whether --enable-targets or --disable-targets was given. +if test "${enable_targets+set}" = set; then + enableval="$enable_targets" + case "${enableval}" in + yes | "") { echo "configure: error: enable-targets option must specify target names or 'all'" 1>&2; exit 1; } + ;; + no) enable_targets= ;; + *) enable_targets=$enableval ;; +esac +fi +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + case "${enableval}" in + yes) shared=true ;; + no) shared=false ;; + *bfd*) shared=true ;; + *) shared=false ;; +esac +fi +# Check whether --enable-64-bit-bfd or --disable-64-bit-bfd was given. +if test "${enable_64_bit_bfd+set}" = set; then + enableval="$enable_64_bit_bfd" + case "${enableval}" in + yes) want64=true ;; + no) want64=false ;; + *) { echo "configure: error: bad value ${enableval} for 64-bit-bfd option" 1>&2; exit 1; } ;; +esac +else + want64=false +fi + + + +ac_aux_dir= +for ac_dir in `cd $srcdir/..; pwd` $srcdir/`cd $srcdir/..; pwd`; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in `cd $srcdir/..; pwd` $srcdir/`cd $srcdir/..; pwd`" 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + +# Do some error checking and defaulting for the host and target type. +# The inputs are: +# configure --host=HOST --target=TARGET --build=BUILD NONOPT +# +# The rules are: +# 1. You are not allowed to specify --host, --target, and nonopt at the +# same time. +# 2. Host defaults to nonopt. +# 3. If nonopt is not specified, then host defaults to the current host, +# as determined by config.guess. +# 4. Target and build default to nonopt. +# 5. If nonopt is not specified, then target and build default to host. + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +case $host---$target---$nonopt in +NONE---*---* | *---NONE---* | *---*---NONE) ;; +*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;; +esac + + +# Make sure we can run config.sub. +if $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:610: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`$ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`$ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:631: checking target system type" >&5 + +target_alias=$target +case "$target_alias" in +NONE) + case $nonopt in + NONE) target_alias=$host_alias ;; + *) target_alias=$nonopt ;; + esac ;; +esac + +target=`$ac_config_sub $target_alias` +target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$target" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:649: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`$ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +test "$host_alias" != "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +if test -z "$target" ; then + { echo "configure: error: Unrecognized target system type; please check config.sub." 1>&2; exit 1; } +fi +if test -z "$host" ; then + { echo "configure: error: Unrecognized host system type; please check config.sub." 1>&2; exit 1; } +fi +if test "$program_transform_name" = s,x,x,; then + program_transform_name= +else + # Double any \ or $. echo might interpret backslashes. + cat <<\EOF_SED > conftestsed +s,\\,\\\\,g; s,\$,$$,g +EOF_SED + program_transform_name="`echo $program_transform_name|sed -f conftestsed`" + rm -f conftestsed +fi +test "$program_prefix" != NONE && + program_transform_name="s,^,${program_prefix},; $program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" + +# sed with no file args requires a program. +test "$program_transform_name" = "" && program_transform_name="s,x,x," + + +# host-specific stuff: + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:702: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:731: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + ac_prog_rejected=no + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:779: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext <<EOF +#line 789 "configure" +#include "confdefs.h" +main(){return(0);} +EOF +if { (eval echo configure:793: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:813: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:818: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes + ac_test_CFLAGS="${CFLAGS+set}" + ac_save_CFLAGS="$CFLAGS" + CFLAGS= + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:842: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 + if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" + elif test $ac_cv_prog_cc_g = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-O2" + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:880: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + for ac_prog in ginstall installbsd scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +. ${srcdir}/configure.host + + + + + + + + + +# For most hosts we can use a simple definition to pick up the BFD and +# opcodes libraries. However, if we are building shared libraries, we +# need to handle some hosts specially. +BFDLIB='-L../bfd -lbfd' +case "${host}" in +*-*-sunos*) + # On SunOS, we must link against the name we are going to install, + # not -lbfd, since SunOS does not support SONAME. + if test "${shared}" = "true"; then + BFDLIB='-L../bfd -l`echo bfd | sed '"'"'$(program_transform_name)'"'"'`' + fi + ;; +alpha*-*-osf*) + # On Alpha OSF/1, the native linker searches all the -L + # directories for any LIB.so files, and only then searches for any + # LIB.a files. That means that if there is an installed + # libbfd.so, but this build is not done with --enable-shared, the + # link will wind up being against the install libbfd.so rather + # than the newly built libbfd. To avoid this, we must explicitly + # link against libbfd.a when --enable-shared is not used. + if test "${shared}" != "true"; then + BFDLIB='../bfd/libbfd.a' + fi + ;; +esac + + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:968: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext <<EOF +#line 983 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:989: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext <<EOF +#line 1000 "configure" +#include "confdefs.h" +#include <assert.h> +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1006: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +for ac_hdr in string.h strings.h stdlib.h unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1032: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1037 "configure" +#include "confdefs.h" +#include <$ac_hdr> +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1042: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +for ac_func in sbrk +do +echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1071: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1076 "configure" +#include "confdefs.h" +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func(); below. */ +#include <assert.h> +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1099: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $ac_tr_func 1 +EOF + +else + echo "$ac_t""no" 1>&6 +fi +done + +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 +echo "configure:1128: checking for $ac_hdr that defines DIR" >&5 +if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1133 "configure" +#include "confdefs.h" +#include <sys/types.h> +#include <$ac_hdr> +int main() { +DIR *dirp = 0; +; return 0; } +EOF +if { (eval echo configure:1141: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_dirent_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <<EOF +#define $ac_tr_hdr 1 +EOF + ac_header_dirent=$ac_hdr; break +else + echo "$ac_t""no" 1>&6 +fi +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then +echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6 +echo "configure:1166: checking for opendir in -ldir" >&5 +ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldir $LIBS" +cat > conftest.$ac_ext <<EOF +#line 1174 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir(); + +int main() { +opendir() +; return 0; } +EOF +if { (eval echo configure:1185: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -ldir" +else + echo "$ac_t""no" 1>&6 +fi + +else +echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6 +echo "configure:1207: checking for opendir in -lx" >&5 +ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-lx $LIBS" +cat > conftest.$ac_ext <<EOF +#line 1215 "configure" +#include "confdefs.h" +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char opendir(); + +int main() { +opendir() +; return 0; } +EOF +if { (eval echo configure:1226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + LIBS="$LIBS -lx" +else + echo "$ac_t""no" 1>&6 +fi + +fi + + + +case "${host}" in +i[345]86-*-msdos* | i[345]86-*-go32* | *-*-cygwin32 | *-*-windows) + cat >> confdefs.h <<\EOF +#define USE_BINARY_FOPEN 1 +EOF + ;; +esac + +echo $ac_n "checking whether strstr must be declared""... $ac_c" 1>&6 +echo "configure:1259: checking whether strstr must be declared" >&5 +if eval "test \"`echo '$''{'bfd_cv_decl_needed_strstr'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1264 "configure" +#include "confdefs.h" + +#include <stdio.h> +#ifdef HAVE_STRING_H +#include <string.h> +#else +#ifdef HAVE_STRINGS_H +#include <strings.h> +#endif +#endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +int main() { +char *(*pfn) = (char *(*)) strstr +; return 0; } +EOF +if { (eval echo configure:1285: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bfd_cv_decl_needed_strstr=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bfd_cv_decl_needed_strstr=yes +fi +rm -f conftest* +fi + +echo "$ac_t""$bfd_cv_decl_needed_strstr" 1>&6 +if test $bfd_cv_decl_needed_strstr = yes; then + bfd_tr_decl=NEED_DECLARATION_`echo strstr | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $bfd_tr_decl 1 +EOF + +fi + +echo $ac_n "checking whether free must be declared""... $ac_c" 1>&6 +echo "configure:1307: checking whether free must be declared" >&5 +if eval "test \"`echo '$''{'bfd_cv_decl_needed_free'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1312 "configure" +#include "confdefs.h" + +#include <stdio.h> +#ifdef HAVE_STRING_H +#include <string.h> +#else +#ifdef HAVE_STRINGS_H +#include <strings.h> +#endif +#endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +int main() { +char *(*pfn) = (char *(*)) free +; return 0; } +EOF +if { (eval echo configure:1333: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bfd_cv_decl_needed_free=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bfd_cv_decl_needed_free=yes +fi +rm -f conftest* +fi + +echo "$ac_t""$bfd_cv_decl_needed_free" 1>&6 +if test $bfd_cv_decl_needed_free = yes; then + bfd_tr_decl=NEED_DECLARATION_`echo free | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $bfd_tr_decl 1 +EOF + +fi + +echo $ac_n "checking whether sbrk must be declared""... $ac_c" 1>&6 +echo "configure:1355: checking whether sbrk must be declared" >&5 +if eval "test \"`echo '$''{'bfd_cv_decl_needed_sbrk'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1360 "configure" +#include "confdefs.h" + +#include <stdio.h> +#ifdef HAVE_STRING_H +#include <string.h> +#else +#ifdef HAVE_STRINGS_H +#include <strings.h> +#endif +#endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +int main() { +char *(*pfn) = (char *(*)) sbrk +; return 0; } +EOF +if { (eval echo configure:1381: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bfd_cv_decl_needed_sbrk=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bfd_cv_decl_needed_sbrk=yes +fi +rm -f conftest* +fi + +echo "$ac_t""$bfd_cv_decl_needed_sbrk" 1>&6 +if test $bfd_cv_decl_needed_sbrk = yes; then + bfd_tr_decl=NEED_DECLARATION_`echo sbrk | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $bfd_tr_decl 1 +EOF + +fi + +echo $ac_n "checking whether getenv must be declared""... $ac_c" 1>&6 +echo "configure:1403: checking whether getenv must be declared" >&5 +if eval "test \"`echo '$''{'bfd_cv_decl_needed_getenv'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <<EOF +#line 1408 "configure" +#include "confdefs.h" + +#include <stdio.h> +#ifdef HAVE_STRING_H +#include <string.h> +#else +#ifdef HAVE_STRINGS_H +#include <strings.h> +#endif +#endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +int main() { +char *(*pfn) = (char *(*)) getenv +; return 0; } +EOF +if { (eval echo configure:1429: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bfd_cv_decl_needed_getenv=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bfd_cv_decl_needed_getenv=yes +fi +rm -f conftest* +fi + +echo "$ac_t""$bfd_cv_decl_needed_getenv" 1>&6 +if test $bfd_cv_decl_needed_getenv = yes; then + bfd_tr_decl=NEED_DECLARATION_`echo getenv | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` + cat >> confdefs.h <<EOF +#define $bfd_tr_decl 1 +EOF + +fi + + +# target-specific stuff: + +all_targets= +EMUL= +all_emuls= +TDIRS= + +for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'` +do + if test "$targ_alias" = "all"; then + all_targets=true + else + # Canonicalize the secondary target names. + result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $targ_alias 2>/dev/null` + if test -n "$result"; then + targ=$result + else + targ=$targ_alias + fi + + . ${srcdir}/configure.tgt + + if test "$targ" = "$target"; then + EMUL=$targ_emul + fi + + for i in $targ_emul $targ_extra_emuls; do + case " $all_emuls " in + *" e${i}.o "*) ;; + *) + all_emuls="$all_emuls e${i}.o" + eval result=\$tdir_$i + test -z "$result" && result=$targ_alias + TDIRS="$TDIRS\\ +tdir_$i=$result" + ;; + esac + done + fi +done + + + + +if test x${all_targets} = xtrue; then + if test x${want64} = xtrue; then + EMULATION_OFILES='$(ALL_EMULATIONS) $(ALL_64_EMULATIONS)' + else + EMULATION_OFILES='$(ALL_EMULATIONS)' + fi +else + EMULATION_OFILES=$all_emuls +fi + + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +DEFS=-DHAVE_CONFIG_H + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS <<EOF +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.12" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile config.h:config.in" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS <<EOF + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@target@%$target%g +s%@target_alias@%$target_alias%g +s%@target_cpu@%$target_cpu%g +s%@target_vendor@%$target_vendor%g +s%@target_os@%$target_os%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g +s%@CC@%$CC%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@HLDFLAGS@%$HLDFLAGS%g +s%@HLDENV@%$HLDENV%g +s%@RPATH_ENVVAR@%$RPATH_ENVVAR%g +s%@HDEFINES@%$HDEFINES%g +s%@HOSTING_CRT0@%$HOSTING_CRT0%g +s%@HOSTING_LIBS@%$HOSTING_LIBS%g +s%@NATIVE_LIB_DIRS@%$NATIVE_LIB_DIRS%g +s%@BFDLIB@%$BFDLIB%g +s%@CPP@%$CPP%g +s%@EMUL@%$EMUL%g +s%@TDIRS@%$TDIRS%g +s%@EMULATION_OFILES@%$EMULATION_OFILES%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <<EOF + +CONFIG_FILES=\${CONFIG_FILES-"Makefile"} +EOF +cat >> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' +ac_dC='\3' +ac_dD='%g' +# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". +ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='\([ ]\)%\1#\2define\3' +ac_uC=' ' +ac_uD='\4%g' +# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_eB='$%\1#\2define\3' +ac_eC=' ' +ac_eD='%g' + +if test "${CONFIG_HEADERS+set}" != set; then +EOF +cat >> $CONFIG_STATUS <<EOF + CONFIG_HEADERS="config.h:config.in" +EOF +cat >> $CONFIG_STATUS <<\EOF +fi +for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + echo creating $ac_file + + rm -f conftest.frag conftest.in conftest.out + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + cat $ac_file_inputs > conftest.in + +EOF + +# Transform confdefs.h into a sed script conftest.vals that substitutes +# the proper values into config.h.in to produce config.h. And first: +# Protect against being on the right side of a sed subst in config.status. +# Protect against being in an unquoted here document in config.status. +rm -f conftest.vals +cat > conftest.hdr <<\EOF +s/[\\&%]/\\&/g +s%[\\$`]%\\&%g +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp +s%ac_d%ac_u%gp +s%ac_u%ac_e%gp +EOF +sed -n -f conftest.hdr confdefs.h > conftest.vals +rm -f conftest.hdr + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >> conftest.vals <<\EOF +s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% +EOF + +# Break up conftest.vals because some shells have a limit on +# the size of here documents, and old seds have small limits too. + +rm -f conftest.tail +while : +do + ac_lines=`grep -c . conftest.vals` + # grep -c gives empty output for an empty file on some AIX systems. + if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi + # Write a limited-size here document to conftest.frag. + echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS + echo 'CEOF + sed -f conftest.frag conftest.in > conftest.out + rm -f conftest.in + mv conftest.out conftest.in +' >> $CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail + rm -f conftest.vals + mv conftest.tail conftest.vals +done +rm -f conftest.vals + +cat >> $CONFIG_STATUS <<\EOF + rm -f conftest.frag conftest.h + echo "/* $ac_file. Generated automatically by configure. */" > conftest.h + cat conftest.in >> conftest.h + rm -f conftest.in + if cmp -s $ac_file conftest.h 2>/dev/null; then + echo "$ac_file is unchanged" + rm -f conftest.h + else + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + fi + rm -f $ac_file + mv conftest.h $ac_file + fi +fi; done + +EOF +cat >> $CONFIG_STATUS <<EOF + +EOF +cat >> $CONFIG_STATUS <<\EOF +case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/contrib/binutils/ld/configure.host b/contrib/binutils/ld/configure.host new file mode 100644 index 0000000..6f71858 --- /dev/null +++ b/contrib/binutils/ld/configure.host @@ -0,0 +1,198 @@ +# This is the linker host specific file. This is invoked by the +# autoconf generated configure script. Putting it in a separate shell +# file lets us skip running autoconf when modifying host specific +# information. + +# This file sets the following shell variables: +# HDEFINES host specific compiler flags +# HOSTING_CRT0 crt0.o file used for bootstrapping +# HOSTING_LIBS libraries used for bootstrapping +# NATIVE_LIB_DIRS library directories to search on this host +# HLDFLAGS link flags to use on this host +# HLDENV environment variable to set when linking for the host +# RPATH_ENVVAR environment variable used to find shared libraries + +HDEFINES= +HOSTING_CRT0=/lib/crt0.o +HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc' +NATIVE_LIB_DIRS= + +case "${host}" in + +alpha-*-linux*) + HOSTING_CRT0=/usr/lib/crt0.o + ;; + +alpha-*-*) + HOSTING_CRT0=/usr/ccs/lib/crt0.o + NATIVE_LIB_DIRS=/usr/ccs/lib + ;; + +i[3456]86-*-bsd* | i[3456]86-*-freebsd* | i[3456]86-*-netbsd*) + # The new BSD `make' has a bug: it doesn't pass empty arguments in + # shell commands. So we need to make this value non-empty in order + # for the genscripts.sh call to work. There's nothing magic about + # the value `/lib'; it's just a dummy. + NATIVE_LIB_DIRS=/lib + HOSTING_CRT0=/usr/lib/crt0.o + ;; + +i[3456]86-*-sysv4*) + HOSTING_CRT0='/usr/ccs/lib/crt1.o /usr/ccs/lib/crti.o /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`' + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi` /usr/ccs/lib/crtn.o' + NATIVE_LIB_DIRS=/usr/ccs/lib + ;; + +i[3456]86-sequent-ptx* | i[3456]86-sequent-sysv*) + HOSTING_CRT0='/lib/crt0.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`' + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi`' + ;; + +i[3456]86-*-sysv*) + HOSTING_CRT0='/lib/crt1.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; fi`' + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; fi` /lib/crtn.o' + ;; + +i[3456]86-*-solaris*) + HOSTING_CRT0='`if [ -f ../gcc/crt1.o ]; then echo ../gcc/crt1.o; else gcc -print-file-name=crt1.o; fi` `if [ -f ../gcc/crti.o ]; then echo ../gcc/crti.o; else gcc -print-file-name=crti.o; fi` /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`' + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else gcc -print-file-name=crtn.o; fi`' + NATIVE_LIB_DIRS=/usr/ccs/lib + ;; + +i[3456]86-*-sco* | i[3456]86-*-isc*) + # In some configurations gcc does not use crtbegin.o and crtend.o. + # In that case gcc -print-file-name=crtbegin.o will simply print + # crtbegin.o. We create dummy crtbegin.o and crtend.o files to + # handle this. + echo "int dummy_crtbegin () { return 0; }" > crtbegin.c + ${CC} -c crtbegin.c -o crtbegin.o + rm -f crtbegin.c + echo "int dummy_crteng () { return 0; }" > crtend.c + ${CC} -c crtend.c -o crtend.o + rm -f crtend.c + HOSTING_CRT0='/lib/crt1.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`' + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi` /lib/crtn.o' + ;; + +i[3456]86-*-linux*aout* | i[3456]86-*-linuxoldld) + HOSTING_CRT0=/usr/lib/crt0.o + ;; + +i[3456]86-*-linux*) + HOSTING_CRT0='-dynamic-linker /lib/ld-linux.so.1 /usr/lib/crt1.o /usr/lib/crti.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; elif [ -f /usr/lib/crtbegin.o ]; then echo /usr/lib/crtbegin.o; else gcc --print-file-name=crtbegin.o; fi`' + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; elif [ -f /usr/lib/crtend.o ]; then echo /usr/lib/crtend.o; else gcc --print-file-name=crtend.o; fi` /usr/lib/crtn.o' + ;; + +i[3456]86-*-lynxos*) + HOSTING_CRT0=/lib/init1.o + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc -lm /lib/initn.o' + ;; + +mips*-dec-bsd*) + HOSTING_CRT0=/usr/lib/crt0.o + ;; + +mips*-sgi-irix4*) + HOSTING_CRT0=/usr/lib/crt1.o + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc /usr/lib/crtn.o' + ;; + +mips*-sgi-irix[56]*) + HOSTING_CRT0=/usr/lib/crt1.o + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc /usr/lib/crtn.o' + ;; + +m68*-*-linux*aout*) + HOSTING_CRT0=/usr/lib/crt0.o + ;; + +m68*-*-linux*) + HOSTING_CRT0='-dynamic-linker /lib/ld-linux.so.1 /usr/lib/crt1.o /usr/lib/crti.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; elif [ -f /usr/lib/crtbegin.o ]; then echo /usr/lib/crtbegin.o; else gcc --print-file-name=crtbegin.o; fi`' + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; elif [ -f /usr/lib/crtend.o ]; then echo /usr/lib/crtend.o; else gcc --print-file-name=crtend.o; fi` /usr/lib/crtn.o' + ;; + +m68*-*-lynxos*) + HOSTING_CRT0=/lib/init1.o + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc -lm /lib/initn.o' + ;; + +m68*-motorola-sysv) + HOSTING_CRT0='`if [ -f ../gcc/crt0.o ]; then echo ../gcc/crt0.o; elif [ -f \`gcc -print-file-name=\`crt0.o ]; then echo \`gcc -print-file-name=\`crt0.o; else echo /lib/crt0.o; fi`' + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc881 `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi`' + ;; + +m68*-sun-*) + HOSTING_CRT0='/usr/lib/crt0.o /usr/lib/Fcrt1.o -L/usr/lib/fsoft.o' + ;; + +m88*-*-dgux*) + HDEFINES=-D__using_DGUX + HOSTING_CRT0='/lib/crt0.o -X' + HOSTING_LIBS=/usr/sde/m88kbcs/lib/libc.a + ;; + +m88*-motorola-sysv3) + HOSTING_CRT0='/lib/crt0.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`' + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi` `if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi`' + ;; + +romp-*-*) + HDEFINES=-DNO_VARARGS + ;; + +sparc*-*-solaris2*) + HOSTING_CRT0='`if [ -f ../gcc/crt1.o ]; then echo ../gcc/crt1.o; else gcc -print-file-name=crt1.o; fi` `if [ -f ../gcc/crti.o ]; then echo ../gcc/crti.o; else gcc -print-file-name=crti.o; fi` /usr/ccs/lib/values-Xa.o `if [ -f ../gcc/crtbegin.o ]; then echo ../gcc/crtbegin.o; else gcc -print-file-name=crtbegin.o; fi`' + HOSTING_LIBS='`if [ -f ../gcc/libgcc.a ] ; then echo ../gcc/libgcc.a ; else gcc -print-libgcc-file-name; fi` -lc `if [ -f ../gcc/crtend.o ]; then echo ../gcc/crtend.o; else gcc -print-file-name=crtend.o; fi` `if [ -f ../gcc/crtn.o ]; then echo ../gcc/crtn.o; else gcc -print-file-name=crtn.o; fi`' + NATIVE_LIB_DIRS=/usr/ccs/lib + ;; + +esac + +HLDFLAGS= +HLDENV= +RPATH_ENVVAR=LD_LIBRARY_PATH +# If we have shared libraries, try to set rpath reasonably. +if test "${shared}" = "true"; then + case "${host}" in + *-*-hpux*) + HLDFLAGS='-Wl,+s,+b,$(libdir)' + RPATH_ENVVAR=SHLIB_PATH + ;; + *-*-irix[56]*) + HLDFLAGS='-Wl,-rpath,$(libdir)' + ;; + *-*-linux*aout*) + ;; + *-*-linux*) + HLDFLAGS='-Wl,-rpath,$(libdir)' + ;; + *-*-solaris*) + HLDFLAGS='-R $(libdir)' + ;; + *-*-sysv4*) + HLDENV='if test -z "$${LD_RUN_PATH}"; then LD_RUN_PATH=$(libdir); else LD_RUN_PATH=$${LD_RUN_PATH}:$(libdir); fi; export LD_RUN_PATH;' + ;; + esac +fi + +# On SunOS, if the linker supports the -rpath option, use it to +# prevent ../bfd and ../opcodes from being included in the run time +# search path. +case "${host}" in + *-*-sunos*) + echo 'main () { }' > conftest.c + ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t + if grep 'unrecognized' conftest.t >/dev/null 2>&1; then + : + elif grep 'No such file' conftest.t >/dev/null 2>&1; then + : + elif grep 'do not mix' conftest.t >/dev/null 2>&1; then + : + elif test "${shared}" = "true"; then + HLDFLAGS='-Wl,-rpath=$(libdir)' + else + HLDFLAGS='-Wl,-rpath=' + fi + rm -f conftest.t conftest.c conftest + ;; +esac diff --git a/contrib/binutils/ld/configure.in b/contrib/binutils/ld/configure.in new file mode 100644 index 0000000..3646e2f --- /dev/null +++ b/contrib/binutils/ld/configure.in @@ -0,0 +1,154 @@ +dnl Process this file with autoconf to produce a configure script +dnl +AC_PREREG(2.5) +AC_INIT(ldmain.c) + +AC_ARG_ENABLE(targets, +[ --enable-targets alternative target configurations], +[case "${enableval}" in + yes | "") AC_ERROR(enable-targets option must specify target names or 'all') + ;; + no) enable_targets= ;; + *) enable_targets=$enableval ;; +esac])dnl +AC_ARG_ENABLE(shared, +[ --enable-shared build shared BFD library], +[case "${enableval}" in + yes) shared=true ;; + no) shared=false ;; + *bfd*) shared=true ;; + *) shared=false ;; +esac])dnl +AC_ARG_ENABLE(64-bit-bfd, +[ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)], +[case "${enableval}" in + yes) want64=true ;; + no) want64=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;; +esac],[want64=false])dnl + +AC_CONFIG_HEADER(config.h:config.in) + +AC_CONFIG_AUX_DIR(`cd $srcdir/..; pwd`) +AC_CANONICAL_SYSTEM +if test -z "$target" ; then + AC_MSG_ERROR(Unrecognized target system type; please check config.sub.) +fi +if test -z "$host" ; then + AC_MSG_ERROR(Unrecognized host system type; please check config.sub.) +fi +AC_ARG_PROGRAM + +# host-specific stuff: + +AC_PROG_CC +AC_PROG_INSTALL + +. ${srcdir}/configure.host + +AC_SUBST(HLDFLAGS) +AC_SUBST(HLDENV) +AC_SUBST(RPATH_ENVVAR) +AC_SUBST(HDEFINES) +AC_SUBST(HOSTING_CRT0) +AC_SUBST(HOSTING_LIBS) +AC_SUBST(NATIVE_LIB_DIRS) + +# For most hosts we can use a simple definition to pick up the BFD and +# opcodes libraries. However, if we are building shared libraries, we +# need to handle some hosts specially. +BFDLIB='-L../bfd -lbfd' +case "${host}" in +*-*-sunos*) + # On SunOS, we must link against the name we are going to install, + # not -lbfd, since SunOS does not support SONAME. + if test "${shared}" = "true"; then + BFDLIB='-L../bfd -l`echo bfd | sed '"'"'$(program_transform_name)'"'"'`' + fi + ;; +alpha*-*-osf*) + # On Alpha OSF/1, the native linker searches all the -L + # directories for any LIB.so files, and only then searches for any + # LIB.a files. That means that if there is an installed + # libbfd.so, but this build is not done with --enable-shared, the + # link will wind up being against the install libbfd.so rather + # than the newly built libbfd. To avoid this, we must explicitly + # link against libbfd.a when --enable-shared is not used. + if test "${shared}" != "true"; then + BFDLIB='../bfd/libbfd.a' + fi + ;; +esac +AC_SUBST(BFDLIB) + +AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h) +AC_CHECK_FUNCS(sbrk) +AC_HEADER_DIRENT + +BFD_BINARY_FOPEN + +BFD_NEED_DECLARATION(strstr) +BFD_NEED_DECLARATION(free) +BFD_NEED_DECLARATION(sbrk) +BFD_NEED_DECLARATION(getenv) + +# target-specific stuff: + +all_targets= +EMUL= +all_emuls= +TDIRS= + +for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'` +do + if test "$targ_alias" = "all"; then + all_targets=true + else + # Canonicalize the secondary target names. + result=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $targ_alias 2>/dev/null` + if test -n "$result"; then + targ=$result + else + targ=$targ_alias + fi + + . ${srcdir}/configure.tgt + + if test "$targ" = "$target"; then + EMUL=$targ_emul + fi + + for i in $targ_emul $targ_extra_emuls; do + case " $all_emuls " in + *" e${i}.o "*) ;; + *) + all_emuls="$all_emuls e${i}.o" + eval result=\$tdir_$i + test -z "$result" && result=$targ_alias + TDIRS="$TDIRS\\ +tdir_$i=$result" + ;; + esac + done + fi +done + +AC_SUBST(EMUL) +AC_SUBST(TDIRS) + +dnl FIXME: We will build a 64 bit BFD for a 64 bit host or a 64 bit +dnl target, and in those cases we should also build the 64 bit +dnl emulations. +if test x${all_targets} = xtrue; then + if test x${want64} = xtrue; then + EMULATION_OFILES='$(ALL_EMULATIONS) $(ALL_64_EMULATIONS)' + else + EMULATION_OFILES='$(ALL_EMULATIONS)' + fi +else + EMULATION_OFILES=$all_emuls +fi +AC_SUBST(EMULATION_OFILES) + +AC_OUTPUT(Makefile, +[case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac]) diff --git a/contrib/binutils/ld/configure.tgt b/contrib/binutils/ld/configure.tgt new file mode 100644 index 0000000..9539e1f --- /dev/null +++ b/contrib/binutils/ld/configure.tgt @@ -0,0 +1,192 @@ +# This is the linker target specific file. This is invoked by the +# autoconf generated configure script. Putting it in a separate shell +# file lets us skip running autoconf when modifying target specific +# information. + +# This file switches on the shell variable ${targ}, and sets the +# following shell variables: +# targ_emul name of linker emulation to use +# targ_extra_emuls additional linker emulations to provide + +targ_extra_emuls= + +case "${targ}" in +arm-*-pe) targ_emul=armpe ;; +d10v-*-*) targ_emul=d10velf ;; +sparc64-*-aout*) targ_emul=sparcaout ;; +sparc64-*-elf*) targ_emul=elf64_sparc ;; +sparc-sun-sunos4*) targ_emul=sun4 ;; +sparclite*-*-coff) targ_emul=coff_sparc ;; +sparclite*-fujitsu-*) targ_emul=sparcaout ;; +sparc*-*-aout) targ_emul=sparcaout ;; +sparc*-*-coff) targ_emul=coff_sparc ;; +sparc*-*-elf) targ_emul=elf32_sparc ;; +sparc*-*-sysv4*) targ_emul=elf32_sparc ;; +sparc*-*-linux*aout*) targ_emul=sparclinux + targ_extra_emuls="elf32_sparc sun4" + tdir_elf32_sparc=`echo ${targ_alias} | sed -e 's/aout//'` + tdir_sun4=sparc-sun-sunos4 + ;; +sparc*-*-linux*) targ_emul=elf32_sparc + targ_extra_emuls="sparclinux sun4" + tdir_sparclinux=${targ_alias}aout + tdir_sun4=sparc-sun-sunos4 + ;; +sparc*-*-lynxos*) targ_emul=sparclynx ;; +sparc*-*-netbsd*) targ_emul=sparcnbsd ;; +sparc*-*-solaris2*) targ_emul=elf32_sparc ;; +sparc*-wrs-vxworks*) targ_emul=sparcaout ;; +sparc*-*-rtems*) targ_emul=sparcaout ;; +i960-wrs-vxworks5.0*) targ_emul=gld960 ;; +i960-wrs-vxworks5*) targ_emul=gld960coff ;; +i960-wrs-vxworks*) targ_emul=gld960 ;; +i960-*-coff) targ_emul=gld960coff ;; +i960-intel-nindy) targ_emul=gld960 ;; +i960-*-rtems*) targ_emul=gld960coff ;; +m32r-*-*) targ_emul=m32relf ;; +m68*-sun-sunos[34]*) targ_emul=sun3 ;; +m68*-wrs-vxworks*) targ_emul=sun3 ;; +m68*-ericsson-ose) targ_emul=sun3 ;; +m68*-apple-aux*) targ_emul=m68kaux ;; +*-tandem-none) targ_emul=st2000 ;; +i[3456]86-*-vsta) targ_emul=vsta ;; +i[3456]86-go32-rtems*) targ_emul=i386go32 ;; +i[3456]86-*-go32) targ_emul=i386go32 ;; +i[3456]86-*-aix*) targ_emul=i386coff ;; +i[3456]86-*-sco*) targ_emul=i386coff ;; +i[3456]86-*-isc*) targ_emul=i386coff ;; +i[3456]86-*-lynxos*) targ_emul=i386lynx ;; +i[3456]86-*-coff) targ_emul=i386coff ;; +i[3456]86-*-rtems*) targ_emul=i386coff ;; +i[3456]86-*-bsd) targ_emul=i386bsd ;; +i[3456]86-*-bsd386) targ_emul=i386bsd ;; +i[3456]86-*-bsdi*) targ_emul=i386bsd ;; +i[3456]86-*-aout) targ_emul=i386aout ;; +i[3456]86-*-linux*aout*) targ_emul=i386linux + targ_extra_emuls=elf_i386 + tdir_elf_i386=`echo ${targ_alias} | sed -e 's/aout//'` + ;; +i[3456]86-*-linuxoldld) targ_emul=i386linux; targ_extra_emuls=elf_i386 ;; +i[3456]86-*-linux*) targ_emul=elf_i386 + targ_extra_emuls=i386linux + tdir_i386linux=${targ_alias}aout + ;; +i[3456]86-*-sysv4*) targ_emul=elf_i386 ;; +i[3456]86-*-unixware) targ_emul=elf_i386 ;; +i[3456]86-*-netbsd*) targ_emul=i386nbsd ;; +i[3456]86-*-netware) targ_emul=i386nw ;; +i[3456]86-*-elf*) targ_emul=elf_i386 ;; +i[3456]86-*-freebsdelf*) targ_emul=elf_i386 ;; +i[3456]86-*-sysv*) targ_emul=i386coff ;; +i[3456]86-*-ptx*) targ_emul=i386coff ;; +i[3456]86-*-mach*) targ_emul=i386mach ;; +i[3456]86-*-gnu*) targ_emul=elf_i386; targ_extra_emuls=i386mach ;; +i[3456]86-*-msdos*) targ_emul=i386msdos; targ_extra_emuls=i386aout ;; +i[3456]86-*-moss*) targ_emul=i386moss; targ_extra_emuls=i386msdos ;; +i[3456]86-*-winnt) targ_emul=i386pe ;; +i[3456]86-*-pe) targ_emul=i386pe ;; +i[3456]86-*-cygwin32) targ_emul=i386pe ;; +m8*-*-*) targ_emul=m88kbcs ;; +a29k-*-udi) targ_emul=sa29200 ;; +a29k-*-ebmon) targ_emul=ebmon29k ;; +a29k-*-*) targ_emul=a29k ;; +# arm-*-riscix*) targ_emul=riscix ;; +arm-*-aout | armel-*-aout) targ_emul=armaoutl ;; +armeb-*-aout) targ_emul=armaoutb ;; +arm-*-coff) targ_emul=armcoff ;; +h8300-*-hms) targ_emul=h8300; targ_extra_emuls="h8300h h8300s" + ;; +h8500-*-hms) targ_emul=h8500 + targ_extra_emuls="h8500s h8500b h8500m h8500c" + ;; +sh-*-elf*) targ_emul=shelf + targ_extra_emuls="shlelf sh shl" + ;; +sh-*-*) targ_emul=sh; targ_extra_emuls=shl ;; +m68k-sony-*) targ_emul=news ;; +m68k-hp-bsd*) targ_emul=hp300bsd ;; +m68*-motorola-sysv*) targ_emul=delta68 ;; +m68*-*-aout) targ_emul=m68kaout ;; +m68*-*-coff) targ_emul=m68kcoff ;; +m68*-*-elf) targ_emul=m68kelf ;; +m68*-*-hpux*) targ_emul=hp3hpux ;; +m68k-*-linux*aout*) targ_emul=m68klinux + targ_extra_emuls=m68kelf + tdir_m68kelf=`echo ${targ_alias} | sed -e 's/aout//'` + ;; +m68k-*-linux*) targ_emul=m68kelf + targ_extra_emuls=m68klinux + tdir_m68klinux=`echo ${targ_alias} | sed -e 's/linux/linuxaout/'` + ;; +m68*-*-lynxos*) targ_emul=m68klynx ;; +m68*-hp*-netbsd*) targ_emul=m68k4knbsd ;; +m68*-*-netbsd*) targ_emul=m68knbsd ;; +m68*-*-psos*) targ_emul=m68kpsos ;; +m68*-*-rtems*) targ_emul=m68kcoff ;; +hppa*-*-*elf*) targ_emul=hppaelf ;; +hppa*-*-lites*) targ_emul=hppaelf ;; +hppa*-*-rtems*) targ_emul=hppaelf ;; +vax-dec-ultrix* | vax-dec-bsd*) targ_emul=vax ;; +mips*-dec-ultrix*) targ_emul=mipslit ;; +mips*-dec-osf*) targ_emul=mipslit ;; +mips*-sgi-irix[56]*) targ_emul=elf32bmip ;; +mips*-sgi-irix*) targ_emul=mipsbig ;; +mips*el-*-ecoff*) targ_emul=mipsidtl ;; +mips*-*-ecoff*) targ_emul=mipsidt ;; +mips*-dec-bsd*) targ_emul=mipsbsd ;; +mips*-dec-netbsd*) targ_emul=elf32lmip ;; +mips*-*-bsd*) targ_emul=mipsbig ;; +mips*vr4300el-*-elf*) targ_emul=elf32l4300 ;; +mips*vr4300-*-elf*) targ_emul=elf32b4300 ;; +mips*vr4100el-*-elf*) targ_emul=elf32l4300 ;; +mips*vr4100-*-elf*) targ_emul=elf32b4300 ;; +mips*vr5000el-*-elf*) targ_emul=elf32l4300 ;; +mips*vr5000-*-elf*) targ_emul=elf32b4300 ;; +mips*el-*-elf*) targ_emul=elf32elmip ;; +mips*-*-elf*) targ_emul=elf32ebmip ;; +mips*-*-rtems*) targ_emul=elf32ebmip ;; +mips*el-*-linux*) targ_emul=elf32lmip + targ_extra_emuls="elf32bmip mipslit mipsbig" + ;; +mips*-*-linux*) targ_emul=elf32bmip + targ_extra_emuls="elf32lmip mipsbig mipslit" + ;; +mips*-*-lnews*) targ_emul=mipslnews ;; +mn10200-*-*) targ_emul=mn10200 ;; +mn10300-*-*) targ_emul=mn10300 ;; +alpha-*-linuxecoff*) targ_emul=alpha targ_extra_emuls=elf64alpha + tdir_elf64alpha=`echo ${targ_alias} | sed -e 's/ecoff//'` + ;; +alpha-*-linux*) targ_emul=elf64alpha targ_extra_emuls=alpha + tdir_alpha=`echo ${targ_alias} | sed -e 's/linux/linuxecoff/'` + ;; +alpha-*-osf*) targ_emul=alpha ;; +alpha-*-gnu*) targ_emul=elf64alpha ;; +alpha-*-netware*) targ_emul=alpha ;; +z8k-*-coff) targ_emul=z8002; targ_extra_emuls=z8001 ;; +ns32k-pc532-mach* | ns32k-pc532-ux*) targ_emul=pc532macha ;; +ns32k-pc532-netbsd* | ns32k-pc532-lites*) targ_emul=ns32knbsd ;; +powerpc-*-elf* | powerpc-*-eabi* | powerpc-*-linux* | powerpc-*-sysv*) + targ_emul=elf32ppc ;; +powerpcle-*-elf* | powerpcle-*-eabi* | powerpcle-*-solaris* | powerpcle-*-sysv*) targ_emul=elf32lppc ;; +powerpc-*-rtems*) targ_emul=elf32ppc ;; +powerpc-*-macos*) targ_emul=ppcmacos ;; +powerpc-*-netware*) targ_emul=ppcnw ;; +powerpcle-*-pe) targ_emul=ppcpe ;; +powerpcle-*-winnt*) targ_emul=ppcpe ;; +powerpcle-*-cygwin32) targ_emul=ppcpe ;; +powerpc-*-aix*) targ_emul=aixppc ;; +powerpc-*-beos*) targ_emul=aixppc ;; +rs6000-*-aix*) targ_emul=aixrs6 ;; +w65-*-*) targ_emul=w65 ;; +*-*-aout) targ_emul=${target_cpu}-${target_vendor} ;; +*-*-coff) targ_emul=${target_cpu}-${target_vendor} ;; +*-*-netware) targ_emul=${target_cpu}-nw ;; +*-*-ieee*) targ_emul=vanilla ;; + +*) + echo 2>&1 "*** ld does not support target ${targ}" + echo 2>&1 "*** see ld/configure.tgt for supported targets" + exit 1 + +esac diff --git a/contrib/binutils/ld/dep-in.sed b/contrib/binutils/ld/dep-in.sed new file mode 100644 index 0000000..8c80eb0 --- /dev/null +++ b/contrib/binutils/ld/dep-in.sed @@ -0,0 +1,16 @@ +:loop +/\\$/N +/\\$/b loop + +s!@INCDIR@!$(INCDIR)!g +s!@SRCDIR@/!!g +s!\.\./bfd/hosts/[^ ]*\.h ! !g + +s/\\\n */ /g + +s/ *$// +s/ */ /g +/:$/d + +s/\(.\{50\}[^ ]*\) /\1 \\\ + /g diff --git a/contrib/binutils/ld/emulparams/README b/contrib/binutils/ld/emulparams/README new file mode 100644 index 0000000..b3d6d26 --- /dev/null +++ b/contrib/binutils/ld/emulparams/README @@ -0,0 +1,2 @@ +The files in this directory are read by genscripts.sh as shell commands. +They set parameters for the emulations. diff --git a/contrib/binutils/ld/emulparams/alpha.sh b/contrib/binutils/ld/emulparams/alpha.sh new file mode 100644 index 0000000..141923f --- /dev/null +++ b/contrib/binutils/ld/emulparams/alpha.sh @@ -0,0 +1,3 @@ +SCRIPT_NAME=alpha +OUTPUT_FORMAT="ecoff-littlealpha" +ARCH=alpha diff --git a/contrib/binutils/ld/emulparams/elf32b4300.sh b/contrib/binutils/ld/emulparams/elf32b4300.sh new file mode 100644 index 0000000..147ec2d --- /dev/null +++ b/contrib/binutils/ld/emulparams/elf32b4300.sh @@ -0,0 +1,29 @@ +SCRIPT_NAME=elfmips +OUTPUT_FORMAT="elf32-bigmips" +BIG_OUTPUT_FORMAT="elf32-bigmips" +LITTLE_OUTPUT_FORMAT="elf32-littlemips" +TEXT_START_ADDR=0xa0020000 +DATA_ADDR=. +MAXPAGESIZE=0x40000 +OTHER_READONLY_SECTIONS='.reginfo : { *(.reginfo) }' +OTHER_GOT_SYMBOLS=' + _gp = ALIGN(16) + 0x7ff0; +' +OTHER_READWRITE_SECTIONS=' + .lit8 : { *(.lit8) } + .lit4 : { *(.lit4) } +' +TEXT_START_SYMBOLS='_ftext = . ;' +DATA_START_SYMBOLS='_fdata = . ;' +OTHER_BSS_SYMBOLS='_fbss = .;' +EXECUTABLE_SYMBOLS='_DYNAMIC_LINK = 0;' +OTHER_SECTIONS=' + .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } + .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } +' +ARCH=mips +MACHINE=4000 +TEMPLATE_NAME=elf32 +GENERATE_SHLIB_SCRIPT=yes +DYNAMIC_LINK=false +EMBEDDED=yes diff --git a/contrib/binutils/ld/emulparams/elf32l4300.sh b/contrib/binutils/ld/emulparams/elf32l4300.sh new file mode 100644 index 0000000..fdf31b1 --- /dev/null +++ b/contrib/binutils/ld/emulparams/elf32l4300.sh @@ -0,0 +1,29 @@ +SCRIPT_NAME=elfmips +OUTPUT_FORMAT="elf32-littlemips" +BIG_OUTPUT_FORMAT="elf32-bigmips" +LITTLE_OUTPUT_FORMAT="elf32-littlemips" +TEXT_START_ADDR=0xa0020000 +DATA_ADDR=. +MAXPAGESIZE=0x40000 +OTHER_READONLY_SECTIONS='.reginfo : { *(.reginfo) }' +OTHER_GOT_SYMBOLS=' + _gp = ALIGN(16) + 0x7ff0; +' +OTHER_READWRITE_SECTIONS=' + .lit8 : { *(.lit8) } + .lit4 : { *(.lit4) } +' +TEXT_START_SYMBOLS='_ftext = . ;' +DATA_START_SYMBOLS='_fdata = . ;' +OTHER_BSS_SYMBOLS='_fbss = .;' +EXECUTABLE_SYMBOLS='_DYNAMIC_LINK = 0;' +OTHER_SECTIONS=' + .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } + .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } +' +ARCH=mips +MACHINE=4000 +TEMPLATE_NAME=elf32 +GENERATE_SHLIB_SCRIPT=yes +DYNAMIC_LINK=false +EMBEDDED=yes diff --git a/contrib/binutils/ld/emulparams/elf64alpha.sh b/contrib/binutils/ld/emulparams/elf64alpha.sh new file mode 100644 index 0000000..afa21f2 --- /dev/null +++ b/contrib/binutils/ld/emulparams/elf64alpha.sh @@ -0,0 +1,15 @@ +ENTRY=__start +SCRIPT_NAME=elf +ELFSIZE=64 +TEMPLATE_NAME=elf32 +OUTPUT_FORMAT="elf64-alpha" +TEXT_START_ADDR="0x120000000" +MAXPAGESIZE=0x100000 +NONPAGED_TEXT_START_ADDR="0x120000000" +ARCH=alpha +MACHINE= +GENERATE_SHLIB_SCRIPT=yes +DATA_PLT= +NOP=0x47ff041f + +OTHER_READONLY_SECTIONS='.reginfo : { *(.reginfo) }' diff --git a/contrib/binutils/ld/emulparams/elf_i386.sh b/contrib/binutils/ld/emulparams/elf_i386.sh new file mode 100644 index 0000000..dff567b --- /dev/null +++ b/contrib/binutils/ld/emulparams/elf_i386.sh @@ -0,0 +1,10 @@ +SCRIPT_NAME=elf +OUTPUT_FORMAT="elf32-i386" +TEXT_START_ADDR=0x08048000 +MAXPAGESIZE=0x1000 +NONPAGED_TEXT_START_ADDR=0x08048000 +ARCH=i386 +MACHINE= +NOP=0x9090 +TEMPLATE_NAME=elf32 +GENERATE_SHLIB_SCRIPT=yes diff --git a/contrib/binutils/ld/emulparams/i386aout.sh b/contrib/binutils/ld/emulparams/i386aout.sh new file mode 100644 index 0000000..dc9e554 --- /dev/null +++ b/contrib/binutils/ld/emulparams/i386aout.sh @@ -0,0 +1,6 @@ +SCRIPT_NAME=aout +OUTPUT_FORMAT="a.out-i386" +TARGET_PAGE_SIZE=0x1000 +TEXT_START_ADDR=0 +NONPAGED_TEXT_START_ADDR=0x1000 +ARCH=i386 diff --git a/contrib/binutils/ld/emulparams/i386bsd.sh b/contrib/binutils/ld/emulparams/i386bsd.sh new file mode 100644 index 0000000..e0c0e2f --- /dev/null +++ b/contrib/binutils/ld/emulparams/i386bsd.sh @@ -0,0 +1,6 @@ +SCRIPT_NAME=aout +OUTPUT_FORMAT="a.out-i386-bsd" +TARGET_PAGE_SIZE=0x1000 +TEXT_START_ADDR=0 +NONPAGED_TEXT_START_ADDR=0x1000 +ARCH=i386 diff --git a/contrib/binutils/ld/emulparams/i386coff.sh b/contrib/binutils/ld/emulparams/i386coff.sh new file mode 100644 index 0000000..3417b7d --- /dev/null +++ b/contrib/binutils/ld/emulparams/i386coff.sh @@ -0,0 +1,5 @@ +SCRIPT_NAME=i386coff +OUTPUT_FORMAT="coff-i386" +TEXT_START_ADDR=0x1000000 +TARGET_PAGE_SIZE=0x1000000 +ARCH=i386 diff --git a/contrib/binutils/ld/emulparams/i386linux.sh b/contrib/binutils/ld/emulparams/i386linux.sh new file mode 100644 index 0000000..a416422 --- /dev/null +++ b/contrib/binutils/ld/emulparams/i386linux.sh @@ -0,0 +1,7 @@ +SCRIPT_NAME=aout +OUTPUT_FORMAT="a.out-i386-linux" +TARGET_PAGE_SIZE=0x1000 +TEXT_START_ADDR=0x1020 +NONPAGED_TEXT_START_ADDR=0 +ARCH=i386 +TEMPLATE_NAME=linux diff --git a/contrib/binutils/ld/emulparams/i386moss.sh b/contrib/binutils/ld/emulparams/i386moss.sh new file mode 100644 index 0000000..a5e0e05 --- /dev/null +++ b/contrib/binutils/ld/emulparams/i386moss.sh @@ -0,0 +1,10 @@ +SCRIPT_NAME=elf +OUTPUT_FORMAT="elf32-i386" +TEXT_START_ADDR=0x00002000 +MAXPAGESIZE=0x1000 +NONPAGED_TEXT_START_ADDR=0x00002000 +ARCH=i386 +MACHINE= +NOP=0x9090 +TEMPLATE_NAME=elf32 +GENERATE_SHLIB_SCRIPT=yes diff --git a/contrib/binutils/ld/emulparams/i386nbsd.sh b/contrib/binutils/ld/emulparams/i386nbsd.sh new file mode 100644 index 0000000..a9e6a38 --- /dev/null +++ b/contrib/binutils/ld/emulparams/i386nbsd.sh @@ -0,0 +1,6 @@ +SCRIPT_NAME=aout +TEXT_START_ADDR=0x1020 +OUTPUT_FORMAT="a.out-i386-netbsd" +TARGET_PAGE_SIZE=0x1000 +ARCH=i386 +EXECUTABLE_SYMBOLS='__DYNAMIC = 0;' diff --git a/contrib/binutils/ld/emulparams/i386nw.sh b/contrib/binutils/ld/emulparams/i386nw.sh new file mode 100644 index 0000000..e70ed67 --- /dev/null +++ b/contrib/binutils/ld/emulparams/i386nw.sh @@ -0,0 +1,9 @@ +SCRIPT_NAME=nw +OUTPUT_FORMAT="elf32-i386" +TEXT_START_ADDR=0x08000000 +MAXPAGESIZE=0x1000 +NONPAGED_TEXT_START_ADDR=0x08000000 +ARCH=i386 +NOP=0x9090 +TEMPLATE_NAME=elf32 +GENERATE_SHLIB_SCRIPT=yes diff --git a/contrib/binutils/ld/emulparams/i386pe.sh b/contrib/binutils/ld/emulparams/i386pe.sh new file mode 100644 index 0000000..1249064 --- /dev/null +++ b/contrib/binutils/ld/emulparams/i386pe.sh @@ -0,0 +1,5 @@ +ARCH=i386 +SCRIPT_NAME=pe +OUTPUT_FORMAT="pei-i386" +TEMPLATE_NAME=pe + diff --git a/contrib/binutils/ld/emulparams/sh.sh b/contrib/binutils/ld/emulparams/sh.sh new file mode 100644 index 0000000..38844fb --- /dev/null +++ b/contrib/binutils/ld/emulparams/sh.sh @@ -0,0 +1,5 @@ +SCRIPT_NAME=sh +OUTPUT_FORMAT="coff-sh" +TEXT_START_ADDR=0x8000 +TARGET_PAGE_SIZE=128 +ARCH=sh diff --git a/contrib/binutils/ld/emulparams/shelf.sh b/contrib/binutils/ld/emulparams/shelf.sh new file mode 100755 index 0000000..95db587 --- /dev/null +++ b/contrib/binutils/ld/emulparams/shelf.sh @@ -0,0 +1,17 @@ +SCRIPT_NAME=elf +OUTPUT_FORMAT="elf32-sh" +TEXT_START_ADDR=0x1000 +MAXPAGESIZE=128 +ARCH=sh +MACHINE= +TEMPLATE_NAME=elf32 +GENERATE_SHLIB_SCRIPT=yes +EMBEDDED=yes + +# These are for compatibility with the COFF toolchain. +ENTRY=start +CTOR_START='___ctors = .;' +CTOR_END='___ctors_end = .;' +DTOR_START='___dtors = .;' +DTOR_END='___dtors_end = .;' +OTHER_RELOCATING_SECTIONS='.stack 0x30000 : { _stack = .; *(.stack) }' diff --git a/contrib/binutils/ld/emulparams/shl.sh b/contrib/binutils/ld/emulparams/shl.sh new file mode 100644 index 0000000..360aac8 --- /dev/null +++ b/contrib/binutils/ld/emulparams/shl.sh @@ -0,0 +1,5 @@ +SCRIPT_NAME=sh +OUTPUT_FORMAT="coff-shl" +TEXT_START_ADDR=0x8000 +TARGET_PAGE_SIZE=128 +ARCH=sh diff --git a/contrib/binutils/ld/emulparams/shlelf.sh b/contrib/binutils/ld/emulparams/shlelf.sh new file mode 100755 index 0000000..bb27f86 --- /dev/null +++ b/contrib/binutils/ld/emulparams/shlelf.sh @@ -0,0 +1,17 @@ +SCRIPT_NAME=elf +OUTPUT_FORMAT="elf32-shl" +TEXT_START_ADDR=0x1000 +MAXPAGESIZE=128 +ARCH=sh +MACHINE= +TEMPLATE_NAME=elf32 +GENERATE_SHLIB_SCRIPT=yes +EMBEDDED=yes + +# These are for compatibility with the COFF toolchain. +ENTRY=start +CTOR_START='___ctors = .;' +CTOR_END='___ctors_end = .;' +DTOR_START='___dtors = .;' +DTOR_END='___dtors_end = .;' +OTHER_RELOCATING_SECTIONS='.stack 0x30000 : { _stack = .; *(.stack) }' diff --git a/contrib/binutils/ld/emulparams/vanilla.sh b/contrib/binutils/ld/emulparams/vanilla.sh new file mode 100644 index 0000000..d8a3b72 --- /dev/null +++ b/contrib/binutils/ld/emulparams/vanilla.sh @@ -0,0 +1,5 @@ +SCRIPT_NAME=vanilla +TEXT_START_ADDR=?? +TARGET_PAGE_SIZE=?? +ARCH=unknown +TEMPLATE_NAME=vanilla diff --git a/contrib/binutils/ld/emulparams/vsta.sh b/contrib/binutils/ld/emulparams/vsta.sh new file mode 100644 index 0000000..cc6249b --- /dev/null +++ b/contrib/binutils/ld/emulparams/vsta.sh @@ -0,0 +1,8 @@ +SCRIPT_NAME=aout +OUTPUT_FORMAT="a.out-i386" +TEXT_START_ADDR=0x1020 +TARGET_PAGE_SIZE=0x1000 +SEGMENT_SIZE=0x400000 +NONPAGED_TEXT_START_ADDR=0x0 +ARCH=i386 + diff --git a/contrib/binutils/ld/emulparams/z8001.sh b/contrib/binutils/ld/emulparams/z8001.sh new file mode 100644 index 0000000..63645c3 --- /dev/null +++ b/contrib/binutils/ld/emulparams/z8001.sh @@ -0,0 +1,7 @@ +SCRIPT_NAME=z8000 +OUTPUT_FORMAT="coff-z8k" +OUTPUT_ARCH="z8001" +TEXT_START_ADDR=0x0 +TARGET_PAGE_SIZE=128 +ARCH=z8k +BIG=1 diff --git a/contrib/binutils/ld/emulparams/z8002.sh b/contrib/binutils/ld/emulparams/z8002.sh new file mode 100644 index 0000000..299b5f5 --- /dev/null +++ b/contrib/binutils/ld/emulparams/z8002.sh @@ -0,0 +1,6 @@ +SCRIPT_NAME=z8000 +OUTPUT_FORMAT="coff-z8k" +OUTPUT_ARCH="z8002" +TEXT_START_ADDR=0x0 +TARGET_PAGE_SIZE=128 +ARCH=z8002 diff --git a/contrib/binutils/ld/emultempl/README b/contrib/binutils/ld/emultempl/README new file mode 100644 index 0000000..30ec0ab --- /dev/null +++ b/contrib/binutils/ld/emultempl/README @@ -0,0 +1,3 @@ +The files in this directory are sourced by genscripts.sh, after +setting some variables to substitute in, to produce +C source files that contain jump tables for each emulation. diff --git a/contrib/binutils/ld/emultempl/elf32.em b/contrib/binutils/ld/emultempl/elf32.em new file mode 100644 index 0000000..f02775e --- /dev/null +++ b/contrib/binutils/ld/emultempl/elf32.em @@ -0,0 +1,1011 @@ +# This shell script emits a C file. -*- C -*- +# It does some substitutions. +# This file is now misnamed, because it supports both 32 bit and 64 bit +# ELF emulations. +test -z "${ELFSIZE}" && ELFSIZE=32 +cat >e${EMULATION_NAME}.c <<EOF +/* This file is is generated by a shell script. DO NOT EDIT! */ + +/* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME} + Copyright (C) 1991, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Written by Steve Chamberlain <sac@cygnus.com> + ELF support by Ian Lance Taylor <ian@cygnus.com> + +This file is part of GLD, the Gnu Linker. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define TARGET_IS_${EMULATION_NAME} + +#include "bfd.h" +#include "sysdep.h" + +#include <ctype.h> + +#include "bfdlink.h" + +#include "ld.h" +#include "ldmain.h" +#include "ldemul.h" +#include "ldfile.h" +#include "ldmisc.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldgram.h" + +static void gld${EMULATION_NAME}_before_parse PARAMS ((void)); +static boolean gld${EMULATION_NAME}_open_dynamic_archive + PARAMS ((const char *, search_dirs_type *, lang_input_statement_type *)); +static void gld${EMULATION_NAME}_after_open PARAMS ((void)); +static void gld${EMULATION_NAME}_check_needed + PARAMS ((lang_input_statement_type *)); +static void gld${EMULATION_NAME}_stat_needed + PARAMS ((lang_input_statement_type *)); +static boolean gld${EMULATION_NAME}_search_needed + PARAMS ((const char *, const char *)); +static boolean gld${EMULATION_NAME}_try_needed PARAMS ((const char *)); +static void gld${EMULATION_NAME}_before_allocation PARAMS ((void)); +static void gld${EMULATION_NAME}_find_statement_assignment + PARAMS ((lang_statement_union_type *)); +static void gld${EMULATION_NAME}_find_exp_assignment PARAMS ((etree_type *)); +static boolean gld${EMULATION_NAME}_place_orphan + PARAMS ((lang_input_statement_type *, asection *)); +static void gld${EMULATION_NAME}_place_section + PARAMS ((lang_statement_union_type *)); +static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile)); + +static void +gld${EMULATION_NAME}_before_parse() +{ + ldfile_output_architecture = bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`; + config.dynamic_link = ${DYNAMIC_LINK-true}; +} + +/* Try to open a dynamic archive. This is where we know that ELF + dynamic libraries have an extension of .so. */ + +static boolean +gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry) + const char *arch; + search_dirs_type *search; + lang_input_statement_type *entry; +{ + const char *filename; + char *string; + + if (! entry->is_archive) + return false; + + filename = entry->filename; + + string = (char *) xmalloc (strlen (search->name) + + strlen (filename) + + strlen (arch) + + sizeof "/lib.so"); + + sprintf (string, "%s/lib%s%s.so", search->name, filename, arch); + + if (! ldfile_try_open_bfd (string, entry)) + { + free (string); + return false; + } + + entry->filename = string; + + /* We have found a dynamic object to include in the link. The ELF + backend linker will create a DT_NEEDED entry in the .dynamic + section naming this file. If this file includes a DT_SONAME + entry, it will be used. Otherwise, the ELF linker will just use + the name of the file. For an archive found by searching, like + this one, the DT_NEEDED entry should consist of just the name of + the file, without the path information used to find it. Note + that we only need to do this if we have a dynamic object; an + archive will never be referenced by a DT_NEEDED entry. + + FIXME: This approach--using bfd_elf_set_dt_needed_name--is not + very pretty. I haven't been able to think of anything that is + pretty, though. */ + if (bfd_check_format (entry->the_bfd, bfd_object) + && (entry->the_bfd->flags & DYNAMIC) != 0) + { + char *needed_name; + + ASSERT (entry->is_archive && entry->search_dirs_flag); + needed_name = (char *) xmalloc (strlen (filename) + + strlen (arch) + + sizeof "lib.so"); + sprintf (needed_name, "lib%s%s.so", filename, arch); + bfd_elf_set_dt_needed_name (entry->the_bfd, needed_name); + } + + return true; +} + +EOF +if [ "x${host}" = "x${target}" ] ; then + if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then +cat >>e${EMULATION_NAME}.c <<EOF + +/* For a native linker, check the file /etc/ld.so.conf for directories + in which we may find shared libraries. /etc/ld.so.conf is really + only meaningful on Linux, but we check it on other systems anyhow. */ + +static boolean gld${EMULATION_NAME}_check_ld_so_conf PARAMS ((const char *)); + +static boolean +gld${EMULATION_NAME}_check_ld_so_conf (name) + const char *name; +{ + static boolean initialized; + static char *ld_so_conf; + + if (! initialized) + { + FILE *f; + + f = fopen ("/etc/ld.so.conf", FOPEN_RT); + if (f != NULL) + { + char *b; + size_t len, alloc; + int c; + + len = 0; + alloc = 100; + b = (char *) xmalloc (alloc); + + while ((c = getc (f)) != EOF) + { + if (len + 1 >= alloc) + { + alloc *= 2; + b = (char *) xrealloc (b, alloc); + } + if (c != ':' + && c != ' ' + && c != '\t' + && c != '\n' + && c != ',') + { + b[len] = c; + ++len; + } + else + { + if (len > 0 && b[len - 1] != ':') + { + b[len] = ':'; + ++len; + } + } + } + + if (len > 0 && b[len - 1] == ':') + --len; + + if (len > 0) + b[len] = '\0'; + else + { + free (b); + b = NULL; + } + + fclose (f); + + ld_so_conf = b; + } + + initialized = true; + } + + if (ld_so_conf == NULL) + return false; + + return gld${EMULATION_NAME}_search_needed (ld_so_conf, name); +} + +EOF + fi +fi +cat >>e${EMULATION_NAME}.c <<EOF + +/* These variables are required to pass information back and forth + between after_open and check_needed and stat_needed. */ + +static struct bfd_link_needed_list *global_needed; +static struct stat global_stat; +static boolean global_found; + +/* This is called after all the input files have been opened. */ + +static void +gld${EMULATION_NAME}_after_open () +{ + 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) + return; + + /* Get the list of files which appear in DT_NEEDED entries in + dynamic objects included in the link (often there will be none). + For each such file, we want to track down the corresponding + library, and include the symbol table in the link. This is what + the runtime dynamic linker will do. Tracking the files down here + permits one dynamic object to include another without requiring + special action by the person doing the link. Note that the + needed list can actually grow while we are stepping through this + loop. */ + needed = bfd_elf_get_needed_list (output_bfd, &link_info); + for (l = needed; l != NULL; l = l->next) + { + struct bfd_link_needed_list *ll; + const char *lib_path; + size_t len; + search_dirs_type *search; + + /* If we've already seen this file, skip it. */ + for (ll = needed; ll != l; ll = ll->next) + if (strcmp (ll->name, l->name) == 0) + break; + if (ll != l) + continue; + + /* See if this file was included in the link explicitly. */ + global_needed = l; + global_found = false; + lang_for_each_input_file (gld${EMULATION_NAME}_check_needed); + if (global_found) + continue; + + /* We need to find this file and include the symbol table. We + want to search for the file in the same way that the dynamic + linker will search. That means that we want to use + rpath_link, rpath, then the environment variable + LD_LIBRARY_PATH (native only), then the linker script + LIB_SEARCH_DIRS. We do not search using the -L arguments. */ + if (gld${EMULATION_NAME}_search_needed (command_line.rpath_link, + l->name)) + continue; + if (gld${EMULATION_NAME}_search_needed (command_line.rpath, l->name)) + continue; + if (command_line.rpath_link == NULL + && command_line.rpath == NULL) + { + lib_path = (const char *) getenv ("LD_RUN_PATH"); + if (gld${EMULATION_NAME}_search_needed (lib_path, l->name)) + continue; + } +EOF +if [ "x${host}" = "x${target}" ] ; then + if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then +cat >>e${EMULATION_NAME}.c <<EOF + lib_path = (const char *) getenv ("LD_LIBRARY_PATH"); + if (gld${EMULATION_NAME}_search_needed (lib_path, l->name)) + continue; +EOF + fi +fi +cat >>e${EMULATION_NAME}.c <<EOF + len = strlen (l->name); + for (search = search_head; search != NULL; search = search->next) + { + char *filename; + + if (search->cmdline) + continue; + filename = (char *) xmalloc (strlen (search->name) + len + 2); + sprintf (filename, "%s/%s", search->name, l->name); + if (gld${EMULATION_NAME}_try_needed (filename)) + break; + free (filename); + } + if (search != NULL) + continue; +EOF +if [ "x${host}" = "x${target}" ] ; then + if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then +cat >>e${EMULATION_NAME}.c <<EOF + if (gld${EMULATION_NAME}_check_ld_so_conf (l->name)) + continue; +EOF + fi +fi +cat >>e${EMULATION_NAME}.c <<EOF + + einfo ("%P: warning: %s, needed by %B, not found (try using --rpath)\n", + l->name, l->by); + } +} + +/* Search for a needed file in a path. */ + +static boolean +gld${EMULATION_NAME}_search_needed (path, name) + const char *path; + const char *name; +{ + const char *s; + size_t len; + + if (path == NULL || *path == '\0') + return false; + len = strlen (name); + while (1) + { + char *filename, *sset; + + s = strchr (path, ':'); + if (s == NULL) + s = path + strlen (path); + + filename = (char *) xmalloc (s - path + len + 2); + if (s == path) + sset = filename; + else + { + memcpy (filename, path, s - path); + filename[s - path] = '/'; + sset = filename + (s - path) + 1; + } + strcpy (sset, name); + + if (gld${EMULATION_NAME}_try_needed (filename)) + return true; + + free (filename); + + if (*s == '\0') + break; + path = s + 1; + } + + return false; +} + +/* This function is called for each possible name for a dynamic object + named by a DT_NEEDED entry. */ + +static boolean +gld${EMULATION_NAME}_try_needed (name) + const char *name; +{ + bfd *abfd; + + abfd = bfd_openr (name, bfd_get_target (output_bfd)); + if (abfd == NULL) + return false; + if (! bfd_check_format (abfd, bfd_object)) + { + (void) bfd_close (abfd); + return false; + } + if ((bfd_get_file_flags (abfd) & DYNAMIC) == 0) + { + (void) bfd_close (abfd); + return false; + } + + /* We've found a dynamic object matching the DT_NEEDED entry. */ + + /* We have already checked that there is no other input file of the + same name. We must now check again that we are not including the + same file twice. We need to do this because on many systems + libc.so is a symlink to, e.g., libc.so.1. The SONAME entry will + reference libc.so.1. If we have already included libc.so, we + don't want to include libc.so.1 if they are the same file, and we + can only check that using stat. */ + + if (bfd_stat (abfd, &global_stat) != 0) + einfo ("%F%P:%B: bfd_stat failed: %E\n", abfd); + global_found = false; + lang_for_each_input_file (gld${EMULATION_NAME}_stat_needed); + if (global_found) + { + /* Return true to indicate that we found the file, even though + we aren't going to do anything with it. */ + return true; + } + + /* Tell the ELF backend that don't want the output file to have a + DT_NEEDED entry for this file. */ + bfd_elf_set_dt_needed_name (abfd, ""); + + /* Add this file into the symbol table. */ + if (! bfd_link_add_symbols (abfd, &link_info)) + einfo ("%F%B: could not read symbols: %E\n", abfd); + + return true; +} + +/* 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; +{ + if (global_found) + return; + + if (s->filename != NULL + && strcmp (s->filename, global_needed->name) == 0) + { + global_found = true; + return; + } + + if (s->the_bfd != NULL) + { + const char *soname; + + soname = bfd_elf_get_dt_soname (s->the_bfd); + if (soname != NULL + && strcmp (soname, global_needed->name) == 0) + { + global_found = true; + return; + } + } + + if (s->search_dirs_flag + && s->filename != NULL + && strchr (global_needed->name, '/') == NULL) + { + const char *f; + + f = strrchr (s->filename, '/'); + if (f != NULL + && strcmp (f + 1, global_needed->name) == 0) + { + global_found = true; + return; + } + } +} + +/* See if an input file matches a DT_NEEDED entry by running stat on + the file. */ + +static void +gld${EMULATION_NAME}_stat_needed (s) + lang_input_statement_type *s; +{ + struct stat st; + const char *suffix; + const char *soname; + const char *f; + + if (global_found) + return; + if (s->the_bfd == NULL) + return; + + if (bfd_stat (s->the_bfd, &st) != 0) + { + einfo ("%P:%B: bfd_stat failed: %E\n", s->the_bfd); + return; + } + + if (st.st_dev == global_stat.st_dev + && st.st_ino == global_stat.st_ino) + { + global_found = true; + return; + } + + /* We issue a warning if it looks like we are including two + different versions of the same shared library. For example, + there may be a problem if -lc picks up libc.so.6 but some other + shared library has a DT_NEEDED entry of libc.so.5. This is a + hueristic test, and it will only work if the name looks like + NAME.so.VERSION. FIXME: Depending on file names is error-prone. + If we really want to issue warnings about mixing version numbers + of shared libraries, we need to find a better way. */ + + if (strchr (global_needed->name, '/') != NULL) + return; + suffix = strstr (global_needed->name, ".so."); + if (suffix == NULL) + return; + suffix += sizeof ".so." - 1; + + soname = bfd_elf_get_dt_soname (s->the_bfd); + if (soname == NULL) + soname = s->filename; + + f = strrchr (soname, '/'); + if (f != NULL) + ++f; + else + f = soname; + + if (strncmp (f, global_needed->name, suffix - global_needed->name) == 0) + einfo ("%P: warning: %s, needed by %B, may conflict with %s\n", + global_needed->name, global_needed->by, f); +} + +/* This is called after the sections have been attached to output + sections, but before any sizes or addresses have been set. */ + +static void +gld${EMULATION_NAME}_before_allocation () +{ + const char *rpath; + asection *sinterp; + + /* 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. */ + lang_for_each_statement (gld${EMULATION_NAME}_find_statement_assignment); + + /* Let the ELF backend work out the sizes of any sections required + by dynamic linking. */ + 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, + command_line.export_dynamic, command_line.filter_shlib, + (const char * const *) command_line.auxiliary_filters, + &link_info, &sinterp, lang_elf_version_info))) + einfo ("%P%F: failed to set dynamic section sizes: %E\n"); + + /* Let the user override the dynamic linker we are using. */ + if (command_line.interpreter != NULL + && sinterp != NULL) + { + sinterp->contents = (bfd_byte *) command_line.interpreter; + sinterp->_raw_size = strlen (command_line.interpreter) + 1; + } + + /* Look for any sections named .gnu.warning. As a GNU extensions, + we treat such sections as containing warning messages. We print + out the warning message, and then zero out the section size so + that it does not get copied into the output file. */ + + { + LANG_FOR_EACH_INPUT_STATEMENT (is) + { + asection *s; + bfd_size_type sz; + char *msg; + boolean ret; + + if (is->just_syms_flag) + continue; + + s = bfd_get_section_by_name (is->the_bfd, ".gnu.warning"); + if (s == NULL) + 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)) + einfo ("%F%B: Can't read contents of section .gnu.warning: %E\n", + is->the_bfd); + msg[sz] = '\0'; + ret = link_info.callbacks->warning (&link_info, msg, + (const char *) NULL, + is->the_bfd, (asection *) NULL, + (bfd_vma) 0); + ASSERT (ret); + free (msg); + + /* Clobber the section size, so that we don't waste copying the + warning into the output file. */ + s->_raw_size = 0; + } + } + +#if defined (TARGET_IS_elf32bmip) || defined (TARGET_IS_elf32lmip) + /* For MIPS ELF the .reginfo section requires special handling. + Each input section is 24 bytes, and the final output section must + also be 24 bytes. We handle this by clobbering all but the first + input section size to 0. The .reginfo section is handled + specially by the backend code anyhow. */ + { + boolean found = false; + LANG_FOR_EACH_INPUT_STATEMENT (is) + { + asection *s; + + if (is->just_syms_flag) + continue; + + s = bfd_get_section_by_name (is->the_bfd, ".reginfo"); + if (s == NULL) + continue; + + if (! found) + { + found = true; + continue; + } + + s->_raw_size = 0; + s->_cooked_size = 0; + } + } +#endif +} + +/* This is called by the before_allocation routine via + lang_for_each_statement. It locates any assignment statements, and + tells the ELF backend about them, in case they are assignments to + symbols which are referred to by dynamic objects. */ + +static void +gld${EMULATION_NAME}_find_statement_assignment (s) + lang_statement_union_type *s; +{ + if (s->header.type == lang_assignment_statement_enum) + gld${EMULATION_NAME}_find_exp_assignment (s->assignment_statement.exp); +} + +/* Look through an expression for an assignment statement. */ + +static void +gld${EMULATION_NAME}_find_exp_assignment (exp) + etree_type *exp; +{ + struct bfd_link_hash_entry *h; + + switch (exp->type.node_class) + { + case etree_provide: + h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst, + false, false, false); + if (h == NULL) + break; + + /* We call record_link_assignment even if the symbol is defined. + This is because if it is defined by a dynamic object, we + actually want to use the value defined by the linker script, + not the value from the dynamic object (because we are setting + symbols like etext). If the symbol is defined by a regular + object, then, as it happens, calling record_link_assignment + will do no harm. */ + + /* Fall through. */ + case etree_assign: + if (strcmp (exp->assign.dst, ".") != 0) + { + if (! (bfd_elf${ELFSIZE}_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", + exp->assign.dst); + } + gld${EMULATION_NAME}_find_exp_assignment (exp->assign.src); + break; + + case etree_binary: + gld${EMULATION_NAME}_find_exp_assignment (exp->binary.lhs); + gld${EMULATION_NAME}_find_exp_assignment (exp->binary.rhs); + break; + + case etree_trinary: + gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.cond); + gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.lhs); + gld${EMULATION_NAME}_find_exp_assignment (exp->trinary.rhs); + break; + + case etree_unary: + gld${EMULATION_NAME}_find_exp_assignment (exp->unary.child); + break; + + default: + break; + } +} + +/* Place an orphan section. We use this to put random SHF_ALLOC + sections in the right segment. */ + +static asection *hold_section; +static lang_output_section_statement_type *hold_use; +static lang_output_section_statement_type *hold_text; +static lang_output_section_statement_type *hold_rodata; +static lang_output_section_statement_type *hold_data; +static lang_output_section_statement_type *hold_bss; +static lang_output_section_statement_type *hold_rel; +static lang_output_section_statement_type *hold_interp; + +/*ARGSUSED*/ +static boolean +gld${EMULATION_NAME}_place_orphan (file, s) + lang_input_statement_type *file; + asection *s; +{ + lang_output_section_statement_type *place; + asection *snew, **pps; + lang_statement_list_type *old; + lang_statement_list_type add; + etree_type *address; + const char *secname, *ps; + const char *outsecname; + lang_output_section_statement_type *os; + + if ((s->flags & SEC_ALLOC) == 0) + return false; + + /* Look through the script to see where to place this section. */ + hold_section = s; + hold_use = NULL; + lang_for_each_statement (gld${EMULATION_NAME}_place_section); + + if (hold_use != NULL) + { + /* We have already placed a section with this name. */ + wild_doit (&hold_use->children, s, hold_use, file); + return true; + } + + secname = bfd_get_section_name (s->owner, 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 + && strncmp (secname, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0 + && hold_text != NULL) + { + wild_doit (&hold_text->children, s, hold_text, file); + return true; + } + + /* Decide which segment the section should go in based on the + section name and section flags. We put loadable .note sections + right after the .interp section, so that the PT_NOTE segment is + stored right after the program headers where the OS can read it + in the first page. */ + place = NULL; + if ((s->flags & SEC_LOAD) != 0 + && strncmp (secname, ".note", 4) == 0 + && hold_interp != NULL) + place = hold_interp; + else if ((s->flags & SEC_HAS_CONTENTS) == 0 + && hold_bss != NULL) + place = hold_bss; + else if ((s->flags & SEC_READONLY) == 0 + && hold_data != NULL) + place = hold_data; + else if (strncmp (secname, ".rel", 4) == 0 + && hold_rel != NULL) + place = hold_rel; + else if ((s->flags & SEC_CODE) == 0 + && (s->flags & SEC_READONLY) != 0 + && hold_rodata != NULL) + place = hold_rodata; + else if ((s->flags & SEC_READONLY) != 0 + && hold_text != NULL) + place = hold_text; + if (place == NULL) + return false; + + /* Choose a unique name for the section. This will be needed if the + same section name appears in the input file with different + loadable or allocateable characteristics. */ + outsecname = secname; + if (bfd_get_section_by_name (output_bfd, outsecname) != NULL) + { + unsigned int len; + char *newname; + unsigned int i; + + len = strlen (outsecname); + newname = xmalloc (len + 5); + strcpy (newname, outsecname); + i = 0; + do + { + sprintf (newname + len, "%d", i); + ++i; + } + while (bfd_get_section_by_name (output_bfd, newname) != NULL); + + outsecname = newname; + } + + /* Create the section in the output file, and put it in the right + place. This shuffling is to make the output file look neater. */ + snew = bfd_make_section (output_bfd, outsecname); + if (snew == NULL) + einfo ("%P%F: output format %s cannot represent section called %s\n", + output_bfd->xvec->name, outsecname); + if (place->bfd_section != NULL) + { + for (pps = &output_bfd->sections; *pps != snew; pps = &(*pps)->next) + ; + *pps = snew->next; + snew->next = place->bfd_section->next; + place->bfd_section->next = snew; + } + + /* Start building a list of statements for this section. */ + old = stat_ptr; + stat_ptr = &add; + lang_list_init (stat_ptr); + + /* 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 (*ps) && *ps != '_') + break; + if (*ps == '\0' && config.build_constructors) + { + char *symname; + + symname = (char *) xmalloc (ps - outsecname + sizeof "__start_"); + sprintf (symname, "__start_%s", outsecname); + lang_add_assignment (exp_assop ('=', symname, + exp_unop (ALIGN_K, + exp_intop ((bfd_vma) 1 + << s->alignment_power)))); + } + + if (! link_info.relocateable) + address = NULL; + else + address = exp_intop ((bfd_vma) 0); + + lang_enter_output_section_statement (outsecname, address, 0, + (bfd_vma) 0, + (etree_type *) NULL, + (etree_type *) NULL, + (etree_type *) NULL); + + os = lang_output_section_statement_lookup (outsecname); + wild_doit (&os->children, s, os, file); + + lang_leave_output_section_statement + ((bfd_vma) 0, "*default*", (struct lang_output_section_phdr_list *) NULL); + stat_ptr = &add; + + if (*ps == '\0' && config.build_constructors) + { + char *symname; + + symname = (char *) xmalloc (ps - outsecname + sizeof "__stop_"); + sprintf (symname, "__stop_%s", outsecname); + lang_add_assignment (exp_assop ('=', symname, + exp_nameop (NAME, "."))); + } + + /* Now stick the new statement list right after PLACE. */ + *add.tail = place->header.next; + place->header.next = add.head; + + stat_ptr = old; + + return true; +} + +static void +gld${EMULATION_NAME}_place_section (s) + lang_statement_union_type *s; +{ + lang_output_section_statement_type *os; + + if (s->header.type != lang_output_section_statement_enum) + return; + + os = &s->output_section_statement; + + if (strcmp (os->name, hold_section->name) == 0 + && ((hold_section->flags & (SEC_LOAD | SEC_ALLOC)) + == (os->bfd_section->flags & (SEC_LOAD | SEC_ALLOC)))) + hold_use = os; + + if (strcmp (os->name, ".text") == 0) + hold_text = os; + else if (strcmp (os->name, ".rodata") == 0) + hold_rodata = os; + else if (strcmp (os->name, ".data") == 0) + hold_data = os; + else if (strcmp (os->name, ".bss") == 0) + hold_bss = os; + else if (hold_rel == NULL + && os->bfd_section != NULL + && (os->bfd_section->flags & SEC_ALLOC) != 0 + && strncmp (os->name, ".rel", 4) == 0) + hold_rel = os; + else if (strcmp (os->name, ".interp") == 0) + hold_interp = os; +} + +static char * +gld${EMULATION_NAME}_get_script(isfile) + int *isfile; +EOF + +if test -n "$COMPILE_IN" +then +# Scripts compiled in. + +# sed commands to quote an ld script as a C string. +sc='s/["\\]/\\&/g +s/$/\\n\\/ +1s/^/"/ +$s/$/n"/ +' + +cat >>e${EMULATION_NAME}.c <<EOF +{ + *isfile = 0; + + if (link_info.relocateable == true && config.build_constructors == true) + return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`; + else if (link_info.relocateable == true) + return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`; + else if (!config.text_read_only) + return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`; + else if (!config.magic_demand_paged) + return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`; + else if (link_info.shared) + return `sed "$sc" ldscripts/${EMULATION_NAME}.xs`; + else + return `sed "$sc" ldscripts/${EMULATION_NAME}.x`; +} +EOF + +else +# Scripts read from the filesystem. + +cat >>e${EMULATION_NAME}.c <<EOF +{ + *isfile = 1; + + if (link_info.relocateable == true && config.build_constructors == true) + return "ldscripts/${EMULATION_NAME}.xu"; + else if (link_info.relocateable == true) + return "ldscripts/${EMULATION_NAME}.xr"; + else if (!config.text_read_only) + return "ldscripts/${EMULATION_NAME}.xbn"; + else if (!config.magic_demand_paged) + return "ldscripts/${EMULATION_NAME}.xn"; + else if (link_info.shared) + return "ldscripts/${EMULATION_NAME}.xs"; + else + return "ldscripts/${EMULATION_NAME}.x"; +} +EOF + +fi + +cat >>e${EMULATION_NAME}.c <<EOF + +struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = +{ + gld${EMULATION_NAME}_before_parse, + syslib_default, + hll_default, + after_parse_default, + gld${EMULATION_NAME}_after_open, + after_allocation_default, + set_output_arch_default, + ldemul_default_target, + gld${EMULATION_NAME}_before_allocation, + gld${EMULATION_NAME}_get_script, + "${EMULATION_NAME}", + "${OUTPUT_FORMAT}", + NULL, + NULL, + gld${EMULATION_NAME}_open_dynamic_archive, + gld${EMULATION_NAME}_place_orphan +}; +EOF diff --git a/contrib/binutils/ld/emultempl/generic.em b/contrib/binutils/ld/emultempl/generic.em new file mode 100644 index 0000000..1c0c8eb --- /dev/null +++ b/contrib/binutils/ld/emultempl/generic.em @@ -0,0 +1,118 @@ +# This shell script emits a C file. -*- C -*- +# It does some substitutions. +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 (C) 1991, 1993 Free Software Foundation, Inc. + Written by Steve Chamberlain steve@cygnus.com + +This file is part of GLD, the Gnu Linker. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define TARGET_IS_${EMULATION_NAME} + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" + +#include "ld.h" +#include "ldmain.h" +#include "ldemul.h" +#include "ldfile.h" +#include "ldmisc.h" + +static void gld${EMULATION_NAME}_before_parse PARAMS ((void)); +static char *gld${EMULATION_NAME}_get_script PARAMS ((int *isfile)); + +static void +gld${EMULATION_NAME}_before_parse() +{ +#ifndef TARGET_ /* I.e., if not generic. */ + ldfile_set_output_arch ("`echo ${ARCH}`"); +#endif /* not TARGET_ */ +} + +static char * +gld${EMULATION_NAME}_get_script(isfile) + int *isfile; +EOF + +if test -n "$COMPILE_IN" +then +# Scripts compiled in. + +# sed commands to quote an ld script as a C string. +sc="-f ${srcdir}/emultempl/stringify.sed" + +cat >>e${EMULATION_NAME}.c <<EOF +{ + *isfile = 0; + + if (link_info.relocateable == true && config.build_constructors == true) + return +EOF +sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c +echo ' ; else if (link_info.relocateable == true) 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 +echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c +sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c +echo ' ; else return' >> e${EMULATION_NAME}.c +sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c +echo '; }' >> e${EMULATION_NAME}.c + +else +# Scripts read from the filesystem. + +cat >>e${EMULATION_NAME}.c <<EOF +{ + *isfile = 1; + + if (link_info.relocateable == true && config.build_constructors == true) + return "ldscripts/${EMULATION_NAME}.xu"; + else if (link_info.relocateable == true) + return "ldscripts/${EMULATION_NAME}.xr"; + else if (!config.text_read_only) + return "ldscripts/${EMULATION_NAME}.xbn"; + else if (!config.magic_demand_paged) + return "ldscripts/${EMULATION_NAME}.xn"; + else + return "ldscripts/${EMULATION_NAME}.x"; +} +EOF + +fi + +cat >>e${EMULATION_NAME}.c <<EOF + +struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = +{ + gld${EMULATION_NAME}_before_parse, + syslib_default, + hll_default, + after_parse_default, + after_open_default, + after_allocation_default, + set_output_arch_default, + ldemul_default_target, + before_allocation_default, + gld${EMULATION_NAME}_get_script, + "${EMULATION_NAME}", + "${OUTPUT_FORMAT}" +}; +EOF diff --git a/contrib/binutils/ld/emultempl/linux.em b/contrib/binutils/ld/emultempl/linux.em new file mode 100644 index 0000000..6860c3f --- /dev/null +++ b/contrib/binutils/ld/emultempl/linux.em @@ -0,0 +1,207 @@ +# This shell script emits a C file. -*- C -*- +# It does some substitutions. +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 (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + Written by Steve Chamberlain <sac@cygnus.com> + Linux support by Eric Youngdale <ericy@cais.cais.com> + +This file is part of GLD, the Gnu Linker. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#define TARGET_IS_${EMULATION_NAME} + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" + +#include "ld.h" +#include "ldmain.h" +#include "ldemul.h" +#include "ldfile.h" +#include "ldmisc.h" +#include "ldexp.h" +#include "ldlang.h" + +static void gld${EMULATION_NAME}_before_parse PARAMS ((void)); +static 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() +{ + ldfile_output_architecture = bfd_arch_${ARCH}; + config.dynamic_link = true; +} + +/* Try to open a dynamic archive. This is where we know that Linux + dynamic libraries have an extension of .sa. */ + +static boolean +gld${EMULATION_NAME}_open_dynamic_archive (arch, search, entry) + const char *arch; + search_dirs_type *search; + lang_input_statement_type *entry; +{ + char *string; + + if (! entry->is_archive) + return false; + + string = (char *) xmalloc (strlen (search->name) + + strlen (entry->filename) + + strlen (arch) + + sizeof "/lib.sa"); + + sprintf (string, "%s/lib%s%s.sa", search->name, entry->filename, arch); + + if (! ldfile_try_open_bfd (string, entry)) + { + free (string); + return false; + } + + entry->filename = string; + + return true; +} + +/* This is called by the create_output_section_statements routine via + lang_for_each_statement. It locates any address assignment to + .text, and modifies it to include the size of the headers. This + causes -Ttext to mean the starting address of the header, rather + than the starting address of .text, which is compatible with other + Linux tools. */ + +static void +gld${EMULATION_NAME}_find_address_statement (s) + lang_statement_union_type *s; +{ + if (s->header.type == lang_address_statement_enum + && strcmp (s->address_statement.section_name, ".text") == 0) + { + ASSERT (s->address_statement.address->type.node_class == etree_value); + s->address_statement.address->value.value += 0x20; + } +} + +/* This is called before opening the input BFD's. */ + +static void +gld${EMULATION_NAME}_create_output_section_statements () +{ + lang_for_each_statement (gld${EMULATION_NAME}_find_address_statement); +} + +/* This is called after the sections have been attached to output + sections, but before any sizes or addresses have been set. */ + +static void +gld${EMULATION_NAME}_before_allocation () +{ + if (link_info.relocateable) + return; + + /* Let the backend work out the sizes of any sections required by + dynamic linking. */ + if (! bfd_${EMULATION_NAME}_size_dynamic_sections (output_bfd, &link_info)) + einfo ("%P%F: failed to set dynamic section sizes: %E\n"); +} + +static char * +gld${EMULATION_NAME}_get_script(isfile) + int *isfile; +EOF + +if test -n "$COMPILE_IN" +then +# Scripts compiled in. + +# sed commands to quote an ld script as a C string. +sc='s/["\\]/\\&/g +s/$/\\n\\/ +1s/^/"/ +$s/$/n"/ +' + +cat >>e${EMULATION_NAME}.c <<EOF +{ + *isfile = 0; + + if (link_info.relocateable == true && config.build_constructors == true) + return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`; + else if (link_info.relocateable == true) + return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`; + else if (!config.text_read_only) + return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`; + else if (!config.magic_demand_paged) + return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`; + else + return `sed "$sc" ldscripts/${EMULATION_NAME}.x`; +} +EOF + +else +# Scripts read from the filesystem. + +cat >>e${EMULATION_NAME}.c <<EOF +{ + *isfile = 1; + + if (link_info.relocateable == true && config.build_constructors == true) + return "ldscripts/${EMULATION_NAME}.xu"; + else if (link_info.relocateable == true) + return "ldscripts/${EMULATION_NAME}.xr"; + else if (!config.text_read_only) + return "ldscripts/${EMULATION_NAME}.xbn"; + else if (!config.magic_demand_paged) + return "ldscripts/${EMULATION_NAME}.xn"; + else + return "ldscripts/${EMULATION_NAME}.x"; +} +EOF + +fi + +cat >>e${EMULATION_NAME}.c <<EOF + +struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = +{ + gld${EMULATION_NAME}_before_parse, + syslib_default, + hll_default, + after_parse_default, + after_open_default, + after_allocation_default, + set_output_arch_default, + ldemul_default_target, + gld${EMULATION_NAME}_before_allocation, + gld${EMULATION_NAME}_get_script, + "${EMULATION_NAME}", + "${OUTPUT_FORMAT}", + NULL, + gld${EMULATION_NAME}_create_output_section_statements, + gld${EMULATION_NAME}_open_dynamic_archive +}; +EOF diff --git a/contrib/binutils/ld/emultempl/pe.em b/contrib/binutils/ld/emultempl/pe.em new file mode 100644 index 0000000..8f0913e --- /dev/null +++ b/contrib/binutils/ld/emultempl/pe.em @@ -0,0 +1,743 @@ +# This shell script emits a C file. -*- C -*- +# It does some substitutions. +cat >e${EMULATION_NAME}.c <<EOF +/* This file is part of GLD, the Gnu Linker. + Copyright 1995, 96, 1997 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* For WINDOWS_NT */ +/* The original file generated returned different default scripts depending + on whether certain switches were set, but these switches pertain to the + Linux system and that particular version of coff. In the NT case, we + only determine if the subsystem is console or windows in order to select + the correct entry point by default. */ + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" +#include "getopt.h" +#include "libiberty.h" +#include "ld.h" +#include "ldmain.h" +#include "ldgram.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldemul.h" +#include "ldlex.h" +#include "ldmisc.h" +#include "ldctor.h" +#include "ldfile.h" +#include "coff/internal.h" +#include "../bfd/libcoff.h" + +#define TARGET_IS_${EMULATION_NAME} + +static void gld_${EMULATION_NAME}_set_symbols PARAMS ((void)); +static void gld_${EMULATION_NAME}_after_open PARAMS ((void)); +static void gld_${EMULATION_NAME}_before_parse PARAMS ((void)); +static void gld_${EMULATION_NAME}_before_allocation PARAMS ((void)); +static boolean gld${EMULATION_NAME}_place_orphan + PARAMS ((lang_input_statement_type *, asection *)); +static char *gld_${EMULATION_NAME}_get_script PARAMS ((int *)); +static int gld_${EMULATION_NAME}_parse_args PARAMS ((int, char **)); + +#if 0 /* argument to qsort so don't prototype */ +static int sort_by_file_name PARAMS ((void *, void *)); +static int sort_by_section_name PARAMS ((void *, void *)); +#endif +static lang_statement_union_type **sort_sections_1 + PARAMS ((lang_statement_union_type **, lang_statement_union_type *, int, + int (*)())); +static void sort_sections PARAMS ((lang_statement_union_type *)); + +static struct internal_extra_pe_aouthdr pe; +static int dll; + +extern const char *output_filename; + +static void +gld_${EMULATION_NAME}_before_parse() +{ + output_filename = "a.exe"; + ldfile_output_architecture = bfd_arch_${ARCH}; +} + +/* PE format extra command line options. */ + +/* Used for setting flags in the PE header. */ +#define OPTION_BASE_FILE (300 + 1) +#define OPTION_DLL (OPTION_BASE_FILE + 1) +#define OPTION_FILE_ALIGNMENT (OPTION_DLL + 1) +#define OPTION_IMAGE_BASE (OPTION_FILE_ALIGNMENT + 1) +#define OPTION_MAJOR_IMAGE_VERSION (OPTION_IMAGE_BASE + 1) +#define OPTION_MAJOR_OS_VERSION (OPTION_MAJOR_IMAGE_VERSION + 1) +#define OPTION_MAJOR_SUBSYSTEM_VERSION (OPTION_MAJOR_OS_VERSION + 1) +#define OPTION_MINOR_IMAGE_VERSION (OPTION_MAJOR_SUBSYSTEM_VERSION + 1) +#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_HEAP (OPTION_SUBSYSTEM + 1) + +static struct option longopts[] = { + /* PE options */ + {"base-file", required_argument, NULL, OPTION_BASE_FILE}, + {"dll", no_argument, NULL, OPTION_DLL}, + {"file-alignment", required_argument, NULL, OPTION_FILE_ALIGNMENT}, + {"heap", required_argument, NULL, OPTION_HEAP}, + {"image-base", required_argument, NULL, OPTION_IMAGE_BASE}, + {"major-image-version", required_argument, NULL, OPTION_MAJOR_IMAGE_VERSION}, + {"major-os-version", required_argument, NULL, OPTION_MAJOR_OS_VERSION}, + {"major-subsystem-version", required_argument, NULL, OPTION_MAJOR_SUBSYSTEM_VERSION}, + {"minor-image-version", required_argument, NULL, OPTION_MINOR_IMAGE_VERSION}, + {"minor-os-version", required_argument, NULL, OPTION_MINOR_OS_VERSION}, + {"minor-subsystem-version", required_argument, NULL, OPTION_MINOR_SUBSYSTEM_VERSION}, + {"section-alignment", required_argument, NULL, OPTION_SECTION_ALIGNMENT}, + {"stack", required_argument, NULL, OPTION_STACK}, + {"subsystem", required_argument, NULL, OPTION_SUBSYSTEM}, + {NULL, no_argument, NULL, 0} + }; + + +/* PE/WIN32; added routines to get the subsystem type, heap and/or stack + parameters which may be input from the command line */ + +typedef struct { + void *ptr; + int size; + int value; + char *symbol; + int inited; +} definfo; + +#define D(field,symbol,def) {&pe.field,sizeof(pe.field), def, symbol,0} + +static definfo init[] = +{ + /* imagebase must be first */ +#define IMAGEBASEOFF 0 + D(ImageBase,"__image_base__", NT_EXE_IMAGE_BASE), +#define DLLOFF 1 + {&dll, sizeof(dll), 0, "__dll__"}, + D(SectionAlignment,"__section_alignment__", PE_DEF_SECTION_ALIGNMENT), + D(FileAlignment,"__file_alignment__", PE_DEF_FILE_ALIGNMENT), + D(MajorOperatingSystemVersion,"__major_os_version__", 4), + D(MinorOperatingSystemVersion,"__minor_os_version__", 0), + D(MajorImageVersion,"__major_image_version__", 1), + D(MinorImageVersion,"__minor_image_version__", 0), + D(MajorSubsystemVersion,"__major_subsystem_version__", 4), + D(MinorSubsystemVersion,"__minor_subsystem_version__", 0), + D(Subsystem,"__subsystem__", 3), + D(SizeOfStackReserve,"__size_of_stack_reserve__", 0x2000000), + D(SizeOfStackCommit,"__size_of_stack_commit__", 0x1000), + D(SizeOfHeapReserve,"__size_of_heap_reserve__", 0x100000), + D(SizeOfHeapCommit,"__size_of_heap_commit__", 0x1000), + D(LoaderFlags,"__loader_flags__", 0x0), + { NULL, 0, 0, NULL, 0 } +}; + + +static void +set_pe_name (name, val) + char *name; + long val; +{ + int i; + /* Find the name and set it. */ + for (i = 0; init[i].ptr; i++) + { + if (strcmp (name, init[i].symbol) == 0) + { + init[i].value = val; + init[i].inited = 1; + return; + } + } + abort(); +} + + +static void +set_pe_subsystem () +{ + const char *sver; + int len; + int i; + static const struct + { + const char *name; + const int value; + const char *entry; + } + v[] = + { + { "native", 1, "_NtProcessStartup" }, + { "windows", 2, "_WinMainCRTStartup" }, + { "console", 3, "_mainCRTStartup" }, +#if 0 + /* The Microsoft linker does not recognize this. */ + { "os2", 5, "" }, +#endif + { "posix", 7, "___PosixProcessStartup"}, + { 0, 0, 0 } + }; + + sver = strchr (optarg, ':'); + if (sver == NULL) + len = strlen (optarg); + else + { + char *end; + + len = sver - optarg; + set_pe_name ("__major_subsystem_version__", + strtoul (sver + 1, &end, 0)); + if (*end == '.') + set_pe_name ("__minor_subsystem_version__", + strtoul (end + 1, &end, 0)); + if (*end != '\0') + einfo ("%P: warning: bad version number in -subsystem option\n"); + } + + for (i = 0; v[i].name; i++) + { + if (strncmp (optarg, v[i].name, len) == 0 + && v[i].name[len] == '\0') + { + set_pe_name ("__subsystem__", v[i].value); + + /* If the subsystem is windows, we use a different entry + point. We also register the entry point as an undefined + symbol. The reason we do this is so that the user + doesn't have to because they would have to use the -u + switch if they were specifying an entry point other than + _mainCRTStartup. Specifically, if creating a windows + application, entry point _WinMainCRTStartup must be + specified. What I have found for non console + applications (entry not _mainCRTStartup) is that the .obj + that contains mainCRTStartup is brought in since it is + the first encountered in libc.lib and it has other + symbols in it which will be pulled in by the link + process. To avoid this, adding -u with the entry point + name specified forces the correct .obj to be used. We + can avoid making the user do this by always adding the + entry point name as an undefined symbol. */ + lang_add_entry (v[i].entry, 1); + ldlang_add_undef (v[i].entry); + + return; + } + } + einfo ("%P%F: invalid subsystem type %s\n", optarg); +} + + + +static void +set_pe_value (name) + char *name; + +{ + char *end; + set_pe_name (name, strtoul (optarg, &end, 0)); + if (end == optarg) + { + einfo ("%P%F: invalid hex number for PE parameter '%s'\n", optarg); + } + + optarg = end; +} + +static void +set_pe_stack_heap (resname, comname) + char *resname; + char *comname; +{ + set_pe_value (resname); + if (*optarg == ',') + { + optarg++; + set_pe_value (comname); + } + else if (*optarg) + { + einfo ("%P%F: strange hex info for PE parameter '%s'\n", optarg); + } +} + + + +static int +gld_${EMULATION_NAME}_parse_args(argc, argv) + int argc; + char **argv; +{ + int longind; + int optc; + int prevoptind = optind; + int prevopterr = opterr; + int wanterror; + static int lastoptind = -1; + + if (lastoptind != optind) + opterr = 0; + wanterror = opterr; + + lastoptind = optind; + + optc = getopt_long_only (argc, argv, "-", longopts, &longind); + opterr = prevopterr; + + switch (optc) + { + default: + if (wanterror) + xexit (1); + optind = prevoptind; + return 0; + + case OPTION_BASE_FILE: + link_info.base_file = (PTR) fopen (optarg, FOPEN_WB); + if (link_info.base_file == NULL) + { + fprintf (stderr, "%s: Can't open base file %s\n", + program_name, optarg); + xexit (1); + } + break; + + /* PE options */ + case OPTION_HEAP: + set_pe_stack_heap ("__size_of_heap_reserve__", "__size_of_heap_commit__"); + break; + case OPTION_STACK: + set_pe_stack_heap ("__size_of_stack_reserve__", "__size_of_stack_commit__"); + break; + case OPTION_SUBSYSTEM: + set_pe_subsystem (); + break; + case OPTION_MAJOR_OS_VERSION: + set_pe_value ("__major_os_version__"); + break; + case OPTION_MINOR_OS_VERSION: + set_pe_value ("__minor_os_version__"); + break; + case OPTION_MAJOR_SUBSYSTEM_VERSION: + set_pe_value ("__major_subsystem_version__"); + break; + case OPTION_MINOR_SUBSYSTEM_VERSION: + set_pe_value ("__minor_subsystem_version__"); + break; + case OPTION_MAJOR_IMAGE_VERSION: + set_pe_value ("__major_image_version__"); + break; + case OPTION_MINOR_IMAGE_VERSION: + set_pe_value ("__minor_image_version__"); + break; + case OPTION_FILE_ALIGNMENT: + set_pe_value ("__file_alignment__"); + break; + case OPTION_SECTION_ALIGNMENT: + set_pe_value ("__section_alignment__"); + break; + case OPTION_DLL: + set_pe_name ("__dll__", 1); + break; + case OPTION_IMAGE_BASE: + set_pe_value ("__image_base__"); + break; + } + return 1; +} + +static void +gld_${EMULATION_NAME}_set_symbols() +{ + /* Run through and invent symbols for all the + names and insert the defaults. */ + int j; + lang_statement_list_type *save; + + if (!init[IMAGEBASEOFF].inited) + init[IMAGEBASEOFF].value = init[DLLOFF].value + ? NT_DLL_IMAGE_BASE : NT_EXE_IMAGE_BASE; + + /* Glue the assignments into the abs section */ + save = stat_ptr; + + stat_ptr = &(abs_output_section->children); + + for (j = 0; init[j].ptr; j++) + { + long val = init[j].value; + lang_add_assignment (exp_assop ('=' ,init[j].symbol, exp_intop (val))); + if (init[j].size == sizeof(short)) + *(short *)init[j].ptr = val; + else if (init[j].size == sizeof(int)) + *(int *)init[j].ptr = val; + else if (init[j].size == sizeof(long)) + *(long *)init[j].ptr = val; + /* This might be a long long or other special type. */ + else if (init[j].size == sizeof(bfd_vma)) + *(bfd_vma *)init[j].ptr = val; + else abort(); + } + /* Restore the pointer. */ + stat_ptr = save; + + if (pe.FileAlignment > + pe.SectionAlignment) + { + einfo ("%P: warning, file alignment > section alignment.\n"); + } +} + +static void +gld_${EMULATION_NAME}_after_open() +{ + /* Pass the wacky PE command line options into the output bfd. + FIXME: This should be done via a function, rather than by + including an internal BFD header. */ + if (!coff_data(output_bfd)->pe) + { + einfo ("%F%P: PE operations on non PE file.\n"); + } + + pe_data(output_bfd)->pe_opthdr = pe; + pe_data(output_bfd)->dll = init[DLLOFF].value; + +} + +/* Callback functions for qsort in sort_sections. */ + +static int +sort_by_file_name (a, b) + void *a; + void *b; +{ + lang_statement_union_type **ra = a; + lang_statement_union_type **rb = b; + int i; + + i = strcmp ((*ra)->input_section.ifile->the_bfd->my_archive->filename, + (*rb)->input_section.ifile->the_bfd->my_archive->filename); + if (i != 0) + return i; + + return strcmp ((*ra)->input_section.ifile->filename, + (*rb)->input_section.ifile->filename); +} + +static int +sort_by_section_name (a, b) + void *a; + void *b; +{ + lang_statement_union_type **ra = a; + lang_statement_union_type **rb = b; + return strcmp ((*ra)->input_section.section->name, + (*rb)->input_section.section->name); +} + +/* Subroutine of sort_sections to a contiguous subset of a list of sections. + NEXT_AFTER is the element after the last one to sort. + The result is a pointer to the last element's "next" pointer. */ + +static lang_statement_union_type ** +sort_sections_1 (startptr, next_after, count, sort_func) + lang_statement_union_type **startptr,*next_after; + int count; + int (*sort_func) (); +{ + lang_statement_union_type **vec; + lang_statement_union_type *p; + int i; + lang_statement_union_type **ret; + + if (count == 0) + return startptr; + + vec = ((lang_statement_union_type **) + xmalloc (count * sizeof (lang_statement_union_type *))); + + for (p = *startptr, i = 0; i < count; i++, p = p->next) + vec[i] = p; + + qsort (vec, count, sizeof (vec[0]), sort_func); + + /* Fill in the next pointers again. */ + *startptr = vec[0]; + for (i = 0; i < count - 1; i++) + vec[i]->header.next = vec[i + 1]; + vec[i]->header.next = next_after; + ret = &vec[i]->header.next; + free (vec); + return ret; +} + +/* Sort the .idata\$foo input sections of archives into filename order. + The reason is so dlltool can arrange to have the pe dll import information + generated correctly - the head of the list goes into dh.o, the tail into + dt.o, and the guts into ds[nnnn].o. Note that this is only needed for the + .idata section. + FIXME: This may no longer be necessary with grouped sections. Instead of + sorting on dh.o, ds[nnnn].o, dt.o, one could, for example, have dh.o use + .idata\$4h, have ds[nnnn].o use .idata\$4s[nnnn], and have dt.o use .idata\$4t. + This would have to be elaborated upon to handle multiple dll's + [assuming such an eloboration is possible of course]. + + We also sort sections in '\$' wild statements. These are created by the + place_orphans routine to implement grouped sections. */ + +static void +sort_sections (s) + lang_statement_union_type *s; +{ + for (; s ; s = s->next) + switch (s->header.type) + { + case lang_output_section_statement_enum: + sort_sections (s->output_section_statement.children.head); + break; + case lang_wild_statement_enum: + { + lang_statement_union_type **p = &s->wild_statement.children.head; + + /* Is this the .idata section? */ + if (s->wild_statement.section_name != NULL + && strncmp (s->wild_statement.section_name, ".idata", 6) == 0) + { + /* Sort the children. We want to sort any objects in + the same archive. In order to handle the case of + including a single archive multiple times, we sort + all the children by archive name and then by object + name. After sorting them, we re-thread the pointer + chain. */ + + while (*p) + { + lang_statement_union_type *start = *p; + if (start->header.type != lang_input_section_enum + || !start->input_section.ifile->the_bfd->my_archive) + p = &(start->header.next); + else + { + lang_statement_union_type *end; + int count; + + for (end = start, count = 0; + end && end->header.type == lang_input_section_enum; + end = end->next) + count++; + + p = sort_sections_1 (p, end, count, sort_by_file_name); + } + } + break; + } + + /* If this is a collection of grouped sections, sort them. + The linker script must explicitly mention "*(.foo\$)". + Don't sort them if \$ is not the last character (not sure if + this is really useful, but it allows explicitly mentioning + some \$ sections and letting the linker handle the rest). */ + if (s->wild_statement.section_name != NULL) + { + char *q = strchr (s->wild_statement.section_name, '\$'); + + if (q && q[1] == 0) + { + lang_statement_union_type *end; + int count; + + for (end = *p, count = 0; end; end = end->next) + { + if (end->header.type != lang_input_section_enum) + abort (); + count++; + } + (void) sort_sections_1 (p, end, count, sort_by_section_name); + } + break; + } + } + break; + default: + break; + } +} + +static void +gld_${EMULATION_NAME}_before_allocation() +{ + extern lang_statement_list_type *stat_ptr; + +#ifdef TARGET_IS_ppcpe + /* Here we rummage through the found bfds to collect toc information */ + { + LANG_FOR_EACH_INPUT_STATEMENT (is) + { + if (!ppc_process_before_allocation(is->the_bfd, &link_info)) + { + einfo("Errors encountered processing file %s", is->filename); + } + } + } + + /* We have seen it all. Allocate it, and carry on */ + ppc_allocate_toc_section (&link_info); +#endif + + sort_sections (stat_ptr->head); +} + +/* Place an orphan section. We use this to put sections with a '\$' in them + into the right place. Any section with a '\$' in them (e.g. .text\$foo) + gets mapped to the output section with everything from the '\$' on stripped + (e.g. .text). + See the Microsoft Portable Executable and Common Object File Format + Specification 4.1, section 4.2, Grouped Sections. */ + +/*ARGSUSED*/ +static boolean +gld${EMULATION_NAME}_place_orphan (file, s) + lang_input_statement_type *file; + asection *s; +{ + const char *secname; + char *output_secname, *ps; + lang_output_section_statement_type *os; + lang_statement_union_type *l; + + if ((s->flags & SEC_ALLOC) == 0) + return false; + + /* Don't process grouped sections unless doing a final link. + If they're marked as COMDAT sections, we don't want .text\$foo to + end up in .text and then have .text disappear because it's marked + link-once-discard. */ + if (link_info.relocateable) + return false; + + secname = bfd_get_section_name (s->owner, s); + + /* Everything from the '\$' on gets deleted so don't allow '\$' as the + first character. */ + if (*secname == '\$') + einfo ("%P%F: section %s has '\$' as first character\n", secname); + if (strchr (secname + 1, '\$') == NULL) + return false; + + /* Look up the output section. The Microsoft specs say sections names in + image files never contain a '\$'. Fortunately, lang_..._lookup creates + the section if it doesn't exist. */ + output_secname = buystring (secname); + ps = strchr (output_secname + 1, '\$'); + *ps = 0; + os = lang_output_section_statement_lookup (output_secname); + + /* Find the '\$' wild statement for this section. We currently require the + linker script to explicitly mention "*(.foo\$)". + FIXME: ppcpe.sc has .CRT\$foo in the .rdata section. According to the + Microsoft docs this isn't correct so it's not (currently) handled. */ + + ps[0] = '\$'; + ps[1] = 0; + for (l = os->children.head; l; l = l->next) + { + if (l->header.type == lang_wild_statement_enum + && strcmp (l->wild_statement.section_name, output_secname) == 0) + break; + } + ps[0] = 0; + if (l == NULL) +#if 1 + einfo ("%P%F: *(%s\$) missing from linker script\n", output_secname); +#else /* FIXME: This block is untried. It exists to convey the intent, + should one decide to not require *(.foo\$) to appear in the linker + script. */ + { + lang_wild_statement_type *new = new_stat (lang_wild_statement, + &os->children); + new->section_name = xmalloc (strlen (output_secname) + 2); + sprintf (new->section_name, "%s\$", output_secname); + new->filename = NULL; + lang_list_init (&new->children); + l = new; + } +#endif + + /* Link the input section in and we're done for now. + The sections still have to be sorted, but that has to wait until + all such sections have been processed by us. The sorting is done by + sort_sections. */ + wild_doit (&l->wild_statement.children, s, os, file); + + return true; +} + +static char * +gld_${EMULATION_NAME}_get_script(isfile) + int *isfile; +EOF +# Scripts compiled in. +# sed commands to quote an ld script as a C string. +sc="-f ${srcdir}/emultempl/stringify.sed" + +cat >>e${EMULATION_NAME}.c <<EOF +{ + *isfile = 0; + + if (link_info.relocateable == true && config.build_constructors == true) + return +EOF +sed $sc ldscripts/${EMULATION_NAME}.xu >> e${EMULATION_NAME}.c +echo ' ; else if (link_info.relocateable == true) 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 +echo ' ; else if (!config.magic_demand_paged) return' >> e${EMULATION_NAME}.c +sed $sc ldscripts/${EMULATION_NAME}.xn >> e${EMULATION_NAME}.c +echo ' ; else return' >> e${EMULATION_NAME}.c +sed $sc ldscripts/${EMULATION_NAME}.x >> e${EMULATION_NAME}.c +echo '; }' >> e${EMULATION_NAME}.c + +cat >>e${EMULATION_NAME}.c <<EOF + + +struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = +{ + gld_${EMULATION_NAME}_before_parse, + syslib_default, + hll_default, + after_parse_default, + gld_${EMULATION_NAME}_after_open, + after_allocation_default, + set_output_arch_default, + ldemul_default_target, + gld_${EMULATION_NAME}_before_allocation, + gld_${EMULATION_NAME}_get_script, + "${EMULATION_NAME}", + "${OUTPUT_FORMAT}", + NULL, /* finish */ + NULL, /* create output section statements */ + NULL, /* open dynamic archive */ + gld${EMULATION_NAME}_place_orphan, + gld_${EMULATION_NAME}_set_symbols, + gld_${EMULATION_NAME}_parse_args +}; +EOF diff --git a/contrib/binutils/ld/emultempl/stringify.sed b/contrib/binutils/ld/emultempl/stringify.sed new file mode 100644 index 0000000..a526d3f --- /dev/null +++ b/contrib/binutils/ld/emultempl/stringify.sed @@ -0,0 +1,4 @@ +s/["\\]/\\&/g +s/$/\\n\\/ +1 s/^/"/ +$ s/$/n"/ diff --git a/contrib/binutils/ld/emultempl/vanilla.em b/contrib/binutils/ld/emultempl/vanilla.em new file mode 100644 index 0000000..04e36fb --- /dev/null +++ b/contrib/binutils/ld/emultempl/vanilla.em @@ -0,0 +1,69 @@ +# This shell script emits a C file. -*- C -*- +# It does some substitutions. +cat >e${EMULATION_NAME}.c <<EOF +/* A vanilla emulation with no defaults + Copyright (C) 1991, 1993 Free Software Foundation, Inc. + Written by Steve Chamberlain steve@cygnus.com + +This file is part of GLD, the Gnu Linker. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" + + +#include "ld.h" +#include "ldemul.h" +#include "ldfile.h" +#include "ldmisc.h" +#include "ldmain.h" + +static void vanilla_before_parse() +{ +} + +static void +vanilla_set_output_arch() +{ + /* Set the output architecture and machine if possible */ + unsigned long machine = 0; + bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine); +} + +static char * +vanilla_get_script(isfile) + int *isfile; +{ + *isfile = 0; + return ""; +} + +struct ld_emulation_xfer_struct ld_vanilla_emulation = +{ + vanilla_before_parse, + syslib_default, + hll_default, + after_parse_default, + after_open_default, + after_allocation_default, + vanilla_set_output_arch, + ldemul_default_target, + before_allocation_default, + vanilla_get_script, + "vanilla", + "a.out-sunos-big" +}; +EOF diff --git a/contrib/binutils/ld/gen-doc.texi b/contrib/binutils/ld/gen-doc.texi new file mode 100644 index 0000000..3a36727 --- /dev/null +++ b/contrib/binutils/ld/gen-doc.texi @@ -0,0 +1,13 @@ +@c ------------------------------ CONFIGURATION VARS: +@c 1. Inclusiveness of this manual +@set GENERIC + +@c 2. Specific target machines +@set H8300 +@set I960 + +@c 3. Properties of this configuration +@clear SingleFormat +@set UsesEnvVars +@c ------------------------------ end CONFIGURATION VARS + diff --git a/contrib/binutils/ld/genscripts.sh b/contrib/binutils/ld/genscripts.sh new file mode 100755 index 0000000..eea5401 --- /dev/null +++ b/contrib/binutils/ld/genscripts.sh @@ -0,0 +1,133 @@ +#!/bin/sh +# genscripts.sh - generate the ld-emulation-target specific files +# +# Usage: genscripts.sh srcdir libdir host target target_alias \ +# default_emulation native_lib_dirs this_emulation tool_dir +# +# Sample usage: +# genscripts.sh /djm/ld-devo/devo/ld /usr/local/lib sparc-sun-sunos4.1.3 \ +# sparc-sun-sunos4.1.3 sparc-sun-sunos4.1.3 sun4 "" sun3 sparc-sun-sunos4.1.3 +# produces sun3.x sun3.xbn sun3.xn sun3.xr sun3.xu em_sun3.c + +srcdir=$1 +libdir=$2 +host=$3 +target=$4 +target_alias=$5 +DEFAULT_EMULATION=$6 +NATIVE_LIB_DIRS=$7 +EMULATION_NAME=$8 +tool_lib=`echo ${libdir} | sed -e 's|/lib$||'`/${9-$target_alias}/lib + +# Include the emulation-specific parameters: +. ${srcdir}/emulparams/${EMULATION_NAME}.sh + +if test -d ldscripts; then + true +else + mkdir ldscripts +fi + +# Set the library search path, for libraries named by -lfoo. +# If LIB_PATH is defined (e.g., by Makefile) and non-empty, it is used. +# Otherwise, the default is set here. +# +# The format is the usual list of colon-separated directories. +# To force a logically empty LIB_PATH, do LIBPATH=":". + +if [ "x${LIB_PATH}" = "x" ] ; then + if [ "x${host}" = "x${target}" ] ; then + if [ "x${DEFAULT_EMULATION}" = "x${EMULATION_NAME}" ] ; then + # Native. + LIB_PATH=/lib:/usr/lib + if [ -n "${NATIVE_LIB_DIRS}" ]; then + LIB_PATH=${LIB_PATH}:${NATIVE_LIB_DIRS} + fi + if [ "${libdir}" != /usr/lib ]; then + LIB_PATH=${LIB_PATH}:${libdir} + fi + if [ "${libdir}" != /usr/local/lib ] ; then + LIB_PATH=${LIB_PATH}:/usr/local/lib + fi + else + # Native, but not default emulation. + LIB_PATH= + fi + else + # Cross. + LIB_PATH= + fi +fi + +# Always search $(tooldir)/lib, aka /usr/local/TARGET/lib. +LIB_PATH=${LIB_PATH}:${tool_lib} + +LIB_SEARCH_DIRS=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'` + +# Generate 5 or 6 script files from a master script template in +# ${srcdir}/scripttempl/${SCRIPT_NAME}.sh. Which one of the 5 or 6 +# script files is actually used depends on command line options given +# to ld. (SCRIPT_NAME was set in the emulparams_file.) +# +# A .x script file is the default script. +# A .xr script is for linking without relocation (-r flag). +# A .xu script is like .xr, but *do* create constructors (-Ur flag). +# A .xn script is for linking with -n flag (mix text and data on same page). +# A .xbn script is for linking with -N flag (mix text and data on same page). +# A .xs script is for generating a shared library with the --shared +# flag; it is only generated if $GENERATE_SHLIB_SCRIPT is set by the +# emulation parameters. + +SEGMENT_SIZE=${SEGMENT_SIZE-${TARGET_PAGE_SIZE}} + +# Determine DATA_ALIGNMENT for the 5 variants, using +# values specified in the emulparams/<emulation>.sh file or default. + +DATA_ALIGNMENT_="${DATA_ALIGNMENT_-${DATA_ALIGNMENT-ALIGN(${SEGMENT_SIZE})}}" +DATA_ALIGNMENT_n="${DATA_ALIGNMENT_n-${DATA_ALIGNMENT_}}" +DATA_ALIGNMENT_N="${DATA_ALIGNMENT_N-${DATA_ALIGNMENT-.}}" +DATA_ALIGNMENT_r="${DATA_ALIGNMENT_r-${DATA_ALIGNMENT-}}" +DATA_ALIGNMENT_u="${DATA_ALIGNMENT_u-${DATA_ALIGNMENT_r}}" + +LD_FLAG=r +DATA_ALIGNMENT=${DATA_ALIGNMENT_r} +DEFAULT_DATA_ALIGNMENT="ALIGN(${SEGMENT_SIZE})" +(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ + ldscripts/${EMULATION_NAME}.xr + +LD_FLAG=u +DATA_ALIGNMENT=${DATA_ALIGNMENT_u} +CONSTRUCTING=" " +(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ + ldscripts/${EMULATION_NAME}.xu + +LD_FLAG= +DATA_ALIGNMENT=${DATA_ALIGNMENT_} +RELOCATING=" " +(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ + ldscripts/${EMULATION_NAME}.x + +LD_FLAG=n +DATA_ALIGNMENT=${DATA_ALIGNMENT_n} +TEXT_START_ADDR=${NONPAGED_TEXT_START_ADDR-${TEXT_START_ADDR}} +(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ + ldscripts/${EMULATION_NAME}.xn + +LD_FLAG=N +DATA_ALIGNMENT=${DATA_ALIGNMENT_N} +(. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ + ldscripts/${EMULATION_NAME}.xbn + +if test -n "$GENERATE_SHLIB_SCRIPT"; then + LD_FLAG=shared + DATA_ALIGNMENT=${DATA_ALIGNMENT_s-${DATA_ALIGNMENT_}} + CREATE_SHLIB=" " + # Note that TEXT_START_ADDR is set to NONPAGED_TEXT_START_ADDR. + (. ${srcdir}/scripttempl/${SCRIPT_NAME}.sc) | sed -e '/^ *$/d' > \ + ldscripts/${EMULATION_NAME}.xs +fi + +test "$DEFAULT_EMULATION" = "$EMULATION_NAME" && COMPILE_IN=true + +# Generate e${EMULATION_NAME}.c. +. ${srcdir}/emultempl/${TEMPLATE_NAME-generic}.em diff --git a/contrib/binutils/ld/h8-doc.texi b/contrib/binutils/ld/h8-doc.texi new file mode 100644 index 0000000..f3c62a1 --- /dev/null +++ b/contrib/binutils/ld/h8-doc.texi @@ -0,0 +1,14 @@ +@c ------------------------------ CONFIGURATION VARS: +@c 1. Inclusiveness of this manual +@clear GENERIC + +@c 2. Specific target machines +@set H8300 +@set Hitachi +@clear I960 + +@c 3. Properties of this configuration +@set SingleFormat +@clear UsesEnvVars +@c ------------------------------ end CONFIGURATION VARS + diff --git a/contrib/binutils/ld/ld.1 b/contrib/binutils/ld/ld.1 new file mode 100644 index 0000000..610f046 --- /dev/null +++ b/contrib/binutils/ld/ld.1 @@ -0,0 +1,1072 @@ +.\" Copyright (c) 1991, 92, 93, 94, 95, 1996 Free Software Foundation +.\" See section COPYING for conditions for redistribution +.TH ld 1 "17 August 1992" "cygnus support" "GNU Development Tools" +.de BP +.sp +.ti \-.2i +\(** +.. + +.SH NAME +ld \- the GNU linker + +.SH SYNOPSIS +.hy 0 +.na +.TP +.B ld +.RB "[\|" \-o " +.I output\c +\&\|] \c +.I objfile\c +\&.\|.\|. +.br +.RB "[\|" \-A\c +.I architecture\c +\&\|] +.RB "[\|" "\-b\ "\c +.I input-format\c +\&\|] +.RB "[\|" \-Bstatic "\|]" +.RB "[\|" \-Bdynamic "\|]" +.RB "[\|" \-Bsymbolic "\|]" +.RB "[\|" "\-c\ "\c +.I commandfile\c +\&\|] +.RB "[\|" \-\-cref "\|]" +.RB "[\|" \-d | \-dc | \-dp\c +\|] +.br +.RB "[\|" "\-defsym\ "\c +.I symbol\c +\& = \c +.I expression\c +\&\|] +.RB "[\|" "\-e\ "\c +.I entry\c +\&\|] +.RB "[\|" \-embedded\-relocs "\|]" +.RB "[\|" \-E "\|]" +.RB "[\|" \-export\-dynamic "\|]" +.RB "[\|" "\-f\ "\c +.I name\c +\&\|] +.RB "[\|" "\-\-auxiliary\ "\c +.I name\c +\&\|] +.RB "[\|" "\-F\ "\c +.I name\c +\&\|] +.RB "[\|" "\-\-filter\ "\c +.I name\c +\&\|] +.RB "[\|" "\-format\ "\c +.I input-format\c +\&\|] +.RB "[\|" \-g "\|]" +.RB "[\|" \-G +.I size\c +\&\|] +.RB "[\|" "\-h\ "\c +.I name\c +\&\|] +.RB "[\|" "\-soname\ "\c +.I name\c +\&\|] +.RB "[\|" \-\-help "\|]" +.RB "[\|" \-i "\|]" +.RB "[\|" \-l\c +.I ar\c +\&\|] +.RB "[\|" \-L\c +.I searchdir\c +\&\|] +.RB "[\|" \-M "\|]" +.RB "[\|" \-Map +.I mapfile\c +\&\|] +.RB "[\|" \-m +.I emulation\c +\&\|] +.RB "[\|" \-n | \-N "\|]" +.RB "[\|" \-noinhibit-exec "\|]" +.RB "[\|" \-no\-keep\-memory "\|]" +.RB "[\|" "\-oformat\ "\c +.I output-format\c +\&\|] +.RB "[\|" "\-R\ "\c +.I filename\c +\&\|] +.RB "[\|" \-relax "\|]" +.RB "[\|" \-r | \-Ur "\|]" +.RB "[\|" "\-rpath\ "\c +.I directory\c +\&\|] +.RB "[\|" "\-rpath\-link\ "\c +.I directory\c +\&\|] +.RB "[\|" \-S "\|]" +.RB "[\|" \-s "\|]" +.RB "[\|" \-shared "\|]" +.RB "[\|" \-sort\-common "\|]" +.RB "[\|" "\-split\-by\-reloc\ "\c +.I count\c +\&\|] +.RB "[\|" \-split\-by\-file "\|]" +.RB "[\|" "\-T\ "\c +.I commandfile\c +\&\|] +.RB "[\|" "\-Ttext\ "\c +.I textorg\c +\&\|] +.RB "[\|" "\-Tdata\ "\c +.I dataorg\c +\&\|] +.RB "[\|" "\-Tbss\ "\c +.I bssorg\c +\&\|] +.RB "[\|" \-t "\|]" +.RB "[\|" "\-u\ "\c +.I sym\c +\&] +.RB "[\|" \-V "\|]" +.RB "[\|" \-v "\|]" +.RB "[\|" \-\-verbose "\|]" +.RB "[\|" \-\-version "\|]" +.RB "[\|" \-warn\-common "\|]" +.RB "[\|" \-warn\-constructors "\|]" +.RB "[\|" \-warn\-multiple\-gp "\|]" +.RB "[\|" \-warn\-once "\|]" +.RB "[\|" \-warn\-section\-align "\|]" +.RB "[\|" \-\-whole\-archive "\|]" +.RB "[\|" \-\-no\-whole\-archive "\|]" +.RB "[\|" "\-\-wrap\ "\c +.I symbol\c +\&\|] +.RB "[\|" \-X "\|]" +.RB "[\|" \-x "\|]" +.ad b +.hy 1 +.SH DESCRIPTION +\c +.B ld\c +\& combines a number of object and archive files, relocates +their data and ties up symbol references. Often the last step in +building a new compiled program to run is a call to \c +.B ld\c +\&. + +\c +.B ld\c +\& accepts Linker Command Language files +to provide explicit and total control over the linking process. +This man page does not describe the command language; see the `\|\c +.B ld\c +\|' entry in `\|\c +.B info\c +\|', or the manual +.I +ld: the GNU linker +\&, for full details on the command language and on other aspects of +the GNU linker. + +This version of \c +.B ld\c +\& uses the general purpose BFD libraries +to operate on object files. This allows \c +.B ld\c +\& to read, combine, and +write object files in many different formats\(em\&for example, COFF or +\c +.B a.out\c +\&. Different formats may be linked together to produce any +available kind of object file. You can use `\|\c +.B objdump \-i\c +\|' to get a list of formats supported on various architectures; see +.BR objdump ( 1 ). + +Aside from its flexibility, the GNU linker is more helpful than other +linkers in providing diagnostic information. Many linkers abandon +execution immediately upon encountering an error; whenever possible, +\c +.B ld\c +\& continues executing, allowing you to identify other errors +(or, in some cases, to get an output file in spite of the error). + +The GNU linker \c +.B ld\c +\& is meant to cover a broad range of situations, +and to be as compatible as possible with other linkers. As a result, +you have many choices to control its behavior through the command line, +and through environment variables. + +.SH OPTIONS +The plethora of command-line options may seem intimidating, but in +actual practice few of them are used in any particular context. +For instance, a frequent use of \c +.B ld\c +\& is to link standard Unix +object files on a standard, supported Unix system. On such a system, to +link a file \c +.B hello.o\c +\&: +.sp +.br +$\ ld\ \-o\ output\ /lib/crt0.o\ hello.o\ \-lc +.br +.sp +This tells \c +.B ld\c +\& to produce a file called \c +.B output\c +\& as the +result of linking the file \c +.B /lib/crt0.o\c +\& with \c +.B hello.o\c +\& and +the library \c +.B libc.a\c +\& which will come from the standard search +directories. + +The command-line options to \c +.B ld\c +\& may be specified in any order, and +may be repeated at will. For the most part, repeating an option with a +different argument will either have no further effect, or override prior +occurrences (those further to the left on the command line) of an +option. + +The exceptions\(em\&which may meaningfully be used more than once\(em\&are +\c +.B \-A\c +\&, \c +.B \-b\c +\& (or its synonym \c +.B \-format\c +\&), \c +.B \-defsym\c +\&, +\c +.B \-L\c +\&, \c +.B \-l\c +\&, \c +.B \-R\c +\&, and \c +.B \-u\c +\&. + +The list of object files to be linked together, shown as \c +.I objfile\c +\&, +may follow, precede, or be mixed in with command-line options; save that +an \c +.I objfile\c +\& argument may not be placed between an option flag and +its argument. + +Usually the linker is invoked with at least one object file, but other +forms of binary input files can also be specified with \c +.B \-l\c +\&, +\c +.B \-R\c +\&, and the script command language. If \c +.I no\c +\& binary input +files at all are specified, the linker does not produce any output, and +issues the message `\|\c +.B No input files\c +\|'. + +Option arguments must either follow the option letter without intervening +whitespace, or be given as separate arguments immediately following the +option that requires them. + +.TP +.BI "-A" "architecture" +In the current release of \c +.B ld\c +\&, this option is useful only for the +Intel 960 family of architectures. In that \c +.B ld\c +\& configuration, the +\c +.I architecture\c +\& argument is one of the two-letter names identifying +members of the 960 family; the option specifies the desired output +target, and warns of any incompatible instructions in the input files. +It also modifies the linker's search strategy for archive libraries, to +support the use of libraries specific to each particular +architecture, by including in the search loop names suffixed with the +string identifying the architecture. + +For example, if your \c +.B ld\c +\& command line included `\|\c +.B \-ACA\c +\|' as +well as `\|\c +.B \-ltry\c +\|', the linker would look (in its built-in search +paths, and in any paths you specify with \c +.B \-L\c +\&) for a library with +the names +.sp +.br +try +.br +libtry.a +.br +tryca +.br +libtryca.a +.br +.sp + +The first two possibilities would be considered in any event; the last +two are due to the use of `\|\c +.B \-ACA\c +\|'. + +Future releases of \c +.B ld\c +\& may support similar functionality for +other architecture families. + +You can meaningfully use \c +.B \-A\c +\& more than once on a command line, if +an architecture family allows combination of target architectures; each +use will add another pair of name variants to search for when \c +.B \-l +specifies a library. + +.TP +.BI "\-b " "input-format" +Specify the binary format for input object files that follow this option +on the command line. You don't usually need to specify this, as +\c +.B ld\c +\& is configured to expect as a default input format the most +usual format on each machine. \c +.I input-format\c +\& is a text string, the +name of a particular format supported by the BFD libraries. +\c +.B \-format \c +.I input-format\c +\&\c +\& has the same effect, as does the script command +.BR TARGET . + +You may want to use this option if you are linking files with an unusual +binary format. You can also use \c +.B \-b\c +\& to switch formats explicitly (when +linking object files of different formats), by including +\c +.B \-b \c +.I input-format\c +\&\c +\& before each group of object files in a +particular format. + +The default format is taken from the environment variable +.B GNUTARGET\c +\&. You can also define the input +format from a script, using the command \c +.B TARGET\c +\&. + +.TP +.B \-Bstatic +Do not link against shared libraries. This is only meaningful on +platforms for which shared libraries are supported. + +.TP +.B \-Bdynamic +Link against dynamic libraries. This is only meaningful on platforms +for which shared libraries are supported. This option is normally the +default on such platforms. + +.TP +.B \-Bsymbolic +When creating a shared library, bind references to global symbols to +the definition within the shared library, if any. Normally, it is +possible for a program linked against a shared library to override the +definition within the shared library. This option is only meaningful +on ELF platforms which support shared libraries. + +.TP +.BI "\-c " "commandfile" +Directs \c +.B ld\c +\& to read link commands from the file +\c +.I commandfile\c +\&. These commands will completely override \c +.B ld\c +\&'s +default link format (rather than adding to it); \c +.I commandfile\c +\& must +specify everything necessary to describe the target format. + + +You may also include a script of link commands directly in the command +line by bracketing it between `\|\c +.B {\c +\|' and `\|\c +.B }\c +\|' characters. + +.TP +.B \-\-cref +Output a cross reference table. If a linker map file is being +generated, the cross reference table is printed to the map file. +Otherwise, it is printed on the standard output. + +.TP +.B \-d +.TP +.B \-dc +.TP +.B \-dp +These three options are equivalent; multiple forms are supported for +compatibility with other linkers. Use any of them to make \c +.B ld +assign space to common symbols even if a relocatable output file is +specified (\c +.B \-r\c +\&). The script command +\c +.B FORCE_COMMON_ALLOCATION\c +\& has the same effect. + +.TP +.BI "-defsym " "symbol" "\fR = \fP" expression +Create a global symbol in the output file, containing the absolute +address given by \c +.I expression\c +\&. You may use this option as many +times as necessary to define multiple symbols in the command line. A +limited form of arithmetic is supported for the \c +.I expression\c +\& in this +context: you may give a hexadecimal constant or the name of an existing +symbol, or use \c +.B +\c +\& and \c +.B \-\c +\& to add or subtract hexadecimal +constants or symbols. If you need more elaborate expressions, consider +using the linker command language from a script. + +.TP +.BI "-e " "entry"\c +\& +Use \c +.I entry\c +\& as the explicit symbol for beginning execution of your +program, rather than the default entry point. for a +discussion of defaults and other ways of specifying the +entry point. + +.TP +.B \-embedded\-relocs +This option is only meaningful when linking MIPS embedded PIC code, +generated by the +.B \-membedded\-pic +option to the GNU compiler and assembler. It causes the linker to +create a table which may be used at runtime to relocate any data which +was statically initialized to pointer values. See the code in +testsuite/ld-empic for details. + +.TP +.B \-E +.TP +.B \-export\-dynamic +When creating an ELF file, add all symbols to the dynamic symbol table. +Normally, the dynamic symbol table contains only symbols which are used +by a dynamic object. This option is needed for some uses of +.I dlopen. + +.TP +.BI "-f " "name" +.TP +.BI "--auxiliary " "name" +When creating an ELF shared object, set the internal DT_AUXILIARY field +to the specified name. This tells the dynamic linker that the symbol +table of the shared object should be used as an auxiliary filter on the +symbol table of the shared object +.I name. + +.TP +.BI "-F " "name" +.TP +.BI "--filter " "name" +When creating an ELF shared object, set the internal DT_FILTER field to +the specified name. This tells the dynamic linker that the symbol table +of the shared object should be used as a filter on the symbol table of +the shared object +.I name. + +.TP +.BI "\-format " "input\-format" +Synonym for \c +.B \-b\c +\& \c +.I input\-format\c +\&. + +.TP +.B \-g +Accepted, but ignored; provided for compatibility with other tools. + +.TP +.BI "\-G " "size"\c +Set the maximum size of objects to be optimized using the GP register +to +.I size +under MIPS ECOFF. Ignored for other object file formats. + +.TP +.BI "-h " "name" +.TP +.BI "-soname " "name" +When creating an ELF shared object, set the internal DT_SONAME field to +the specified name. When an executable is linked with a shared object +which has a DT_SONAME field, then when the executable is run the dynamic +linker will attempt to load the shared object specified by the DT_SONAME +field rather than the using the file name given to the linker. + +.TP +.B \-\-help +Print a summary of the command-line options on the standard output and exit. +This option and +.B \-\-version +begin with two dashes instead of one +for compatibility with other GNU programs. The other options start with +only one dash for compatibility with other linkers. + +.TP +.B \-i +Perform an incremental link (same as option \c +.B \-r\c +\&). + +.TP +.BI "\-l" "ar"\c +\& +Add an archive file \c +.I ar\c +\& to the list of files to link. This +option may be used any number of times. \c +.B ld\c +\& will search its +path-list for occurrences of \c +.B lib\c +.I ar\c +\&.a\c +\& for every \c +.I ar +specified. + +.TP +.BI "\-L" "searchdir" +This command adds path \c +.I searchdir\c +\& to the list of paths that +\c +.B ld\c +\& will search for archive libraries. You may use this option +any number of times. + +The default set of paths searched (without being specified with +\c +.B \-L\c +\&) depends on what emulation mode \c +.B ld\c +\& is using, and in +some cases also on how it was configured. The +paths can also be specified in a link script with the \c +.B SEARCH_DIR +command. + +.TP +.B \-M +Print (to the standard output file) a link map\(em\&diagnostic information +about where symbols are mapped by \c +.B ld\c +\&, and information on global +common storage allocation. + +.TP +.BI "\-Map " "mapfile"\c +Print to the file +.I mapfile +a link map\(em\&diagnostic information +about where symbols are mapped by \c +.B ld\c +\&, and information on global +common storage allocation. + +.TP +.BI "\-m " "emulation"\c +Emulate the +.I emulation +linker. You can list the available emulations with the +.I \-\-verbose +or +.I \-V +options. This option overrides the compiled-in default, which is the +system for which you configured +.BR ld . + +.TP +.B \-N +specifies readable and writable \c +.B text\c +\& and \c +.B data\c +\& sections. If +the output format supports Unix style magic numbers, the output is +marked as \c +.B OMAGIC\c +\&. + +When you use the `\|\c +.B \-N\c +\&\|' option, the linker does not page-align the +data segment. + +.TP +.B \-n +sets the text segment to be read only, and \c +.B NMAGIC\c +\& is written +if possible. + +.TP +.B \-noinhibit\-exec +Normally, the linker will not produce an output file if it encounters +errors during the link process. With this flag, you can specify that +you wish the output file retained even after non-fatal errors. + +.TP +.B \-no\-keep\-memory +The linker normally optimizes for speed over memory usage by caching +the symbol tables of input files in memory. This option tells the +linker to instead optimize for memory usage, by rereading the symbol +tables as necessary. This may be required if the linker runs out of +memory space while linking a large executable. + +.TP +.BI "\-o " "output" +.I output\c +\& is a name for the program produced by \c +.B ld\c +\&; if this +option is not specified, the name `\|\c +.B a.out\c +\|' is used by default. The +script command \c +.B OUTPUT\c +\& can also specify the output file name. + +.TP +.BI "\-oformat " "output\-format" +Specify the binary format for the output object file. +You don't usually need to specify this, as +\c +.B ld\c +\& is configured to produce as a default output format the most +usual format on each machine. \c +.I output-format\c +\& is a text string, the +name of a particular format supported by the BFD libraries. +The script command +.B OUTPUT_FORMAT +can also specify the output format, but this option overrides it. + +.TP +.BI "\-R " "filename" +Read symbol names and their addresses from \c +.I filename\c +\&, but do not +relocate it or include it in the output. This allows your output file +to refer symbolically to absolute locations of memory defined in other +programs. + +.TP +.B \-relax +An option with machine dependent effects. Currently this option is only +supported on the H8/300. + +On some platforms, use this option to perform global optimizations that +become possible when the linker resolves addressing in your program, such +as relaxing address modes and synthesizing new instructions in the +output object file. + +On platforms where this is not supported, `\|\c +.B \-relax\c +\&\|' is accepted, but has no effect. + +.TP +.B \-r +Generates relocatable output\(em\&i.e., generate an output file that can in +turn serve as input to \c +.B ld\c +\&. This is often called \c +.I partial +linking\c +\&. As a side effect, in environments that support standard Unix +magic numbers, this option also sets the output file's magic number to +\c +.B OMAGIC\c +\&. +If this option is not specified, an absolute file is produced. When +linking C++ programs, this option \c +.I will not\c +\& resolve references to +constructors; \c +.B \-Ur\c +\& is an alternative. + +This option does the same as \c +.B \-i\c +\&. + +.TP +.B \-rpath\ \fIdirectory +Add a directory to the runtime library search path. This is used when +linking an ELF executable with shared objects. All +.B \-rpath +arguments are concatenated and passed to the runtime linker, which uses +them to locate shared objects at runtime. The +.B \-rpath +option is also used when locating shared objects which are needed by +shared objects explicitly included in the link; see the description of +the +.B \-rpath\-link +option. If +.B \-rpath +is not used when linking an ELF executable, the contents of the +environment variable +.B LD_RUN_PATH +will be used if it is defined. + +The +.B \-rpath +option may also be used on SunOS. By default, on SunOS, the linker +will form a runtime search patch out of all the +.B \-L +options it is given. If a +.B \-rpath +option is used, the runtime search path will be formed exclusively +using the +.B \-rpath +options, ignoring +the +.B \-L +options. This can be useful when using gcc, which adds many +.B \-L +options which may be on NFS mounted filesystems. + +.TP +.B \-rpath\-link\ \fIdirectory +When using ELF or SunOS, one shared library may require another. This +happens when an +.B ld\ \-shared +link includes a shared library as one of the input files. + +When the linker encounters such a dependency when doing a non-shared, +non-relocateable link, it will automatically try to locate the required +shared library and include it in the link, if it is not included +explicitly. In such a case, the +.B \-rpath\-link +option specifies the first set of directories to search. The +.B \-rpath\-link +option may specify a sequence of directory names either by specifying +a list of names separated by colons, or by appearing multiple times. + +If the required shared library is not found, the linker will issue a +warning and continue with the link. + +.TP +.B \-S +Omits debugger symbol information (but not all symbols) from the output file. + +.TP +.B \-s +Omits all symbol information from the output file. + +.TP +.B \-shared +Create a shared library. This is currently only supported on ELF and +SunOS platforms (on SunOS it is not required, as the linker will +automatically create a shared library when there are undefined symbols +and the +.B \-e +option is not used). + +.TP +.B \-sort\-common +Normally, when +.B ld +places the global common symbols in the appropriate output sections, +it sorts them by size. First come all the one byte symbols, then all +the two bytes, then all the four bytes, and then everything else. +This is to prevent gaps between symbols due to +alignment constraints. This option disables that sorting. + +.TP +.B \-split\-by\-reloc\ \fIcount +Trys to creates extra sections in the output file so that no single +output section in the file contains more than +.I count +relocations. +This is useful when generating huge relocatable for downloading into +certain real time kernels with the COFF object file format; since COFF +cannot represent more than 65535 relocations in a single section. +Note that this will fail to work with object file formats which do not +support arbitrary sections. The linker will not split up individual +input sections for redistribution, so if a single input section +contains more than +.I count +relocations one output section will contain that many relocations. + +.TP +.B \-split\-by\-file +Similar to +.B \-split\-by\-reloc +but creates a new output section for each input file. + +.TP +.BI "\-Tbss " "org"\c +.TP +.BI "\-Tdata " "org"\c +.TP +.BI "\-Ttext " "org"\c +Use \c +.I org\c +\& as the starting address for\(em\&respectively\(em\&the +\c +.B bss\c +\&, \c +.B data\c +\&, or the \c +.B text\c +\& segment of the output file. +\c +.I textorg\c +\& must be a hexadecimal integer. + +.TP +.BI "\-T " "commandfile" +Equivalent to \c +.B \-c \c +.I commandfile\c +\&\c +\&; supported for compatibility with +other tools. + +.TP +.B \-t +Prints names of input files as \c +.B ld\c +\& processes them. + +.TP +.BI "\-u " "sym" +Forces \c +.I sym\c +\& to be entered in the output file as an undefined symbol. +This may, for example, trigger linking of additional modules from +standard libraries. \c +.B \-u\c +\& may be repeated with different option +arguments to enter additional undefined symbols. + +.TP +.B \-Ur +For anything other than C++ programs, this option is equivalent to +\c +.B \-r\c +\&: it generates relocatable output\(em\&i.e., an output file that can in +turn serve as input to \c +.B ld\c +\&. When linking C++ programs, \c +.B \-Ur +.I will\c +\& resolve references to constructors, unlike \c +.B \-r\c +\&. + +.TP +.B \-\-verbose +Display the version number for \c +.B ld +and list the supported emulations. +Display which input files can and can not be opened. + +.TP +.B \-v, \-V +Display the version number for \c +.B ld\c +\&. +The +.B \-V +option also lists the supported emulations. + +.TP +.B \-\-version +Display the version number for \c +.B ld +and exit. + +.TP +.B \-warn\-common +Warn when a common symbol is combined with another common symbol or with +a symbol definition. Unix linkers allow this somewhat sloppy practice, +but linkers on some other operating systems do not. This option allows +you to find potential problems from combining global symbols. + +.TP +.B \-warn\-constructors +Warn if any global constructors are used. This is only useful for a +few object file formats. For formats like COFF or ELF, the linker can +not detect the use of global constructors. + +.TP +.B \-warn\-multiple\-gp +Warn if the output file requires multiple global-pointer values. This +option is only meaningful for certain processors, such as the Alpha. + +.TP +.B \-warn\-once +Only warn once for each undefined symbol, rather than once per module +which refers to it. + +.TP +.B \-warn\-section\-align +Warn if the address of an output section is changed because of +alignment. Typically, the alignment will be set by an input section. +The address will only be changed if it not explicitly specified; that +is, if the SECTIONS command does not specify a start address for the +section. + +.TP +.B \-\-whole\-archive +For each archive mentioned on the command line after the +.B \-\-whole\-archive +option, include every object file in the archive in the link, rather +than searching the archive for the required object files. This is +normally used to turn an archive file into a shared library, forcing +every object to be included in the resulting shared library. + +.TP +.B \-\-no\-whole\-archive +Turn off the effect of the +.B \-\-whole\-archive +option for archives which appear later on the command line. + +.TP +.BI "--wrap " "symbol" +Use a wrapper function for +.I symbol. +Any undefined reference to +.I symbol +will be resolved to +.BI "__wrap_" "symbol". +Any undefined reference to +.BI "__real_" "symbol" +will be resolved to +.I symbol. + +.TP +.B \-X +Delete all temporary local symbols. For most targets, this is all local +symbols whose names begin with `\|\c +.B L\c +\|'. + +.TP +.B \-x +Delete all local symbols. + +.PP + +.SH ENVIRONMENT +\c +You can change the behavior of +.B ld\c +\& with the environment variable \c +.B GNUTARGET\c +\&. + +\c +.B GNUTARGET\c +\& determines the input-file object format if you don't +use \c +.B \-b\c +\& (or its synonym \c +.B \-format\c +\&). Its value should be one +of the BFD names for an input format. If there is no +\c +.B GNUTARGET\c +\& in the environment, \c +.B ld\c +\& uses the natural format +of the host. If \c +.B GNUTARGET\c +\& is set to \c +.B default\c +\& then BFD attempts to discover the +input format by examining binary input files; this method often +succeeds, but there are potential ambiguities, since there is no method +of ensuring that the magic number used to flag object-file formats is +unique. However, the configuration procedure for BFD on each system +places the conventional format for that system first in the search-list, +so ambiguities are resolved in favor of convention. + +.PP + +.SH "SEE ALSO" + +.BR objdump ( 1 ) +.br +.br +.RB "`\|" ld "\|' and `\|" binutils "\|'" +entries in +.B info\c +.br +.I +ld: the GNU linker\c +, Steve Chamberlain and Roland Pesch; +.I +The GNU Binary Utilities\c +, Roland H. Pesch. + +.SH COPYING +Copyright (c) 1991, 1992 Free Software Foundation, Inc. +.PP +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. +.PP +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the +entire resulting derived work is distributed under the terms of a +permission notice identical to this one. +.PP +Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be included in +translations approved by the Free Software Foundation instead of in +the original English. diff --git a/contrib/binutils/ld/ld.h b/contrib/binutils/ld/ld.h new file mode 100644 index 0000000..d504a2e --- /dev/null +++ b/contrib/binutils/ld/ld.h @@ -0,0 +1,170 @@ +/* ld.h -- general linker header file + Copyright (C) 1991, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GLD; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#ifndef LD_H +#define LD_H + +/* Look in this environment name for the linker to pretend to be */ +#define EMULATION_ENVIRON "LDEMULATION" +/* If in there look for the strings: */ + +/* Look in this variable for a target format */ +#define TARGET_ENVIRON "GNUTARGET" + +/* Input sections which are put in a section of this name are actually + discarded. */ +#define DISCARD_SECTION_NAME "/DISCARD/" + +/* Extra information we hold on sections */ +typedef struct user_section_struct +{ + /* Pointer to the section where this data will go */ + struct lang_input_statement_struct *file; +} section_userdata_type; + + +#define get_userdata(x) ((x)->userdata) + +#define BYTE_SIZE (1) +#define SHORT_SIZE (2) +#define LONG_SIZE (4) +#define QUAD_SIZE (8) + +/* ALIGN macro changed to ALIGN_N to avoid */ +/* conflict in /usr/include/machine/machparam.h */ +/* WARNING: If THIS is a 64 bit address and BOUNDARY is a 32 bit int, + you must coerce boundary to the same type as THIS. + ??? Is there a portable way to avoid this. */ +#define ALIGN_N(this, boundary) \ + ((( (this) + ((boundary) -1)) & (~((boundary)-1)))) + +typedef struct +{ + /* 1 => assign space to common symbols even if `relocatable_output'. */ + boolean force_common_definition; + boolean relax; + + /* Name of runtime interpreter to invoke. */ + char *interpreter; + + /* Name to give runtime libary from the -soname argument. */ + char *soname; + + /* Runtime library search path from the -rpath argument. */ + char *rpath; + + /* Link time runtime library search path from the -rpath-link + argument. */ + char *rpath_link; + + /* Big or little endian as set on command line. */ + enum { ENDIAN_UNSET = 0, ENDIAN_BIG, ENDIAN_LITTLE } endian; + + /* If true, export all symbols in the dynamic symbol table of an ELF + executable. */ + boolean export_dynamic; + + /* If true, build MIPS embedded PIC relocation tables in the output + file. */ + boolean embedded_relocs; + + /* If true, force generation of a file with a .exe file. */ + boolean force_exe_suffix; + + /* If true, generate a cross reference report. */ + boolean cref; + + /* Name of shared object whose symbol table should be filtered with + this shared object. From the --filter option. */ + char *filter_shlib; + + /* Name of shared object for whose symbol table this shared object + is an auxiliary filter. From the --auxiliary option. */ + char **auxiliary_filters; +} args_type; + +extern args_type command_line; + +typedef int token_code_type; + +typedef struct +{ + bfd_size_type specified_data_size; + boolean magic_demand_paged; + boolean make_executable; + + /* If true, doing a dynamic link. */ + boolean dynamic_link; + + /* If true, build constructors. */ + boolean build_constructors; + + /* If true, warn about any constructors. */ + boolean warn_constructors; + + /* If true, warn about merging common symbols with others. */ + boolean warn_common; + + /* If true, only warn once about a particular undefined symbol. */ + boolean warn_once; + + /* If true, warn if multiple global-pointers are needed (Alpha + only). */ + boolean warn_multiple_gp; + + /* If true, warn if the starting address of an output section + changes due to the alignment of an input section. */ + boolean warn_section_align; + + boolean sort_common; + + boolean text_read_only; + + char *map_filename; + FILE *map_file; + + boolean stats; + + int split_by_reloc; + boolean split_by_file; +} ld_config_type; + +extern ld_config_type config; + +typedef enum +{ + lang_first_phase_enum, + lang_allocating_phase_enum, + lang_final_phase_enum +} lang_phase_type; + +extern boolean had_script; +extern boolean force_make_executable; + +/* Non-zero if we are processing a --defsym from the command line. */ +extern int parsing_defsym; + +extern int yyparse PARAMS ((void)); + +extern void add_cref PARAMS ((const char *, bfd *, asection *, bfd_vma)); +extern void output_cref PARAMS ((FILE *)); +extern void check_nocrossrefs PARAMS ((void)); + +#endif diff --git a/contrib/binutils/ld/ld.texinfo b/contrib/binutils/ld/ld.texinfo new file mode 100644 index 0000000..0a5d17a --- /dev/null +++ b/contrib/binutils/ld/ld.texinfo @@ -0,0 +1,3620 @@ +\input texinfo +@setfilename ld.info +@syncodeindex ky cp +@include configdoc.texi +@c (configdoc.texi is generated by the Makefile) + +@c @smallbook + +@ifinfo +@format +START-INFO-DIR-ENTRY +* Ld: (ld). The GNU linker. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@ifinfo +This file documents the @sc{gnu} linker LD. + +Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions. + +@ignore +Permission is granted to process this file through Tex and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +@end ifinfo +@iftex +@finalout +@setchapternewpage odd +@settitle Using LD, the GNU linker +@titlepage +@title Using ld +@subtitle The GNU linker +@sp 1 +@subtitle @code{ld} version 2 +@subtitle January 1994 +@author Steve Chamberlain +@author Cygnus Support +@page + +@tex +{\parskip=0pt +\hfill Cygnus Support\par +\hfill steve\@cygnus.com, doc\@cygnus.com\par +\hfill {\it Using LD, the GNU linker}\par +\hfill Edited by Jeffrey Osier (jeffrey\@cygnus.com)\par +} +\global\parindent=0pt % Steve likes it this way. +@end tex + +@vskip 0pt plus 1filll +Copyright @copyright{} 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided also that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions. +@end titlepage +@end iftex +@c FIXME: Talk about importance of *order* of args, cmds to linker! + +@ifinfo +@node Top +@top Using ld +This file documents the @sc{gnu} linker ld. + +@menu +* Overview:: Overview +* Invocation:: Invocation +* Commands:: Command Language +@ifset GENERIC +* Machine Dependent:: Machine Dependent Features +@end ifset +@ifclear GENERIC +@ifset H8300 +* H8/300:: ld and the H8/300 +@end ifset +@ifset Hitachi +* Hitachi:: ld and other Hitachi micros +@end ifset +@ifset I960 +* i960:: ld and the Intel 960 family +@end ifset +@end ifclear +@ifclear SingleFormat +* BFD:: BFD +@end ifclear +@c Following blank line required for remaining bug in makeinfo conds/menus + +* Reporting Bugs:: Reporting Bugs +* MRI:: MRI Compatible Script Files +* Index:: Index +@end menu +@end ifinfo + +@node Overview +@chapter Overview + +@cindex @sc{gnu} linker +@cindex what is this? +@code{ld} combines a number of object and archive files, relocates +their data and ties up symbol references. Usually the last step in +compiling a program is to run @code{ld}. + +@code{ld} accepts Linker Command Language files written in +a superset of AT&T's Link Editor Command Language syntax, +to provide explicit and total control over the linking process. + +@ifclear SingleFormat +This version of @code{ld} uses the general purpose BFD libraries +to operate on object files. This allows @code{ld} to read, combine, and +write object files in many different formats---for example, COFF or +@code{a.out}. Different formats may be linked together to produce any +available kind of object file. @xref{BFD}, for more information. +@end ifclear + +Aside from its flexibility, the @sc{gnu} linker is more helpful than other +linkers in providing diagnostic information. Many linkers abandon +execution immediately upon encountering an error; whenever possible, +@code{ld} continues executing, allowing you to identify other errors +(or, in some cases, to get an output file in spite of the error). + +@node Invocation +@chapter Invocation + +The @sc{gnu} linker @code{ld} is meant to cover a broad range of situations, +and to be as compatible as possible with other linkers. As a result, +you have many choices to control its behavior. + +@ifset UsesEnvVars +@menu +* Options:: Command Line Options +* Environment:: Environment Variables +@end menu + +@node Options +@section Command Line Options +@end ifset + +@cindex command line +@cindex options +The linker supports a plethora of command-line options, but in actual +practice few of them are used in any particular context. +@cindex standard Unix system +For instance, a frequent use of @code{ld} is to link standard Unix +object files on a standard, supported Unix system. On such a system, to +link a file @code{hello.o}: + +@smallexample +ld -o @var{output} /lib/crt0.o hello.o -lc +@end smallexample + +This tells @code{ld} to produce a file called @var{output} as the +result of linking the file @code{/lib/crt0.o} with @code{hello.o} and +the library @code{libc.a}, which will come from the standard search +directories. (See the discussion of the @samp{-l} option below.) + +The command-line options to @code{ld} may be specified in any order, and +may be repeated at will. Repeating most options with a different +argument will either have no further effect, or override prior +occurrences (those further to the left on the command line) of that +option. Options which may be meaningfully specified more than once are +noted in the descriptions below. + +@cindex object files +Non-option arguments are objects files which are to be linked together. +They may follow, precede, or be mixed in with command-line options, +except that an object file argument may not be placed between an option +and its argument. + +Usually the linker is invoked with at least one object file, but you can +specify other forms of binary input files using @samp{-l}, @samp{-R}, +and the script command language. If @emph{no} binary input files at all +are specified, the linker does not produce any output, and issues the +message @samp{No input files}. + +If the linker can not recognize the format of an object file, it will +assume that it is a linker script. A script specified in this way +augments the main linker script used for the link (either the default +linker script or the one specified by using @samp{-T}). This feature +permits the linker to link against a file which appears to be an object +or an archive, but actually merely defines some symbol values, or uses +@code{INPUT} or @code{GROUP} to load other objects. Note that +specifying a script in this way should only be used to augment the main +linker script; if you want to use some command that logically can only +appear once, such as the @code{SECTIONS} or @code{MEMORY} command, you +must replace the default linker script using the @samp{-T} option. +@xref{Commands}. + +For options whose names are a single letter, +option arguments must either follow the option letter without intervening +whitespace, or be given as separate arguments immediately following the +option that requires them. + +For options whose names are multiple letters, either one dash or two can +precede the option name; for example, @samp{--oformat} and +@samp{--oformat} are equivalent. Arguments to multiple-letter options +must either be separated from the option name by an equals sign, or be +given as separate arguments immediately following the option that +requires them. For example, @samp{--oformat srec} and +@samp{--oformat=srec} are equivalent. Unique abbreviations of the names +of multiple-letter options are accepted. + +@table @code +@kindex -a@var{keyword} +@item -a@var{keyword} +This option is supported for HP/UX compatibility. The @var{keyword} +argument must be one of the strings @samp{archive}, @samp{shared}, or +@samp{default}. @samp{-aarchive} is functionally equivalent to +@samp{-Bstatic}, and the other two keywords are functionally equivalent +to @samp{-Bdynamic}. This option may be used any number of times. + +@ifset I960 +@cindex architectures +@kindex -A@var{arch} +@item -A@var{architecture} +@kindex --architecture=@var{arch} +@itemx --architecture=@var{architecture} +In the current release of @code{ld}, this option is useful only for the +Intel 960 family of architectures. In that @code{ld} configuration, the +@var{architecture} argument identifies the particular architecture in +the 960 family, enabling some safeguards and modifying the +archive-library search path. @xref{i960,,@code{ld} and the Intel 960 +family}, for details. + +Future releases of @code{ld} may support similar functionality for +other architecture families. +@end ifset + +@ifclear SingleFormat +@cindex binary input format +@kindex -b @var{format} +@kindex --format=@var{format} +@cindex input format +@cindex input format +@item -b @var{input-format} +@itemx --format=@var{input-format} +@code{ld} may be configured to support more than one kind of object +file. If your @code{ld} is configured this way, you can use the +@samp{-b} option to specify the binary format for input object files +that follow this option on the command line. Even when @code{ld} is +configured to support alternative object formats, you don't usually need +to specify this, as @code{ld} should be configured to expect as a +default input format the most usual format on each machine. +@var{input-format} is a text string, the name of a particular format +supported by the BFD libraries. (You can list the available binary +formats with @samp{objdump -i}.) +@xref{BFD}. + +You may want to use this option if you are linking files with an unusual +binary format. You can also use @samp{-b} to switch formats explicitly (when +linking object files of different formats), by including +@samp{-b @var{input-format}} before each group of object files in a +particular format. + +The default format is taken from the environment variable +@code{GNUTARGET}. +@ifset UsesEnvVars +@xref{Environment}. +@end ifset +You can also define the input +format from a script, using the command @code{TARGET}; see @ref{Option +Commands}. +@end ifclear + +@kindex -c @var{MRI-cmdfile} +@kindex --mri-script=@var{MRI-cmdfile} +@cindex compatibility, MRI +@item -c @var{MRI-commandfile} +@itemx --mri-script=@var{MRI-commandfile} +For compatibility with linkers produced by MRI, @code{ld} accepts script +files written in an alternate, restricted command language, described in +@ref{MRI,,MRI Compatible Script Files}. Introduce MRI script files with +the option @samp{-c}; use the @samp{-T} option to run linker +scripts written in the general-purpose @code{ld} scripting language. +If @var{MRI-cmdfile} does not exist, @code{ld} looks for it in the directories +specified by any @samp{-L} options. + +@cindex common allocation +@kindex -d +@kindex -dc +@kindex -dp +@item -d +@itemx -dc +@itemx -dp +These three options are equivalent; multiple forms are supported for +compatibility with other linkers. They +assign space to common symbols even if a relocatable output file is +specified (with @samp{-r}). The script command +@code{FORCE_COMMON_ALLOCATION} has the same effect. @xref{Option +Commands}. + +@cindex entry point, from command line +@kindex -e @var{entry} +@kindex --entry=@var{entry} +@item -e @var{entry} +@itemx --entry=@var{entry} +Use @var{entry} as the explicit symbol for beginning execution of your +program, rather than the default entry point. @xref{Entry Point}, for a +discussion of defaults and other ways of specifying the +entry point. + +@cindex dynamic symbol table +@kindex -E +@kindex --export-dynamic +@item -E +@itemx --export-dynamic +When creating a dynamically linked executable, add all symbols to the +dynamic symbol table. Normally, the dynamic symbol table contains only +symbols which are used by a dynamic object. This option is needed for +some uses of @code{dlopen}. + +@kindex -f +@kindex --auxiliary +@item -f +@itemx --auxiliary @var{name} +When creating an ELF shared object, set the internal DT_AUXILIARY field +to the specified name. This tells the dynamic linker that the symbol +table of the shared object should be used as an auxiliary filter on the +symbol table of the shared object @var{name}. + +If you later link a program against this filter object, then, when you +run the program, the dynamic linker will see the DT_AUXILIARY field. If +the dynamic linker resolves any symbols from the filter object, it will +first check whether there is a definition in the shared object +@var{name}. If there is one, it will be used instead of the definition +in the filter object. The shared object @var{name} need not exist. +Thus the shared object @var{name} may be used to provide an alternative +implementation of certain functions, perhaps for debugging or for +machine specific performance. + +This option may be specified more than once. The DT_AUXILIARY entries +will be created in the order in which they appear on the command line. + +@kindex -F +@kindex --filter +@item -F @var{name} +@itemx --filter @var{name} +When creating an ELF shared object, set the internal DT_FILTER field to +the specified name. This tells the dynamic linker that the symbol table +of the shared object which is being created should be used as a filter +on the symbol table of the shared object @var{name}. + +If you later link a program against this filter object, then, when you +run the program, the dynamic linker will see the DT_FILTER field. The +dynamic linker will resolve symbols according to the symbol table of the +filter object as usual, but it will actually link to the definitions +found in the shared object @var{name}. Thus the filter object can be +used to select a subset of the symbols provided by the object +@var{name}. + +Some older linkers used the @code{-F} option throughout a compilation +toolchain for specifying object-file format for both input and output +object files. The @sc{gnu} linker uses other mechanisms for this +purpose: the @code{-b}, @code{--format}, @code{--oformat} options, the +@code{TARGET} command in linker scripts, and the @code{GNUTARGET} +environment variable. The @sc{gnu} linker will ignore the @code{-F} +option when not creating an ELF shared object. + +@kindex --force-exe-suffix +@item --force-exe-suffix +Make sure that an output file has a .exe suffix. + +If a successfully built fully linked output file does not have a +@code{.exe} or @code{.dll} suffix, this option forces the linker to copy +the output file to one of the same name with a @code{.exe} suffix. This +option is useful when using unmodified Unix makefiles on a Microsoft +Windows host, since some versions of Windows won't run an image unless +it ends in a @code{.exe} suffix. + +@kindex -g +@item -g +Ignored. Provided for compatibility with other tools. + +@kindex -G +@kindex --gpsize +@cindex object size +@item -G@var{value} +@itemx --gpsize=@var{value} +Set the maximum size of objects to be optimized using the GP register to +@var{size}. This is only meaningful for object file formats such as +MIPS ECOFF which supports putting large and small objects into different +sections. This is ignored for other object file formats. + +@cindex runtime library name +@kindex -h@var{name} +@kindex -soname=@var{name} +@item -h@var{name} +@itemx -soname=@var{name} +When creating an ELF shared object, set the internal DT_SONAME field to +the specified name. When an executable is linked with a shared object +which has a DT_SONAME field, then when the executable is run the dynamic +linker will attempt to load the shared object specified by the DT_SONAME +field rather than the using the file name given to the linker. + +@kindex -i +@cindex incremental link +@item -i +Perform an incremental link (same as option @samp{-r}). + +@cindex archive files, from cmd line +@kindex -l@var{archive} +@kindex --library=@var{archive} +@item -l@var{archive} +@itemx --library=@var{archive} +Add archive file @var{archive} to the list of files to link. This +option may be used any number of times. @code{ld} will search its +path-list for occurrences of @code{lib@var{archive}.a} for every +@var{archive} specified. + +On systems which support shared libraries, @code{ld} may also search for +libraries with extensions other than @code{.a}. Specifically, on ELF +and SunOS systems, @code{ld} will search a directory for a library with +an extension of @code{.so} before searching for one with an extension of +@code{.a}. By convention, a @code{.so} extension indicates a shared +library. + +The linker will search an archive only once, at the location where it is +specified on the command line. If the archive defines a symbol which +was undefined in some object which appeared before the archive on the +command line, the linker will include the appropriate file(s) from the +archive. However, an undefined symbol in an object appearing later on +the command line will not cause the linker to search the archive again. + +See the @code{-(} option for a way to force the linker to search +archives multiple times. + +You may list the same archive multiple times on the command line. + +@ifset GENERIC +This type of archive searching is standard for Unix linkers. However, +if you are using @code{ld} on AIX, note that it is different from the +behaviour of the AIX linker. +@end ifset + +@cindex search directory, from cmd line +@kindex -L@var{dir} +@kindex --library-path=@var{dir} +@item -L@var{searchdir} +@itemx --library-path=@var{searchdir} +Add path @var{searchdir} to the list of paths that @code{ld} will search +for archive libraries and @code{ld} control scripts. You may use this +option any number of times. The directories are searched in the order +in which they are specified on the command line. Directories specified +on the command line are searched before the default directories. All +@code{-L} options apply to all @code{-l} options, regardless of the +order in which the options appear. + +@ifset UsesEnvVars +The default set of paths searched (without being specified with +@samp{-L}) depends on which emulation mode @code{ld} is using, and in +some cases also on how it was configured. @xref{Environment}. +@end ifset + +The paths can also be specified in a link script with the +@code{SEARCH_DIR} command. Directories specified this way are searched +at the point in which the linker script appears in the command line. + +@cindex emulation +@kindex -m @var{emulation} +@item -m@var{emulation} +Emulate the @var{emulation} linker. You can list the available +emulations with the @samp{--verbose} or @samp{-V} options. The default +depends on how your @code{ld} was configured. + +@cindex link map +@kindex -M +@kindex --print-map +@item -M +@itemx --print-map +Print (to the standard output) a link map---diagnostic information about +where symbols are mapped by @code{ld}, and information on global common +storage allocation. + +@kindex -n +@cindex read-only text +@cindex NMAGIC +@kindex --nmagic +@item -n +@itemx --nmagic +Set the text segment to be read only, and mark the output as +@code{NMAGIC} if possible. + +@kindex -N +@kindex --omagic +@cindex read/write from cmd line +@cindex OMAGIC +@item -N +@itemx --omagic +Set the text and data sections to be readable and writable. Also, do +not page-align the data segment. If the output format supports Unix +style magic numbers, mark the output as @code{OMAGIC}. + +@kindex -o @var{output} +@kindex --output=@var{output} +@cindex naming the output file +@item -o @var{output} +@itemx --output=@var{output} +Use @var{output} as the name for the program produced by @code{ld}; if this +option is not specified, the name @file{a.out} is used by default. The +script command @code{OUTPUT} can also specify the output file name. + +@cindex partial link +@cindex relocatable output +@kindex -r +@kindex --relocateable +@item -r +@itemx --relocateable +Generate relocatable output---i.e., generate an output file that can in +turn serve as input to @code{ld}. This is often called @dfn{partial +linking}. As a side effect, in environments that support standard Unix +magic numbers, this option also sets the output file's magic number to +@code{OMAGIC}. +@c ; see @code{-N}. +If this option is not specified, an absolute file is produced. When +linking C++ programs, this option @emph{will not} resolve references to +constructors; to do that, use @samp{-Ur}. + +This option does the same thing as @samp{-i}. + +@kindex -R @var{file} +@kindex --just-symbols=@var{file} +@cindex symbol-only input +@item -R @var{filename} +@itemx --just-symbols=@var{filename} +Read symbol names and their addresses from @var{filename}, but do not +relocate it or include it in the output. This allows your output file +to refer symbolically to absolute locations of memory defined in other +programs. You may use this option more than once. + +For compatibility with other ELF linkers, if the @code{-R} option is +followed by a directory name, rather than a file name, it is treated as +the @code{-rpath} option. + +@kindex -s +@kindex --strip-all +@cindex strip all symbols +@item -s +@itemx --strip-all +Omit all symbol information from the output file. + +@kindex -S +@kindex --strip-debug +@cindex strip debugger symbols +@item -S +@itemx --strip-debug +Omit debugger symbol information (but not all symbols) from the output file. + +@kindex -t +@kindex --trace +@cindex input files, displaying +@item -t +@itemx --trace +Print the names of the input files as @code{ld} processes them. + +@kindex -T @var{script} +@kindex --script=@var{script} +@cindex script files +@item -T @var{commandfile} +@itemx --script=@var{commandfile} +Read link commands from the file @var{commandfile}. These commands +replace @code{ld}'s default link script (rather than adding to it), so +@var{commandfile} must specify everything necessary to describe the +target format. You must use this option if you want to use a command +which can only appear once in a linker script, such as the +@code{SECTIONS} or @code{MEMORY} command. @xref{Commands}. If +@var{commandfile} does not exist, @code{ld} looks for it in the +directories specified by any preceding @samp{-L} options. Multiple +@samp{-T} options accumulate. + +@kindex -u @var{symbol} +@kindex --undefined=@var{symbol} +@cindex undefined symbol +@item -u @var{symbol} +@itemx --undefined=@var{symbol} +Force @var{symbol} to be entered in the output file as an undefined symbol. +Doing this may, for example, trigger linking of additional modules from +standard libraries. @samp{-u} may be repeated with different option +arguments to enter additional undefined symbols. +@c Nice idea, but no such command: This option is equivalent +@c to the @code{EXTERN} linker command. + +@kindex -v +@kindex -V +@kindex --version +@cindex version +@item -v +@itemx --version +@itemx -V +Display the version number for @code{ld}. The @code{-V} option also +lists the supported emulations. + +@kindex -x +@kindex --discard-all +@cindex deleting local symbols +@item -x +@itemx --discard-all +Delete all local symbols. + +@kindex -X +@kindex --discard-locals +@cindex local symbols, deleting +@cindex L, deleting symbols beginning +@item -X +@itemx --discard-locals +Delete all temporary local symbols. For most targets, this is all local +symbols whose names begin with @samp{L}. + +@kindex -y @var{symbol} +@kindex --trace-symbol=@var{symbol} +@cindex symbol tracing +@item -y @var{symbol} +@itemx --trace-symbol=@var{symbol} +Print the name of each linked file in which @var{symbol} appears. This +option may be given any number of times. On many systems it is necessary +to prepend an underscore. + +This option is useful when you have an undefined symbol in your link but +don't know where the reference is coming from. + +@kindex -Y @var{path} +@item -Y @var{path} +Add @var{path} to the default library search path. This option exists +for Solaris compatibility. + +@kindex -z @var{keyword} +@item -z @var{keyword} +This option is ignored for Solaris compatibility. + +@kindex -( +@cindex groups of archives +@item -( @var{archives} -) +@itemx --start-group @var{archives} --end-group +The @var{archives} should be a list of archive files. They may be +either explicit file names, or @samp{-l} options. + +The specified archives are searched repeatedly until no new undefined +references are created. Normally, an archive is searched only once in +the order that it is specified on the command line. If a symbol in that +archive is needed to resolve an undefined symbol referred to by an +object in an archive that appears later on the command line, the linker +would not be able to resolve that reference. By grouping the archives, +they all be searched repeatedly until all possible references are +resolved. + +Using this option has a significant performance cost. It is best to use +it only when there are unavoidable circular references between two or +more archives. + +@kindex -assert @var{keyword} +@item -assert @var{keyword} +This option is ignored for SunOS compatibility. + +@kindex -Bdynamic +@kindex -dy +@kindex -call_shared +@item -Bdynamic +@itemx -dy +@itemx -call_shared +Link against dynamic libraries. This is only meaningful on platforms +for which shared libraries are supported. This option is normally the +default on such platforms. The different variants of this option are +for compatibility with various systems. You may use this option +multiple times on the command line: it affects library searching for +@code{-l} options which follow it. + +@kindex -Bstatic +@kindex -dn +@kindex -non_shared +@kindex -static +@item -Bstatic +@itemx -dn +@itemx -non_shared +@itemx -static +Do not link against shared libraries. This is only meaningful on +platforms for which shared libraries are supported. The different +variants of this option are for compatibility with various systems. You +may use this option multiple times on the command line: it affects +library searching for @code{-l} options which follow it. + +@kindex -Bsymbolic +@item -Bsymbolic +When creating a shared library, bind references to global symbols to the +definition within the shared library, if any. Normally, it is possible +for a program linked against a shared library to override the definition +within the shared library. This option is only meaningful on ELF +platforms which support shared libraries. + +@cindex cross reference table +@kindex --cref +@item --cref +Output a cross reference table. If a linker map file is being +generated, the cross reference table is printed to the map file. +Otherwise, it is printed on the standard output. + +The format of the table is intentionally simple, so that it may be +easily processed by a script if necessary. The symbols are printed out, +sorted by name. For each symbol, a list of file names is given. If the +symbol is defined, the first file listed is the location of the +definition. The remaining files contain references to the symbol. + +@cindex symbols, from command line +@kindex --defsym @var{symbol}=@var{exp} +@item --defsym @var{symbol}=@var{expression} +Create a global symbol in the output file, containing the absolute +address given by @var{expression}. You may use this option as many +times as necessary to define multiple symbols in the command line. A +limited form of arithmetic is supported for the @var{expression} in this +context: you may give a hexadecimal constant or the name of an existing +symbol, or use @code{+} and @code{-} to add or subtract hexadecimal +constants or symbols. If you need more elaborate expressions, consider +using the linker command language from a script (@pxref{Assignment, , +Assignment: Symbol Definitions}). @emph{Note:} there should be no +white space between @var{symbol}, the equals sign (``@key{=}''), and +@var{expression}. + +@cindex dynamic linker, from command line +@kindex --dynamic-linker @var{file} +@item --dynamic-linker @var{file} +Set the name of the dynamic linker. This is only meaningful when +generating dynamically linked ELF executables. The default dynamic +linker is normally correct; don't use this unless you know what you are +doing. + +@cindex big-endian objects +@cindex endianness +@kindex -EB +@item -EB +Link big-endian objects. This affects the default output format. + +@cindex little-endian objects +@kindex -EL +@item -EL +Link little-endian objects. This affects the default output format. + +@cindex MIPS embedded PIC code +@kindex --embedded-relocs +@item --embedded-relocs +This option is only meaningful when linking MIPS embedded PIC code, +generated by the -membedded-pic option to the @sc{gnu} compiler and +assembler. It causes the linker to create a table which may be used at +runtime to relocate any data which was statically initialized to pointer +values. See the code in testsuite/ld-empic for details. + +@cindex help +@cindex usage +@kindex --help +@item --help +Print a summary of the command-line options on the standard output and exit. + +@cindex link map +@kindex -Map +@item -Map @var{mapfile} +Print to the file @var{mapfile} a link map---diagnostic information +about where symbols are mapped by @code{ld}, and information on global +common storage allocation. + +@cindex memory usage +@kindex --no-keep-memory +@item --no-keep-memory +@code{ld} normally optimizes for speed over memory usage by caching the +symbol tables of input files in memory. This option tells @code{ld} to +instead optimize for memory usage, by rereading the symbol tables as +necessary. This may be required if @code{ld} runs out of memory space +while linking a large executable. + +@kindex --no-whole-archive +@item --no-whole-archive +Turn off the effect of the @code{--whole-archive} option for subsequent +archive files. + +@cindex output file after errors +@kindex --noinhibit-exec +@item --noinhibit-exec +Retain the executable output file whenever it is still usable. +Normally, the linker will not produce an output file if it encounters +errors during the link process; it exits without writing an output file +when it issues any error whatsoever. + +@ifclear SingleFormat +@kindex --oformat +@item --oformat @var{output-format} +@code{ld} may be configured to support more than one kind of object +file. If your @code{ld} is configured this way, you can use the +@samp{--oformat} option to specify the binary format for the output +object file. Even when @code{ld} is configured to support alternative +object formats, you don't usually need to specify this, as @code{ld} +should be configured to produce as a default output format the most +usual format on each machine. @var{output-format} is a text string, the +name of a particular format supported by the BFD libraries. (You can +list the available binary formats with @samp{objdump -i}.) The script +command @code{OUTPUT_FORMAT} can also specify the output format, but +this option overrides it. @xref{BFD}. +@end ifclear + +@kindex -qmagic +@item -qmagic +This option is ignored for Linux compatibility. + +@kindex -Qy +@item -Qy +This option is ignored for SVR4 compatibility. + +@kindex --relax +@cindex synthesizing linker +@cindex relaxing addressing modes +@item --relax +An option with machine dependent effects. +@ifset GENERIC +This option is only supported on a few targets. +@end ifset +@ifset H8300 +@xref{H8/300,,@code{ld} and the H8/300}. +@end ifset +@ifset I960 +@xref{i960,, @code{ld} and the Intel 960 family}. +@end ifset + +On some platforms, the @samp{--relax} option performs global +optimizations that become possible when the linker resolves addressing +in the program, such as relaxing address modes and synthesizing new +instructions in the output object file. + +@ifset GENERIC +On platforms where this is not supported, @samp{--relax} is accepted, +but ignored. +@end ifset + +@cindex retaining specified symbols +@cindex stripping all but some symbols +@cindex symbols, retaining selectively +@item --retain-symbols-file @var{filename} +Retain @emph{only} the symbols listed in the file @var{filename}, +discarding all others. @var{filename} is simply a flat file, with one +symbol name per line. This option is especially useful in environments +@ifset GENERIC +(such as VxWorks) +@end ifset +where a large global symbol table is accumulated gradually, to conserve +run-time memory. + +@samp{--retain-symbols-file} does @emph{not} discard undefined symbols, +or symbols needed for relocations. + +You may only specify @samp{--retain-symbols-file} once in the command +line. It overrides @samp{-s} and @samp{-S}. + +@ifset GENERIC +@item -rpath @var{dir} +@cindex runtime library search path +@kindex -rpath +Add a directory to the runtime library search path. This is used when +linking an ELF executable with shared objects. All @code{-rpath} +arguments are concatenated and passed to the runtime linker, which uses +them to locate shared objects at runtime. The @code{-rpath} option is +also used when locating shared objects which are needed by shared +objects explicitly included in the link; see the description of the +@code{-rpath-link} option. If @code{-rpath} is not used when linking an +ELF executable, the contents of the environment variable +@code{LD_RUN_PATH} will be used if it is defined. + +The @code{-rpath} option may also be used on SunOS. By default, on +SunOS, the linker will form a runtime search patch out of all the +@code{-L} options it is given. If a @code{-rpath} option is used, the +runtime search path will be formed exclusively using the @code{-rpath} +options, ignoring the @code{-L} options. This can be useful when using +gcc, which adds many @code{-L} options which may be on NFS mounted +filesystems. + +For compatibility with other ELF linkers, if the @code{-R} option is +followed by a directory name, rather than a file name, it is treated as +the @code{-rpath} option. +@end ifset + +@ifset GENERIC +@cindex link-time runtime library search path +@kindex -rpath-link +@item -rpath-link @var{DIR} +When using ELF or SunOS, one shared library may require another. This +happens when an @code{ld -shared} link includes a shared library as one +of the input files. + +When the linker encounters such a dependency when doing a non-shared, +non-relocateable link, it will automatically try to locate the required +shared library and include it in the link, if it is not included +explicitly. In such a case, the @code{-rpath-link} option +specifies the first set of directories to search. The +@code{-rpath-link} option may specify a sequence of directory names +either by specifying a list of names separated by colons, or by +appearing multiple times. + +The linker uses the following search paths to locate required shared +libraries. +@enumerate +@item +Any directories specified by @code{-rpath-link} options. +@item +Any directories specified by @code{-rpath} options. The difference +between @code{-rpath} and @code{-rpath-link} is that directories +specified by @code{-rpath} options are included in the executable and +used at runtime, whereas the @code{-rpath-link} option is only effective +at link time. +@item +On an ELF system, if the @code{-rpath} and @code{rpath-link} options +were not used, search the contents of the environment variable +@code{LD_RUN_PATH}. +@item +On SunOS, if the @code{-rpath} option was not used, search any +directories specified using @code{-L} options. +@item +For a native linker, the contents of the environment variable +@code{LD_LIBRARY_PATH}. +@item +The default directories, normally @file{/lib} and @file{/usr/lib}. +@end enumerate + +If the required shared library is not found, the linker will issue a +warning and continue with the link. +@end ifset + +@kindex -shared +@kindex -Bshareable +@item -shared +@itemx -Bshareable +@cindex shared libraries +Create a shared library. This is currently only supported on ELF, XCOFF +and SunOS platforms. On SunOS, the linker will automatically create a +shared library if the @code{-e} option is not used and there are +undefined symbols in the link. + +@item --sort-common +@kindex --sort-common +This option tells @code{ld} to sort the common symbols by size when it +places them in the appropriate output sections. First come all the one +byte symbols, then all the two bytes, then all the four bytes, and then +everything else. This is to prevent gaps between symbols due to +alignment constraints. + +@kindex --split-by-file +@item --split-by-file +Similar to @code{--split-by-reloc} but creates a new output section for +each input file. + +@kindex --split-by-reloc +@item --split-by-reloc @var{count} +Trys to creates extra sections in the output file so that no single +output section in the file contains more than @var{count} relocations. +This is useful when generating huge relocatable for downloading into +certain real time kernels with the COFF object file format; since COFF +cannot represent more than 65535 relocations in a single section. Note +that this will fail to work with object file formats which do not +support arbitrary sections. The linker will not split up individual +input sections for redistribution, so if a single input section contains +more than @var{count} relocations one output section will contain that +many relocations. + +@kindex --stats +@item --stats +Compute and display statistics about the operation of the linker, such +as execution time and memory usage. + +@kindex --traditional-format +@cindex traditional format +@item --traditional-format +For some targets, the output of @code{ld} is different in some ways from +the output of some existing linker. This switch requests @code{ld} to +use the traditional format instead. + +@cindex dbx +For example, on SunOS, @code{ld} combines duplicate entries in the +symbol string table. This can reduce the size of an output file with +full debugging information by over 30 percent. Unfortunately, the SunOS +@code{dbx} program can not read the resulting program (@code{gdb} has no +trouble). The @samp{--traditional-format} switch tells @code{ld} to not +combine duplicate entries. + +@kindex -Tbss @var{org} +@kindex -Tdata @var{org} +@kindex -Ttext @var{org} +@cindex segment origins, cmd line +@item -Tbss @var{org} +@itemx -Tdata @var{org} +@itemx -Ttext @var{org} +Use @var{org} as the starting address for---respectively---the +@code{bss}, @code{data}, or the @code{text} segment of the output file. +@var{org} must be a single hexadecimal integer; +for compatibility with other linkers, you may omit the leading +@samp{0x} usually associated with hexadecimal values. + +@kindex -Ur +@cindex constructors +@item -Ur +For anything other than C++ programs, this option is equivalent to +@samp{-r}: it generates relocatable output---i.e., an output file that can in +turn serve as input to @code{ld}. When linking C++ programs, @samp{-Ur} +@emph{does} resolve references to constructors, unlike @samp{-r}. +It does not work to use @samp{-Ur} on files that were themselves linked +with @samp{-Ur}; once the constructor table has been built, it cannot +be added to. Use @samp{-Ur} only for the last partial link, and +@samp{-r} for the others. + +@kindex --verbose +@cindex verbose +@item --verbose +Display the version number for @code{ld} and list the linker emulations +supported. Display which input files can and cannot be opened. Display +the linker script if using a default builtin script. + +@kindex --version-script=@var{version-scriptfile} +@cindex version script, symbol versions +@itemx --version-script=@var{version-scriptfile} +Specify the name of a version script to the linker. This is typically +used when creating shared libraries to specify additional information +about the version heirarchy for the library being created. This option +is only meaningful on ELF platforms which support shared libraries. +@xref{Version Script}. + +@kindex --warn-comon +@cindex warnings, on combining symbols +@cindex combining symbols, warnings on +@item --warn-common +Warn when a common symbol is combined with another common symbol or with +a symbol definition. Unix linkers allow this somewhat sloppy practice, +but linkers on some other operating systems do not. This option allows +you to find potential problems from combining global symbols. +Unfortunately, some C libraries use this practice, so you may get some +warnings about symbols in the libraries as well as in your programs. + +There are three kinds of global symbols, illustrated here by C examples: + +@table @samp +@item int i = 1; +A definition, which goes in the initialized data section of the output +file. + +@item extern int i; +An undefined reference, which does not allocate space. +There must be either a definition or a common symbol for the +variable somewhere. + +@item int i; +A common symbol. If there are only (one or more) common symbols for a +variable, it goes in the uninitialized data area of the output file. +The linker merges multiple common symbols for the same variable into a +single symbol. If they are of different sizes, it picks the largest +size. The linker turns a common symbol into a declaration, if there is +a definition of the same variable. +@end table + +The @samp{--warn-common} option can produce five kinds of warnings. +Each warning consists of a pair of lines: the first describes the symbol +just encountered, and the second describes the previous symbol +encountered with the same name. One or both of the two symbols will be +a common symbol. + +@enumerate +@item +Turning a common symbol into a reference, because there is already a +definition for the symbol. +@smallexample +@var{file}(@var{section}): warning: common of `@var{symbol}' + overridden by definition +@var{file}(@var{section}): warning: defined here +@end smallexample + +@item +Turning a common symbol into a reference, because a later definition for +the symbol is encountered. This is the same as the previous case, +except that the symbols are encountered in a different order. +@smallexample +@var{file}(@var{section}): warning: definition of `@var{symbol}' + overriding common +@var{file}(@var{section}): warning: common is here +@end smallexample + +@item +Merging a common symbol with a previous same-sized common symbol. +@smallexample +@var{file}(@var{section}): warning: multiple common + of `@var{symbol}' +@var{file}(@var{section}): warning: previous common is here +@end smallexample + +@item +Merging a common symbol with a previous larger common symbol. +@smallexample +@var{file}(@var{section}): warning: common of `@var{symbol}' + overridden by larger common +@var{file}(@var{section}): warning: larger common is here +@end smallexample + +@item +Merging a common symbol with a previous smaller common symbol. This is +the same as the previous case, except that the symbols are +encountered in a different order. +@smallexample +@var{file}(@var{section}): warning: common of `@var{symbol}' + overriding smaller common +@var{file}(@var{section}): warning: smaller common is here +@end smallexample +@end enumerate + +@kindex --warn-constructors +@item --warn-constructors +Warn if any global constructors are used. This is only useful for a few +object file formats. For formats like COFF or ELF, the linker can not +detect the use of global constructors. + +@kindex --warn-multiple-gp +@item --warn-multiple-gp +Warn if multiple global pointer values are required in the output file. +This is only meaningful for certain processors, such as the Alpha. +Specifically, some processors put large-valued constants in a special +section. A special register (the global pointer) points into the middle +of this section, so that constants can be loaded efficiently via a +base-register relative addressing mode. Since the offset in +base-register relative mode is fixed and relatively small (e.g., 16 +bits), this limits the maximum size of the constant pool. Thus, in +large programs, it is often necessary to use multiple global pointer +values in order to be able to address all possible constants. This +option causes a warning to be issued whenever this case occurs. + +@kindex --warn-once +@cindex warnings, on undefined symbols +@cindex undefined symbols, warnings on +@item --warn-once +Only warn once for each undefined symbol, rather than once per module +which refers to it. + +@kindex --warn-section-align +@cindex warnings, on section alignment +@cindex section alignment, warnings on +@item --warn-section-align +Warn if the address of an output section is changed because of +alignment. Typically, the alignment will be set by an input section. +The address will only be changed if it not explicitly specified; that +is, if the @code{SECTIONS} command does not specify a start address for +the section (@pxref{SECTIONS}). + +@kindex --whole-archive +@cindex including an entire archive +@item --whole-archive +For each archive mentioned on the command line after the +@code{--whole-archive} option, include every object file in the archive +in the link, rather than searching the archive for the required object +files. This is normally used to turn an archive file into a shared +library, forcing every object to be included in the resulting shared +library. This option may be used more than once. + +@kindex --wrap +@item --wrap @var{symbol} +Use a wrapper function for @var{symbol}. Any undefined reference to +@var{symbol} will be resolved to @code{__wrap_@var{symbol}}. Any +undefined reference to @code{__real_@var{symbol}} will be resolved to +@var{symbol}. + +This can be used to provide a wrapper for a system function. The +wrapper function should be called @code{__wrap_@var{symbol}}. If it +wishes to call the system function, it should call +@code{__real_@var{symbol}}. + +Here is a trivial example: + +@smallexample +void * +__wrap_malloc (int c) +@{ + printf ("malloc called with %ld\n", c); + return __real_malloc (c); +@} +@end smallexample + +If you link other code with this file using @code{--wrap malloc}, then +all calls to @code{malloc} will call the function @code{__wrap_malloc} +instead. The call to @code{__real_malloc} in @code{__wrap_malloc} will +call the real @code{malloc} function. + +You may wish to provide a @code{__real_malloc} function as well, so that +links without the @code{--wrap} option will succeed. If you do this, +you should not put the definition of @code{__real_malloc} in the same +file as @code{__wrap_malloc}; if you do, the assembler may resolve the +call before the linker has a chance to wrap it to @code{malloc}. + +@end table + +@ifset UsesEnvVars +@node Environment +@section Environment Variables + +You can change the behavior of @code{ld} with the environment +variable @code{GNUTARGET}. + +@kindex GNUTARGET +@cindex default input format +@code{GNUTARGET} determines the input-file object format if you don't +use @samp{-b} (or its synonym @samp{--format}). Its value should be one +of the BFD names for an input format (@pxref{BFD}). If there is no +@code{GNUTARGET} in the environment, @code{ld} uses the natural format +of the target. If @code{GNUTARGET} is set to @code{default} then BFD +attempts to discover the input format by examining binary input files; +this method often succeeds, but there are potential ambiguities, since +there is no method of ensuring that the magic number used to specify +object-file formats is unique. However, the configuration procedure for +BFD on each system places the conventional format for that system first +in the search-list, so ambiguities are resolved in favor of convention. +@end ifset + +@node Commands +@chapter Command Language + +@cindex command files +The command language provides explicit control over the link process, +allowing complete specification of the mapping between the linker's +input files and its output. It controls: +@itemize @bullet +@item +input files +@item +file formats +@item +output file layout +@item +addresses of sections +@item +placement of common blocks +@end itemize + +You may supply a command file (also known as a linker script) to the +linker either explicitly through the @samp{-T} option, or implicitly as +an ordinary file. Normally you should use the @samp{-T} option. An +implicit linker script should only be used when you want to augment, +rather than replace, the default linker script; typically an implicit +linker script would consist only of @code{INPUT} or @code{GROUP} +commands. + +If the linker opens a file which it cannot recognize as a supported +object or archive format, nor as a linker script, it reports an error. + +@menu +* Scripts:: Linker Scripts +* Expressions:: Expressions +* MEMORY:: MEMORY Command +* SECTIONS:: SECTIONS Command +* PHDRS:: PHDRS Command +* Entry Point:: The Entry Point +* Version Script:: Version Script +* Option Commands:: Option Commands +@end menu + +@node Scripts +@section Linker Scripts +The @code{ld} command language is a collection of statements; some are +simple keywords setting a particular option, some are used to select and +group input files or name output files; and two statement +types have a fundamental and pervasive impact on the linking process. + +@cindex fundamental script commands +@cindex commands, fundamental +@cindex output file layout +@cindex layout of output file +The most fundamental command of the @code{ld} command language is the +@code{SECTIONS} command (@pxref{SECTIONS}). Every meaningful command +script must have a @code{SECTIONS} command: it specifies a +``picture'' of the output file's layout, in varying degrees of detail. +No other command is required in all cases. + +The @code{MEMORY} command complements @code{SECTIONS} by describing the +available memory in the target architecture. This command is optional; +if you don't use a @code{MEMORY} command, @code{ld} assumes sufficient +memory is available in a contiguous block for all output. +@xref{MEMORY}. + +@cindex comments +You may include comments in linker scripts just as in C: delimited +by @samp{/*} and @samp{*/}. As in C, comments are syntactically +equivalent to whitespace. + +@node Expressions +@section Expressions +@cindex expression syntax +@cindex arithmetic +Many useful commands involve arithmetic expressions. The syntax for +expressions in the command language is identical to that of C +expressions, with the following features: +@itemize @bullet +@item +All expressions evaluated as integers and +are of ``long'' or ``unsigned long'' type. +@item +All constants are integers. +@item +All of the C arithmetic operators are provided. +@item +You may reference, define, and create global variables. +@item +You may call special purpose built-in functions. +@end itemize + +@menu +* Integers:: Integers +* Symbols:: Symbol Names +* Location Counter:: The Location Counter +* Operators:: Operators +* Evaluation:: Evaluation +* Assignment:: Assignment: Defining Symbols +* Arithmetic Functions:: Built-In Functions +* Semicolons:: Semicolon Usage +@end menu + +@node Integers +@subsection Integers +@cindex integer notation +@cindex octal integers +An octal integer is @samp{0} followed by zero or more of the octal +digits (@samp{01234567}). +@smallexample +_as_octal = 0157255; +@end smallexample + +@cindex decimal integers +A decimal integer starts with a non-zero digit followed by zero or +more digits (@samp{0123456789}). +@smallexample +_as_decimal = 57005; +@end smallexample + +@cindex hexadecimal integers +@kindex 0x +A hexadecimal integer is @samp{0x} or @samp{0X} followed by one or +more hexadecimal digits chosen from @samp{0123456789abcdefABCDEF}. +@smallexample +_as_hex = 0xdead; +@end smallexample + +@cindex negative integers +To write a negative integer, use +the prefix operator @samp{-} (@pxref{Operators}). +@smallexample +_as_neg = -57005; +@end smallexample + +@cindex scaled integers +@cindex K and M integer suffixes +@cindex M and K integer suffixes +@cindex suffixes for integers +@cindex integer suffixes +Additionally the suffixes @code{K} and @code{M} may be used to scale a +constant by +@c TEXI2ROFF-KILL +@ifinfo +@c END TEXI2ROFF-KILL +@code{1024} or @code{1024*1024} +@c TEXI2ROFF-KILL +@end ifinfo +@tex +${\rm 1024}$ or ${\rm 1024}^2$ +@end tex +@c END TEXI2ROFF-KILL +respectively. For example, the following all refer to the same quantity: + +@smallexample + _fourk_1 = 4K; + _fourk_2 = 4096; + _fourk_3 = 0x1000; +@end smallexample + +@node Symbols +@subsection Symbol Names +@cindex symbol names +@cindex names +@cindex quoted symbol names +@kindex " +Unless quoted, symbol names start with a letter, underscore, or point +and may include any letters, underscores, digits, points, +and hyphens. Unquoted symbol names must not conflict with any +keywords. You can specify a symbol which contains odd characters or has +the same name as a keyword, by surrounding the symbol name in double quotes: +@smallexample + "SECTION" = 9; + "with a space" = "also with a space" + 10; +@end smallexample + +Since symbols can contain many non-alphabetic characters, it is safest +to delimit symbols with spaces. For example, @samp{A-B} is one symbol, +whereas @samp{A - B} is an expression involving subtraction. + +@node Location Counter +@subsection The Location Counter +@kindex . +@cindex dot +@cindex location counter +@cindex current output location +The special linker variable @dfn{dot} @samp{.} always contains the +current output location counter. Since the @code{.} always refers to +a location in an output section, it must always appear in an +expression within a @code{SECTIONS} command. The @code{.} symbol +may appear anywhere that an ordinary symbol is allowed in an +expression, but its assignments have a side effect. Assigning a value +to the @code{.} symbol will cause the location counter to be moved. +@cindex holes +This may be used to create holes in the output section. The location +counter may never be moved backwards. +@smallexample +SECTIONS +@{ + output : + @{ + file1(.text) + . = . + 1000; + file2(.text) + . += 1000; + file3(.text) + @} = 0x1234; +@} +@end smallexample +@noindent +In the previous example, @code{file1} is located at the beginning of the +output section, then there is a 1000 byte gap. Then @code{file2} +appears, also with a 1000 byte gap following before @code{file3} is +loaded. The notation @samp{= 0x1234} specifies what data to write in +the gaps (@pxref{Section Options}). + +@iftex +@vfill +@end iftex + +@need 2000 +@node Operators +@subsection Operators +@cindex Operators for arithmetic +@cindex arithmetic operators +@cindex precedence in expressions +The linker recognizes the standard C set of arithmetic operators, with +the standard bindings and precedence levels: +@c TEXI2ROFF-KILL +@ifinfo +@c END TEXI2ROFF-KILL +@smallexample +precedence associativity Operators Notes +(highest) +1 left ! - ~ (1) +2 left * / % +3 left + - +4 left >> << +5 left == != > < <= >= +6 left & +7 left | +8 left && +9 left || +10 right ? : +11 right &= += -= *= /= (2) +(lowest) +@end smallexample +Notes: +(1) Prefix operators +(2) @xref{Assignment}. +@c TEXI2ROFF-KILL +@end ifinfo +@tex +\vskip \baselineskip +%"lispnarrowing" is the extra indent used generally for smallexample +\hskip\lispnarrowing\vbox{\offinterlineskip +\hrule +\halign +{\vrule#&\strut\hfil\ #\ \hfil&\vrule#&\strut\hfil\ #\ \hfil&\vrule#&\strut\hfil\ {\tt #}\ \hfil&\vrule#\cr +height2pt&\omit&&\omit&&\omit&\cr +&Precedence&& Associativity &&{\rm Operators}&\cr +height2pt&\omit&&\omit&&\omit&\cr +\noalign{\hrule} +height2pt&\omit&&\omit&&\omit&\cr +&highest&&&&&\cr +% '176 is tilde, '~' in tt font +&1&&left&&\qquad- \char'176\ !\qquad\dag&\cr +&2&&left&&* / \%&\cr +&3&&left&&+ -&\cr +&4&&left&&>> <<&\cr +&5&&left&&== != > < <= >=&\cr +&6&&left&&\&&\cr +&7&&left&&|&\cr +&8&&left&&{\&\&}&\cr +&9&&left&&||&\cr +&10&&right&&? :&\cr +&11&&right&&\qquad\&= += -= *= /=\qquad\ddag&\cr +&lowest&&&&&\cr +height2pt&\omit&&\omit&&\omit&\cr} +\hrule} +@end tex +@iftex +{ +@obeylines@parskip=0pt@parindent=0pt +@dag@quad Prefix operators. +@ddag@quad @xref{Assignment}. +} +@end iftex +@c END TEXI2ROFF-KILL + +@node Evaluation +@subsection Evaluation + +@cindex lazy evaluation +@cindex expression evaluation order +The linker uses ``lazy evaluation'' for expressions; it only calculates +an expression when absolutely necessary. The linker needs the value of +the start address, and the lengths of memory regions, in order to do any +linking at all; these values are computed as soon as possible when the +linker reads in the command file. However, other values (such as symbol +values) are not known or needed until after storage allocation. Such +values are evaluated later, when other information (such as the sizes of +output sections) is available for use in the symbol assignment +expression. + +@node Assignment +@subsection Assignment: Defining Symbols +@cindex assignment in scripts +@cindex symbol definition, scripts +@cindex variables, defining +You may create global symbols, and assign values (addresses) to global +symbols, using any of the C assignment operators: + +@table @code +@item @var{symbol} = @var{expression} ; +@itemx @var{symbol} &= @var{expression} ; +@itemx @var{symbol} += @var{expression} ; +@itemx @var{symbol} -= @var{expression} ; +@itemx @var{symbol} *= @var{expression} ; +@itemx @var{symbol} /= @var{expression} ; +@end table + +Two things distinguish assignment from other operators in @code{ld} +expressions. +@itemize @bullet +@item +Assignment may only be used at the root of an expression; +@samp{a=b+3;} is allowed, but @samp{a+b=3;} is an error. + +@kindex ; +@cindex semicolon +@item +You must place a trailing semicolon (``@key{;}'') at the end of an +assignment statement. +@end itemize + +Assignment statements may appear: +@itemize @bullet +@item +as commands in their own right in an @code{ld} script; or +@item +as independent statements within a @code{SECTIONS} command; or +@item +as part of the contents of a section definition in a +@code{SECTIONS} command. +@end itemize + +The first two cases are equivalent in effect---both define a symbol with +an absolute address. The last case defines a symbol whose address is +relative to a particular section (@pxref{SECTIONS}). + +@cindex absolute and relocatable symbols +@cindex relocatable and absolute symbols +@cindex symbols, relocatable and absolute +When a linker expression is evaluated and assigned to a variable, it is +given either an absolute or a relocatable type. An absolute expression +type is one in which the symbol contains the value that it will have in +the output file; a relocatable expression type is one in which the +value is expressed as a fixed offset from the base of a section. + +The type of the expression is controlled by its position in the script +file. A symbol assigned within a section definition is created relative +to the base of the section; a symbol assigned in any other place is +created as an absolute symbol. Since a symbol created within a +section definition is relative to the base of the section, it +will remain relocatable if relocatable output is requested. A symbol +may be created with an absolute value even when assigned to within a +section definition by using the absolute assignment function +@code{ABSOLUTE}. For example, to create an absolute symbol whose address +is the last byte of an output section named @code{.data}: +@smallexample +SECTIONS@{ @dots{} + .data : + @{ + *(.data) + _edata = ABSOLUTE(.) ; + @} +@dots{} @} +@end smallexample + +The linker tries to put off the evaluation of an assignment until all +the terms in the source expression are known (@pxref{Evaluation}). For +instance, the sizes of sections cannot be known until after allocation, +so assignments dependent upon these are not performed until after +allocation. Some expressions, such as those depending upon the location +counter @dfn{dot}, @samp{.} must be evaluated during allocation. If the +result of an expression is required, but the value is not available, +then an error results. For example, a script like the following +@smallexample +SECTIONS @{ @dots{} + text 9+this_isnt_constant : + @{ @dots{} + @} +@dots{} @} +@end smallexample +@kindex Non constant expression +@noindent +will cause the error message ``@code{Non constant expression for initial +address}''. + +@cindex provide +In some cases, it is desirable for a linker script to define a symbol +only if it is referenced, and only if it is not defined by any object +included in the link. For example, traditional linkers defined the +symbol @samp{etext}. However, ANSI C requires that the user be able to +use @samp{etext} as a function name without encountering an error. +The @code{PROVIDE} keyword may be used to define a symbol, such as +@samp{etext}, only if it is referenced but not defined. The syntax is +@code{PROVIDE(@var{symbol} = @var{expression})}. + +@node Arithmetic Functions +@subsection Arithmetic Functions +@cindex functions in expression language +The command language includes a number of built-in +functions for use in link script expressions. +@table @code +@kindex ABSOLUTE(@var{exp}) +@cindex expression, absolute +@item ABSOLUTE(@var{exp}) +Return the absolute (non-relocatable, as opposed to non-negative) value +of the expression @var{exp}. Primarily useful to assign an absolute +value to a symbol within a section definition, where symbol values are +normally section-relative. + +@kindex ADDR(@var{section}) +@cindex section address +@item ADDR(@var{section}) +Return the absolute address of the named @var{section}. Your script must +previously have defined the location of that section. In the following +example, @code{symbol_1} and @code{symbol_2} are assigned identical +values: +@smallexample +@group +SECTIONS@{ @dots{} + .output1 : + @{ + start_of_output_1 = ABSOLUTE(.); + @dots{} + @} + .output : + @{ + symbol_1 = ADDR(.output1); + symbol_2 = start_of_output_1; + @} +@dots{} @} +@end group +@end smallexample + +@kindex LOADADDR(@var{section}) +@cindex section load address +@item LOADADDR(@var{section}) +Return the absolute load address of the named @var{section}. This is +normally the same as @code{ADDR}, but it may be different if the +@code{AT} keyword is used in the section definition (@pxref{Section +Options}). + +@kindex ALIGN(@var{exp}) +@cindex rounding up location counter +@item ALIGN(@var{exp}) +Return the result of the current location counter (@code{.}) aligned to +the next @var{exp} boundary. @var{exp} must be an expression whose +value is a power of two. This is equivalent to +@smallexample +(. + @var{exp} - 1) & ~(@var{exp} - 1) +@end smallexample + +@code{ALIGN} doesn't change the value of the location counter---it just +does arithmetic on it. As an example, to align the output @code{.data} +section to the next @code{0x2000} byte boundary after the preceding +section and to set a variable within the section to the next +@code{0x8000} boundary after the input sections: +@smallexample +@group +SECTIONS@{ @dots{} + .data ALIGN(0x2000): @{ + *(.data) + variable = ALIGN(0x8000); + @} +@dots{} @} +@end group +@end smallexample +@noindent +The first use of @code{ALIGN} in this example specifies the location of +a section because it is used as the optional @var{start} attribute of a +section definition (@pxref{Section Options}). The second use simply +defines the value of a variable. + +The built-in @code{NEXT} is closely related to @code{ALIGN}. + +@kindex DEFINED(@var{symbol}) +@cindex symbol defaults +@item DEFINED(@var{symbol}) +Return 1 if @var{symbol} is in the linker global symbol table and is +defined, otherwise return 0. You can use this function to provide default +values for symbols. For example, the following command-file fragment shows how +to set a global symbol @code{begin} to the first location in the +@code{.text} section---but if a symbol called @code{begin} already +existed, its value is preserved: + +@smallexample +@group +SECTIONS@{ @dots{} + .text : @{ + begin = DEFINED(begin) ? begin : . ; + @dots{} + @} +@dots{} @} +@end group +@end smallexample + +@kindex NEXT(@var{exp}) +@cindex unallocated address, next +@item NEXT(@var{exp}) +Return the next unallocated address that is a multiple of @var{exp}. +This function is closely related to @code{ALIGN(@var{exp})}; unless you +use the @code{MEMORY} command to define discontinuous memory for the +output file, the two functions are equivalent. + +@kindex SIZEOF(@var{section}) +@cindex section size +@item SIZEOF(@var{section}) +Return the size in bytes of the named @var{section}, if that section has +been allocated. In the following example, @code{symbol_1} and +@code{symbol_2} are assigned identical values: +@c What does it return if the section hasn't been allocated? 0? +@smallexample +@group +SECTIONS@{ @dots{} + .output @{ + .start = . ; + @dots{} + .end = . ; + @} + symbol_1 = .end - .start ; + symbol_2 = SIZEOF(.output); +@dots{} @} +@end group +@end smallexample + +@kindex SIZEOF_HEADERS +@cindex header size +@kindex sizeof_headers +@item SIZEOF_HEADERS +@itemx sizeof_headers +Return the size in bytes of the output file's headers. You can use this number +as the start address of the first section, if you choose, to facilitate +paging. + +@kindex MAX +@item MAX(@var{exp1}, @var{exp2}) +Returns the maximum of @var{exp1} and @var{exp2}. + +@kindex MIN +@item MIN(@var{exp1}, @var{exp2}) +Returns the minimum of @var{exp1} and @var{exp2}. + +@end table + +@node Semicolons +@subsection Semicolons + +Semicolons (``@key{;}'') are required in the following places. In all +other places they can appear for aesthetic reasons but are otherwise ignored. + +@table @code +@item Assignment +Semicolons must appear at the end of assignment expressions. +@xref{Assignment} + +@item PHDRS +Semicolons must appear at the end of a @code{PHDRS} statement. +@xref{PHDRS} +@end table + +@node MEMORY +@section Memory Layout +@kindex MEMORY +@cindex regions of memory +@cindex discontinuous memory +@cindex allocating memory +The linker's default configuration permits allocation of all available memory. +You can override this configuration by using the @code{MEMORY} command. The +@code{MEMORY} command describes the location and size of blocks of +memory in the target. By using it carefully, you can describe which +memory regions may be used by the linker, and which memory regions it +must avoid. The linker does not shuffle sections to fit into the +available regions, but does move the requested sections into the correct +regions and issue errors when the regions become too full. + +A command file may contain at most one use of the @code{MEMORY} +command; however, you can define as many blocks of memory within it as +you wish. The syntax is: + +@smallexample +@group +MEMORY + @{ + @var{name} (@var{attr}) : ORIGIN = @var{origin}, LENGTH = @var{len} + @dots{} + @} +@end group +@end smallexample +@table @code +@cindex naming memory regions +@item @var{name} +is a name used internally by the linker to refer to the region. Any +symbol name may be used. The region names are stored in a separate +name space, and will not conflict with symbols, file names or section +names. Use distinct names to specify multiple regions. + +@cindex memory region attributes +@item (@var{attr}) +is an optional list of attributes, permitted for compatibility with the +AT&T linker but not used by @code{ld} beyond checking that the +attribute list is valid. Valid attribute lists must be made up of the +characters ``@code{LIRWX}''. If you omit the attribute list, you may +omit the parentheses around it as well. + +@kindex ORIGIN = +@kindex o = +@kindex org = +@item @var{origin} +is the start address of the region in physical memory. It is +an expression that must evaluate to a constant before +memory allocation is performed. The keyword @code{ORIGIN} may be +abbreviated to @code{org} or @code{o} (but not, for example, @samp{ORG}). + +@kindex LENGTH = +@kindex len = +@kindex l = +@item @var{len} +is the size in bytes of the region (an expression). +The keyword @code{LENGTH} may be abbreviated to @code{len} or @code{l}. +@end table + +For example, to specify that memory has two regions available for +allocation---one starting at 0 for 256 kilobytes, and the other +starting at @code{0x40000000} for four megabytes: + +@smallexample +@group +MEMORY + @{ + rom : ORIGIN = 0, LENGTH = 256K + ram : org = 0x40000000, l = 4M + @} +@end group +@end smallexample + +Once you have defined a region of memory named @var{mem}, you can direct +specific output sections there by using a command ending in +@samp{>@var{mem}} within the @code{SECTIONS} command (@pxref{Section +Options}). If the combined output sections directed to a region are too +big for the region, the linker will issue an error message. + +@node SECTIONS +@section Specifying Output Sections + +@kindex SECTIONS +The @code{SECTIONS} command controls exactly where input sections are +placed into output sections, their order in the output file, and to +which output sections they are allocated. + +You may use at most one @code{SECTIONS} command in a script file, +but you can have as many statements within it as you wish. Statements +within the @code{SECTIONS} command can do one of three things: + +@itemize @bullet +@item +define the entry point; + +@item +assign a value to a symbol; + +@item +describe the placement of a named output section, and which input +sections go into it. +@end itemize + +You can also use the first two operations---defining the entry point and +defining symbols---outside the @code{SECTIONS} command: @pxref{Entry +Point}, and @ref{Assignment}. They are permitted here as well for +your convenience in reading the script, so that symbols and the entry +point can be defined at meaningful points in your output-file layout. + +If you do not use a @code{SECTIONS} command, the linker places each input +section into an identically named output section in the order that the +sections are first encountered in the input files. If all input sections +are present in the first file, for example, the order of sections in the +output file will match the order in the first input file. + +@menu +* Section Definition:: Section Definitions +* Section Placement:: Section Placement +* Section Data Expressions:: Section Data Expressions +* Section Options:: Optional Section Attributes +* Overlays:: Overlays +@end menu + +@node Section Definition +@subsection Section Definitions +@cindex section definition +The most frequently used statement in the @code{SECTIONS} command is +the @dfn{section definition}, which specifies the +properties of an output section: its location, alignment, contents, +fill pattern, and target memory region. Most of +these specifications are optional; the simplest form of a section +definition is +@smallexample +SECTIONS @{ @dots{} + @var{secname} : @{ + @var{contents} + @} +@dots{} @} +@end smallexample +@cindex naming output sections +@noindent +@var{secname} is the name of the output section, and @var{contents} a +specification of what goes there---for example, a list of input files or +sections of input files (@pxref{Section Placement}). As you might +assume, the whitespace shown is optional. You do need the colon +@samp{:} and the braces @samp{@{@}}, however. + +@var{secname} must meet the constraints of your output format. In +formats which only support a limited number of sections, such as +@code{a.out}, the name must be one of the names supported by the format +(@code{a.out}, for example, allows only @code{.text}, @code{.data} or +@code{.bss}). If the output format supports any number of sections, but +with numbers and not names (as is the case for Oasys), the name should be +supplied as a quoted numeric string. A section name may consist of any +sequence of characters, but any name which does not conform to the standard +@code{ld} symbol name syntax must be quoted. +@xref{Symbols, , Symbol Names}. + +The special @var{secname} @samp{/DISCARD/} may be used to discard input +sections. Any sections which are assigned to an output section named +@samp{/DISCARD/} are not included in the final link output. + +The linker will not create output sections which do not have any +contents. This is for convenience when referring to input sections that +may or may not exist. For example, +@smallexample +.foo @{ *(.foo) @} +@end smallexample +will only create a @samp{.foo} section in the output file if there is a +@samp{.foo} section in at least one input file. + +@node Section Placement +@subsection Section Placement + +@cindex contents of a section +In a section definition, you can specify the contents of an output +section by listing particular input files, by listing particular +input-file sections, or by a combination of the two. You can also place +arbitrary data in the section, and define symbols relative to the +beginning of the section. + +The @var{contents} of a section definition may include any of the +following kinds of statement. You can include as many of these as you +like in a single section definition, separated from one another by +whitespace. + +@table @code +@kindex @var{filename} +@cindex input files, section defn +@cindex files, including in output sections +@item @var{filename} +You may simply name a particular input file to be placed in the current +output section; @emph{all} sections from that file are placed in the +current section definition. If the file name has already been mentioned +in another section definition, with an explicit section name list, then +only those sections which have not yet been allocated are used. + +To specify a list of particular files by name: +@smallexample +.data : @{ afile.o bfile.o cfile.o @} +@end smallexample +@noindent +The example also illustrates that multiple statements can be included in +the contents of a section definition, since each file name is a separate +statement. + +@kindex @var{filename}(@var{section}) +@cindex files and sections, section defn +@item @var{filename}( @var{section} ) +@itemx @var{filename}( @var{section} , @var{section}, @dots{} ) +@itemx @var{filename}( @var{section} @var{section} @dots{} ) +You can name one or more sections from your input files, for +insertion in the current output section. If you wish to specify a list +of input-file sections inside the parentheses, you may separate the +section names by either commas or whitespace. + +@cindex input sections to output section +@kindex *(@var{section}) +@item * (@var{section}) +@itemx * (@var{section}, @var{section}, @dots{}) +@itemx * (@var{section} @var{section} @dots{}) +Instead of explicitly naming particular input files in a link control +script, you can refer to @emph{all} files from the @code{ld} command +line: use @samp{*} instead of a particular file name before the +parenthesized input-file section list. + +If you have already explicitly included some files by name, @samp{*} +refers to all @emph{remaining} files---those whose places in the output +file have not yet been defined. + +For example, to copy sections @code{1} through @code{4} from an Oasys file +into the @code{.text} section of an @code{a.out} file, and sections @code{13} +and @code{14} into the @code{.data} section: +@smallexample +@group +SECTIONS @{ + .text :@{ + *("1" "2" "3" "4") + @} + + .data :@{ + *("13" "14") + @} +@} +@end group +@end smallexample + +@cindex @code{[@var{section}@dots{}]}, not supported +@samp{[ @var{section} @dots{} ]} used to be accepted as an alternate way +to specify named sections from all unallocated input files. Because +some operating systems (VMS) allow brackets in file names, that notation +is no longer supported. + +@cindex uninitialized data +@cindex commons in output +@kindex *( COMMON ) +@item @var{filename}@code{( COMMON )} +@itemx *( COMMON ) +Specify where in your output file to place uninitialized data +with this notation. @code{*(COMMON)} by itself refers to all +uninitialized data from all input files (so far as it is not yet +allocated); @var{filename}@code{(COMMON)} refers to uninitialized data +from a particular file. Both are special cases of the general +mechanisms for specifying where to place input-file sections: +@code{ld} permits you to refer to uninitialized data as if it +were in an input-file section named @code{COMMON}, regardless of the +input file's format. +@end table + +In any place where you may use a specific file or section name, you may +also use a wildcard pattern. The linker handles wildcards much as the +Unix shell does. A @samp{*} character matches any number of characters. +A @samp{?} character matches any single character. The sequence +@samp{[@var{chars}]} will match a single instance of any of the +@var{chars}; the @samp{-} character may be used to specify a range of +characters, as in @samp{[a-z]} to match any lower case letter. A +@samp{\} character may be used to quote the following character. + +When a file name is matched with a wildcard, the wildcard characters +will not match a @samp{/} character (used to separate directory names on +Unix). A pattern consisting of a single @samp{*} character is an +exception; it will always match any file name. In a section name, the +wildcard characters will match a @samp{/} character. + +Wildcards only match files which are explicitly specified on the command +line. The linker does not search directories to expand wildcards. +However, if you specify a simple file name---a name with no wildcard +characters---in a linker script, and the file name is not also specified +on the command line, the linker will attempt to open the file as though +it appeared on the command line. + +In the following example, the command script arranges the output file +into three consecutive sections, named @code{.text}, @code{.data}, and +@code{.bss}, taking the input for each from the correspondingly named +sections of all the input files: + +@smallexample +@group +SECTIONS @{ + .text : @{ *(.text) @} + .data : @{ *(.data) @} + .bss : @{ *(.bss) *(COMMON) @} +@} +@end group +@end smallexample + +The following example reads all of the sections from file @code{all.o} +and places them at the start of output section @code{outputa} which +starts at location @code{0x10000}. All of section @code{.input1} from +file @code{foo.o} follows immediately, in the same output section. All +of section @code{.input2} from @code{foo.o} goes into output section +@code{outputb}, followed by section @code{.input1} from @code{foo1.o}. +All of the remaining @code{.input1} and @code{.input2} sections from any +files are written to output section @code{outputc}. + +@smallexample +@group +SECTIONS @{ + outputa 0x10000 : + @{ + all.o + foo.o (.input1) + @} + outputb : + @{ + foo.o (.input2) + foo1.o (.input1) + @} + outputc : + @{ + *(.input1) + *(.input2) + @} +@} +@end group +@end smallexample + +This example shows how wildcard patterns might be used to partition +files. All @code{.text} sections are placed in @code{.text}, and all +@code{.bss} sections are placed in @code{.bss}. For all files beginning +with an upper case character, the @code{.data} section is placed into +@code{.DATA}; for all other files, the @code{.data} section is placed +into @code{.data}. + +@smallexample +@group +SECTIONS @{ + .text : @{ *(.text) @} + .DATA : @{ [A-Z]*(.data) @} + .data : @{ *(.data) @} + .bss : @{ *(.bss) @} +@} +@end group +@end smallexample + +@node Section Data Expressions +@subsection Section Data Expressions + +@cindex expressions in a section +The foregoing statements arrange, in your output file, data originating +from your input files. You can also place data directly in an output +section from the link command script. Most of these additional +statements involve expressions (@pxref{Expressions}). Although these +statements are shown separately here for ease of presentation, no such +segregation is needed within a section definition in the @code{SECTIONS} +command; you can intermix them freely with any of the statements we've +just described. + +@table @code +@cindex input filename symbols +@cindex filename symbols +@kindex CREATE_OBJECT_SYMBOLS +@item CREATE_OBJECT_SYMBOLS +Create a symbol for each input file +in the current section, set to the address of the first byte of +data written from that input file. For instance, with @code{a.out} +files it is conventional to have a symbol for each input file. You can +accomplish this by defining the output @code{.text} section as follows: +@smallexample +@group +SECTIONS @{ + .text 0x2020 : + @{ + CREATE_OBJECT_SYMBOLS + *(.text) + _etext = ALIGN(0x2000); + @} + @dots{} +@} +@end group +@end smallexample + +If @code{sample.ld} is a file containing this script, and @code{a.o}, +@code{b.o}, @code{c.o}, and @code{d.o} are four input files with +contents like the following--- +@smallexample +@group +/* a.c */ + +afunction() @{ @} +int adata=1; +int abss; +@end group +@end smallexample + +@noindent +@samp{ld -M -T sample.ld a.o b.o c.o d.o} would create a map like this, +containing symbols matching the object file names: +@smallexample +00000000 A __DYNAMIC +00004020 B _abss +00004000 D _adata +00002020 T _afunction +00004024 B _bbss +00004008 D _bdata +00002038 T _bfunction +00004028 B _cbss +00004010 D _cdata +00002050 T _cfunction +0000402c B _dbss +00004018 D _ddata +00002068 T _dfunction +00004020 D _edata +00004030 B _end +00004000 T _etext +00002020 t a.o +00002038 t b.o +00002050 t c.o +00002068 t d.o +@end smallexample + +@kindex @var{symbol} = @var{expression} ; +@kindex @var{symbol} @var{f}= @var{expression} ; +@item @var{symbol} = @var{expression} ; +@itemx @var{symbol} @var{f}= @var{expression} ; +@var{symbol} is any symbol name (@pxref{Symbols}). ``@var{f}='' +refers to any of the operators @code{&= += -= *= /=} which combine +arithmetic and assignment. + +@cindex assignment, in section defn +When you assign a value to a symbol within a particular section +definition, the value is relative to the beginning of the section +(@pxref{Assignment}). If you write + +@smallexample +@group +SECTIONS @{ + abs = 14 ; + @dots{} + .data : @{ @dots{} rel = 14 ; @dots{} @} + abs2 = 14 + ADDR(.data); + @dots{} +@} +@end group +@end smallexample + +@c FIXME: Try above example! +@noindent +@code{abs} and @code{rel} do not have the same value; @code{rel} has the +same value as @code{abs2}. + +@kindex BYTE(@var{expression}) +@kindex SHORT(@var{expression}) +@kindex LONG(@var{expression}) +@kindex QUAD(@var{expression}) +@cindex direct output +@item BYTE(@var{expression}) +@itemx SHORT(@var{expression}) +@itemx LONG(@var{expression}) +@itemx QUAD(@var{expression}) +By including one of these four statements in a section definition, you +can explicitly place one, two, four, or eight bytes (respectively) at +the current address of that section. @code{QUAD} is only supported when +using a 64 bit host or target. + +@ifclear SingleFormat +Multiple-byte quantities are represented in whatever byte order is +appropriate for the output file format (@pxref{BFD}). +@end ifclear + +@kindex FILL(@var{expression}) +@cindex holes, filling +@cindex unspecified memory +@item FILL(@var{expression}) +Specify the ``fill pattern'' for the current section. Any otherwise +unspecified regions of memory within the section (for example, regions +you skip over by assigning a new value to the location counter @samp{.}) +are filled with the two least significant bytes from the +@var{expression} argument. A @code{FILL} statement covers memory +locations @emph{after} the point it occurs in the section definition; by +including more than one @code{FILL} statement, you can have different +fill patterns in different parts of an output section. +@end table + +@node Section Options +@subsection Optional Section Attributes +@cindex section defn, full syntax +Here is the full syntax of a section definition, including all the +optional portions: + +@smallexample +@group +SECTIONS @{ +@dots{} +@var{secname} @var{start} BLOCK(@var{align}) (NOLOAD) : AT ( @var{ldadr} ) + @{ @var{contents} @} >@var{region} :@var{phdr} =@var{fill} +@dots{} +@} +@end group +@end smallexample + +@var{secname} and @var{contents} are required. @xref{Section +Definition}, and @ref{Section Placement}, for details on +@var{contents}. The remaining elements---@var{start}, +@code{BLOCK(@var{align)}}, @code{(NOLOAD)}, @code{AT ( @var{ldadr} )}, +@code{>@var{region}}, @code{:@var{phdr}}, and @code{=@var{fill}}---are +all optional. + +@table @code +@cindex start address, section +@cindex section start +@cindex section address +@item @var{start} +You can force the output section to be loaded at a specified address by +specifying @var{start} immediately following the section name. +@var{start} can be represented as any expression. The following +example generates section @var{output} at location +@code{0x40000000}: + +@smallexample +@group +SECTIONS @{ + @dots{} + output 0x40000000: @{ + @dots{} + @} + @dots{} +@} +@end group +@end smallexample + +@kindex BLOCK(@var{align}) +@cindex section alignment +@cindex aligning sections +@item BLOCK(@var{align}) +You can include @code{BLOCK()} specification to advance +the location counter @code{.} prior to the beginning of the section, so +that the section will begin at the specified alignment. @var{align} is +an expression. + +@kindex NOLOAD +@cindex prevent unnecessary loading +@cindex loading, preventing +@item (NOLOAD) +Use @samp{(NOLOAD)} to prevent a section from being loaded into memory +each time it is accessed. For example, in the script sample below, the +@code{ROM} segment is addressed at memory location @samp{0} and does not +need to be loaded into each object file: + +@smallexample +@group +SECTIONS @{ + ROM 0 (NOLOAD) : @{ @dots{} @} + @dots{} +@} +@end group +@end smallexample + +@kindex AT ( @var{ldadr} ) +@cindex specify load address +@cindex load address, specifying +@item AT ( @var{ldadr} ) +The expression @var{ldadr} that follows the @code{AT} keyword specifies +the load address of the section. The default (if you do not use the +@code{AT} keyword) is to make the load address the same as the +relocation address. This feature is designed to make it easy to build a +ROM image. For example, this @code{SECTIONS} definition creates two +output sections: one called @samp{.text}, which starts at @code{0x1000}, +and one called @samp{.mdata}, which is loaded at the end of the +@samp{.text} section even though its relocation address is +@code{0x2000}. The symbol @code{_data} is defined with the value +@code{0x2000}: + +@smallexample +@group +SECTIONS + @{ + .text 0x1000 : @{ *(.text) _etext = . ; @} + .mdata 0x2000 : + AT ( ADDR(.text) + SIZEOF ( .text ) ) + @{ _data = . ; *(.data); _edata = . ; @} + .bss 0x3000 : + @{ _bstart = . ; *(.bss) *(COMMON) ; _bend = . ;@} +@} +@end group +@end smallexample + +The run-time initialization code (for C programs, usually @code{crt0}) +for use with a ROM generated this way has to include something like +the following, to copy the initialized data from the ROM image to its runtime +address: + +@smallexample +@group +char *src = _etext; +char *dst = _data; + +/* ROM has data at end of text; copy it. */ +while (dst < _edata) @{ + *dst++ = *src++; +@} + +/* Zero bss */ +for (dst = _bstart; dst< _bend; dst++) + *dst = 0; +@end group +@end smallexample + +@kindex >@var{region} +@cindex section, assigning to memory region +@cindex memory regions and sections +@item >@var{region} +Assign this section to a previously defined region of memory. +@xref{MEMORY}. + +@kindex :@var{phdr} +@cindex section, assigning to program header +@cindex program headers and sections +@item :@var{phdr} +Assign this section to a segment described by a program header. +@xref{PHDRS}. If a section is assigned to one or more segments, then +all subsequent allocated sections will be assigned to those segments as +well, unless they use an explicitly @code{:@var{phdr}} modifier. To +prevent a section from being assigned to a segment when it would +normally default to one, use @code{:NONE}. + +@kindex =@var{fill} +@cindex section fill pattern +@cindex fill pattern, entire section +@item =@var{fill} +Including @code{=@var{fill}} in a section definition specifies the +initial fill value for that section. You may use any expression to +specify @var{fill}. Any unallocated holes in the current output section +when written to the output file will be filled with the two least +significant bytes of the value, repeated as necessary. You can also +change the fill value with a @code{FILL} statement in the @var{contents} +of a section definition. + +@end table + +@node Overlays +@subsection Overlays +@kindex OVERLAY +@cindex overlays + +The @code{OVERLAY} command provides an easy way to describe sections +which are to be loaded as part of a single memory image but are to be +run at the same memory address. At run time, some sort of overlay +manager will copy the overlaid sections in and out of the runtime memory +address as required, perhaps by simply manipulating addressing bits. +This approach can be useful, for example, when a certain region of +memory is faster than another. + +The @code{OVERLAY} command is used within a @code{SECTIONS} command. It +appears as follows: +@smallexample +@group + OVERLAY @var{start} : [ NOCROSSREFS ] AT ( @var{ldaddr} ) + @{ + @var{secname1} @{ @var{contents} @} :@var{phdr} =@var{fill} + @var{secname2} @{ @var{contents} @} :@var{phdr} =@var{fill} + @dots{} + @} >@var{region} :@var{phdr} =@var{fill} +@end group +@end smallexample + +Everything is optional except @code{OVERLAY} (a keyword), and each +section must have a name (@var{secname1} and @var{secname2} above). The +section definitions within the @code{OVERLAY} construct are identical to +those within the general @code{SECTIONS} contruct (@pxref{SECTIONS}), +except that no addresses and no memory regions may be defined for +sections within an @code{OVERLAY}. + +The sections are all defined with the same starting address. The load +addresses of the sections are arranged such that they are consecutive in +memory starting at the load address used for the @code{OVERLAY} as a +whole (as with normal section definitions, the load address is optional, +and defaults to the start address; the start address is also optional, +and defaults to @code{.}). + +If the @code{NOCROSSREFS} keyword is used, and there any references +among the sections, the linker will report an error. Since the sections +all run at the same address, it normally does not make sense for one +section to refer directly to another. @xref{Option Commands, +NOCROSSREFS}. + +For each section within the @code{OVERLAY}, the linker automatically +defines two symbols. The symbol @code{__load_start_@var{secname}} is +defined as the starting load address of the section. The symbol +@code{__load_stop_@var{secname}} is defined as the final load address of +the section. Any characters within @var{secname} which are not legal +within C identifiers are removed. C (or assembler) code may use these +symbols to move the overlaid sections around as necessary. + +At the end of the overlay, the value of @code{.} is set to the start +address of the overlay plus the size of the largest section. + +Here is an example. Remember that this would appear inside a +@code{SECTIONS} construct. + +@smallexample +@group + OVERLAY 0x1000 : AT (0x4000) + @{ + .text0 @{ o1/*.o(.text) @} + .text1 @{ o2/*.o(.text) @} + @} +@end group +@end smallexample + +This will define both @code{.text0} and @code{.text1} to start at +address 0x1000. @code{.text0} will be loaded at address 0x4000, and +@code{.text1} will be loaded immediately after @code{.text0}. The +following symbols will be defined: @code{__load_start_text0}, +@code{__load_stop_text0}, @code{__load_start_text1}, +@code{__load_stop_text1}. + +C code to copy overlay @code{.text1} into the overlay area might look +like the following. + +@smallexample +@group + extern char __load_start_text1, __load_stop_text1; + memcpy ((char *) 0x1000, &__load_start_text1, + &__load_stop_text1 - &__load_start_text1); +@end group +@end smallexample + +Note that the @code{OVERLAY} command is just syntactic sugar, since +everything it does can be done using the more basic commands. The above +example could have been written identically as follows. + +@smallexample +@group + .text0 0x1000 : AT (0x4000) @{ o1/*.o(.text) @} + __load_start_text0 = LOADADDR (.text0); + __load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0); + .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) @{ o2/*.o(.text) @} + __load_start_text1 = LOADADDR (.text1); + __load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1); + . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1)); +@end group +@end smallexample + +@node PHDRS +@section ELF Program Headers +@kindex PHDRS +@cindex program headers +@cindex ELF program headers + +The ELF object file format uses @dfn{program headers}, which are read by +the system loader and describe how the program should be loaded into +memory. These program headers must be set correctly in order to run the +program on a native ELF system. The linker will create reasonable +program headers by default. However, in some cases, it is desirable to +specify the program headers more precisely; the @code{PHDRS} command may +be used for this purpose. When the @code{PHDRS} command is used, the +linker will not generate any program headers itself. + +The @code{PHDRS} command is only meaningful when generating an ELF +output file. It is ignored in other cases. This manual does not +describe the details of how the system loader interprets program +headers; for more information, see the ELF ABI. The program headers of +an ELF file may be displayed using the @samp{-p} option of the +@code{objdump} command. + +This is the syntax of the @code{PHDRS} command. The words @code{PHDRS}, +@code{FILEHDR}, @code{AT}, and @code{FLAGS} are keywords. + +@smallexample +@group +PHDRS +@{ + @var{name} @var{type} [ FILEHDR ] [ PHDRS ] [ AT ( @var{address} ) ] + [ FLAGS ( @var{flags} ) ] ; +@} +@end group +@end smallexample + +The @var{name} is used only for reference in the @code{SECTIONS} command +of the linker script. It does not get put into the output file. + +Certain program header types describe segments of memory which are +loaded from the file by the system loader. In the linker script, the +contents of these segments are specified by directing allocated output +sections to be placed in the segment. To do this, the command +describing the output section in the @code{SECTIONS} command should use +@samp{:@var{name}}, where @var{name} is the name of the program header +as it appears in the @code{PHDRS} command. @xref{Section Options}. + +It is normal for certain sections to appear in more than one segment. +This merely implies that one segment of memory contains another. This +is specified by repeating @samp{:@var{name}}, using it once for each +program header in which the section is to appear. + +If a section is placed in one or more segments using @samp{:@var{name}}, +then all subsequent allocated sections which do not specify +@samp{:@var{name}} are placed in the same segments. This is for +convenience, since generally a whole set of contiguous sections will be +placed in a single segment. To prevent a section from being assigned to +a segment when it would normally default to one, use @code{:NONE}. + +The @code{FILEHDR} and @code{PHDRS} keywords which may appear after the +program header type also indicate contents of the segment of memory. +The @code{FILEHDR} keyword means that the segment should include the ELF +file header. The @code{PHDRS} keyword means that the segment should +include the ELF program headers themselves. + +The @var{type} may be one of the following. The numbers indicate the +value of the keyword. + +@table @asis +@item @code{PT_NULL} (0) +Indicates an unused program header. + +@item @code{PT_LOAD} (1) +Indicates that this program header describes a segment to be loaded from +the file. + +@item @code{PT_DYNAMIC} (2) +Indicates a segment where dynamic linking information can be found. + +@item @code{PT_INTERP} (3) +Indicates a segment where the name of the program interpreter may be +found. + +@item @code{PT_NOTE} (4) +Indicates a segment holding note information. + +@item @code{PT_SHLIB} (5) +A reserved program header type, defined but not specified by the ELF +ABI. + +@item @code{PT_PHDR} (6) +Indicates a segment where the program headers may be found. + +@item @var{expression} +An expression giving the numeric type of the program header. This may +be used for types not defined above. +@end table + +It is possible to specify that a segment should be loaded at a +particular address in memory. This is done using an @code{AT} +expression. This is identical to the @code{AT} command used in the +@code{SECTIONS} command (@pxref{Section Options}). Using the @code{AT} +command for a program header overrides any information in the +@code{SECTIONS} command. + +Normally the segment flags are set based on the sections. The +@code{FLAGS} keyword may be used to explicitly specify the segment +flags. The value of @var{flags} must be an integer. It is used to +set the @code{p_flags} field of the program header. + +Here is an example of the use of @code{PHDRS}. This shows a typical set +of program headers used on a native ELF system. + +@example +@group +PHDRS +@{ + headers PT_PHDR PHDRS ; + interp PT_INTERP ; + text PT_LOAD FILEHDR PHDRS ; + data PT_LOAD ; + dynamic PT_DYNAMIC ; +@} + +SECTIONS +@{ + . = SIZEOF_HEADERS; + .interp : @{ *(.interp) @} :text :interp + .text : @{ *(.text) @} :text + .rodata : @{ *(.rodata) @} /* defaults to :text */ + @dots{} + . = . + 0x1000; /* move to a new page in memory */ + .data : @{ *(.data) @} :data + .dynamic : @{ *(.dynamic) @} :data :dynamic + @dots{} +@} +@end group +@end example + +@node Entry Point +@section The Entry Point +@kindex ENTRY(@var{symbol}) +@cindex start of execution +@cindex first instruction +The linker command language includes a command specifically for +defining the first executable instruction in an output file (its +@dfn{entry point}). Its argument is a symbol name: +@smallexample +ENTRY(@var{symbol}) +@end smallexample + +Like symbol assignments, the @code{ENTRY} command may be placed either +as an independent command in the command file, or among the section +definitions within the @code{SECTIONS} command---whatever makes the most +sense for your layout. + +@cindex entry point, defaults +@code{ENTRY} is only one of several ways of choosing the entry point. +You may indicate it in any of the following ways (shown in descending +order of priority: methods higher in the list override methods lower down). +@itemize @bullet +@item +the @samp{-e} @var{entry} command-line option; +@item +the @code{ENTRY(@var{symbol})} command in a linker control script; +@item +the value of the symbol @code{start}, if present; +@item +the address of the first byte of the @code{.text} section, if present; +@item +The address @code{0}. +@end itemize + +For example, you can use these rules to generate an entry point with an +assignment statement: if no symbol @code{start} is defined within your +input files, you can simply define it, assigning it an appropriate +value--- + +@smallexample +start = 0x2020; +@end smallexample + +@noindent +The example shows an absolute address, but you can use any expression. +For example, if your input object files use some other symbol-name +convention for the entry point, you can just assign the value of +whatever symbol contains the start address to @code{start}: + +@smallexample +start = other_symbol ; +@end smallexample + +@node Version Script +@section Version Script +@kindex VERSION @{script text@} +@cindex symbol versions +@cindex version script +@cindex versions of symbols +The linker command script includes a command specifically for +specifying a version script, and is only meaningful for ELF platforms +that support shared libraries. A version script can be +build directly into the linker script that you are using, or you +can supply the version script as just another input file to the linker +at the time that you link. The command script syntax is: +@smallexample +VERSION @{ version script contents @} +@end smallexample +The version script can also be specified to the linker by means of the +@samp{--version-script} linker command line option. +Version scripts are only meaningful when creating shared libraries. + +The format of the version script itself is identical to that used by +Sun's linker in Solaris 2.5. Versioning is done by defining a tree of +version nodes with the names and interdependencies specified in the +version script. The version script can specify which symbols are bound +to which version nodes, and it can reduce a specified set of symbols to +local scope so that they are not globally visible outside of the shared +library. + +The easiest way to demonstrate the version script language is with a few +examples. + +@smallexample +VERS_1.1 @{ + global: + foo1; + local: + old*; + original*; + new*; +@}; + +VERS_1.2 @{ + foo2; +@} VERS_1.1; + +VERS_2.0 @{ + bar1; bar2; +@} VERS_1.2; +@end smallexample + +In this example, three version nodes are defined. @samp{VERS_1.1} is the +first version node defined, and has no other dependencies. The symbol +@samp{foo1} is bound to this version node, and a number of symbols +that have appeared within various object files are reduced in scope to +local so that they are not visible outside of the shared library. + +Next, the node @samp{VERS_1.2} is defined. It depends upon +@samp{VERS_1.1}. The symbol @samp{foo2} is bound to this version node. + +Finally, the node @samp{VERS_2.0} is defined. It depends upon +@samp{VERS_1.2}. The symbols @samp{bar1} and @samp{bar2} are bound to +this version node. + +Symbols defined in the library which aren't specifically bound to a +version node are effectively bound to an unspecified base version of the +library. It is possible to bind all otherwise unspecified symbols to a +given version node using @samp{global: *} somewhere in the version +script. + +Lexically the names of the version nodes have no specific meaning other +than what they might suggest to the person reading them. The @samp{2.0} +version could just as well have appeared in between @samp{1.1} and +@samp{1.2}. However, this would be a confusing way to write a version +script. + +When you link an application against a shared library that has versioned +symbols, the application itself knows which version of each symbol it requires, +and it also knows which version nodes it needs from each shared library it is +linked against. Thus at runtime, the dynamic loader can make a quick check to +make sure that the libraries you have linked against do in fact supply all +of the version nodes that the application will need to resolve all of the +dynamic symbols. In this way it is possible for the dynamic linker to know +with certainty that all external symbols that it needs will be resolvable +without having to search for each symbol reference. + +The symbol versioning is in effect a much more sophisticated way of +doing minor version checking that SunOS does. The fundamental problem +that is being addressed here is that typically references to external +functions are bound on an as-needed basis, and are not all bound when +the application starts up. If a shared library is out of date, a +required interface may be missing; when the application tries to use +that interface, it may suddenly and unexpectedly fail. With symbol +versioning, the user will get a warning when they start their program if +the libraries being used with the application are too old. + +There are several GNU extensions to Sun's versioning approach. The +first of these is the ability to bind a symbol to a version node in the +source file where the symbol is defined instead of in the versioning +script. This was done mainly to reduce the burden on the library +maintainer. This can be done by putting something like: + +@smallexample +__asm__(".symver original_foo,foo@@VERS_1.1"); +@end smallexample + +in the C source file. This renamed the function @samp{original_foo} to +be an alias for @samp{foo} bound to the version node @samp{VERS_1.1}. +The @samp{local:} directive can be used to prevent the symbol +@samp{original_foo} from being exported. + +The second GNU extension is to allow multiple versions of the same function +to appear in a given shared library. In this way an incompatible change to +an interface can take place without increasing the major version number of +the shared library, while still allowing applications linked against the old +interface to continue to function. + +This can only be accomplished by using multiple @samp{.symver} +directives in the assembler. An example of this would be: + +@smallexample +__asm__(".symver original_foo,foo@@"); +__asm__(".symver old_foo,foo@@VERS_1.1"); +__asm__(".symver old_foo1,foo@@VERS_1.2"); +__asm__(".symver new_foo,foo@@@@VERS_2.0"); +@end smallexample + +In this example, @samp{foo@@} represents the symbol @samp{foo} bound to the +unspecified base version of the symbol. The source file that contains this +example would define 4 C functions: @samp{original_foo}, @samp{old_foo}, +@samp{old_foo1}, and @samp{new_foo}. + +When you have multiple definitions of a given symbol, there needs to be +some way to specify a default version to which external references to +this symbol will be bound. This can be accomplished with the +@samp{foo@@@@VERS_2.0} type of @samp{.symver} directive. Only one version of +a symbol can be declared 'default' in this manner - otherwise you would +effectively have multiple definitions of the same symbol. + +If you wish to bind a reference to a specific version of the symbol +within the shared library, you can use the aliases of convenience +(i.e. @samp{old_foo}), or you can use the @samp{.symver} directive to +specifically bind to an external version of the function in question. + +@node Option Commands +@section Option Commands +The command language includes a number of other commands that you can +use for specialized purposes. They are similar in purpose to +command-line options. + +@table @code +@kindex CONSTRUCTORS +@cindex C++ constructors, arranging in link +@cindex constructors, arranging in link +@item CONSTRUCTORS +When linking using the @code{a.out} object file format, the linker uses +an unusual set construct to support C++ global constructors and +destructors. When linking object file formats which do not support +arbitrary sections, such as @code{ECOFF} and @code{XCOFF}, the linker +will automatically recognize C++ global constructors and destructors by +name. For these object file formats, the @code{CONSTRUCTORS} command +tells the linker where this information should be placed. The +@code{CONSTRUCTORS} command is ignored for other object file formats. + +The symbol @w{@code{__CTOR_LIST__}} marks the start of the global +constructors, and the symbol @w{@code{__DTOR_LIST}} marks the end. The +first word in the list is the number of entries, followed by the address +of each constructor or destructor, followed by a zero word. The +compiler must arrange to actually run the code. For these object file +formats @sc{gnu} C++ calls constructors from a subroutine @code{__main}; +a call to @code{__main} is automatically inserted into the startup code +for @code{main}. @sc{gnu} C++ runs destructors either by using +@code{atexit}, or directly from the function @code{exit}. + +For object file formats such as @code{COFF} or @code{ELF} which support +multiple sections, @sc{gnu} C++ will normally arrange to put the +addresses of global constructors and destructors into the @code{.ctors} +and @code{.dtors} sections. Placing the following sequence into your +linker script will build the sort of table which the @sc{gnu} C++ +runtime code expects to see. + +@smallexample + __CTOR_LIST__ = .; + LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + *(.ctors) + LONG(0) + __CTOR_END__ = .; + __DTOR_LIST__ = .; + LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) + *(.dtors) + LONG(0) + __DTOR_END__ = .; +@end smallexample + +Normally the compiler and linker will handle these issues automatically, +and you will not need to concern yourself with them. However, you may +need to consider this if you are using C++ and writing your own linker +scripts. + +@need 1000 +@kindex FLOAT +@kindex NOFLOAT +@item FLOAT +@itemx NOFLOAT +These keywords were used in some older linkers to request a particular +math subroutine library. @code{ld} doesn't use the keywords, assuming +instead that any necessary subroutines are in libraries specified using +the general mechanisms for linking to archives; but to permit the use of +scripts that were written for the older linkers, the keywords +@code{FLOAT} and @code{NOFLOAT} are accepted and ignored. + +@kindex FORCE_COMMON_ALLOCATION +@cindex common allocation +@item FORCE_COMMON_ALLOCATION +This command has the same effect as the @samp{-d} command-line option: +to make @code{ld} assign space to common symbols even if a relocatable +output file is specified (@samp{-r}). + +@kindex INCLUDE @var{filename} +@cindex including a linker script +@item INCLUDE @var{filename} +Include the linker script @var{filename} at this point. The file will +be searched for in the current directory, and in any directory specified +with the @code{-L} option. You can nest calls to @code{INCLUDE} up to +10 levels deep. + +@kindex INPUT ( @var{files} ) +@cindex binary input files +@item INPUT ( @var{file}, @var{file}, @dots{} ) +@itemx INPUT ( @var{file} @var{file} @dots{} ) +Use this command to include binary input files in the link, without +including them in a particular section definition. +Specify the full name for each @var{file}, including @samp{.a} if +required. + +@code{ld} searches for each @var{file} through the archive-library +search path, just as for files you specify on the command line. +See the description of @samp{-L} in @ref{Options,,Command Line +Options}. + +If you use @samp{-l@var{file}}, @code{ld} will transform the name to +@code{lib@var{file}.a} as with the command line argument @samp{-l}. + +@kindex GROUP ( @var{files} ) +@cindex grouping input files +@item GROUP ( @var{file}, @var{file}, @dots{} ) +@itemx GROUP ( @var{file} @var{file} @dots{} ) +This command is like @code{INPUT}, except that the named files should +all be archives, and they are searched repeatedly until no new undefined +references are created. See the description of @samp{-(} in +@ref{Options,,Command Line Options}. + +@ignore +@kindex MAP ( @var{name} ) +@item MAP ( @var{name} ) +@c MAP(...) appears to look for an F in the arg, ignoring all other +@c chars; if it finds one, it sets "map_option_f" to true. But nothing +@c checks map_option_f. Apparently a stub for the future... +@end ignore + +@kindex OUTPUT ( @var{filename} ) +@cindex naming the output file +@item OUTPUT ( @var{filename} ) +Use this command to name the link output file @var{filename}. The +effect of @code{OUTPUT(@var{filename})} is identical to the effect of +@w{@samp{-o @var{filename}}}, which overrides it. You can use this +command to supply a default output-file name other than @code{a.out}. + +@ifclear SingleFormat +@kindex OUTPUT_ARCH ( @var{bfdname} ) +@cindex machine architecture, output +@item OUTPUT_ARCH ( @var{bfdname} ) +Specify a particular output machine architecture, with one of the names +used by the BFD back-end routines (@pxref{BFD}). This command is often +unnecessary; the architecture is most often set implicitly by either the +system BFD configuration or as a side effect of the @code{OUTPUT_FORMAT} +command. + +@kindex OUTPUT_FORMAT ( @var{bfdname} ) +@cindex format, output file +@item OUTPUT_FORMAT ( @var{bfdname} ) +When @code{ld} is configured to support multiple object code formats, +you can use this command to specify a particular output format. +@var{bfdname} is one of the names used by the BFD back-end routines +(@pxref{BFD}). The effect is identical to the effect of the +@samp{--oformat} command-line option. This selection affects only the +output file; the related command @code{TARGET} affects primarily input +files. +@end ifclear + +@kindex SEARCH_DIR ( @var{path} ) +@cindex path for libraries +@cindex search path, libraries +@item SEARCH_DIR ( @var{path} ) +Add @var{path} to the list of paths where @code{ld} looks for +archive libraries. @code{SEARCH_DIR(@var{path})} has the same +effect as @samp{-L@var{path}} on the command line. + +@kindex STARTUP ( @var{filename} ) +@cindex first input file +@item STARTUP ( @var{filename} ) +Ensure that @var{filename} is the first input file used in the link +process. + +@ifclear SingleFormat +@cindex input file format +@kindex TARGET ( @var{format} ) +@item TARGET ( @var{format} ) +When @code{ld} is configured to support multiple object code formats, +you can use this command to change the input-file object code format +(like the command-line option @samp{-b} or its synonym @samp{--format}). +The argument @var{format} is one of the strings used by BFD to name +binary formats. If @code{TARGET} is specified but @code{OUTPUT_FORMAT} +is not, the last @code{TARGET} argument is also used as the default +format for the @code{ld} output file. @xref{BFD}. + +@kindex GNUTARGET +If you don't use the @code{TARGET} command, @code{ld} uses the value of +the environment variable @code{GNUTARGET}, if available, to select the +output file format. If that variable is also absent, @code{ld} uses +the default format configured for your machine in the BFD libraries. +@end ifclear + +@cindex cross references +@kindex NOCROSSREFS ( @var{sections} ) +@item NOCROSSREFS ( @var{section} @var{section} @dots{} ) +This command may be used to tell @code{ld} to issue an error about any +references among certain sections. + +In certain types of programs, particularly on embedded systems, when one +section is loaded into memory, another section will not be. Any direct +references between the two sections would be errors. For example, it +would be an error if code in one section called a function defined in +the other section. + +The @code{NOCROSSREFS} command takes a list of section names. If +@code{ld} detects any cross references between the sections, it reports +an error and returns a non-zero exit status. The @code{NOCROSSREFS} +command uses output section names, defined in the @code{SECTIONS} +command. It does not use the names of input sections. +@end table + +@ifset GENERIC +@node Machine Dependent +@chapter Machine Dependent Features + +@cindex machine dependencies +@code{ld} has additional features on some platforms; the following +sections describe them. Machines where @code{ld} has no additional +functionality are not listed. + +@menu +* H8/300:: @code{ld} and the H8/300 +* i960:: @code{ld} and the Intel 960 family +@end menu +@end ifset + +@c FIXME! This could use @raisesections/@lowersections, but there seems to be a conflict +@c between those and node-defaulting. +@ifset H8300 +@ifclear GENERIC +@raisesections +@end ifclear +@node H8/300 +@section @code{ld} and the H8/300 + +@cindex H8/300 support +For the H8/300, @code{ld} can perform these global optimizations when +you specify the @samp{--relax} command-line option. + +@table @emph +@cindex relaxing on H8/300 +@item relaxing address modes +@code{ld} finds all @code{jsr} and @code{jmp} instructions whose +targets are within eight bits, and turns them into eight-bit +program-counter relative @code{bsr} and @code{bra} instructions, +respectively. + +@cindex synthesizing on H8/300 +@item synthesizing instructions +@c FIXME: specifically mov.b, or any mov instructions really? +@code{ld} finds all @code{mov.b} instructions which use the +sixteen-bit absolute address form, but refer to the top +page of memory, and changes them to use the eight-bit address form. +(That is: the linker turns @samp{mov.b @code{@@}@var{aa}:16} into +@samp{mov.b @code{@@}@var{aa}:8} whenever the address @var{aa} is in the +top page of memory). +@end table +@ifclear GENERIC +@lowersections +@end ifclear +@end ifset + +@ifclear GENERIC +@ifset Hitachi +@c This stuff is pointless to say unless you're especially concerned +@c with Hitachi chips; don't enable it for generic case, please. +@node Hitachi +@chapter @code{ld} and other Hitachi chips + +@code{ld} also supports the H8/300H, the H8/500, and the Hitachi SH. No +special features, commands, or command-line options are required for +these chips. +@end ifset +@end ifclear + +@ifset I960 +@ifclear GENERIC +@raisesections +@end ifclear +@node i960 +@section @code{ld} and the Intel 960 family + +@cindex i960 support + +You can use the @samp{-A@var{architecture}} command line option to +specify one of the two-letter names identifying members of the 960 +family; the option specifies the desired output target, and warns of any +incompatible instructions in the input files. It also modifies the +linker's search strategy for archive libraries, to support the use of +libraries specific to each particular architecture, by including in the +search loop names suffixed with the string identifying the architecture. + +For example, if your @code{ld} command line included @w{@samp{-ACA}} as +well as @w{@samp{-ltry}}, the linker would look (in its built-in search +paths, and in any paths you specify with @samp{-L}) for a library with +the names + +@smallexample +@group +try +libtry.a +tryca +libtryca.a +@end group +@end smallexample + +@noindent +The first two possibilities would be considered in any event; the last +two are due to the use of @w{@samp{-ACA}}. + +You can meaningfully use @samp{-A} more than once on a command line, since +the 960 architecture family allows combination of target architectures; each +use will add another pair of name variants to search for when @w{@samp{-l}} +specifies a library. + +@cindex @code{--relax} on i960 +@cindex relaxing on i960 +@code{ld} supports the @samp{--relax} option for the i960 family. If +you specify @samp{--relax}, @code{ld} finds all @code{balx} and +@code{calx} instructions whose targets are within 24 bits, and turns +them into 24-bit program-counter relative @code{bal} and @code{cal} +instructions, respectively. @code{ld} also turns @code{cal} +instructions into @code{bal} instructions when it determines that the +target subroutine is a leaf routine (that is, the target subroutine does +not itself call any subroutines). + +@ifclear GENERIC +@lowersections +@end ifclear +@end ifset + +@ifclear SingleFormat +@node BFD +@chapter BFD + +@cindex back end +@cindex object file management +@cindex object formats available +@kindex objdump -i +The linker accesses object and archive files using the BFD libraries. +These libraries allow the linker to use the same routines to operate on +object files whatever the object file format. A different object file +format can be supported simply by creating a new BFD back end and adding +it to the library. To conserve runtime memory, however, the linker and +associated tools are usually configured to support only a subset of the +object file formats available. You can use @code{objdump -i} +(@pxref{objdump,,objdump,binutils.info,The GNU Binary Utilities}) to +list all the formats available for your configuration. + +@cindex BFD requirements +@cindex requirements for BFD +As with most implementations, BFD is a compromise between +several conflicting requirements. The major factor influencing +BFD design was efficiency: any time used converting between +formats is time which would not have been spent had BFD not +been involved. This is partly offset by abstraction payback; since +BFD simplifies applications and back ends, more time and care +may be spent optimizing algorithms for a greater speed. + +One minor artifact of the BFD solution which you should bear in +mind is the potential for information loss. There are two places where +useful information can be lost using the BFD mechanism: during +conversion and during output. @xref{BFD information loss}. + +@menu +* BFD outline:: How it works: an outline of BFD +@end menu + +@node BFD outline +@section How it works: an outline of BFD +@cindex opening object files +@include bfdsumm.texi +@end ifclear + +@node Reporting Bugs +@chapter Reporting Bugs +@cindex bugs in @code{ld} +@cindex reporting bugs in @code{ld} + +Your bug reports play an essential role in making @code{ld} reliable. + +Reporting a bug may help you by bringing a solution to your problem, or +it may not. But in any case the principal function of a bug report is +to help the entire community by making the next version of @code{ld} +work better. Bug reports are your contribution to the maintenance of +@code{ld}. + +In order for a bug report to serve its purpose, you must include the +information that enables us to fix the bug. + +@menu +* Bug Criteria:: Have you found a bug? +* Bug Reporting:: How to report bugs +@end menu + +@node Bug Criteria +@section Have you found a bug? +@cindex bug criteria + +If you are not sure whether you have found a bug, here are some guidelines: + +@itemize @bullet +@cindex fatal signal +@cindex linker crash +@cindex crash of linker +@item +If the linker gets a fatal signal, for any input whatever, that is a +@code{ld} bug. Reliable linkers never crash. + +@cindex error on valid input +@item +If @code{ld} produces an error message for valid input, that is a bug. + +@cindex invalid input +@item +If @code{ld} does not produce an error message for invalid input, that +may be a bug. In the general case, the linker can not verify that +object files are correct. + +@item +If you are an experienced user of linkers, your suggestions for +improvement of @code{ld} are welcome in any case. +@end itemize + +@node Bug Reporting +@section How to report bugs +@cindex bug reports +@cindex @code{ld} bugs, reporting + +A number of companies and individuals offer support for @sc{gnu} +products. If you obtained @code{ld} from a support organization, we +recommend you contact that organization first. + +You can find contact information for many support companies and +individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs +distribution. + +In any event, we also recommend that you send bug reports for @code{ld} +to @samp{bug-gnu-utils@@prep.ai.mit.edu}. + +The fundamental principle of reporting bugs usefully is this: +@strong{report all the facts}. If you are not sure whether to state a +fact or leave it out, state it! + +Often people omit facts because they think they know what causes the +problem and assume that some details do not matter. Thus, you might +assume that the name of a symbol you use in an example does not matter. +Well, probably it does not, but one cannot be sure. Perhaps the bug is +a stray memory reference which happens to fetch from the location where +that name is stored in memory; perhaps, if the name were different, the +contents of that location would fool the linker into doing the right +thing despite the bug. Play it safe and give a specific, complete +example. That is the easiest thing for you to do, and the most helpful. + +Keep in mind that the purpose of a bug report is to enable us to fix the bug if +it is new to us. Therefore, always write your bug reports on the assumption +that the bug has not been reported previously. + +Sometimes people give a few sketchy facts and ask, ``Does this ring a +bell?'' Those bug reports are useless, and we urge everyone to +@emph{refuse to respond to them} except to chide the sender to report +bugs properly. + +To enable us to fix the bug, you should include all these things: + +@itemize @bullet +@item +The version of @code{ld}. @code{ld} announces it if you start it with +the @samp{--version} argument. + +Without this, we will not know whether there is any point in looking for +the bug in the current version of @code{ld}. + +@item +Any patches you may have applied to the @code{ld} source, including any +patches made to the @code{BFD} library. + +@item +The type of machine you are using, and the operating system name and +version number. + +@item +What compiler (and its version) was used to compile @code{ld}---e.g. +``@code{gcc-2.7}''. + +@item +The command arguments you gave the linker to link your example and +observe the bug. To guarantee you will not omit something important, +list them all. A copy of the Makefile (or the output from make) is +sufficient. + +If we were to try to guess the arguments, we would probably guess wrong +and then we might not encounter the bug. + +@item +A complete input file, or set of input files, that will reproduce the +bug. It is generally most helpful to send the actual object files, +uuencoded if necessary to get them through the mail system. Making them +available for anonymous FTP is not as good, but may be the only +reasonable choice for large object files. + +If the source files were assembled using @code{gas} or compiled using +@code{gcc}, then it may be OK to send the source files rather than the +object files. In this case, be sure to say exactly what version of +@code{gas} or @code{gcc} was used to produce the object files. Also say +how @code{gas} or @code{gcc} were configured. + +@item +A description of what behavior you observe that you believe is +incorrect. For example, ``It gets a fatal signal.'' + +Of course, if the bug is that @code{ld} gets a fatal signal, then we +will certainly notice it. But if the bug is incorrect output, we might +not notice unless it is glaringly wrong. You might as well not give us +a chance to make a mistake. + +Even if the problem you experience is a fatal signal, you should still +say so explicitly. Suppose something strange is going on, such as, your +copy of @code{ld} is out of synch, or you have encountered a bug in the +C library on your system. (This has happened!) Your copy might crash +and ours would not. If you told us to expect a crash, then when ours +fails to crash, we would know that the bug was not happening for us. If +you had not told us to expect a crash, then we would not be able to draw +any conclusion from our observations. + +@item +If you wish to suggest changes to the @code{ld} source, send us context +diffs, as generated by @code{diff} with the @samp{-u}, @samp{-c}, or +@samp{-p} option. Always send diffs from the old file to the new file. +If you even discuss something in the @code{ld} source, refer to it by +context, not by line number. + +The line numbers in our development sources will not match those in your +sources. Your line numbers would convey no useful information to us. +@end itemize + +Here are some things that are not necessary: + +@itemize @bullet +@item +A description of the envelope of the bug. + +Often people who encounter a bug spend a lot of time investigating +which changes to the input file will make the bug go away and which +changes will not affect it. + +This is often time consuming and not very useful, because the way we +will find the bug is by running a single example under the debugger +with breakpoints, not by pure deduction from a series of examples. +We recommend that you save your time for something else. + +Of course, if you can find a simpler example to report @emph{instead} +of the original one, that is a convenience for us. Errors in the +output will be easier to spot, running under the debugger will take +less time, and so on. + +However, simplification is not vital; if you do not want to do this, +report the bug anyway and send us the entire test case you used. + +@item +A patch for the bug. + +A patch for the bug does help us if it is a good one. But do not omit +the necessary information, such as the test case, on the assumption that +a patch is all we need. We might see problems with your patch and decide +to fix the problem another way, or we might not understand it at all. + +Sometimes with a program as complicated as @code{ld} it is very hard to +construct an example that will make the program follow a certain path +through the code. If you do not send us the example, we will not be +able to construct one, so we will not be able to verify that the bug is +fixed. + +And if we cannot understand what bug you are trying to fix, or why your +patch should be an improvement, we will not install it. A test case will +help us to understand. + +@item +A guess about what the bug is or what it depends on. + +Such guesses are usually wrong. Even we cannot guess right about such +things without first using the debugger to find the facts. +@end itemize + +@node MRI +@appendix MRI Compatible Script Files +@cindex MRI compatibility +To aid users making the transition to @sc{gnu} @code{ld} from the MRI +linker, @code{ld} can use MRI compatible linker scripts as an +alternative to the more general-purpose linker scripting language +described in @ref{Commands,,Command Language}. MRI compatible linker +scripts have a much simpler command set than the scripting language +otherwise used with @code{ld}. @sc{gnu} @code{ld} supports the most +commonly used MRI linker commands; these commands are described here. + +In general, MRI scripts aren't of much use with the @code{a.out} object +file format, since it only has three sections and MRI scripts lack some +features to make use of them. + +You can specify a file containing an MRI-compatible script using the +@samp{-c} command-line option. + +Each command in an MRI-compatible script occupies its own line; each +command line starts with the keyword that identifies the command (though +blank lines are also allowed for punctuation). If a line of an +MRI-compatible script begins with an unrecognized keyword, @code{ld} +issues a warning message, but continues processing the script. + +Lines beginning with @samp{*} are comments. + +You can write these commands using all upper-case letters, or all +lower case; for example, @samp{chip} is the same as @samp{CHIP}. +The following list shows only the upper-case form of each command. + +@table @code +@cindex @code{ABSOLUTE} (MRI) +@item ABSOLUTE @var{secname} +@itemx ABSOLUTE @var{secname}, @var{secname}, @dots{} @var{secname} +Normally, @code{ld} includes in the output file all sections from all +the input files. However, in an MRI-compatible script, you can use the +@code{ABSOLUTE} command to restrict the sections that will be present in +your output program. If the @code{ABSOLUTE} command is used at all in a +script, then only the sections named explicitly in @code{ABSOLUTE} +commands will appear in the linker output. You can still use other +input sections (whatever you select on the command line, or using +@code{LOAD}) to resolve addresses in the output file. + +@cindex @code{ALIAS} (MRI) +@item ALIAS @var{out-secname}, @var{in-secname} +Use this command to place the data from input section @var{in-secname} +in a section called @var{out-secname} in the linker output file. + +@var{in-secname} may be an integer. + +@cindex @code{ALIGN} (MRI) +@item ALIGN @var{secname} = @var{expression} +Align the section called @var{secname} to @var{expression}. The +@var{expression} should be a power of two. + +@cindex @code{BASE} (MRI) +@item BASE @var{expression} +Use the value of @var{expression} as the lowest address (other than +absolute addresses) in the output file. + +@cindex @code{CHIP} (MRI) +@item CHIP @var{expression} +@itemx CHIP @var{expression}, @var{expression} +This command does nothing; it is accepted only for compatibility. + +@cindex @code{END} (MRI) +@item END +This command does nothing whatever; it's only accepted for compatibility. + +@cindex @code{FORMAT} (MRI) +@item FORMAT @var{output-format} +Similar to the @code{OUTPUT_FORMAT} command in the more general linker +language, but restricted to one of these output formats: + +@enumerate +@item +S-records, if @var{output-format} is @samp{S} + +@item +IEEE, if @var{output-format} is @samp{IEEE} + +@item +COFF (the @samp{coff-m68k} variant in BFD), if @var{output-format} is +@samp{COFF} +@end enumerate + +@cindex @code{LIST} (MRI) +@item LIST @var{anything}@dots{} +Print (to the standard output file) a link map, as produced by the +@code{ld} command-line option @samp{-M}. + +The keyword @code{LIST} may be followed by anything on the +same line, with no change in its effect. + +@cindex @code{LOAD} (MRI) +@item LOAD @var{filename} +@itemx LOAD @var{filename}, @var{filename}, @dots{} @var{filename} +Include one or more object file @var{filename} in the link; this has the +same effect as specifying @var{filename} directly on the @code{ld} +command line. + +@cindex @code{NAME} (MRI) +@item NAME @var{output-name} +@var{output-name} is the name for the program produced by @code{ld}; the +MRI-compatible command @code{NAME} is equivalent to the command-line +option @samp{-o} or the general script language command @code{OUTPUT}. + +@cindex @code{ORDER} (MRI) +@item ORDER @var{secname}, @var{secname}, @dots{} @var{secname} +@itemx ORDER @var{secname} @var{secname} @var{secname} +Normally, @code{ld} orders the sections in its output file in the +order in which they first appear in the input files. In an MRI-compatible +script, you can override this ordering with the @code{ORDER} command. The +sections you list with @code{ORDER} will appear first in your output +file, in the order specified. + +@cindex @code{PUBLIC} (MRI) +@item PUBLIC @var{name}=@var{expression} +@itemx PUBLIC @var{name},@var{expression} +@itemx PUBLIC @var{name} @var{expression} +Supply a value (@var{expression}) for external symbol +@var{name} used in the linker input files. + +@cindex @code{SECT} (MRI) +@item SECT @var{secname}, @var{expression} +@itemx SECT @var{secname}=@var{expression} +@itemx SECT @var{secname} @var{expression} +You can use any of these three forms of the @code{SECT} command to +specify the start address (@var{expression}) for section @var{secname}. +If you have more than one @code{SECT} statement for the same +@var{secname}, only the @emph{first} sets the start address. +@end table + +@node Index +@unnumbered Index + +@printindex cp + +@tex +% I think something like @colophon should be in texinfo. In the +% meantime: +\long\def\colophon{\hbox to0pt{}\vfill +\centerline{The body of this manual is set in} +\centerline{\fontname\tenrm,} +\centerline{with headings in {\bf\fontname\tenbf}} +\centerline{and examples in {\tt\fontname\tentt}.} +\centerline{{\it\fontname\tenit\/} and} +\centerline{{\sl\fontname\tensl\/}} +\centerline{are used for emphasis.}\vfill} +\page\colophon +% Blame: doc@cygnus.com, 28mar91. +@end tex + + +@contents +@bye + + diff --git a/contrib/binutils/ld/ldcref.c b/contrib/binutils/ld/ldcref.c new file mode 100644 index 0000000..d9e6ebb --- /dev/null +++ b/contrib/binutils/ld/ldcref.c @@ -0,0 +1,547 @@ +/* ldcref.c -- output a cross reference table + Copyright (C) 1996 Free Software Foundation, Inc. + Written by Ian Lance Taylor <ian@cygnus.com> + +This file is part of GLD, the Gnu Linker. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* This file holds routines that manage the cross reference table. + The table is used to generate cross reference reports. It is also + used to implement the NOCROSSREFS command in the linker script. */ + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" +#include "libiberty.h" + +#include "ld.h" +#include "ldmain.h" +#include "ldmisc.h" +#include "ldexp.h" +#include "ldlang.h" + +/* We keep an instance of this structure for each reference to a + symbol from a given object. */ + +struct cref_ref +{ + /* The next reference. */ + struct cref_ref *next; + /* The object. */ + bfd *abfd; + /* True if the symbol is defined. */ + unsigned int def : 1; + /* True if the symbol is common. */ + unsigned int common : 1; + /* True if the symbol is undefined. */ + unsigned int undef : 1; +}; + +/* We keep a hash table of symbols. Each entry looks like this. */ + +struct cref_hash_entry +{ + struct bfd_hash_entry root; + /* The demangled name. */ + char *demangled; + /* References to and definitions of this symbol. */ + struct cref_ref *refs; +}; + +/* This is what the hash table looks like. */ + +struct cref_hash_table +{ + struct bfd_hash_table root; +}; + +/* Local functions. */ + +static struct bfd_hash_entry *cref_hash_newfunc + PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); +static boolean cref_fill_array PARAMS ((struct cref_hash_entry *, PTR)); +static int cref_sort_array PARAMS ((const PTR, const PTR)); +static void output_one_cref PARAMS ((FILE *, struct cref_hash_entry *)); +static boolean check_nocrossref PARAMS ((struct cref_hash_entry *, PTR)); +static void check_refs + PARAMS ((struct cref_hash_entry *, struct bfd_link_hash_entry *, + struct lang_nocrossrefs *)); +static void check_reloc_refs PARAMS ((bfd *, asection *, PTR)); + +/* Look up an entry in the cref hash table. */ + +#define cref_hash_lookup(table, string, create, copy) \ + ((struct cref_hash_entry *) \ + bfd_hash_lookup (&(table)->root, (string), (create), (copy))) + +/* Traverse the cref hash table. */ + +#define cref_hash_traverse(table, func, info) \ + (bfd_hash_traverse \ + (&(table)->root, \ + (boolean (*) PARAMS ((struct bfd_hash_entry *, PTR))) (func), \ + (info))) + +/* The cref hash table. */ + +static struct cref_hash_table cref_table; + +/* Whether the cref hash table has been initialized. */ + +static boolean cref_initialized; + +/* The number of symbols seen so far. */ + +static size_t cref_symcount; + +/* Create an entry in a cref hash table. */ + +static struct bfd_hash_entry * +cref_hash_newfunc (entry, table, string) + struct bfd_hash_entry *entry; + struct bfd_hash_table *table; + const char *string; +{ + struct cref_hash_entry *ret = (struct cref_hash_entry *) entry; + + /* Allocate the structure if it has not already been allocated by a + subclass. */ + if (ret == NULL) + ret = ((struct cref_hash_entry *) + bfd_hash_allocate (table, sizeof (struct cref_hash_entry))); + if (ret == NULL) + return (struct bfd_hash_entry *) ret; + + /* Call the allocation method of the superclass. */ + ret = ((struct cref_hash_entry *) + bfd_hash_newfunc ((struct bfd_hash_entry *) ret, table, string)); + if (ret != NULL) + { + /* Set local fields. */ + ret->demangled = NULL; + ret->refs = NULL; + + /* Keep a count of the number of entries created in the hash + table. */ + ++cref_symcount; + } + + return (struct bfd_hash_entry *) ret; +} + +/* Add a symbol to the cref hash table. This is called for every + symbol that is seen during the link. */ + +/*ARGSUSED*/ +void +add_cref (name, abfd, section, value) + const char *name; + bfd *abfd; + asection *section; + bfd_vma value; +{ + struct cref_hash_entry *h; + struct cref_ref *r; + + if (! cref_initialized) + { + if (! bfd_hash_table_init (&cref_table.root, cref_hash_newfunc)) + einfo ("%X%P: bfd_hash_table_init of cref table failed: %E\n"); + cref_initialized = true; + } + + h = cref_hash_lookup (&cref_table, name, true, false); + if (h == NULL) + einfo ("%X%P: cref_hash_lookup failed: %E\n"); + + for (r = h->refs; r != NULL; r = r->next) + if (r->abfd == abfd) + break; + + if (r == NULL) + { + r = (struct cref_ref *) xmalloc (sizeof *r); + r->next = h->refs; + h->refs = r; + r->abfd = abfd; + r->def = false; + r->common = false; + r->undef = false; + } + + if (bfd_is_und_section (section)) + r->undef = true; + else if (bfd_is_com_section (section)) + r->common = true; + else + r->def = true; +} + +/* Copy the addresses of the hash table entries into an array. This + is called via cref_hash_traverse. We also fill in the demangled + name. */ + +static boolean +cref_fill_array (h, data) + struct cref_hash_entry *h; + PTR data; +{ + struct cref_hash_entry ***pph = (struct cref_hash_entry ***) data; + + ASSERT (h->demangled == NULL); + h->demangled = demangle (h->root.string); + + **pph = h; + + ++*pph; + + return true; +} + +/* Sort an array of cref hash table entries by name. */ + +static int +cref_sort_array (a1, a2) + const PTR a1; + const PTR a2; +{ + const struct cref_hash_entry **p1 = (const struct cref_hash_entry **) a1; + const struct cref_hash_entry **p2 = (const struct cref_hash_entry **) a2; + + return strcmp ((*p1)->demangled, (*p2)->demangled); +} + +/* Write out the cref table. */ + +#define FILECOL (50) + +void +output_cref (fp) + FILE *fp; +{ + int len; + struct cref_hash_entry **csyms, **csym_fill, **csym, **csym_end; + + fprintf (fp, "\nCross Reference Table\n\n"); + fprintf (fp, "Symbol"); + len = sizeof "Symbol" - 1; + while (len < FILECOL) + { + putc (' ' , fp); + ++len; + } + fprintf (fp, "File\n"); + + if (! cref_initialized) + { + fprintf (fp, "No symbols\n"); + return; + } + + csyms = ((struct cref_hash_entry **) + xmalloc (cref_symcount * sizeof (*csyms))); + + csym_fill = csyms; + cref_hash_traverse (&cref_table, cref_fill_array, &csym_fill); + ASSERT (csym_fill - csyms == cref_symcount); + + qsort (csyms, cref_symcount, sizeof (*csyms), cref_sort_array); + + csym_end = csyms + cref_symcount; + for (csym = csyms; csym < csym_end; csym++) + output_one_cref (fp, *csym); +} + +/* Output one entry in the cross reference table. */ + +static void +output_one_cref (fp, h) + FILE *fp; + struct cref_hash_entry *h; +{ + int len; + struct bfd_link_hash_entry *hl; + struct cref_ref *r; + + hl = bfd_link_hash_lookup (link_info.hash, h->root.string, false, + false, true); + if (hl == NULL) + einfo ("%P: symbol `%T' missing from main hash table\n", + h->root.string); + else + { + /* If this symbol is defined in a dynamic object but never + referenced by a normal object, then don't print it. */ + if (hl->type == bfd_link_hash_defined) + { + if (hl->u.def.section->output_section == NULL) + return; + if (hl->u.def.section->owner != NULL + && (hl->u.def.section->owner->flags & DYNAMIC) != 0) + { + for (r = h->refs; r != NULL; r = r->next) + if ((r->abfd->flags & DYNAMIC) == 0) + break; + if (r == NULL) + return; + } + } + } + + fprintf (fp, "%s ", h->demangled); + len = strlen (h->demangled) + 1; + + for (r = h->refs; r != NULL; r = r->next) + { + if (r->def) + { + while (len < FILECOL) + { + putc (' ', fp); + ++len; + } + finfo (fp, "%B\n", r->abfd); + len = 0; + } + } + + for (r = h->refs; r != NULL; r = r->next) + { + if (! r->def) + { + while (len < FILECOL) + { + putc (' ', fp); + ++len; + } + finfo (fp, "%B\n", r->abfd); + len = 0; + } + } + + ASSERT (len == 0); +} + +/* Check for prohibited cross references. */ + +void +check_nocrossrefs () +{ + if (! cref_initialized) + return; + + cref_hash_traverse (&cref_table, check_nocrossref, (PTR) NULL); +} + +/* Check one symbol to see if it is a prohibited cross reference. */ + +/*ARGSUSED*/ +static boolean +check_nocrossref (h, ignore) + struct cref_hash_entry *h; + PTR ignore; +{ + struct bfd_link_hash_entry *hl; + asection *defsec; + const char *defsecname; + struct lang_nocrossrefs *ncrs; + struct lang_nocrossref *ncr; + + hl = bfd_link_hash_lookup (link_info.hash, h->root.string, false, + false, true); + if (hl == NULL) + { + einfo ("%P: symbol `%T' missing from main hash table\n", + h->root.string); + return true; + } + + if (hl->type != bfd_link_hash_defined + && hl->type != bfd_link_hash_defweak) + return true; + + defsec = hl->u.def.section->output_section; + if (defsec == NULL) + return true; + defsecname = bfd_get_section_name (defsec->owner, defsec); + + for (ncrs = nocrossref_list; ncrs != NULL; ncrs = ncrs->next) + for (ncr = ncrs->list; ncr != NULL; ncr = ncr->next) + if (strcmp (ncr->name, defsecname) == 0) + check_refs (h, hl, ncrs); + + return true; +} + +/* The struct is used to pass information from check_refs to + check_reloc_refs through bfd_map_over_sections. */ + +struct check_refs_info +{ + struct cref_hash_entry *h; + asection *defsec; + struct lang_nocrossrefs *ncrs; + asymbol **asymbols; + boolean same; +}; + +/* This function is called for each symbol defined in a section which + prohibits cross references. We need to look through all references + to this symbol, and ensure that the references are not from + prohibited sections. */ + +static void +check_refs (h, hl, ncrs) + struct cref_hash_entry *h; + struct bfd_link_hash_entry *hl; + struct lang_nocrossrefs *ncrs; +{ + struct cref_ref *ref; + + for (ref = h->refs; ref != NULL; ref = ref->next) + { + lang_input_statement_type *li; + asymbol **asymbols; + struct check_refs_info info; + + /* We need to look through the relocations for this BFD, to see + if any of the relocations which refer to this symbol are from + a prohibited section. Note that we need to do this even for + the BFD in which the symbol is defined, since even a single + BFD might contain a prohibited cross reference; for this + case, we set the SAME field in INFO, which will cause + CHECK_RELOCS_REFS to check for relocations against the + section as well as against the symbol. */ + + li = (lang_input_statement_type *) ref->abfd->usrdata; + if (li != NULL && li->asymbols != NULL) + asymbols = li->asymbols; + else + { + long symsize; + long symbol_count; + + symsize = bfd_get_symtab_upper_bound (ref->abfd); + if (symsize < 0) + einfo ("%B%F: could not read symbols; %E\n", ref->abfd); + asymbols = (asymbol **) xmalloc (symsize); + symbol_count = bfd_canonicalize_symtab (ref->abfd, asymbols); + if (symbol_count < 0) + einfo ("%B%F: could not read symbols: %E\n", ref->abfd); + if (li != NULL) + { + li->asymbols = asymbols; + li->symbol_count = symbol_count; + } + } + + info.h = h; + info.defsec = hl->u.def.section; + info.ncrs = ncrs; + info.asymbols = asymbols; + if (ref->abfd == hl->u.def.section->owner) + info.same = true; + else + info.same = false; + bfd_map_over_sections (ref->abfd, check_reloc_refs, (PTR) &info); + + if (li == NULL) + free (asymbols); + } +} + +/* This is called via bfd_map_over_sections. INFO->H is a symbol + defined in INFO->DEFSECNAME. If this section maps into any of the + sections listed in INFO->NCRS, other than INFO->DEFSECNAME, then we + look through the relocations. If any of the relocations are to + INFO->H, then we report a prohibited cross reference error. */ + +static void +check_reloc_refs (abfd, sec, iarg) + bfd *abfd; + asection *sec; + PTR iarg; +{ + struct check_refs_info *info = (struct check_refs_info *) iarg; + asection *outsec; + const char *outsecname; + asection *outdefsec; + const char *outdefsecname; + struct lang_nocrossref *ncr; + const char *symname; + long relsize; + arelent **relpp; + long relcount; + arelent **p, **pend; + + outsec = sec->output_section; + outsecname = bfd_get_section_name (outsec->owner, outsec); + + outdefsec = info->defsec->output_section; + outdefsecname = bfd_get_section_name (outdefsec->owner, outdefsec); + + /* The section where the symbol is defined is permitted. */ + if (strcmp (outsecname, outdefsecname) == 0) + return; + + for (ncr = info->ncrs->list; ncr != NULL; ncr = ncr->next) + if (strcmp (outsecname, ncr->name) == 0) + break; + + if (ncr == NULL) + return; + + /* This section is one for which cross references are prohibited. + Look through the relocations, and see if any of them are to + INFO->H. */ + + symname = info->h->root.string; + + relsize = bfd_get_reloc_upper_bound (abfd, sec); + if (relsize < 0) + einfo ("%B%F: could not read relocs: %E\n", abfd); + if (relsize == 0) + return; + + relpp = (arelent **) xmalloc (relsize); + relcount = bfd_canonicalize_reloc (abfd, sec, relpp, info->asymbols); + if (relcount < 0) + einfo ("%B%F: could not read relocs: %E\n", abfd); + + p = relpp; + pend = p + relcount; + for (; p < pend && *p != NULL; p++) + { + arelent *q = *p; + + if (q->sym_ptr_ptr != NULL + && *q->sym_ptr_ptr != NULL + && (strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), symname) == 0 + || (info->same + && bfd_get_section (*q->sym_ptr_ptr) == info->defsec))) + { + /* We found a reloc for the symbol. The symbol is defined + in OUTSECNAME. This reloc is from a section which is + mapped into a section from which references to OUTSECNAME + are prohibited. We must report an error. */ + einfo ("%X%C: prohibited cross reference from %s to `%T' in %s\n", + abfd, sec, q->address, outsecname, + bfd_asymbol_name (*q->sym_ptr_ptr), outdefsecname); + } + } + + free (relpp); +} diff --git a/contrib/binutils/ld/ldctor.c b/contrib/binutils/ld/ldctor.c new file mode 100644 index 0000000..d986f32 --- /dev/null +++ b/contrib/binutils/ld/ldctor.c @@ -0,0 +1,247 @@ +/* ldctor.c -- constructor support routines + Copyright (C) 1991, 92, 93, 94, 1995 Free Software Foundation, Inc. + By Steve Chamberlain <sac@cygnus.com> + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" + +#include "ld.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldmisc.h" +#include "ldgram.h" +#include "ldmain.h" +#include "ldctor.h" + +/* The list of statements needed to handle constructors. These are + invoked by the command CONSTRUCTORS in the linker script. */ +lang_statement_list_type constructor_list; + +/* The sets we have seen. */ +struct set_info *sets; + +/* Add an entry to a set. H is the entry in the linker hash table. + RELOC is the relocation to use for an entry in the set. SECTION + and VALUE are the value to add. This is called during the first + phase of the link, when we are still gathering symbols together. + We just record the information now. The ldctor_find_constructors + function will construct the sets. */ + +void +ldctor_add_set_entry (h, reloc, name, section, value) + struct bfd_link_hash_entry *h; + bfd_reloc_code_real_type reloc; + const char *name; + asection *section; + bfd_vma value; +{ + struct set_info *p; + struct set_element *e; + struct set_element **epp; + + for (p = sets; p != (struct set_info *) NULL; p = p->next) + if (p->h == h) + break; + + if (p == (struct set_info *) NULL) + { + p = (struct set_info *) xmalloc (sizeof (struct set_info)); + p->next = sets; + sets = p; + p->h = h; + p->reloc = reloc; + p->count = 0; + p->elements = NULL; + } + else + { + if (p->reloc != reloc) + { + einfo ("%P%X: Different relocs used in set %s\n", h->root.string); + return; + } + + /* Don't permit a set to be constructed from different object + file formats. The same reloc may have different results. We + actually could sometimes handle this, but the case is + unlikely to ever arise. Sometimes constructor symbols are in + unusual sections, such as the absolute section--this appears + to be the case in Linux a.out--and in such cases we just + assume everything is OK. */ + if (p->elements != NULL + && section->owner != NULL + && p->elements->section->owner != NULL + && strcmp (bfd_get_target (section->owner), + bfd_get_target (p->elements->section->owner)) != 0) + { + einfo ("%P%X: Different object file formats composing set %s\n", + h->root.string); + return; + } + } + + e = (struct set_element *) xmalloc (sizeof (struct set_element)); + e->next = NULL; + e->name = name; + e->section = section; + e->value = value; + + for (epp = &p->elements; *epp != NULL; epp = &(*epp)->next) + ; + *epp = e; + + ++p->count; +} + +/* This function is called after the first phase of the link and + before the second phase. At this point all set information has + been gathered. We now put the statements to build the sets + themselves into constructor_list. */ + +void +ldctor_build_sets () +{ + static boolean called; + lang_statement_list_type *old; + boolean header_printed; + struct set_info *p; + + /* The emulation code may call us directly, but we only want to do + this once. */ + if (called) + return; + called = true; + + old = stat_ptr; + stat_ptr = &constructor_list; + + lang_list_init (stat_ptr); + + header_printed = false; + for (p = sets; p != (struct set_info *) NULL; p = p->next) + { + struct set_element *e; + reloc_howto_type *howto; + int size; + + /* If the symbol is defined, we may have been invoked from + collect, and the sets may already have been built, so we do + not do anything. */ + if (p->h->type == bfd_link_hash_defined + || p->h->type == bfd_link_hash_defweak) + continue; + + /* For each set we build: + set: + .long number_of_elements + .long element0 + ... + .long elementN + .long 0 + except that we use the right size instead of .long. When + generating relocateable output, we generate relocs instead of + addresses. */ + howto = bfd_reloc_type_lookup (output_bfd, p->reloc); + if (howto == (reloc_howto_type *) NULL) + { + if (link_info.relocateable) + { + einfo ("%P%X: %s does not support reloc %s for set %s\n", + bfd_get_target (output_bfd), + bfd_get_reloc_code_name (p->reloc), + p->h->root.string); + continue; + } + + /* If this is not a relocateable link, all we need is the + size, which we can get from the input BFD. */ + howto = bfd_reloc_type_lookup (p->elements->section->owner, + p->reloc); + if (howto == NULL) + { + einfo ("%P%X: %s does not support reloc %s for set %s\n", + bfd_get_target (p->elements->section->owner), + bfd_get_reloc_code_name (p->reloc), + p->h->root.string); + continue; + } + } + + switch (bfd_get_reloc_size (howto)) + { + case 1: size = BYTE; break; + case 2: size = SHORT; break; + case 4: size = LONG; break; + case 8: size = QUAD; break; + default: + einfo ("%P%X: Unsupported size %d for set %s\n", + bfd_get_reloc_size (howto), p->h->root.string); + size = LONG; + break; + } + + lang_add_assignment (exp_assop ('=', p->h->root.string, + exp_nameop (NAME, "."))); + lang_add_data (size, exp_intop ((bfd_vma) p->count)); + + for (e = p->elements; e != (struct set_element *) NULL; e = e->next) + { + if (config.map_file != NULL) + { + int len; + + if (! header_printed) + { + minfo ("\nSet Symbol\n\n"); + header_printed = true; + } + + minfo ("%s", p->h->root.string); + len = strlen (p->h->root.string); + + if (len >= 19) + { + print_nl (); + len = 0; + } + while (len < 20) + { + print_space (); + ++len; + } + + if (e->name != NULL) + minfo ("%T\n", e->name); + else + minfo ("%G\n", e->section->owner, e->section, e->value); + } + + if (link_info.relocateable) + lang_add_reloc (p->reloc, howto, e->section, e->name, + exp_intop (e->value)); + else + lang_add_data (size, exp_relop (e->section, e->value)); + } + + lang_add_data (size, exp_intop (0)); + } + + stat_ptr = old; +} diff --git a/contrib/binutils/ld/ldctor.h b/contrib/binutils/ld/ldctor.h new file mode 100644 index 0000000..d87f0db --- /dev/null +++ b/contrib/binutils/ld/ldctor.h @@ -0,0 +1,54 @@ +/* ldctor.h - linker constructor support + Copyright 1991, 1992, 1993 Free Software Foundation, Inc. + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef LDCTOR_H +#define LDCTOR_H + +/* List of statements needed to handle constructors */ +extern lang_statement_list_type constructor_list; + +/* We keep a list of these structures for each set we build. */ + +struct set_info +{ + struct set_info *next; /* Next set. */ + struct bfd_link_hash_entry *h; /* Hash table entry. */ + bfd_reloc_code_real_type reloc; /* Reloc to use for an entry. */ + size_t count; /* Number of elements. */ + struct set_element *elements; /* Elements in set. */ +}; + +struct set_element +{ + struct set_element *next; /* Next element. */ + const char *name; /* Name in set (may be NULL). */ + asection *section; /* Section of value in set. */ + bfd_vma value; /* Value in set. */ +}; + +/* The sets we have seen. */ + +extern struct set_info *sets; + +extern void ldctor_add_set_entry PARAMS ((struct bfd_link_hash_entry *, + bfd_reloc_code_real_type, + const char *, asection *, bfd_vma)); +extern void ldctor_build_sets PARAMS ((void)); + +#endif diff --git a/contrib/binutils/ld/ldemul.c b/contrib/binutils/ld/ldemul.c new file mode 100644 index 0000000..c6fe25b --- /dev/null +++ b/contrib/binutils/ld/ldemul.c @@ -0,0 +1,262 @@ +/* ldemul.c -- clearing house for ld emulation states + Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" + +#include "ld.h" +#include "ldemul.h" +#include "ldmisc.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldfile.h" +#include "ldmain.h" +#include "ldemul-list.h" + +ld_emulation_xfer_type *ld_emulation; + +void +ldemul_hll(name) + char *name; +{ + ld_emulation->hll(name); +} + + +void ldemul_syslib(name) + char *name; +{ + ld_emulation->syslib(name); +} + +void +ldemul_after_parse() +{ + ld_emulation->after_parse(); +} + +void +ldemul_before_parse() +{ + ld_emulation->before_parse(); +} + +void +ldemul_after_open () +{ + ld_emulation->after_open (); +} + +void +ldemul_after_allocation() +{ + ld_emulation->after_allocation(); +} + +void +ldemul_before_allocation() +{ + if (ld_emulation->before_allocation) + ld_emulation->before_allocation(); +} + + +void +ldemul_set_output_arch() +{ + ld_emulation->set_output_arch(); +} + +void +ldemul_finish() +{ + if (ld_emulation->finish) + ld_emulation->finish(); +} + +void +ldemul_set_symbols() +{ + if (ld_emulation->set_symbols) + ld_emulation->set_symbols(); +} + +void +ldemul_create_output_section_statements() +{ + if (ld_emulation->create_output_section_statements) + ld_emulation->create_output_section_statements(); +} + +char * +ldemul_get_script(isfile) + int *isfile; +{ + return ld_emulation->get_script(isfile); +} + +boolean +ldemul_open_dynamic_archive (arch, search, entry) + const char *arch; + search_dirs_type *search; + lang_input_statement_type *entry; +{ + if (ld_emulation->open_dynamic_archive) + return (*ld_emulation->open_dynamic_archive) (arch, search, entry); + return false; +} + +boolean +ldemul_place_orphan (file, s) + lang_input_statement_type *file; + asection *s; +{ + if (ld_emulation->place_orphan) + return (*ld_emulation->place_orphan) (file, s); + return false; +} + +int +ldemul_parse_args (argc, argv) + int argc; + char **argv; +{ + /* Try and use the emulation parser if there is one. */ + if (ld_emulation->parse_args) + { + return ld_emulation->parse_args (argc, argv); + } + return 0; +} + +/* Let the emulation code handle an unrecognized file. */ + +boolean +ldemul_unrecognized_file (entry) + lang_input_statement_type *entry; +{ + if (ld_emulation->unrecognized_file) + return (*ld_emulation->unrecognized_file) (entry); + return false; +} + +char * +ldemul_choose_target() +{ + return ld_emulation->choose_target(); +} + +/* The default choose_target function. */ + +char * +ldemul_default_target() +{ + char *from_outside = getenv (TARGET_ENVIRON); + if (from_outside != (char *)NULL) + return from_outside; + return ld_emulation->target_name; +} + +void +after_parse_default() +{ + +} + +void +after_open_default () +{ +} + +void +after_allocation_default() +{ + +} + +void +before_allocation_default() +{ + +} + +void +set_output_arch_default() +{ + /* Set the output architecture and machine if possible */ + bfd_set_arch_mach(output_bfd, + ldfile_output_architecture, ldfile_output_machine); +} + +/*ARGSUSED*/ +void +syslib_default(ignore) + char *ignore; +{ + info_msg ("%S SYSLIB ignored\n"); +} + +/*ARGSUSED*/ +void +hll_default(ignore) + char *ignore; +{ + info_msg ("%S HLL ignored\n"); +} + +ld_emulation_xfer_type *ld_emulations[] = { EMULATION_LIST }; + +void +ldemul_choose_mode(target) + char *target; +{ + ld_emulation_xfer_type **eptr = ld_emulations; + /* Ignore "gld" prefix. */ + if (target[0] == 'g' && target[1] == 'l' && target[2] == 'd') + target += 3; + for (; *eptr; eptr++) + { + if (strcmp(target, (*eptr)->emulation_name) == 0) + { + ld_emulation = *eptr; + return; + } + } + einfo ("%P: unrecognised emulation mode: %s\n", target); + einfo ("Supported emulations: ", program_name); + ldemul_list_emulations (stderr); + einfo ("%F\n"); +} + +void +ldemul_list_emulations (f) + FILE *f; +{ + ld_emulation_xfer_type **eptr = ld_emulations; + boolean first = true; + + for (; *eptr; eptr++) + { + if (first) + first = false; + else + fprintf (f, " "); + fprintf (f, "%s", (*eptr)->emulation_name); + } +} diff --git a/contrib/binutils/ld/ldemul.h b/contrib/binutils/ld/ldemul.h new file mode 100644 index 0000000..f01f357 --- /dev/null +++ b/contrib/binutils/ld/ldemul.h @@ -0,0 +1,138 @@ +/* ld-emul.h - Linker emulation header file + Copyright 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. */ + +#ifndef LDEMUL_H +#define LDEMUL_H + +#if ANSI_PROTOTYPES +struct lang_input_statement_struct; +struct search_dirs; +#endif + +extern void ldemul_hll PARAMS ((char *)); +extern void ldemul_syslib PARAMS ((char *)); +extern void ldemul_after_parse PARAMS ((void)); +extern void ldemul_before_parse PARAMS ((void)); +extern void ldemul_after_open PARAMS ((void)); +extern void ldemul_after_allocation PARAMS ((void)); +extern void ldemul_before_allocation PARAMS ((void)); +extern void ldemul_set_output_arch PARAMS ((void)); +extern char *ldemul_choose_target PARAMS ((void)); +extern void ldemul_choose_mode PARAMS ((char *)); +extern void ldemul_list_emulations PARAMS ((FILE *)); +extern char *ldemul_get_script PARAMS ((int *isfile)); +extern void ldemul_finish PARAMS ((void)); +extern void ldemul_set_symbols PARAMS ((void)); +extern void ldemul_create_output_section_statements PARAMS ((void)); +extern boolean ldemul_place_orphan + PARAMS ((struct lang_input_statement_struct *, asection *)); +extern int ldemul_parse_args PARAMS ((int, char **)); +extern boolean ldemul_unrecognized_file + PARAMS ((struct lang_input_statement_struct *)); +extern boolean ldemul_open_dynamic_archive + PARAMS ((const char *, struct search_dirs *, + struct lang_input_statement_struct *)); +extern char *ldemul_default_target PARAMS ((void)); +extern void after_parse_default PARAMS ((void)); +extern void after_open_default PARAMS ((void)); +extern void after_allocation_default PARAMS ((void)); +extern void before_allocation_default PARAMS ((void)); +extern void set_output_arch_default PARAMS ((void)); +extern void syslib_default PARAMS ((char*)); +extern void hll_default PARAMS ((char*)); + +typedef struct ld_emulation_xfer_struct +{ + /* Run before parsing the command line and script file. + Set the architecture, maybe other things. */ + void (*before_parse) PARAMS ((void)); + + /* Handle the SYSLIB (low level library) script command. */ + void (*syslib) PARAMS ((char *)); + + /* Handle the HLL (high level library) script command. */ + void (*hll) PARAMS ((char *)); + + /* Run after parsing the command line and script file. */ + void (*after_parse) PARAMS ((void)); + + /* Run after opening all input files, and loading the symbols. */ + void (*after_open) PARAMS ((void)); + + /* Run after allocating output sections. */ + void (*after_allocation) PARAMS ( (void)); + + /* Set the output architecture and machine if possible. */ + void (*set_output_arch) PARAMS ((void)); + + /* Decide which target name to use. */ + char * (*choose_target) PARAMS ((void)); + + /* Run before allocating output sections. */ + void (*before_allocation) PARAMS ((void)); + + /* Return the appropriate linker script. */ + char * (*get_script) PARAMS ((int *isfile)); + + /* The name of this emulation. */ + char *emulation_name; + + /* The output format. */ + char *target_name; + + /* Run after assigning values from the script. */ + void (*finish) PARAMS ((void)); + + /* Create any output sections needed by the target. */ + void (*create_output_section_statements) PARAMS ((void)); + + /* Try to open a dynamic library. ARCH is an architecture name, and + is normally the empty string. ENTRY is the lang_input_statement + that should be opened. */ + boolean (*open_dynamic_archive) + PARAMS ((const char *arch, struct search_dirs *, + struct lang_input_statement_struct *entry)); + + /* Place an orphan section. Return true if it was placed, false if + the default action should be taken. This field may be NULL, in + which case the default action will always be taken. */ + boolean (*place_orphan) + PARAMS ((struct lang_input_statement_struct *, asection *)); + + /* Run after assigning parsing with the args, but before + reading the script. Used to initialize symbols used in the script. */ + void (*set_symbols) PARAMS ((void)); + + /* Run to parse args which the base linker doesn't + understand. Return non zero on sucess. */ + int (*parse_args) PARAMS ((int, char **)); + + /* Run to handle files which are not recognized as object files or + archives. Return true if the file was handled. */ + boolean (*unrecognized_file) + PARAMS ((struct lang_input_statement_struct *)); + +} ld_emulation_xfer_type; + +typedef enum +{ + intel_ic960_ld_mode_enum, + default_mode_enum , + intel_gld960_ld_mode_enum +} lang_emulation_mode_enum_type; + +extern ld_emulation_xfer_type *ld_emulations[]; + +#endif diff --git a/contrib/binutils/ld/ldexp.c b/contrib/binutils/ld/ldexp.c new file mode 100644 index 0000000..f24ce79 --- /dev/null +++ b/contrib/binutils/ld/ldexp.c @@ -0,0 +1,938 @@ +/* This module handles expression trees. +Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. +Written by Steve Chamberlain of Cygnus Support (sac@cygnus.com). + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* +This module is in charge of working out the contents of expressions. + +It has to keep track of the relative/absness of a symbol etc. This is +done by keeping all values in a struct (an etree_value_type) which +contains a value, a section to which it is relative and a valid bit. + +*/ + + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" + +#include "ld.h" +#include "ldmain.h" +#include "ldmisc.h" +#include "ldexp.h" +#include "ldgram.h" +#include "ldlang.h" + +static void exp_print_token PARAMS ((token_code_type code)); +static void make_abs PARAMS ((etree_value_type *ptr)); +static etree_value_type new_abs PARAMS ((bfd_vma value)); +static void check PARAMS ((lang_output_section_statement_type *os, + const char *name, const char *op)); +static etree_value_type new_rel + PARAMS ((bfd_vma value, lang_output_section_statement_type *section)); +static etree_value_type new_rel_from_section + PARAMS ((bfd_vma value, lang_output_section_statement_type *section)); +static etree_value_type fold_binary + PARAMS ((etree_type *tree, + lang_output_section_statement_type *current_section, + lang_phase_type allocation_done, + bfd_vma dot, bfd_vma *dotp)); +static etree_value_type fold_name + PARAMS ((etree_type *tree, + lang_output_section_statement_type *current_section, + lang_phase_type allocation_done, + bfd_vma dot)); +static etree_value_type exp_fold_tree_no_dot + PARAMS ((etree_type *tree, + lang_output_section_statement_type *current_section, + lang_phase_type allocation_done)); + +static void +exp_print_token (code) + token_code_type code; +{ + static CONST struct + { + token_code_type code; + char *name; + } table[] = + { + { INT, "int" }, + { REL, "relocateable" }, + { NAME,"NAME" }, + { PLUSEQ,"+=" }, + { MINUSEQ,"-=" }, + { MULTEQ,"*=" }, + { DIVEQ,"/=" }, + { LSHIFTEQ,"<<=" }, + { RSHIFTEQ,">>=" }, + { ANDEQ,"&=" }, + { OREQ,"|=" }, + { OROR,"||" }, + { ANDAND,"&&" }, + { EQ,"==" }, + { NE,"!=" }, + { LE,"<=" }, + { GE,">=" }, + { LSHIFT,"<<" }, + { RSHIFT,">>=" }, + { ALIGN_K,"ALIGN" }, + { BLOCK,"BLOCK" }, + { SECTIONS,"SECTIONS" }, + { SIZEOF_HEADERS,"SIZEOF_HEADERS" }, + { NEXT,"NEXT" }, + { SIZEOF,"SIZEOF" }, + { ADDR,"ADDR" }, + { LOADADDR,"LOADADDR" }, + { MEMORY,"MEMORY" }, + { DEFINED,"DEFINED" }, + { TARGET_K,"TARGET" }, + { SEARCH_DIR,"SEARCH_DIR" }, + { MAP,"MAP" }, + { QUAD,"QUAD" }, + { LONG,"LONG" }, + { SHORT,"SHORT" }, + { BYTE,"BYTE" }, + { ENTRY,"ENTRY" }, + { 0,(char *)NULL } + }; + unsigned int idx; + + for (idx = 0; table[idx].name != (char*)NULL; idx++) { + if (table[idx].code == code) { + fprintf(config.map_file, "%s", table[idx].name); + return; + } + } + /* Not in table, just print it alone */ + fprintf(config.map_file, "%c",code); +} + +static void +make_abs (ptr) + etree_value_type *ptr; +{ + asection *s = ptr->section->bfd_section; + ptr->value += s->vma; + ptr->section = abs_output_section; +} + +static etree_value_type +new_abs (value) + bfd_vma value; +{ + etree_value_type new; + new.valid = true; + new.section = abs_output_section; + new.value = value; + return new; +} + +static void +check (os, name, op) + lang_output_section_statement_type *os; + const char *name; + const char *op; +{ + if (os == NULL) + einfo ("%F%P: %s uses undefined section %s\n", op, name); + if (! os->processed) + einfo ("%F%P: %s forward reference of section %s\n", op, name); +} + +etree_type * +exp_intop (value) + bfd_vma value; +{ + etree_type *new = (etree_type *) stat_alloc(sizeof(new->value)); + new->type.node_code = INT; + new->value.value = value; + new->type.node_class = etree_value; + return new; + +} + +/* Build an expression representing an unnamed relocateable value. */ + +etree_type * +exp_relop (section, value) + asection *section; + bfd_vma value; +{ + etree_type *new = (etree_type *) stat_alloc (sizeof (new->rel)); + new->type.node_code = REL; + new->type.node_class = etree_rel; + new->rel.section = section; + new->rel.value = value; + return new; +} + +static etree_value_type +new_rel (value, section) + bfd_vma value; + lang_output_section_statement_type *section; +{ + etree_value_type new; + new.valid = true; + new.value = value; + new.section = section; + return new; +} + +static etree_value_type +new_rel_from_section (value, section) + bfd_vma value; + lang_output_section_statement_type *section; +{ + etree_value_type new; + new.valid = true; + new.value = value; + new.section = section; + + new.value -= section->bfd_section->vma; + + return new; +} + +static etree_value_type +fold_binary (tree, current_section, allocation_done, dot, dotp) + etree_type *tree; + lang_output_section_statement_type *current_section; + lang_phase_type allocation_done; + bfd_vma dot; + bfd_vma *dotp; +{ + etree_value_type result; + + result = exp_fold_tree (tree->binary.lhs, current_section, + allocation_done, dot, dotp); + if (result.valid) + { + etree_value_type other; + + other = exp_fold_tree (tree->binary.rhs, + current_section, + allocation_done, dot,dotp) ; + if (other.valid) + { + /* If the values are from different sections, or this is an + absolute expression, make both the source arguments + absolute. However, adding or subtracting an absolute + value from a relative value is meaningful, and is an + exception. */ + if (current_section != abs_output_section + && (other.section == abs_output_section + || (result.section == abs_output_section + && tree->type.node_code == '+')) + && (tree->type.node_code == '+' + || tree->type.node_code == '-')) + { + etree_value_type hold; + + /* If there is only one absolute term, make sure it is the + second one. */ + if (other.section != abs_output_section) + { + hold = result; + result = other; + other = hold; + } + } + else if (result.section != other.section + || current_section == abs_output_section) + { + make_abs(&result); + make_abs(&other); + } + + switch (tree->type.node_code) + { + case '%': + if (other.value == 0) + einfo ("%F%S %% by zero\n"); + result.value = ((bfd_signed_vma) result.value + % (bfd_signed_vma) other.value); + break; + + case '/': + if (other.value == 0) + einfo ("%F%S / by zero\n"); + result.value = ((bfd_signed_vma) result.value + / (bfd_signed_vma) other.value); + break; + +#define BOP(x,y) case x : result.value = result.value y other.value; break; + BOP('+',+); + BOP('*',*); + BOP('-',-); + BOP(LSHIFT,<<); + BOP(RSHIFT,>>); + BOP(EQ,==); + BOP(NE,!=); + BOP('<',<); + BOP('>',>); + BOP(LE,<=); + BOP(GE,>=); + BOP('&',&); + BOP('^',^); + BOP('|',|); + BOP(ANDAND,&&); + BOP(OROR,||); + + case MAX: + if (result.value < other.value) + result = other; + break; + + case MIN: + if (result.value > other.value) + result = other; + break; + + default: + FAIL(); + } + } + else + { + result.valid = false; + } + } + + return result; +} + +etree_value_type +invalid () +{ + etree_value_type new; + new.valid = false; + return new; +} + +static etree_value_type +fold_name (tree, current_section, allocation_done, dot) + etree_type *tree; + lang_output_section_statement_type *current_section; + lang_phase_type allocation_done; + bfd_vma dot; +{ + etree_value_type result; + switch (tree->type.node_code) + { + case SIZEOF_HEADERS: + if (allocation_done != lang_first_phase_enum) + { + result = new_abs ((bfd_vma) + bfd_sizeof_headers (output_bfd, + link_info.relocateable)); + } + else + { + result.valid = false; + } + break; + case DEFINED: + if (allocation_done == lang_first_phase_enum) + result.valid = false; + else + { + struct bfd_link_hash_entry *h; + + h = bfd_wrapped_link_hash_lookup (output_bfd, &link_info, + tree->name.name, + false, false, true); + result.value = (h != (struct bfd_link_hash_entry *) NULL + && (h->type == bfd_link_hash_defined + || h->type == bfd_link_hash_defweak + || h->type == bfd_link_hash_common)); + result.section = 0; + result.valid = true; + } + break; + case NAME: + result.valid = false; + if (tree->name.name[0] == '.' && tree->name.name[1] == 0) + { + if (allocation_done != lang_first_phase_enum) + result = new_rel_from_section(dot, current_section); + else + result = invalid(); + } + else if (allocation_done != lang_first_phase_enum) + { + struct bfd_link_hash_entry *h; + + h = bfd_wrapped_link_hash_lookup (output_bfd, &link_info, + tree->name.name, + false, false, true); + if (h != NULL + && (h->type == bfd_link_hash_defined + || h->type == bfd_link_hash_defweak)) + { + if (bfd_is_abs_section (h->u.def.section)) + result = new_abs (h->u.def.value); + else if (allocation_done == lang_final_phase_enum + || allocation_done == lang_allocating_phase_enum) + { + lang_output_section_statement_type *os; + + os = (lang_output_section_statement_lookup + (h->u.def.section->output_section->name)); + + /* FIXME: Is this correct if this section is being + linked with -R? */ + result = new_rel ((h->u.def.value + + h->u.def.section->output_offset), + os); + } + } + else if (allocation_done == lang_final_phase_enum) + einfo ("%F%S: undefined symbol `%s' referenced in expression\n", + tree->name.name); + } + break; + + case ADDR: + if (allocation_done != lang_first_phase_enum) + { + lang_output_section_statement_type *os; + + os = lang_output_section_find (tree->name.name); + check (os, tree->name.name, "ADDR"); + result = new_rel (0, os); + } + else + result = invalid (); + break; + + case LOADADDR: + if (allocation_done != lang_first_phase_enum) + { + lang_output_section_statement_type *os; + + os = lang_output_section_find (tree->name.name); + check (os, tree->name.name, "LOADADDR"); + if (os->load_base == NULL) + result = new_rel (0, os); + else + result = exp_fold_tree_no_dot (os->load_base, + abs_output_section, + allocation_done); + } + else + result = invalid (); + break; + + case SIZEOF: + if (allocation_done != lang_first_phase_enum) + { + lang_output_section_statement_type *os; + + os = lang_output_section_find (tree->name.name); + check (os, tree->name.name, "SIZEOF"); + result = new_abs (os->bfd_section->_raw_size); + } + else + result = invalid (); + break; + + default: + FAIL(); + break; + } + + return result; +} +etree_value_type +exp_fold_tree (tree, current_section, allocation_done, dot, dotp) + etree_type *tree; + lang_output_section_statement_type *current_section; + lang_phase_type allocation_done; + bfd_vma dot; + bfd_vma *dotp; +{ + etree_value_type result; + + if (tree == NULL) + { + result.valid = false; + return result; + } + + switch (tree->type.node_class) + { + case etree_value: + result = new_rel (tree->value.value, current_section); + break; + + case etree_rel: + if (allocation_done != lang_final_phase_enum) + result.valid = false; + else + result = new_rel ((tree->rel.value + + tree->rel.section->output_section->vma + + tree->rel.section->output_offset), + current_section); + break; + + case etree_unary: + result = exp_fold_tree (tree->unary.child, + current_section, + allocation_done, dot, dotp); + if (result.valid) + { + switch (tree->type.node_code) + { + case ALIGN_K: + if (allocation_done != lang_first_phase_enum) + result = new_rel_from_section (ALIGN_N (dot, result.value), + current_section); + else + result.valid = false; + break; + + case ABSOLUTE: + if (allocation_done != lang_first_phase_enum && result.valid) + { + result.value += result.section->bfd_section->vma; + result.section = abs_output_section; + } + else + result.valid = false; + break; + + case '~': + make_abs (&result); + result.value = ~result.value; + break; + + case '!': + make_abs (&result); + result.value = !result.value; + break; + + case '-': + make_abs (&result); + result.value = -result.value; + break; + + case NEXT: + /* Return next place aligned to value. */ + if (allocation_done == lang_allocating_phase_enum) + { + make_abs (&result); + result.value = ALIGN_N (dot, result.value); + } + else + result.valid = false; + break; + + default: + FAIL (); + break; + } + } + break; + + case etree_trinary: + result = exp_fold_tree (tree->trinary.cond, current_section, + allocation_done, dot, dotp); + if (result.valid) + result = exp_fold_tree ((result.value + ? tree->trinary.lhs + : tree->trinary.rhs), + current_section, + allocation_done, dot, dotp); + break; + + case etree_binary: + result = fold_binary (tree, current_section, allocation_done, + dot, dotp); + break; + + case etree_assign: + case etree_provide: + if (tree->assign.dst[0] == '.' && tree->assign.dst[1] == 0) + { + /* Assignment to dot can only be done during allocation */ + if (tree->type.node_class == etree_provide) + einfo ("%F%S can not PROVIDE assignment to location counter\n"); + if (allocation_done == lang_allocating_phase_enum + || (allocation_done == lang_final_phase_enum + && current_section == abs_output_section)) + { + result = exp_fold_tree (tree->assign.src, + current_section, + lang_allocating_phase_enum, dot, + dotp); + if (! result.valid) + einfo ("%F%S invalid assignment to location counter\n"); + else + { + if (current_section == NULL) + einfo ("%F%S assignment to location counter invalid outside of SECTION\n"); + else + { + bfd_vma nextdot; + + nextdot = (result.value + + current_section->bfd_section->vma); + if (nextdot < dot + && current_section != abs_output_section) + { + einfo ("%F%S cannot move location counter backwards (from %V to %V)\n", + dot, nextdot); + } + else + *dotp = nextdot; + } + } + } + } + else + { + result = exp_fold_tree (tree->assign.src, + current_section, allocation_done, + dot, dotp); + if (result.valid) + { + boolean create; + struct bfd_link_hash_entry *h; + + if (tree->type.node_class == etree_assign) + create = true; + else + create = false; + h = bfd_link_hash_lookup (link_info.hash, tree->assign.dst, + create, false, false); + if (h == (struct bfd_link_hash_entry *) NULL) + { + if (tree->type.node_class == etree_assign) + einfo ("%P%F:%s: hash creation failed\n", + tree->assign.dst); + } + else if (tree->type.node_class == etree_provide + && h->type != bfd_link_hash_undefined + && h->type != bfd_link_hash_common) + { + /* Do nothing. The symbol was defined by some + object. */ + } + else + { + /* FIXME: Should we worry if the symbol is already + defined? */ + h->type = bfd_link_hash_defined; + h->u.def.value = result.value; + h->u.def.section = result.section->bfd_section; + } + } + } + break; + + case etree_name: + result = fold_name (tree, current_section, allocation_done, dot); + break; + + default: + FAIL (); + break; + } + + return result; +} + +static etree_value_type +exp_fold_tree_no_dot (tree, current_section, allocation_done) + etree_type *tree; + lang_output_section_statement_type *current_section; + lang_phase_type allocation_done; +{ +return exp_fold_tree(tree, current_section, allocation_done, (bfd_vma) + 0, (bfd_vma *)NULL); +} + +etree_type * +exp_binop (code, lhs, rhs) + int code; + etree_type *lhs; + etree_type *rhs; +{ + etree_type value, *new; + etree_value_type r; + + value.type.node_code = code; + value.binary.lhs = lhs; + value.binary.rhs = rhs; + value.type.node_class = etree_binary; + r = exp_fold_tree_no_dot(&value, + abs_output_section, + lang_first_phase_enum ); + if (r.valid) + { + return exp_intop(r.value); + } + new = (etree_type *) stat_alloc (sizeof (new->binary)); + memcpy((char *)new, (char *)&value, sizeof(new->binary)); + return new; +} + +etree_type * +exp_trinop (code, cond, lhs, rhs) + int code; + etree_type *cond; + etree_type *lhs; + etree_type *rhs; +{ + etree_type value, *new; + etree_value_type r; + value.type.node_code = code; + value.trinary.lhs = lhs; + value.trinary.cond = cond; + value.trinary.rhs = rhs; + value.type.node_class = etree_trinary; + r= exp_fold_tree_no_dot(&value, (lang_output_section_statement_type + *)NULL,lang_first_phase_enum); + if (r.valid) { + return exp_intop(r.value); + } + new = (etree_type *) stat_alloc (sizeof (new->trinary)); + memcpy((char *)new,(char *) &value, sizeof(new->trinary)); + return new; +} + + +etree_type * +exp_unop (code, child) + int code; + etree_type *child; +{ + etree_type value, *new; + + etree_value_type r; + value.unary.type.node_code = code; + value.unary.child = child; + value.unary.type.node_class = etree_unary; + r = exp_fold_tree_no_dot(&value,abs_output_section, + lang_first_phase_enum); + if (r.valid) { + return exp_intop(r.value); + } + new = (etree_type *) stat_alloc (sizeof (new->unary)); + memcpy((char *)new, (char *)&value, sizeof(new->unary)); + return new; +} + + +etree_type * +exp_nameop (code, name) + int code; + CONST char *name; +{ + etree_type value, *new; + etree_value_type r; + value.name.type.node_code = code; + value.name.name = name; + value.name.type.node_class = etree_name; + + + r = exp_fold_tree_no_dot(&value, + (lang_output_section_statement_type *)NULL, + lang_first_phase_enum); + if (r.valid) { + return exp_intop(r.value); + } + new = (etree_type *) stat_alloc (sizeof (new->name)); + memcpy((char *)new, (char *)&value, sizeof(new->name)); + return new; + +} + + + + +etree_type * +exp_assop (code, dst, src) + int code; + CONST char *dst; + etree_type *src; +{ + etree_type value, *new; + + value.assign.type.node_code = code; + + + value.assign.src = src; + value.assign.dst = dst; + value.assign.type.node_class = etree_assign; + +#if 0 + if (exp_fold_tree_no_dot(&value, &result)) { + return exp_intop(result); + } +#endif + new = (etree_type*) stat_alloc (sizeof (new->assign)); + memcpy((char *)new, (char *)&value, sizeof(new->assign)); + return new; +} + +/* Handle PROVIDE. */ + +etree_type * +exp_provide (dst, src) + const char *dst; + etree_type *src; +{ + etree_type *n; + + n = (etree_type *) stat_alloc (sizeof (n->assign)); + n->assign.type.node_code = '='; + n->assign.type.node_class = etree_provide; + n->assign.src = src; + n->assign.dst = dst; + return n; +} + +void +exp_print_tree (tree) + etree_type *tree; +{ + switch (tree->type.node_class) { + case etree_value: + minfo ("0x%v", tree->value.value); + return; + case etree_rel: + if (tree->rel.section->owner != NULL) + minfo ("%B:", tree->rel.section->owner); + minfo ("%s+0x%v", tree->rel.section->name, tree->rel.value); + return; + case etree_assign: +#if 0 + if (tree->assign.dst->sdefs != (asymbol *)NULL){ + fprintf(config.map_file,"%s (%x) ",tree->assign.dst->name, + tree->assign.dst->sdefs->value); + } + else { + fprintf(config.map_file,"%s (UNDEFINED)",tree->assign.dst->name); + } +#endif + fprintf(config.map_file,"%s",tree->assign.dst); + exp_print_token(tree->type.node_code); + exp_print_tree(tree->assign.src); + break; + case etree_provide: + fprintf (config.map_file, "PROVIDE (%s, ", tree->assign.dst); + exp_print_tree (tree->assign.src); + fprintf (config.map_file, ")"); + break; + case etree_binary: + fprintf(config.map_file,"("); + exp_print_tree(tree->binary.lhs); + exp_print_token(tree->type.node_code); + exp_print_tree(tree->binary.rhs); + fprintf(config.map_file,")"); + break; + case etree_trinary: + exp_print_tree(tree->trinary.cond); + fprintf(config.map_file,"?"); + exp_print_tree(tree->trinary.lhs); + fprintf(config.map_file,":"); + exp_print_tree(tree->trinary.rhs); + break; + case etree_unary: + exp_print_token(tree->unary.type.node_code); + if (tree->unary.child) + { + + fprintf(config.map_file,"("); + exp_print_tree(tree->unary.child); + fprintf(config.map_file,")"); + } + + break; + case etree_undef: + fprintf(config.map_file,"????????"); + break; + case etree_name: + if (tree->type.node_code == NAME) { + fprintf(config.map_file,"%s", tree->name.name); + } + else { + exp_print_token(tree->type.node_code); + if (tree->name.name) + fprintf(config.map_file,"(%s)", tree->name.name); + } + break; + default: + FAIL(); + break; + } +} + +bfd_vma +exp_get_vma (tree, def, name, allocation_done) + etree_type *tree; + bfd_vma def; + char *name; + lang_phase_type allocation_done; +{ + etree_value_type r; + + if (tree != NULL) + { + r = exp_fold_tree_no_dot (tree, abs_output_section, allocation_done); + if (! r.valid && name != NULL) + einfo ("%F%S nonconstant expression for %s\n", name); + return r.value; + } + else + return def; +} + +int +exp_get_value_int (tree,def,name, allocation_done) + etree_type *tree; + int def; + char *name; + lang_phase_type allocation_done; +{ + return (int)exp_get_vma(tree,(bfd_vma)def,name, allocation_done); +} + + +bfd_vma +exp_get_abs_int (tree, def, name, allocation_done) + etree_type *tree; + int def; + char *name; + lang_phase_type allocation_done; +{ + etree_value_type res; + res = exp_fold_tree_no_dot (tree, abs_output_section, allocation_done); + + if (res.valid) + { + res.value += res.section->bfd_section->vma; + } + else { + einfo ("%F%S non constant expression for %s\n",name); + } + return res.value; +} diff --git a/contrib/binutils/ld/ldexp.h b/contrib/binutils/ld/ldexp.h new file mode 100644 index 0000000..8726a01 --- /dev/null +++ b/contrib/binutils/ld/ldexp.h @@ -0,0 +1,109 @@ +/* ldexp.h - + Copyright 1991, 1992, 1993 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GLD; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef LDEXP_H +#define LDEXP_H + +/* The result of an expression tree */ +typedef struct +{ + bfd_vma value; + struct lang_output_section_statement_struct *section; + boolean valid; +} etree_value_type; + + + +typedef struct +{ + int node_code; + enum { etree_binary, + etree_trinary, + etree_unary, + etree_name, + etree_assign, + etree_provide, + etree_undef, + etree_unspec, + etree_value, + etree_rel } node_class; +} node_type; + + + +typedef union etree_union +{ + node_type type; + struct { + node_type type; + union etree_union *lhs; + union etree_union *rhs; + } binary; + struct { + node_type type; + union etree_union *cond; + union etree_union *lhs; + union etree_union *rhs; + } trinary; + struct { + node_type type; + CONST char *dst; + union etree_union *src; + } assign; + + struct { + node_type type; + union etree_union *child; + } unary; + struct { + node_type type; + CONST char *name; + } name; + struct { + node_type type; + bfd_vma value; + } value; + struct { + node_type type; + asection *section; + bfd_vma value; + } rel; + +} etree_type; + + +etree_type *exp_intop PARAMS ((bfd_vma)); +etree_type *exp_relop PARAMS ((asection *, bfd_vma)); +etree_value_type invalid PARAMS ((void)); +etree_value_type exp_fold_tree PARAMS ((etree_type *, struct + lang_output_section_statement_struct *, + lang_phase_type, + bfd_vma, bfd_vma *)); +etree_type *exp_binop PARAMS ((int, etree_type *, etree_type *)); +etree_type *exp_trinop PARAMS ((int,etree_type *, etree_type *, etree_type *)); +etree_type *exp_unop PARAMS ((int, etree_type *)); +etree_type *exp_nameop PARAMS ((int, CONST char *)); +etree_type *exp_assop PARAMS ((int, CONST char *, etree_type *)); +etree_type *exp_provide PARAMS ((const char *, etree_type *)); +void exp_print_tree PARAMS ((etree_type *)); +bfd_vma exp_get_vma PARAMS ((etree_type *, bfd_vma, char *, lang_phase_type)); +int exp_get_value_int PARAMS ((etree_type *, int, char *,lang_phase_type)); +bfd_vma exp_get_abs_int PARAMS ((etree_type *, int, char *,lang_phase_type)); + +#endif diff --git a/contrib/binutils/ld/ldfile.c b/contrib/binutils/ld/ldfile.c new file mode 100644 index 0000000..a1f2b49 --- /dev/null +++ b/contrib/binutils/ld/ldfile.c @@ -0,0 +1,397 @@ +/* Copyright (C) 1991, 92, 93, 94 Free Software Foundation, Inc. + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* + ldfile.c + + look after all the file stuff + + */ + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" +#include "ld.h" +#include "ldmisc.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldfile.h" +#include "ldmain.h" +#include "ldgram.h" +#include "ldlex.h" +#include "ldemul.h" + +#include <ctype.h> + +const char *ldfile_input_filename; +boolean ldfile_assumed_script = false; +const char *ldfile_output_machine_name = ""; +unsigned long ldfile_output_machine; +enum bfd_architecture ldfile_output_architecture; +search_dirs_type *search_head; + +#ifndef MPW +#ifdef VMS +char *slash = ""; +#else +char *slash = "/"; +#endif +#else /* MPW */ +/* The MPW path char is a colon. */ +char *slash = ":"; +#endif /* MPW */ + +/* LOCAL */ + +static search_dirs_type **search_tail_ptr = &search_head; + +typedef struct search_arch +{ + char *name; + struct search_arch *next; +} search_arch_type; + +static search_arch_type *search_arch_head; +static search_arch_type **search_arch_tail_ptr = &search_arch_head; + +static boolean ldfile_open_file_search + PARAMS ((const char *arch, lang_input_statement_type *, + const char *lib, const char *suffix)); +static FILE *try_open PARAMS ((const char *name, const char *exten)); + +void +ldfile_add_library_path (name, cmdline) + const char *name; + boolean cmdline; +{ + search_dirs_type *new; + + new = (search_dirs_type *) xmalloc (sizeof (search_dirs_type)); + new->next = NULL; + new->name = name; + new->cmdline = cmdline; + *search_tail_ptr = new; + search_tail_ptr = &new->next; +} + +/* Try to open a BFD for a lang_input_statement. */ + +boolean +ldfile_try_open_bfd (attempt, entry) + const char *attempt; + lang_input_statement_type *entry; +{ + entry->the_bfd = bfd_openr (attempt, entry->target); + + if (trace_file_tries) + info_msg ("attempt to open %s %s\n", attempt, + entry->the_bfd == NULL ? "failed" : "succeeded"); + + if (entry->the_bfd != NULL) + return true; + else + { + if (bfd_get_error () == bfd_error_invalid_target) + einfo ("%F%P: invalid BFD target `%s'\n", entry->target); + return false; + } +} + +/* Search for and open the file specified by ENTRY. If it is an + archive, use ARCH, LIB and SUFFIX to modify the file name. */ + +static boolean +ldfile_open_file_search (arch, entry, lib, suffix) + const char *arch; + lang_input_statement_type *entry; + const char *lib; + const char *suffix; +{ + search_dirs_type *search; + + /* If this is not an archive, try to open it in the current + directory first. */ + if (! entry->is_archive) + { + if (ldfile_try_open_bfd (entry->filename, entry)) + return true; + } + + for (search = search_head; + search != (search_dirs_type *)NULL; + search = search->next) + { + char *string; + + if (entry->dynamic && ! link_info.relocateable) + { + if (ldemul_open_dynamic_archive (arch, search, entry)) + return true; + } + + string = (char *) xmalloc (strlen (search->name) + + strlen (slash) + + strlen (lib) + + strlen (entry->filename) + + strlen (arch) + + strlen (suffix) + + 1); + + if (entry->is_archive) + sprintf (string, "%s%s%s%s%s%s", search->name, slash, + lib, entry->filename, arch, suffix); + else if (entry->filename[0] == '/' || entry->filename[0] == '.') + strcpy (string, entry->filename); + else + sprintf (string, "%s%s%s", search->name, slash, entry->filename); + + if (ldfile_try_open_bfd (string, entry)) + { + entry->filename = string; + return true; + } + + free (string); + } + + return false; +} + +/* Open the input file specified by ENTRY. */ + +void +ldfile_open_file (entry) + lang_input_statement_type *entry; +{ + if (entry->the_bfd != NULL) + return; + + if (! entry->search_dirs_flag) + { + if (ldfile_try_open_bfd (entry->filename, entry)) + return; + } + else + { + search_arch_type *arch; + + /* Try to open <filename><suffix> or lib<filename><suffix>.a */ + for (arch = search_arch_head; + arch != (search_arch_type *) NULL; + arch = arch->next) + { + if (ldfile_open_file_search (arch->name, entry, "lib", ".a")) + return; +#ifdef VMS + if (ldfile_open_file_search (arch->name, entry, ":lib", ".a")) + return; +#endif + } + } + + einfo("%F%P: cannot open %s: %E\n", entry->local_sym_name); +} + +/* Try to open NAME; if that fails, try NAME with EXTEN appended to it. */ + +static FILE * +try_open (name, exten) + const char *name; + const char *exten; +{ + FILE *result; + char buff[1000]; + + result = fopen (name, "r"); + if (trace_file_tries) + { + if (result == NULL) + info_msg ("cannot find script file "); + else + info_msg ("opened script file "); + info_msg ("%s\n",name); + } + + if (result != NULL) + return result; + + if (*exten) + { + sprintf (buff, "%s%s", name, exten); + result = fopen (buff, "r"); + if (trace_file_tries) + { + if (result == NULL) + info_msg ("cannot find script file "); + else + info_msg ("opened script file "); + info_msg ("%s\n", buff); + } + } + + return result; +} + +/* Try to open NAME; if that fails, look for it in any directories + specified with -L, without and with EXTEND apppended. */ + +FILE * +ldfile_find_command_file (name, extend) + const char *name; + const char *extend; +{ + search_dirs_type *search; + FILE *result; + char buffer[1000]; + + /* First try raw name */ + result = try_open(name,""); + if (result == (FILE *)NULL) { + /* Try now prefixes */ + for (search = search_head; + search != (search_dirs_type *)NULL; + search = search->next) { + sprintf(buffer,"%s/%s", search->name, name); + result = try_open(buffer, extend); + if (result)break; + } + } + return result; +} + +void +ldfile_open_command_file (name) + const char *name; +{ + FILE *ldlex_input_stack; + ldlex_input_stack = ldfile_find_command_file(name, ""); + + if (ldlex_input_stack == (FILE *)NULL) { + bfd_set_error (bfd_error_system_call); + einfo("%P%F: cannot open linker script file %s: %E\n",name); + } + lex_push_file(ldlex_input_stack, name); + + ldfile_input_filename = name; + lineno = 1; + had_script = true; +} + + + + + +#ifdef GNU960 +static +char * +gnu960_map_archname( name ) +char *name; +{ + struct tabentry { char *cmd_switch; char *arch; }; + static struct tabentry arch_tab[] = { + "", "", + "KA", "ka", + "KB", "kb", + "KC", "mc", /* Synonym for MC */ + "MC", "mc", + "CA", "ca", + "SA", "ka", /* Functionally equivalent to KA */ + "SB", "kb", /* Functionally equivalent to KB */ + NULL, "" + }; + struct tabentry *tp; + + + for ( tp = arch_tab; tp->cmd_switch != NULL; tp++ ){ + if ( !strcmp(name,tp->cmd_switch) ){ + break; + } + } + + if ( tp->cmd_switch == NULL ){ + einfo("%P%F: unknown architecture: %s\n",name); + } + return tp->arch; +} + + + +void +ldfile_add_arch(name) +char *name; +{ + search_arch_type *new = + (search_arch_type *)xmalloc((bfd_size_type)(sizeof(search_arch_type))); + + + if (*name != '\0') { + if (ldfile_output_machine_name[0] != '\0') { + einfo("%P%F: target architecture respecified\n"); + return; + } + ldfile_output_machine_name = name; + } + + new->next = (search_arch_type*)NULL; + new->name = gnu960_map_archname( name ); + *search_arch_tail_ptr = new; + search_arch_tail_ptr = &new->next; + +} + +#else /* not GNU960 */ + + +void +ldfile_add_arch (in_name) + CONST char * in_name; +{ + char *name = buystring(in_name); + search_arch_type *new = + (search_arch_type *) xmalloc (sizeof (search_arch_type)); + + ldfile_output_machine_name = in_name; + + new->name = name; + new->next = (search_arch_type*)NULL; + while (*name) { + if (isupper(*name)) *name = tolower(*name); + name++; + } + *search_arch_tail_ptr = new; + search_arch_tail_ptr = &new->next; + +} +#endif + +/* Set the output architecture */ +void +ldfile_set_output_arch (string) + CONST char *string; +{ + const bfd_arch_info_type *arch = bfd_scan_arch(string); + + if (arch) { + ldfile_output_architecture = arch->arch; + ldfile_output_machine = arch->mach; + ldfile_output_machine_name = arch->printable_name; + } + else { + einfo("%P%F: cannot represent machine `%s'\n", string); + } +} diff --git a/contrib/binutils/ld/ldfile.h b/contrib/binutils/ld/ldfile.h new file mode 100644 index 0000000..f33c9ce --- /dev/null +++ b/contrib/binutils/ld/ldfile.h @@ -0,0 +1,53 @@ +/* ldfile.h - + Copyright 1991, 1992 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GLD; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +extern const char *ldfile_input_filename; +extern boolean ldfile_assumed_script; +extern unsigned long ldfile_output_machine; +extern enum bfd_architecture ldfile_output_architecture; +extern const char *ldfile_output_machine_name; + +/* Structure used to hold the list of directories to search for + libraries. */ + +typedef struct search_dirs +{ + /* Next directory on list. */ + struct search_dirs *next; + /* Name of directory. */ + const char *name; + /* true if this is from the command line. */ + boolean cmdline; +} search_dirs_type; + +extern search_dirs_type *search_head; + +#if ANSI_PROTOTYPES +struct lang_input_statement_struct; +#endif + +extern void ldfile_add_arch PARAMS ((CONST char *)); +extern void ldfile_add_library_path PARAMS ((const char *, boolean cmdline)); +extern void ldfile_open_command_file PARAMS ((const char *name)); +extern void ldfile_open_file PARAMS ((struct lang_input_statement_struct *)); +extern boolean ldfile_try_open_bfd + PARAMS ((const char *, struct lang_input_statement_struct *)); +extern FILE *ldfile_find_command_file + PARAMS ((const char *name, const char *extend)); +extern void ldfile_set_output_arch PARAMS ((CONST char *)); diff --git a/contrib/binutils/ld/ldgram.y b/contrib/binutils/ld/ldgram.y new file mode 100644 index 0000000..87bf928 --- /dev/null +++ b/contrib/binutils/ld/ldgram.y @@ -0,0 +1,1017 @@ +/* A YACC grammer to parse a superset of the AT&T linker scripting languaue. + Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Written by Steve Chamberlain of Cygnus Support (steve@cygnus.com). + +This file is part of GNU ld. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +%{ +/* + + */ + +#define DONTDECLARE_MALLOC + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" +#include "ld.h" +#include "ldexp.h" +#include "ldver.h" +#include "ldlang.h" +#include "ldemul.h" +#include "ldfile.h" +#include "ldmisc.h" +#include "ldmain.h" +#include "mri.h" +#include "ldlex.h" + +#ifndef YYDEBUG +#define YYDEBUG 1 +#endif + +static enum section_type sectype; + +lang_memory_region_type *region; + + +char *current_file; +boolean ldgram_want_filename = true; +boolean had_script = false; +boolean force_make_executable = false; + +boolean ldgram_in_script = false; +boolean ldgram_had_equals = false; + + +#define ERROR_NAME_MAX 20 +static char *error_names[ERROR_NAME_MAX]; +static int error_index; +#define PUSH_ERROR(x) if (error_index < ERROR_NAME_MAX) error_names[error_index] = x; error_index++; +#define POP_ERROR() error_index--; +%} +%union { + bfd_vma integer; + char *name; + int token; + union etree_union *etree; + struct phdr_info + { + boolean filehdr; + boolean phdrs; + union etree_union *at; + union etree_union *flags; + } phdr; + struct lang_nocrossref *nocrossref; + struct lang_output_section_phdr_list *section_phdr; + struct bfd_elf_version_deps *deflist; + struct bfd_elf_version_expr *versyms; + struct bfd_elf_version_tree *versnode; +} + +%type <etree> exp opt_exp_with_type mustbe_exp opt_at phdr_type phdr_val +%type <etree> opt_exp_without_type +%type <integer> fill_opt +%type <name> memspec_opt casesymlist +%token <integer> INT +%token <name> NAME LNAME +%type <integer> length +%type <phdr> phdr_qualifiers +%type <nocrossref> nocrossref_list +%type <section_phdr> phdr_opt +%type <integer> opt_nocrossrefs + +%right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ +%right <token> '?' ':' +%left <token> OROR +%left <token> ANDAND +%left <token> '|' +%left <token> '^' +%left <token> '&' +%left <token> EQ NE +%left <token> '<' '>' LE GE +%left <token> LSHIFT RSHIFT + +%left <token> '+' '-' +%left <token> '*' '/' '%' + +%right UNARY +%token END +%left <token> '(' +%token <token> ALIGN_K BLOCK BIND QUAD LONG SHORT BYTE +%token SECTIONS PHDRS +%token '{' '}' +%token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH +%token SIZEOF_HEADERS +%token INCLUDE +%token MEMORY DEFSYMEND +%token NOLOAD DSECT COPY INFO OVERLAY +%token NAME LNAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY +%token <integer> NEXT +%token SIZEOF ADDR LOADADDR MAX MIN +%token STARTUP HLL SYSLIB FLOAT NOFLOAT NOCROSSREFS +%token ORIGIN FILL +%token LENGTH CREATE_OBJECT_SYMBOLS INPUT GROUP OUTPUT CONSTRUCTORS +%token ALIGNMOD AT PROVIDE +%type <token> assign_op atype +%type <name> filename +%token CHIP LIST SECT ABSOLUTE LOAD NEWLINE ENDWORD ORDER NAMEWORD +%token FORMAT PUBLIC DEFSYMEND BASE ALIAS TRUNCATE REL +%token INPUT_SCRIPT INPUT_MRI_SCRIPT INPUT_DEFSYM CASE EXTERN START +%token <name> VERS_TAG VERS_IDENTIFIER +%token GLOBAL LOCAL VERSION INPUT_VERSION_SCRIPT +%type <versyms> vers_defns +%type <versnode> vers_tag +%type <deflist> verdep + +%% + +file: + INPUT_SCRIPT script_file + | INPUT_MRI_SCRIPT mri_script_file + | INPUT_VERSION_SCRIPT version_script_file + | INPUT_DEFSYM defsym_expr + ; + + +filename: NAME; + + +defsym_expr: + { ldlex_defsym(); } + NAME '=' exp + { + ldlex_popstate(); + lang_add_assignment(exp_assop($3,$2,$4)); + } + +/* SYNTAX WITHIN AN MRI SCRIPT FILE */ +mri_script_file: + { + ldlex_mri_script (); + PUSH_ERROR ("MRI style script"); + } + mri_script_lines + { + ldlex_popstate (); + mri_draw_tree (); + POP_ERROR (); + } + ; + +mri_script_lines: + mri_script_lines mri_script_command NEWLINE + | + ; + +mri_script_command: + CHIP exp + | CHIP exp ',' exp + | NAME { + einfo("%P%F: unrecognised keyword in MRI style script '%s'\n",$1); + } + | LIST { + config.map_filename = "-"; + } + | ORDER ordernamelist + | ENDWORD + | PUBLIC NAME '=' exp + { mri_public($2, $4); } + | PUBLIC NAME ',' exp + { mri_public($2, $4); } + | PUBLIC NAME exp + { mri_public($2, $3); } + | FORMAT NAME + { mri_format($2); } + | SECT NAME ',' exp + { mri_output_section($2, $4);} + | SECT NAME exp + { mri_output_section($2, $3);} + | SECT NAME '=' exp + { mri_output_section($2, $4);} + | ALIGN_K NAME '=' exp + { mri_align($2,$4); } + | ALIGN_K NAME ',' exp + { mri_align($2,$4); } + | ALIGNMOD NAME '=' exp + { mri_alignmod($2,$4); } + | ALIGNMOD NAME ',' exp + { mri_alignmod($2,$4); } + | ABSOLUTE mri_abs_name_list + | LOAD mri_load_name_list + | NAMEWORD NAME + { mri_name($2); } + | ALIAS NAME ',' NAME + { mri_alias($2,$4,0);} + | ALIAS NAME ',' INT + { mri_alias($2,0,(int) $4);} + | BASE exp + { mri_base($2); } + | TRUNCATE INT + { mri_truncate((unsigned int) $2); } + | CASE casesymlist + | EXTERN extern_name_list + | INCLUDE filename + { ldfile_open_command_file ($2); } mri_script_lines END + | START NAME + { lang_add_entry ($2, false); } + | + ; + +ordernamelist: + ordernamelist ',' NAME { mri_order($3); } + | ordernamelist NAME { mri_order($2); } + | + ; + +mri_load_name_list: + NAME + { mri_load($1); } + | mri_load_name_list ',' NAME { mri_load($3); } + ; + +mri_abs_name_list: + NAME + { mri_only_load($1); } + | mri_abs_name_list ',' NAME + { mri_only_load($3); } + ; + +casesymlist: + /* empty */ { $$ = NULL; } + | NAME + | casesymlist ',' NAME + ; + +extern_name_list: + NAME + { ldlang_add_undef ($1); } + | extern_name_list ',' NAME + { ldlang_add_undef ($3); } + ; + +script_file: + { + ldlex_both(); + } + ifile_list + { + ldlex_popstate(); + } + ; + + +ifile_list: + ifile_list ifile_p1 + | + ; + + + +ifile_p1: + memory + | sections + | phdrs + | startup + | high_level_library + | low_level_library + | floating_point_support + | statement_anywhere + | version + | ';' + | TARGET_K '(' NAME ')' + { lang_add_target($3); } + | SEARCH_DIR '(' filename ')' + { ldfile_add_library_path ($3, false); } + | OUTPUT '(' filename ')' + { lang_add_output($3, 1); } + | OUTPUT_FORMAT '(' NAME ')' + { lang_add_output_format ($3, (char *) NULL, + (char *) NULL, 1); } + | OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')' + { lang_add_output_format ($3, $5, $7, 1); } + | OUTPUT_ARCH '(' NAME ')' + { ldfile_set_output_arch($3); } + | FORCE_COMMON_ALLOCATION + { command_line.force_common_definition = true ; } + | INPUT '(' input_list ')' + | GROUP + { lang_enter_group (); } + '(' input_list ')' + { lang_leave_group (); } + | MAP '(' filename ')' + { lang_add_map($3); } + | INCLUDE filename + { ldfile_open_command_file($2); } ifile_list END + | NOCROSSREFS '(' nocrossref_list ')' + { + lang_add_nocrossref ($3); + } + ; + +input_list: + NAME + { lang_add_input_file($1,lang_input_file_is_search_file_enum, + (char *)NULL); } + | input_list ',' NAME + { lang_add_input_file($3,lang_input_file_is_search_file_enum, + (char *)NULL); } + | input_list NAME + { lang_add_input_file($2,lang_input_file_is_search_file_enum, + (char *)NULL); } + | LNAME + { lang_add_input_file($1,lang_input_file_is_l_enum, + (char *)NULL); } + | input_list ',' LNAME + { lang_add_input_file($3,lang_input_file_is_l_enum, + (char *)NULL); } + | input_list LNAME + { lang_add_input_file($2,lang_input_file_is_l_enum, + (char *)NULL); } + ; + +sections: + SECTIONS '{' sec_or_group_p1 '}' + ; + +sec_or_group_p1: + sec_or_group_p1 section + | sec_or_group_p1 statement_anywhere + | + ; + +statement_anywhere: + ENTRY '(' NAME ')' + { lang_add_entry ($3, false); } + | assignment end + ; + +/* The '*' and '?' cases are there because the lexer returns them as + separate tokens rather than as NAME. */ +file_NAME_list: + NAME + { lang_add_wild ($1, current_file); } + | '*' + { lang_add_wild ("*", current_file); } + | '?' + { lang_add_wild ("?", current_file); } + | file_NAME_list opt_comma NAME + { lang_add_wild ($3, current_file); } + | file_NAME_list opt_comma '*' + { lang_add_wild ("*", current_file); } + | file_NAME_list opt_comma '?' + { lang_add_wild ("?", current_file); } + ; + +input_section_spec: + NAME + { + lang_add_wild((char *)NULL, $1); + } + | '[' + { + current_file = (char *)NULL; + } + file_NAME_list + ']' + | NAME + { + current_file = $1; + } + '(' file_NAME_list ')' + | '?' + /* This case is needed because the lexer returns a + single question mark as '?' rather than NAME. */ + { + current_file = "?"; + } + '(' file_NAME_list ')' + | '*' + { + current_file = (char *)NULL; + } + '(' file_NAME_list ')' + ; + +statement: + assignment end + | CREATE_OBJECT_SYMBOLS + { + lang_add_attribute(lang_object_symbols_statement_enum); + } + | ';' + | CONSTRUCTORS + { + + lang_add_attribute(lang_constructors_statement_enum); + } + | input_section_spec + | length '(' mustbe_exp ')' + { + lang_add_data((int) $1,$3); + } + + | FILL '(' mustbe_exp ')' + { + lang_add_fill + (exp_get_value_int($3, + 0, + "fill value", + lang_first_phase_enum)); + } + ; + +statement_list: + statement_list statement + | statement + ; + +statement_list_opt: + /* empty */ + | statement_list + ; + +length: + QUAD + { $$ = $1; } + | LONG + { $$ = $1; } + | SHORT + { $$ = $1; } + | BYTE + { $$ = $1; } + ; + +fill_opt: + '=' mustbe_exp + { + $$ = exp_get_value_int($2, + 0, + "fill value", + lang_first_phase_enum); + } + | { $$ = 0; } + ; + + + +assign_op: + PLUSEQ + { $$ = '+'; } + | MINUSEQ + { $$ = '-'; } + | MULTEQ + { $$ = '*'; } + | DIVEQ + { $$ = '/'; } + | LSHIFTEQ + { $$ = LSHIFT; } + | RSHIFTEQ + { $$ = RSHIFT; } + | ANDEQ + { $$ = '&'; } + | OREQ + { $$ = '|'; } + + ; + +end: ';' | ',' + ; + + +assignment: + NAME '=' mustbe_exp + { + lang_add_assignment (exp_assop ($2, $1, $3)); + } + | NAME assign_op mustbe_exp + { + lang_add_assignment (exp_assop ('=', $1, + exp_binop ($2, + exp_nameop (NAME, + $1), + $3))); + } + | PROVIDE '(' NAME '=' mustbe_exp ')' + { + lang_add_assignment (exp_provide ($3, $5)); + } + ; + + +opt_comma: + ',' | ; + + +memory: + MEMORY '{' memory_spec memory_spec_list '}' + ; + +memory_spec_list: + memory_spec_list memory_spec + | memory_spec_list ',' memory_spec + | + ; + + +memory_spec: NAME + { region = lang_memory_region_lookup($1); } + attributes_opt ':' + origin_spec opt_comma length_spec + + ; origin_spec: + ORIGIN '=' mustbe_exp + { region->current = + region->origin = + exp_get_vma($3, 0L,"origin", lang_first_phase_enum); +} + ; length_spec: + LENGTH '=' mustbe_exp + { region->length = exp_get_vma($3, + ~((bfd_vma)0), + "length", + lang_first_phase_enum); + } + + +attributes_opt: + '(' NAME ')' + { + lang_set_flags(®ion->flags, $2); + } + | + + ; + +startup: + STARTUP '(' filename ')' + { lang_startup($3); } + ; + +high_level_library: + HLL '(' high_level_library_NAME_list ')' + | HLL '(' ')' + { ldemul_hll((char *)NULL); } + ; + +high_level_library_NAME_list: + high_level_library_NAME_list opt_comma filename + { ldemul_hll($3); } + | filename + { ldemul_hll($1); } + + ; + +low_level_library: + SYSLIB '(' low_level_library_NAME_list ')' + ; low_level_library_NAME_list: + low_level_library_NAME_list opt_comma filename + { ldemul_syslib($3); } + | + ; + +floating_point_support: + FLOAT + { lang_float(true); } + | NOFLOAT + { lang_float(false); } + ; + +nocrossref_list: + /* empty */ + { + $$ = NULL; + } + | NAME nocrossref_list + { + struct lang_nocrossref *n; + + n = (struct lang_nocrossref *) xmalloc (sizeof *n); + n->name = $1; + n->next = $2; + $$ = n; + } + | NAME ',' nocrossref_list + { + struct lang_nocrossref *n; + + n = (struct lang_nocrossref *) xmalloc (sizeof *n); + n->name = $1; + n->next = $3; + $$ = n; + } + ; + +mustbe_exp: { ldlex_expression(); } + exp + { ldlex_popstate(); $$=$2;} + ; + +exp : + '-' exp %prec UNARY + { $$ = exp_unop('-', $2); } + | '(' exp ')' + { $$ = $2; } + | NEXT '(' exp ')' %prec UNARY + { $$ = exp_unop((int) $1,$3); } + | '!' exp %prec UNARY + { $$ = exp_unop('!', $2); } + | '+' exp %prec UNARY + { $$ = $2; } + | '~' exp %prec UNARY + { $$ = exp_unop('~', $2);} + + | exp '*' exp + { $$ = exp_binop('*', $1, $3); } + | exp '/' exp + { $$ = exp_binop('/', $1, $3); } + | exp '%' exp + { $$ = exp_binop('%', $1, $3); } + | exp '+' exp + { $$ = exp_binop('+', $1, $3); } + | exp '-' exp + { $$ = exp_binop('-' , $1, $3); } + | exp LSHIFT exp + { $$ = exp_binop(LSHIFT , $1, $3); } + | exp RSHIFT exp + { $$ = exp_binop(RSHIFT , $1, $3); } + | exp EQ exp + { $$ = exp_binop(EQ , $1, $3); } + | exp NE exp + { $$ = exp_binop(NE , $1, $3); } + | exp LE exp + { $$ = exp_binop(LE , $1, $3); } + | exp GE exp + { $$ = exp_binop(GE , $1, $3); } + | exp '<' exp + { $$ = exp_binop('<' , $1, $3); } + | exp '>' exp + { $$ = exp_binop('>' , $1, $3); } + | exp '&' exp + { $$ = exp_binop('&' , $1, $3); } + | exp '^' exp + { $$ = exp_binop('^' , $1, $3); } + | exp '|' exp + { $$ = exp_binop('|' , $1, $3); } + | exp '?' exp ':' exp + { $$ = exp_trinop('?' , $1, $3, $5); } + | exp ANDAND exp + { $$ = exp_binop(ANDAND , $1, $3); } + | exp OROR exp + { $$ = exp_binop(OROR , $1, $3); } + | DEFINED '(' NAME ')' + { $$ = exp_nameop(DEFINED, $3); } + | INT + { $$ = exp_intop($1); } + | SIZEOF_HEADERS + { $$ = exp_nameop(SIZEOF_HEADERS,0); } + + | SIZEOF '(' NAME ')' + { $$ = exp_nameop(SIZEOF,$3); } + | ADDR '(' NAME ')' + { $$ = exp_nameop(ADDR,$3); } + | LOADADDR '(' NAME ')' + { $$ = exp_nameop(LOADADDR,$3); } + | ABSOLUTE '(' exp ')' + { $$ = exp_unop(ABSOLUTE, $3); } + | ALIGN_K '(' exp ')' + { $$ = exp_unop(ALIGN_K,$3); } + | BLOCK '(' exp ')' + { $$ = exp_unop(ALIGN_K,$3); } + | NAME + { $$ = exp_nameop(NAME,$1); } + | MAX '(' exp ',' exp ')' + { $$ = exp_binop (MAX, $3, $5 ); } + | MIN '(' exp ',' exp ')' + { $$ = exp_binop (MIN, $3, $5 ); } + ; + + +opt_at: + AT '(' exp ')' { $$ = $3; } + | { $$ = 0; } + ; + +section: NAME { ldlex_expression(); } + opt_exp_with_type + opt_at { ldlex_popstate (); ldlex_script (); } + '{' + { + lang_enter_output_section_statement($1, $3, + sectype, + 0, 0, 0, $4); + } + statement_list_opt + '}' { ldlex_popstate (); ldlex_expression (); } + memspec_opt phdr_opt fill_opt + { + ldlex_popstate (); + lang_leave_output_section_statement ($13, $11, $12); + } + opt_comma + | OVERLAY + { ldlex_expression (); } + opt_exp_without_type opt_nocrossrefs opt_at + { ldlex_popstate (); ldlex_script (); } + '{' + { + lang_enter_overlay ($3, $5, (int) $4); + } + overlay_section + '}' + { ldlex_popstate (); ldlex_expression (); } + memspec_opt phdr_opt fill_opt + { + ldlex_popstate (); + lang_leave_overlay ($14, $12, $13); + } + opt_comma + | /* The GROUP case is just enough to support the gcc + svr3.ifile script. It is not intended to be full + support. I'm not even sure what GROUP is supposed + to mean. */ + GROUP { ldlex_expression (); } + opt_exp_with_type + { + ldlex_popstate (); + lang_add_assignment (exp_assop ('=', ".", $3)); + } + '{' sec_or_group_p1 '}' + ; + +type: + NOLOAD { sectype = noload_section; } + | DSECT { sectype = dsect_section; } + | COPY { sectype = copy_section; } + | INFO { sectype = info_section; } + | OVERLAY { sectype = overlay_section; } + ; + +atype: + '(' type ')' + | /* EMPTY */ { sectype = normal_section; } + ; + +opt_exp_with_type: + exp atype ':' { $$ = $1; } + | atype ':' { $$ = (etree_type *)NULL; } + | /* The BIND cases are to support the gcc svr3.ifile + script. They aren't intended to implement full + support for the BIND keyword. I'm not even sure + what BIND is supposed to mean. */ + BIND '(' exp ')' atype ':' { $$ = $3; } + | BIND '(' exp ')' BLOCK '(' exp ')' atype ':' + { $$ = $3; } + ; + +opt_exp_without_type: + exp ':' { $$ = $1; } + | ':' { $$ = (etree_type *) NULL; } + ; + +opt_nocrossrefs: + /* empty */ + { $$ = 0; } + | NOCROSSREFS + { $$ = 1; } + ; + +memspec_opt: + '>' NAME + { $$ = $2; } + | { $$ = "*default*"; } + ; + +phdr_opt: + /* empty */ + { + $$ = NULL; + } + | phdr_opt ':' NAME + { + struct lang_output_section_phdr_list *n; + + n = ((struct lang_output_section_phdr_list *) + xmalloc (sizeof *n)); + n->name = $3; + n->used = false; + n->next = $1; + $$ = n; + } + ; + +overlay_section: + /* empty */ + | overlay_section + NAME + { + ldlex_script (); + lang_enter_overlay_section ($2); + } + '{' statement_list_opt '}' + { ldlex_popstate (); ldlex_expression (); } + phdr_opt fill_opt + { + ldlex_popstate (); + lang_leave_overlay_section ($9, $8); + } + opt_comma + ; + +phdrs: + PHDRS '{' phdr_list '}' + ; + +phdr_list: + /* empty */ + | phdr_list phdr + ; + +phdr: + NAME { ldlex_expression (); } + phdr_type phdr_qualifiers { ldlex_popstate (); } + ';' + { + lang_new_phdr ($1, $3, $4.filehdr, $4.phdrs, $4.at, + $4.flags); + } + ; + +phdr_type: + exp + { + $$ = $1; + + if ($1->type.node_class == etree_name + && $1->type.node_code == NAME) + { + const char *s; + unsigned int i; + static const char * const phdr_types[] = + { + "PT_NULL", "PT_LOAD", "PT_DYNAMIC", + "PT_INTERP", "PT_NOTE", "PT_SHLIB", + "PT_PHDR" + }; + + s = $1->name.name; + for (i = 0; + i < sizeof phdr_types / sizeof phdr_types[0]; + i++) + if (strcmp (s, phdr_types[i]) == 0) + { + $$ = exp_intop (i); + break; + } + } + } + ; + +phdr_qualifiers: + /* empty */ + { + memset (&$$, 0, sizeof (struct phdr_info)); + } + | NAME phdr_val phdr_qualifiers + { + $$ = $3; + if (strcmp ($1, "FILEHDR") == 0 && $2 == NULL) + $$.filehdr = true; + else if (strcmp ($1, "PHDRS") == 0 && $2 == NULL) + $$.phdrs = true; + else if (strcmp ($1, "FLAGS") == 0 && $2 != NULL) + $$.flags = $2; + else + einfo ("%X%P:%S: PHDRS syntax error at `%s'\n", $1); + } + | AT '(' exp ')' phdr_qualifiers + { + $$ = $5; + $$.at = $3; + } + ; + +phdr_val: + /* empty */ + { + $$ = NULL; + } + | '(' exp ')' + { + $$ = $2; + } + ; + +/* This syntax is used within an external version script file. */ + +version_script_file: + { + ldlex_version_file (); + PUSH_ERROR ("VERSION script"); + } + vers_nodes + { + ldlex_popstate (); + POP_ERROR (); + } + ; + +/* This is used within a normal linker script file. */ + +version: + { + ldlex_version_script (); + } + VERSION '{' vers_nodes '}' + { + ldlex_popstate (); + } + ; + +vers_nodes: + vers_node + | vers_nodes vers_node + ; + +vers_node: + VERS_TAG '{' vers_tag '}' ';' + { + lang_register_vers_node ($1, $3, NULL); + } + | VERS_TAG '{' vers_tag '}' verdep ';' + { + lang_register_vers_node ($1, $3, $5); + } + ; + +verdep: + VERS_TAG + { + $$ = lang_add_vers_depend (NULL, $1); + } + | verdep VERS_TAG + { + $$ = lang_add_vers_depend ($1, $2); + } + ; + +vers_tag: + /* empty */ + { + $$ = lang_new_vers_node (NULL, NULL); + } + | vers_defns ';' + { + $$ = lang_new_vers_node ($1, NULL); + } + | GLOBAL ':' vers_defns ';' + { + $$ = lang_new_vers_node ($3, NULL); + } + | LOCAL ':' vers_defns ';' + { + $$ = lang_new_vers_node (NULL, $3); + } + | GLOBAL ':' vers_defns ';' LOCAL ':' vers_defns ';' + { + $$ = lang_new_vers_node ($3, $7); + } + ; + +vers_defns: + VERS_IDENTIFIER + { + $$ = lang_new_vers_regex (NULL, $1); + } + | vers_defns ';' VERS_IDENTIFIER + { + $$ = lang_new_vers_regex ($1, $3); + } + ; + +%% +void +yyerror(arg) + const char *arg; +{ + if (ldfile_assumed_script) + einfo ("%P:%s: file format not recognized; treating as linker script\n", + ldfile_input_filename); + if (error_index > 0 && error_index < ERROR_NAME_MAX) + einfo ("%P%F:%S: %s in %s\n", arg, error_names[error_index-1]); + else + einfo ("%P%F:%S: %s\n", arg); +} diff --git a/contrib/binutils/ld/ldint.texinfo b/contrib/binutils/ld/ldint.texinfo new file mode 100644 index 0000000..612fc2a --- /dev/null +++ b/contrib/binutils/ld/ldint.texinfo @@ -0,0 +1,412 @@ +\input texinfo +@setfilename ldint.info + +@ifinfo +@format +START-INFO-DIR-ENTRY +* Ld-Internals: (ldint). The GNU linker internals. +END-INFO-DIR-ENTRY +@end format +@end ifinfo + +@ifinfo +This file documents the internals of the GNU linker ld. + +Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc. +Contributed by Cygnus Support. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through Tex and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy or distribute modified versions of this +manual under the terms of the GPL (for which purpose this text may be +regarded as a program in the language TeX). +@end ifinfo + +@iftex +@finalout +@setchapternewpage off +@settitle GNU Linker Internals +@titlepage +@title{A guide to the internals of the GNU linker} +@author Per Bothner, Steve Chamberlain, Ian Lance Taylor +@author Cygnus Support +@page + +@tex +\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$ +\xdef\manvers{\$Revision: 1.10 $} % For use in headers, footers too +{\parskip=0pt +\hfill Cygnus Support\par +\hfill \manvers\par +\hfill \TeX{}info \texinfoversion\par +} +@end tex + +@vskip 0pt plus 1filll +Copyright @copyright{} 1992, 93, 94, 95, 1996 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@end titlepage +@end iftex + +@node Top +@top + +This file documents the internals of the GNU linker @code{ld}. It is a +collection of miscellaneous information with little form at this point. +Mostly, it is a repository into which you can put information about +GNU @code{ld} as you discover it (or as you design changes to @code{ld}). + +@menu +* README:: The README File +* Emulations:: How linker emulations are generated +@end menu + +@node README +@chapter The @file{README} File + +Check the @file{README} file; it often has useful information that does not +appear anywhere else in the directory. + +@node Emulations +@chapter How linker emulations are generated + +Each linker target has an @dfn{emulation}. The emulation includes the +default linker script, and certain emulations also modify certain types +of linker behaviour. + +Emulations are created during the build process by the shell script +@file{genscripts.sh}. + +The @file{genscripts.sh} script starts by reading a file in the +@file{emulparams} directory. This is a shell script which sets various +shell variables used by @file{genscripts.sh} and the other shell scripts +it invokes. + +The @file{genscripts.sh} script will invoke a shell script in the +@file{scripttempl} directory in order to create default linker scripts +written in the linker command language. The @file{scripttempl} script +will be invoked 5 (or, in some cases, 6) times, with different +assignments to shell variables, to create different default scripts. +The choice of script is made based on the command line options. + +After creating the scripts, @file{genscripts.sh} will invoke yet another +shell script, this time in the @file{emultempl} directory. That shell +script will create the emulation source file, which contains C code. +This C code permits the linker emulation to override various linker +behaviours. Most targets use the generic emulation code, which is in +@file{emultempl/generic.em}. + +To summarize, @file{genscripts.sh} reads three shell scripts: an +emulation parameters script in the @file{emulparams} directory, a linker +script generation script in the @file{scripttempl} directory, and an +emulation source file generation script in the @file{emultempl} +directory. + +For example, the Sun 4 linker sets up variables in +@file{emulparams/sun4.sh}, creates linker scripts using +@file{scripttempl/aout.sc}, and creates the emulation code using +@file{emultempl/sunos.em}. + +Note that the linker can support several emulations simultaneously, +depending upon how it is configured. An emulation can be selected with +the @code{-m} option. The @code{-V} option will list all supported +emulations. + +@menu +* emulation parameters:: @file{emulparams} scripts +* linker scripts:: @file{scripttempl} scripts +* linker emulations:: @file{emultempl} scripts +@end menu + +@node emulation parameters +@section @file{emulparams} scripts + +Each target selects a particular file in the @file{emulparams} directory +by setting the shell variable @code{targ_emul} in @file{configure.tgt}. +This shell variable is used by the @file{configure} script to control +building an emulation source file. + +Certain conventions are enforced. Suppose the @code{targ_emul} variable +is set to @var{emul} in @file{configure.tgt}. The name of the emulation +shell script will be @file{emulparams/@var{emul}.sh}. The +@file{Makefile} must have a target named @file{e@var{emul}.c}; this +target must depend upon @file{emulparams/@var{emul}.sh}, as well as the +appropriate scripts in the @file{scripttempl} and @file{emultempl} +directories. The @file{Makefile} target must invoke @code{GENSCRIPTS} +with two arguments: @var{emul}, and the value of the make variable +@code{tdir_@var{emul}}. The value of the latter variable will be set by +the @file{configure} script, and is used to set the default target +directory to search. + +By convention, the @file{emulparams/@var{emul}.sh} shell script should +only set shell variables. It may set shell variables which are to be +interpreted by the @file{scripttempl} and the @file{emultempl} scripts. +Certain shell variables are interpreted directly by the +@file{genscripts.sh} script. + +Here is a list of shell variables interpreted by @file{genscripts.sh}, +as well as some conventional shell variables interpreted by the +@file{scripttempl} and @file{emultempl} scripts. + +@table @code +@item SCRIPT_NAME +This is the name of the @file{scripttempl} script to use. If +@code{SCRIPT_NAME} is set to @var{script}, @file{genscripts.sh} will use +the script @file{scriptteml/@var{script}.sc}. + +@item TEMPLATE_NAME +This is the name of the @file{emultemlp} script to use. If +@code{TEMPLATE_NAME} is set to @var{template}, @file{genscripts.sh} will +use the script @file{emultempl/@var{template}.em}. If this variable is +not set, the default value is @samp{generic}. + +@item GENERATE_SHLIB_SCRIPT +If this is set to a nonempty string, @file{genscripts.sh} will invoke +the @file{scripttempl} script an extra time to create a shared library +script. @ref{linker scripts}. + +@item OUTPUT_FORMAT +This is normally set to indicate the BFD output format use (e.g., +@samp{"a.out-sunos-big"}. The @file{scripttempl} script will normally +use it in an @code{OUTPUT_FORMAT} expression in the linker script. + +@item ARCH +This is normally set to indicate the architecture to use (e.g., +@samp{sparc}). The @file{scripttempl} script will normally use it in an +@code{OUTPUT_ARCH} expression in the linker script. + +@item ENTRY +Some @file{scripttempl} scripts use this to set the entry address, in an +@code{ENTRY} expression in the linker script. + +@item TEXT_START_ADDR +Some @file{scripttempl} scripts use this to set the start address of the +@samp{.text} section. + +@item NONPAGED_TEXT_START_ADDR +If this is defined, the @file{genscripts.sh} script sets +@code{TEXT_START_ADDR} to its value before running the +@file{scripttempl} script for the @code{-n} and @code{-N} options +(@pxref{linker scripts}). + +@item SEGMENT_SIZE +The @file{genscripts.sh} script uses this to set the default value of +@code{DATA_ALIGNMENT} when running the @file{scripttempl} script. + +@item TARGET_PAGE_SIZE +If @code{SEGMENT_SIZE} is not defined, the @file{genscripts.sh} script +uses this to define it. +@end table + +@node linker scripts +@section @file{scripttempl} scripts + +Each linker target uses a @file{scripttempl} script to generate the +default linker scripts. The name of the @file{scripttempl} script is +set by the @code{SCRIPT_NAME} variable in the @file{emulparams} script. +If @code{SCRIPT_NAME} is set to @var{script}, @code{genscripts.sh} will +invoke @file{scripttempl/@var{script}.sc}. + +The @file{genscripts.sh} script will invoke the @file{scripttempl} +script 5 or 6 times. Each time it will set the shell variable +@code{LD_FLAG} to a different value. When the linker is run, the +options used will direct it to select a particular script. (Script +selection is controlled by the @code{get_script} emulation entry point; +this describes the conventional behaviour). + +The @file{scripttempl} script should just write a linker script, written +in the linker command language, to standard output. If the emulation +name--the name of the @file{emulparams} file without the @file{.sc} +extension--is @var{emul}, then the output will be directed to +@file{ldscripts/@var{emul}.@var{extension}} in the build directory, +where @var{extension} changes each time the @file{scripttempl} script is +invoked. + +Here is the list of values assigned to @code{LD_FLAG}. + +@table @code +@item (empty) +The script generated is used by default (when none of the following +cases apply). The output has an extension of @file{.x}. +@item n +The script generated is used when the linker is invoked with the +@code{-n} option. The output has an extension of @file{.xn}. +@item N +The script generated is used when the linker is invoked with the +@code{-N} option. The output has an extension of @file{.xbn}. +@item r +The script generated is used when the linker is invoked with the +@code{-r} option. The output has an extension of @file{.xr}. +@item u +The script generated is used when the linker is invoked with the +@code{-Ur} option. The output has an extension of @file{.xu}. +@item shared +The @file{scripttempl} script is only invoked with @code{LD_FLAG} set to +this value if @code{GENERATE_SHLIB_SCRIPT} is defined in the +@file{emulparams} file. The @file{emultempl} script must arrange to use +this script at the appropriate time, normally when the linker is invoked +with the @code{-shared} option. The output has an extension of +@file{.xs}. +@end table + +Besides the shell variables set by the @file{emulparams} script, and the +@code{LD_FLAG} variable, the @file{genscripts.sh} script will set +certain variables for each run of the @file{scripttempl} script. + +@table @code +@item RELOCATING +This will be set to a non-empty string when the linker is doing a final +relocation (e.g., all scripts other than @code{-r} and @code{-Ur}). + +@item CONSTRUCTING +This will be set to a non-empty string when the linker is building +global constructor and destructor tables (e.g., all scripts other than +@code{-r}). + +@item DATA_ALIGNMENT +This will be set to an @code{ALIGN} expression when the output should be +page aligned, or to @samp{.} when generating the @code{-N} script. + +@item CREATE_SHLIB +This will be set to a non-empty string when generating a @code{-shared} +script. +@end table + +The conventional way to write a @file{scripttempl} script is to first +set a few shell variables, and then write out a linker script using +@code{cat} with a here document. The linker script will use variable +substitutions, based on the above variables and those set in the +@file{emulparams} script, to control its behaviour. + +When there are parts of the @file{scripttempl} script which should only +be run when doing a final relocation, they should be enclosed within a +variable substitution based on @code{RELOCATING}. For example, on many +targets special symbols such as @code{_end} should be defined when doing +a final link. Naturally, those symbols should not be defined when doing +a relocateable link using @code{-r}. The @file{scripttempl} script +could use a construct like this to define those symbols: +@smallexample + $@{RELOCATING+ _end = .;@} +@end smallexample +This will do the symbol assignment only if the @code{RELOCATING} +variable is defined. + +The basic job of the linker script is to put the sections in the correct +order, and at the correct memory addresses. For some targets, the +linker script may have to do some other operations. + +For example, on most MIPS platforms, the linker is responsible for +defining the special symbol @code{_gp}, used to initialize the +@code{$gp} register. It must be set to the start of the small data +section plus @code{0x8000}. Naturally, it should only be defined when +doing a final relocation. This will typically be done like this: +@smallexample + $@{RELOCATING+ _gp = ALIGN(16) + 0x8000;@} +@end smallexample +This line would appear just before the sections which compose the small +data section (@samp{.sdata}, @samp{.sbss}). All those sections would be +contiguous in memory. + +Many COFF systems build constructor tables in the linker script. The +compiler will arrange to output the address of each global constructor +in a @samp{.ctor} section, and the address of each global destructor in +a @samp{.dtor} section (this is done by defining +@code{ASM_OUTPUT_CONSTRUCTOR} and @code{ASM_OUTPUT_DESTRUCTOR} in the +@code{gcc} configuration files). The @code{gcc} runtime support +routines expect the constructor table to be named @code{__CTOR_LIST__}. +They expect it to be a list of words, with the first word being the +count of the number of entries. There should be a trailing zero word. +(Actually, the count may be -1 if the trailing word is present, and the +trailing word may be omitted if the count is correct, but, as the +@code{gcc} behaviour has changed slightly over the years, it is safest +to provide both). Here is a typical way that might be handled in a +@file{scripttempl} file. +@smallexample + $@{CONSTRUCTING+ __CTOR_LIST__ = .;@} + $@{CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)@} + $@{CONSTRUCTING+ *(.ctors)@} + $@{CONSTRUCTING+ LONG(0)@} + $@{CONSTRUCTING+ __CTOR_END__ = .;@} + $@{CONSTRUCTING+ __DTOR_LIST__ = .;@} + $@{CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)@} + $@{CONSTRUCTING+ *(.dtors)@} + $@{CONSTRUCTING+ LONG(0)@} + $@{CONSTRUCTING+ __DTOR_END__ = .;@} +@end smallexample +The use of @code{CONSTRUCTING} ensures that these linker script commands +will only appear when the linker is supposed to be building the +constructor and destructor tables. This example is written for a target +which uses 4 byte pointers. + +Embedded systems often need to set a stack address. This is normally +best done by using the @code{PROVIDE} construct with a default stack +address. This permits the user to easily override the stack address +using the @code{--defsym} option. Here is an example: +@smallexample + $@{RELOCATING+ PROVIDE (__stack = 0x80000000);@} +@end smallexample +The value of the symbol @code{__stack} would then be used in the startup +code to initialize the stack pointer. + +@node linker emulations +@section @file{emultempl} scripts + +Each linker target uses an @file{emultempl} script to generate the +emulation code. The name of the @file{emultempl} script is set by the +@code{TEMPLATE_NAME} variable in the @file{emulparams} script. If the +@code{TEMPLATE_NAME} variable is not set, the default is +@samp{generic}. If the value of @code{TEMPLATE_NAME} is @var{template}, +@file{genscripts.sh} will use @file{emultempl/@var{template}.em}. + +Most targets use the generic @file{emultempl} script, +@file{emultempl/generic.em}. A different @file{emultempl} script is +only needed if the linker must support unusual actions, such as linking +against shared libraries. + +The @file{emultempl} script is normally written as a simple invocation +of @code{cat} with a here document. The document will use a few +variable substitutions. Typically each function names uses a +substitution involving @code{EMULATION_NAME}, for ease of debugging when +the linker supports multiple emulations. + +Every function and variable in the emitted file should be static. The +only globally visible object must be named +@code{ld_@var{EMULATION_NAME}_emulation}, where @var{EMULATION_NAME} is +the name of the emulation set in @file{configure.tgt} (this is also the +name of the @file{emulparams} file without the @file{.sh} extension). +The @file{genscripts.sh} script will set the shell variable +@code{EMULATION_NAME} before invoking the @file{emultempl} script. + +The @code{ld_@var{EMULATION_NAME}_emulation} variable must be a +@code{struct ld_emulation_xfer_struct}, as defined in @file{ldemul.h}. +It defines a set of function pointers which are invoked by the linker, +as well as strings for the emulation name (normally set from the shell +variable @code{EMULATION_NAME} and the default BFD target name (normally +set from the shell variable @code{OUTPUT_FORMAT} which is normally set +by the @file{emulparams} file). + +The @file{genscripts.sh} script will set the shell variable +@code{COMPILE_IN} when it invokes the @file{emultempl} script for the +default emulation. In this case, the @file{emultempl} script should +include the linker scripts directly, and return them from the +@code{get_scripts} entry point. When the emulation is not the default, +the @code{get_scripts} entry point should just return a file name. See +@file{emultempl/generic.em} for an example of how this is done. + +At some point, the linker emulation entry points should be documented. + +@contents +@bye diff --git a/contrib/binutils/ld/ldlang.c b/contrib/binutils/ld/ldlang.c new file mode 100644 index 0000000..19aedf4 --- /dev/null +++ b/contrib/binutils/ld/ldlang.c @@ -0,0 +1,3978 @@ +/* Linker command language support. + Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libiberty.h" +#include "obstack.h" +#include "bfdlink.h" + +#include "ld.h" +#include "ldmain.h" +#include "ldgram.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldemul.h" +#include "ldlex.h" +#include "ldmisc.h" +#include "ldctor.h" +#include "ldfile.h" +#include "fnmatch.h" + +#include <ctype.h> + +/* FORWARDS */ +static lang_statement_union_type *new_statement PARAMS ((enum statement_enum, + size_t, + lang_statement_list_type*)); + + +/* LOCALS */ +static struct obstack stat_obstack; + +#define obstack_chunk_alloc xmalloc +#define obstack_chunk_free free +static CONST char *startup_file; +static lang_statement_list_type input_file_chain; +static boolean placed_commons = false; +static lang_output_section_statement_type *default_common_section; +static boolean map_option_f; +static bfd_vma print_dot; +static lang_input_statement_type *first_file; +static lang_statement_list_type lang_output_section_statement; +static CONST char *current_target; +static CONST char *output_target; +static lang_statement_list_type statement_list; +static struct lang_phdr *lang_phdr_list; + +static void lang_for_each_statement_worker + PARAMS ((void (*func) (lang_statement_union_type *), + lang_statement_union_type *s)); +static lang_input_statement_type *new_afile + PARAMS ((const char *name, lang_input_file_enum_type file_type, + const char *target, boolean add_to_list)); +static void init_os PARAMS ((lang_output_section_statement_type *s)); +static void exp_init_os PARAMS ((etree_type *)); +static void section_already_linked PARAMS ((bfd *, asection *, PTR)); +static boolean wildcardp PARAMS ((const char *)); +static void wild_section PARAMS ((lang_wild_statement_type *ptr, + const char *section, + lang_input_statement_type *file, + lang_output_section_statement_type *output)); +static lang_input_statement_type *lookup_name PARAMS ((const char *name)); +static void load_symbols PARAMS ((lang_input_statement_type *entry, + lang_statement_list_type *)); +static void wild_file PARAMS ((lang_wild_statement_type *, const char *, + lang_input_statement_type *, + lang_output_section_statement_type *)); +static void wild PARAMS ((lang_wild_statement_type *s, + const char *section, const char *file, + const char *target, + lang_output_section_statement_type *output)); +static bfd *open_output PARAMS ((const char *name)); +static void ldlang_open_output PARAMS ((lang_statement_union_type *statement)); +static void open_input_bfds + PARAMS ((lang_statement_union_type *statement, boolean)); +static void lang_reasonable_defaults PARAMS ((void)); +static void lang_place_undefineds PARAMS ((void)); +static void map_input_to_output_sections + PARAMS ((lang_statement_union_type *s, + const char *target, + lang_output_section_statement_type *output_section_statement)); +static void print_output_section_statement + PARAMS ((lang_output_section_statement_type *output_section_statement)); +static void print_assignment + PARAMS ((lang_assignment_statement_type *assignment, + lang_output_section_statement_type *output_section)); +static void print_input_statement PARAMS ((lang_input_statement_type *statm)); +static boolean print_one_symbol PARAMS ((struct bfd_link_hash_entry *, PTR)); +static void print_input_section PARAMS ((lang_input_section_type *in)); +static void print_fill_statement PARAMS ((lang_fill_statement_type *fill)); +static void print_data_statement PARAMS ((lang_data_statement_type *data)); +static void print_address_statement PARAMS ((lang_address_statement_type *)); +static void print_reloc_statement PARAMS ((lang_reloc_statement_type *reloc)); +static void print_padding_statement PARAMS ((lang_padding_statement_type *s)); +static void print_wild_statement + PARAMS ((lang_wild_statement_type *w, + lang_output_section_statement_type *os)); +static void print_group + PARAMS ((lang_group_statement_type *, lang_output_section_statement_type *)); +static void print_statement PARAMS ((lang_statement_union_type *s, + lang_output_section_statement_type *os)); +static void print_statement_list PARAMS ((lang_statement_union_type *s, + lang_output_section_statement_type *os)); +static void print_statements PARAMS ((void)); +static bfd_vma insert_pad PARAMS ((lang_statement_union_type **this_ptr, + fill_type fill, unsigned int power, + asection *output_section_statement, + bfd_vma dot)); +static bfd_vma size_input_section + PARAMS ((lang_statement_union_type **this_ptr, + lang_output_section_statement_type *output_section_statement, + fill_type fill, bfd_vma dot, boolean relax)); +static void lang_finish PARAMS ((void)); +static void lang_check PARAMS ((void)); +static void lang_common PARAMS ((void)); +static boolean lang_one_common PARAMS ((struct bfd_link_hash_entry *, PTR)); +static void lang_place_orphans PARAMS ((void)); +static int topower PARAMS ((int)); +static void lang_set_startof PARAMS ((void)); +static void reset_memory_regions PARAMS ((void)); +static void lang_record_phdrs PARAMS ((void)); + +/* EXPORTS */ +lang_output_section_statement_type *abs_output_section; +lang_statement_list_type *stat_ptr = &statement_list; +lang_statement_list_type file_chain = { 0 }; +const char *entry_symbol = NULL; +boolean entry_from_cmdline; +boolean lang_has_input_file = false; +boolean had_output_filename = false; +boolean lang_float_flag = false; +boolean delete_output_file_on_failure = false; +struct lang_nocrossrefs *nocrossref_list; + +etree_type *base; /* Relocation base - or null */ + + +#if defined(__STDC__) || defined(ALMOST_STDC) +#define cat(a,b) a##b +#else +#define cat(a,b) a/**/b +#endif + +#define new_stat(x,y) (cat(x,_type)*) new_statement(cat(x,_enum), sizeof(cat(x,_type)),y) + +#define outside_section_address(q) ( (q)->output_offset + (q)->output_section->vma) + +#define outside_symbol_address(q) ((q)->value + outside_section_address(q->section)) + +#define SECTION_NAME_MAP_LENGTH (16) + +PTR +stat_alloc (size) + size_t size; +{ + return obstack_alloc (&stat_obstack, size); +} + +/*---------------------------------------------------------------------- + lang_for_each_statement walks the parse tree and calls the provided + function for each node +*/ + +static void +lang_for_each_statement_worker (func, s) + void (*func) PARAMS ((lang_statement_union_type *)); + lang_statement_union_type *s; +{ + for (; s != (lang_statement_union_type *) NULL; s = s->next) + { + func (s); + + switch (s->header.type) + { + case lang_constructors_statement_enum: + lang_for_each_statement_worker (func, constructor_list.head); + break; + case lang_output_section_statement_enum: + lang_for_each_statement_worker + (func, + s->output_section_statement.children.head); + break; + case lang_wild_statement_enum: + lang_for_each_statement_worker + (func, + s->wild_statement.children.head); + break; + case lang_group_statement_enum: + lang_for_each_statement_worker (func, + s->group_statement.children.head); + break; + case lang_data_statement_enum: + case lang_reloc_statement_enum: + case lang_object_symbols_statement_enum: + case lang_output_statement_enum: + case lang_target_statement_enum: + case lang_input_section_enum: + case lang_input_statement_enum: + case lang_assignment_statement_enum: + case lang_padding_statement_enum: + case lang_address_statement_enum: + case lang_fill_statement_enum: + break; + default: + FAIL (); + break; + } + } +} + +void +lang_for_each_statement (func) + void (*func) PARAMS ((lang_statement_union_type *)); +{ + lang_for_each_statement_worker (func, + statement_list.head); +} + +/*----------------------------------------------------------------------*/ +void +lang_list_init (list) + lang_statement_list_type *list; +{ + list->head = (lang_statement_union_type *) NULL; + list->tail = &list->head; +} + +/*---------------------------------------------------------------------- + + build a new statement node for the parse tree + + */ + +static +lang_statement_union_type * +new_statement (type, size, list) + enum statement_enum type; + size_t size; + lang_statement_list_type * list; +{ + lang_statement_union_type *new = (lang_statement_union_type *) + stat_alloc (size); + + new->header.type = type; + new->header.next = (lang_statement_union_type *) NULL; + lang_statement_append (list, new, &new->header.next); + return new; +} + +/* + Build a new input file node for the language. There are several ways + in which we treat an input file, eg, we only look at symbols, or + prefix it with a -l etc. + + We can be supplied with requests for input files more than once; + they may, for example be split over serveral lines like foo.o(.text) + foo.o(.data) etc, so when asked for a file we check that we havn't + got it already so we don't duplicate the bfd. + + */ +static lang_input_statement_type * +new_afile (name, file_type, target, add_to_list) + CONST char *name; + lang_input_file_enum_type file_type; + CONST char *target; + boolean add_to_list; +{ + lang_input_statement_type *p; + + if (add_to_list) + p = new_stat (lang_input_statement, stat_ptr); + else + { + p = ((lang_input_statement_type *) + stat_alloc (sizeof (lang_input_statement_type))); + p->header.next = NULL; + } + + lang_has_input_file = true; + p->target = target; + switch (file_type) + { + case lang_input_file_is_symbols_only_enum: + p->filename = name; + p->is_archive = false; + p->real = true; + p->local_sym_name = name; + p->just_syms_flag = true; + p->search_dirs_flag = false; + break; + case lang_input_file_is_fake_enum: + p->filename = name; + p->is_archive = false; + p->real = false; + p->local_sym_name = name; + p->just_syms_flag = false; + p->search_dirs_flag = false; + break; + case lang_input_file_is_l_enum: + p->is_archive = true; + p->filename = name; + p->real = true; + p->local_sym_name = concat ("-l", name, (const char *) NULL); + p->just_syms_flag = false; + p->search_dirs_flag = true; + break; + case lang_input_file_is_marker_enum: + p->filename = name; + p->is_archive = false; + p->real = false; + p->local_sym_name = name; + p->just_syms_flag = false; + p->search_dirs_flag = true; + break; + case lang_input_file_is_search_file_enum: + p->filename = name; + p->is_archive = false; + p->real = true; + p->local_sym_name = name; + p->just_syms_flag = false; + p->search_dirs_flag = true; + break; + case lang_input_file_is_file_enum: + p->filename = name; + p->is_archive = false; + p->real = true; + p->local_sym_name = name; + p->just_syms_flag = false; + p->search_dirs_flag = false; + break; + default: + FAIL (); + } + p->the_bfd = (bfd *) NULL; + p->asymbols = (asymbol **) NULL; + p->next_real_file = (lang_statement_union_type *) NULL; + p->next = (lang_statement_union_type *) NULL; + p->symbol_count = 0; + p->dynamic = config.dynamic_link; + p->whole_archive = whole_archive; + p->loaded = false; + lang_statement_append (&input_file_chain, + (lang_statement_union_type *) p, + &p->next_real_file); + return p; +} + +lang_input_statement_type * +lang_add_input_file (name, file_type, target) + CONST char *name; + lang_input_file_enum_type file_type; + CONST char *target; +{ + lang_has_input_file = true; + return new_afile (name, file_type, target, true); +} + +/* Build enough state so that the parser can build its tree */ +void +lang_init () +{ + obstack_begin (&stat_obstack, 1000); + + stat_ptr = &statement_list; + + lang_list_init (stat_ptr); + + lang_list_init (&input_file_chain); + lang_list_init (&lang_output_section_statement); + lang_list_init (&file_chain); + first_file = lang_add_input_file ((char *) NULL, + lang_input_file_is_marker_enum, + (char *) NULL); + abs_output_section = lang_output_section_statement_lookup (BFD_ABS_SECTION_NAME); + + abs_output_section->bfd_section = bfd_abs_section_ptr; + +} + +/*---------------------------------------------------------------------- + A region is an area of memory declared with the + MEMORY { name:org=exp, len=exp ... } + syntax. + + We maintain a list of all the regions here + + If no regions are specified in the script, then the default is used + which is created when looked up to be the entire data space +*/ + +static lang_memory_region_type *lang_memory_region_list; +static lang_memory_region_type **lang_memory_region_list_tail = &lang_memory_region_list; + +lang_memory_region_type * +lang_memory_region_lookup (name) + CONST char *CONST name; +{ + + lang_memory_region_type *p = lang_memory_region_list; + + for (p = lang_memory_region_list; + p != (lang_memory_region_type *) NULL; + p = p->next) + { + if (strcmp (p->name, name) == 0) + { + return p; + } + } + +#if 0 + /* This code used to always use the first region in the list as the + default region. I changed it to instead use a region + encompassing all of memory as the default region. This permits + NOLOAD sections to work reasonably without requiring a region. + People should specify what region they mean, if they really want + a region. */ + if (strcmp (name, "*default*") == 0) + { + if (lang_memory_region_list != (lang_memory_region_type *) NULL) + { + return lang_memory_region_list; + } + } +#endif + + { + lang_memory_region_type *new = + (lang_memory_region_type *) stat_alloc (sizeof (lang_memory_region_type)); + + new->name = buystring (name); + new->next = (lang_memory_region_type *) NULL; + + *lang_memory_region_list_tail = new; + lang_memory_region_list_tail = &new->next; + new->origin = 0; + new->length = ~(bfd_size_type)0; + new->current = 0; + new->had_full_message = false; + + return new; + } +} + + +lang_output_section_statement_type * +lang_output_section_find (name) + CONST char *CONST name; +{ + lang_statement_union_type *u; + lang_output_section_statement_type *lookup; + + for (u = lang_output_section_statement.head; + u != (lang_statement_union_type *) NULL; + u = lookup->next) + { + lookup = &u->output_section_statement; + if (strcmp (name, lookup->name) == 0) + { + return lookup; + } + } + return (lang_output_section_statement_type *) NULL; +} + +lang_output_section_statement_type * +lang_output_section_statement_lookup (name) + CONST char *CONST name; +{ + lang_output_section_statement_type *lookup; + + lookup = lang_output_section_find (name); + if (lookup == (lang_output_section_statement_type *) NULL) + { + + lookup = (lang_output_section_statement_type *) + new_stat (lang_output_section_statement, stat_ptr); + lookup->region = (lang_memory_region_type *) NULL; + lookup->fill = 0; + lookup->block_value = 1; + lookup->name = name; + + lookup->next = (lang_statement_union_type *) NULL; + lookup->bfd_section = (asection *) NULL; + lookup->processed = false; + lookup->sectype = normal_section; + lookup->addr_tree = (etree_type *) NULL; + lang_list_init (&lookup->children); + + lookup->memspec = (CONST char *) NULL; + lookup->flags = 0; + lookup->subsection_alignment = -1; + lookup->section_alignment = -1; + lookup->load_base = (union etree_union *) NULL; + lookup->phdrs = NULL; + + lang_statement_append (&lang_output_section_statement, + (lang_statement_union_type *) lookup, + &lookup->next); + } + return lookup; +} + +void +lang_map () +{ + lang_memory_region_type *m; + + minfo ("\nMemory Configuration\n\n"); + fprintf (config.map_file, "%-16s %-18s %-18s\n", + "Name", "Origin", "Length"); + + for (m = lang_memory_region_list; + m != (lang_memory_region_type *) NULL; + m = m->next) + { + char buf[100]; + int len; + + fprintf (config.map_file, "%-16s ", m->name); + + sprintf_vma (buf, m->origin); + minfo ("0x%s ", buf); + len = strlen (buf); + while (len < 16) + { + print_space (); + ++len; + } + + minfo ("0x%V\n", m->length); + } + + fprintf (config.map_file, "\nLinker script and memory map\n\n"); + + print_statements (); +} + +/* Initialize an output section. */ + +static void +init_os (s) + lang_output_section_statement_type *s; +{ + section_userdata_type *new; + + if (s->bfd_section != NULL) + return; + + if (strcmp (s->name, DISCARD_SECTION_NAME) == 0) + einfo ("%P%F: Illegal use of `%s' section", DISCARD_SECTION_NAME); + + new = ((section_userdata_type *) + stat_alloc (sizeof (section_userdata_type))); + + s->bfd_section = bfd_get_section_by_name (output_bfd, s->name); + if (s->bfd_section == (asection *) NULL) + s->bfd_section = bfd_make_section (output_bfd, s->name); + if (s->bfd_section == (asection *) NULL) + { + einfo ("%P%F: output format %s cannot represent section called %s\n", + output_bfd->xvec->name, s->name); + } + s->bfd_section->output_section = s->bfd_section; + + /* We initialize an output sections output offset to minus its own */ + /* vma to allow us to output a section through itself */ + s->bfd_section->output_offset = 0; + get_userdata (s->bfd_section) = (PTR) new; + + /* If there is a base address, make sure that any sections it might + mention are initialized. */ + if (s->addr_tree != NULL) + exp_init_os (s->addr_tree); +} + +/* Make sure that all output sections mentioned in an expression are + initialized. */ + +static void +exp_init_os (exp) + etree_type *exp; +{ + switch (exp->type.node_class) + { + case etree_assign: + exp_init_os (exp->assign.src); + break; + + case etree_binary: + exp_init_os (exp->binary.lhs); + exp_init_os (exp->binary.rhs); + break; + + case etree_trinary: + exp_init_os (exp->trinary.cond); + exp_init_os (exp->trinary.lhs); + exp_init_os (exp->trinary.rhs); + break; + + case etree_unary: + exp_init_os (exp->unary.child); + break; + + case etree_name: + switch (exp->type.node_code) + { + case ADDR: + case LOADADDR: + case SIZEOF: + { + lang_output_section_statement_type *os; + + os = lang_output_section_find (exp->name.name); + if (os != NULL && os->bfd_section == NULL) + init_os (os); + } + } + break; + + default: + break; + } +} + +/* Sections marked with the SEC_LINK_ONCE flag should only be linked + once into the output. This routine checks each sections, and + arranges to discard it if a section of the same name has already + been linked. This code assumes that all relevant sections have the + SEC_LINK_ONCE flag set; that is, it does not depend solely upon the + section name. This is called via bfd_map_over_sections. */ + +/*ARGSUSED*/ +static void +section_already_linked (abfd, sec, data) + bfd *abfd; + asection *sec; + PTR data; +{ + lang_input_statement_type *entry = (lang_input_statement_type *) data; + struct sec_link_once + { + struct sec_link_once *next; + asection *sec; + }; + static struct sec_link_once *sec_link_once_list; + flagword flags; + const char *name; + struct sec_link_once *l; + + /* If we are only reading symbols from this object, then we want to + discard all sections. */ + if (entry->just_syms_flag) + { + sec->output_section = bfd_abs_section_ptr; + sec->output_offset = sec->vma; + return; + } + + flags = bfd_get_section_flags (abfd, sec); + + if ((flags & SEC_LINK_ONCE) == 0) + return; + + name = bfd_get_section_name (abfd, sec); + + for (l = sec_link_once_list; l != NULL; l = l->next) + { + if (strcmp (name, bfd_get_section_name (l->sec->owner, l->sec)) == 0) + { + /* The section has already been linked. See if we should + issue a warning. */ + switch (flags & SEC_LINK_DUPLICATES) + { + default: + abort (); + + case SEC_LINK_DUPLICATES_DISCARD: + break; + + case SEC_LINK_DUPLICATES_ONE_ONLY: + einfo ("%P: %B: warning: ignoring duplicate section `%s'\n", + abfd, name); + break; + + case SEC_LINK_DUPLICATES_SAME_CONTENTS: + /* FIXME: We should really dig out the contents of both + sections and memcmp them. The COFF/PE spec says that + the Microsoft linker does not implement this + correctly, so I'm not going to bother doing it + either. */ + /* Fall through. */ + case SEC_LINK_DUPLICATES_SAME_SIZE: + if (bfd_section_size (abfd, sec) + != bfd_section_size (l->sec->owner, l->sec)) + einfo ("%P: %B: warning: duplicate section `%s' has different size\n", + abfd, name); + break; + } + + /* Set the output_section field so that wild_doit does not + create a lang_input_section structure for this section. */ + sec->output_section = bfd_abs_section_ptr; + + return; + } + } + + /* This is the first section with this name. Record it. */ + + l = (struct sec_link_once *) xmalloc (sizeof *l); + l->sec = sec; + l->next = sec_link_once_list; + sec_link_once_list = l; +} + +/* The wild routines. + + These expand statements like *(.text) and foo.o to a list of + explicit actions, like foo.o(.text), bar.o(.text) and + foo.o(.text, .data). */ + +/* Return true if the PATTERN argument is a wildcard pattern. */ + +static boolean +wildcardp (pattern) + const char *pattern; +{ + const char *s; + + for (s = pattern; *s != '\0'; ++s) + if (*s == '?' + || *s == '\\' + || *s == '*' + || *s == '[') + return true; + return false; +} + +/* Add SECTION to the output section OUTPUT. Do this by creating a + lang_input_section statement which is placed at PTR. FILE is the + input file which holds SECTION. */ + +void +wild_doit (ptr, section, output, file) + lang_statement_list_type *ptr; + asection *section; + lang_output_section_statement_type *output; + lang_input_statement_type *file; +{ + flagword flags; + boolean discard; + + flags = bfd_get_section_flags (section->owner, section); + + discard = false; + + /* If we are doing a final link, discard sections marked with + SEC_EXCLUDE. */ + if (! link_info.relocateable + && (flags & SEC_EXCLUDE) != 0) + discard = true; + + /* Discard input sections which are assigned to a section named + DISCARD_SECTION_NAME. */ + if (strcmp (output->name, DISCARD_SECTION_NAME) == 0) + discard = true; + + /* Discard debugging sections if we are stripping debugging + information. */ + if ((link_info.strip == strip_debugger || link_info.strip == strip_all) + && (flags & SEC_DEBUGGING) != 0) + discard = true; + + if (discard) + { + if (section->output_section == NULL) + { + /* This prevents future calls from assigning this section. */ + section->output_section = bfd_abs_section_ptr; + } + return; + } + + if (section->output_section == NULL) + { + lang_input_section_type *new; + + if (output->bfd_section == NULL) + init_os (output); + + /* Add a section reference to the list */ + new = new_stat (lang_input_section, ptr); + + new->section = section; + new->ifile = file; + section->output_section = output->bfd_section; + + /* We don't copy the SEC_NEVER_LOAD flag from an input section + to an output section, because we want to be able to include a + SEC_NEVER_LOAD section in the middle of an otherwise loaded + section (I don't know why we want to do this, but we do). + build_link_order in ldwrite.c handles this case by turning + the embedded SEC_NEVER_LOAD section into a fill. + + If final link, don't copy the SEC_LINK_ONCE flags, they've already + been processed. One reason to do this is that on pe format targets, + .text$foo sections go into .text and it's odd to see .text with + SEC_LINK_ONCE set. */ + + section->output_section->flags |= + section->flags & (flagword) (~ (SEC_NEVER_LOAD + | (! link_info.relocateable + ? SEC_LINK_ONCE | SEC_LINK_DUPLICATES + : 0))); + + switch (output->sectype) + { + case normal_section: + break; + case dsect_section: + case copy_section: + case info_section: + case overlay_section: + output->bfd_section->flags &= ~SEC_ALLOC; + break; + case noload_section: + output->bfd_section->flags &= ~SEC_LOAD; + output->bfd_section->flags |= SEC_NEVER_LOAD; + break; + } + + if (section->alignment_power > output->bfd_section->alignment_power) + output->bfd_section->alignment_power = section->alignment_power; + + /* If supplied an aligment, then force it. */ + if (output->section_alignment != -1) + output->bfd_section->alignment_power = output->section_alignment; + } +} + +/* Expand a wild statement for a particular FILE. SECTION may be + NULL, in which case it is a wild card. */ + +static void +wild_section (ptr, section, file, output) + lang_wild_statement_type *ptr; + const char *section; + lang_input_statement_type *file; + lang_output_section_statement_type *output; +{ + if (file->just_syms_flag == false) + { + register asection *s; + boolean wildcard; + + if (section == NULL) + wildcard = false; + else + wildcard = wildcardp (section); + + for (s = file->the_bfd->sections; s != NULL; s = s->next) + { + boolean match; + + /* Attach all sections named SECTION. If SECTION is NULL, + then attach all sections. + + Previously, if SECTION was NULL, this code did not call + wild_doit if the SEC_IS_COMMON flag was set for the + section. I did not understand that, and I took it out. + --ian@cygnus.com. */ + + if (section == NULL) + match = true; + else + { + const char *name; + + name = bfd_get_section_name (file->the_bfd, s); + if (wildcard) + match = fnmatch (section, name, 0) == 0 ? true : false; + else + match = strcmp (section, name) == 0 ? true : false; + } + if (match) + wild_doit (&ptr->children, s, output, file); + } + } +} + +/* This is passed a file name which must have been seen already and + added to the statement tree. We will see if it has been opened + already and had its symbols read. If not then we'll read it. */ + +static lang_input_statement_type * +lookup_name (name) + const char *name; +{ + lang_input_statement_type *search; + + for (search = (lang_input_statement_type *) input_file_chain.head; + search != (lang_input_statement_type *) NULL; + search = (lang_input_statement_type *) search->next_real_file) + { + if (search->filename == (char *) NULL && name == (char *) NULL) + return search; + if (search->filename != (char *) NULL + && name != (char *) NULL + && strcmp (search->filename, name) == 0) + break; + } + + if (search == (lang_input_statement_type *) NULL) + search = new_afile (name, lang_input_file_is_file_enum, default_target, + false); + + /* If we have already added this file, or this file is not real + (FIXME: can that ever actually happen?) or the name is NULL + (FIXME: can that ever actually happen?) don't add this file. */ + if (search->loaded + || ! search->real + || search->filename == (const char *) NULL) + return search; + + load_symbols (search, (lang_statement_list_type *) NULL); + + return search; +} + +/* Get the symbols for an input file. */ + +static void +load_symbols (entry, place) + lang_input_statement_type *entry; + lang_statement_list_type *place; +{ + char **matching; + + if (entry->loaded) + return; + + ldfile_open_file (entry); + + if (! bfd_check_format (entry->the_bfd, bfd_archive) + && ! bfd_check_format_matches (entry->the_bfd, bfd_object, &matching)) + { + bfd_error_type err; + lang_statement_list_type *hold; + + err = bfd_get_error (); + if (err == bfd_error_file_ambiguously_recognized) + { + char **p; + + einfo ("%B: file not recognized: %E\n", entry->the_bfd); + einfo ("%B: matching formats:", entry->the_bfd); + for (p = matching; *p != NULL; p++) + einfo (" %s", *p); + einfo ("%F\n"); + } + else if (err != bfd_error_file_not_recognized + || place == NULL) + einfo ("%F%B: file not recognized: %E\n", entry->the_bfd); + + bfd_close (entry->the_bfd); + entry->the_bfd = NULL; + + /* See if the emulation has some special knowledge. */ + + if (ldemul_unrecognized_file (entry)) + return; + + /* Try to interpret the file as a linker script. */ + + ldfile_open_command_file (entry->filename); + + hold = stat_ptr; + stat_ptr = place; + + ldfile_assumed_script = true; + parser_input = input_script; + yyparse (); + ldfile_assumed_script = false; + + stat_ptr = hold; + + return; + } + + /* We don't call ldlang_add_file for an archive. Instead, the + add_symbols entry point will call ldlang_add_file, via the + add_archive_element callback, for each element of the archive + which is used. */ + switch (bfd_get_format (entry->the_bfd)) + { + default: + break; + + case bfd_object: + ldlang_add_file (entry); + if (trace_files || trace_file_tries) + info_msg ("%I\n", entry); + break; + + case bfd_archive: + if (entry->whole_archive) + { + bfd *member = bfd_openr_next_archived_file (entry->the_bfd, + (bfd *) NULL); + while (member != NULL) + { + if (! bfd_check_format (member, bfd_object)) + einfo ("%F%B: object %B in archive is not object\n", + entry->the_bfd, member); + if (! ((*link_info.callbacks->add_archive_element) + (&link_info, member, "--whole-archive"))) + abort (); + if (! bfd_link_add_symbols (member, &link_info)) + einfo ("%F%B: could not read symbols: %E\n", member); + member = bfd_openr_next_archived_file (entry->the_bfd, + member); + } + + entry->loaded = true; + + return; + } + } + + if (! bfd_link_add_symbols (entry->the_bfd, &link_info)) + einfo ("%F%B: could not read symbols: %E\n", entry->the_bfd); + + entry->loaded = true; +} + +/* Handle a wild statement for a single file F. */ + +static void +wild_file (s, section, f, output) + lang_wild_statement_type *s; + const char *section; + lang_input_statement_type *f; + lang_output_section_statement_type *output; +{ + if (f->the_bfd == NULL + || ! bfd_check_format (f->the_bfd, bfd_archive)) + wild_section (s, section, f, output); + else + { + bfd *member; + + /* This is an archive file. We must map each member of the + archive separately. */ + member = bfd_openr_next_archived_file (f->the_bfd, (bfd *) NULL); + while (member != NULL) + { + /* When lookup_name is called, it will call the add_symbols + entry point for the archive. For each element of the + archive which is included, BFD will call ldlang_add_file, + which will set the usrdata field of the member to the + lang_input_statement. */ + if (member->usrdata != NULL) + { + wild_section (s, section, + (lang_input_statement_type *) member->usrdata, + output); + } + + member = bfd_openr_next_archived_file (f->the_bfd, member); + } + } +} + +/* Handle a wild statement. SECTION or FILE or both may be NULL, + indicating that it is a wildcard. Separate lang_input_section + statements are created for each part of the expansion; they are + added after the wild statement S. OUTPUT is the output section. */ + +static void +wild (s, section, file, target, output) + lang_wild_statement_type *s; + const char *section; + const char *file; + const char *target; + lang_output_section_statement_type *output; +{ + lang_input_statement_type *f; + + if (file == (char *) NULL) + { + /* Perform the iteration over all files in the list */ + for (f = (lang_input_statement_type *) file_chain.head; + f != (lang_input_statement_type *) NULL; + f = (lang_input_statement_type *) f->next) + { + wild_file (s, section, f, output); + } + } + else if (wildcardp (file)) + { + for (f = (lang_input_statement_type *) file_chain.head; + f != (lang_input_statement_type *) NULL; + f = (lang_input_statement_type *) f->next) + { + if (fnmatch (file, f->filename, FNM_FILE_NAME) == 0) + wild_file (s, section, f, output); + } + } + else + { + /* Perform the iteration over a single file */ + f = lookup_name (file); + wild_file (s, section, f, output); + } + + if (section != (char *) NULL + && strcmp (section, "COMMON") == 0 + && default_common_section == NULL) + { + /* Remember the section that common is going to in case we later + get something which doesn't know where to put it. */ + default_common_section = output; + } +} + +/* Open the output file. */ + +static bfd * +open_output (name) + const char *name; +{ + bfd *output; + + if (output_target == (char *) NULL) + { + if (current_target != (char *) NULL) + output_target = current_target; + else + output_target = default_target; + } + output = bfd_openw (name, output_target); + + if (output == (bfd *) NULL) + { + if (bfd_get_error () == bfd_error_invalid_target) + { + einfo ("%P%F: target %s not found\n", output_target); + } + einfo ("%P%F: cannot open output file %s: %E\n", name); + } + + delete_output_file_on_failure = true; + + /* output->flags |= D_PAGED;*/ + + if (! bfd_set_format (output, bfd_object)) + einfo ("%P%F:%s: can not make object file: %E\n", name); + if (! bfd_set_arch_mach (output, + ldfile_output_architecture, + ldfile_output_machine)) + einfo ("%P%F:%s: can not set architecture: %E\n", name); + + link_info.hash = bfd_link_hash_table_create (output); + if (link_info.hash == (struct bfd_link_hash_table *) NULL) + einfo ("%P%F: can not create link hash table: %E\n"); + + bfd_set_gp_size (output, g_switch_value); + return output; +} + + + + +static void +ldlang_open_output (statement) + lang_statement_union_type * statement; +{ + switch (statement->header.type) + { + case lang_output_statement_enum: + ASSERT (output_bfd == (bfd *) NULL); + output_bfd = open_output (statement->output_statement.name); + ldemul_set_output_arch (); + if (config.magic_demand_paged && !link_info.relocateable) + output_bfd->flags |= D_PAGED; + else + output_bfd->flags &= ~D_PAGED; + if (config.text_read_only) + output_bfd->flags |= WP_TEXT; + else + output_bfd->flags &= ~WP_TEXT; + if (link_info.traditional_format) + output_bfd->flags |= BFD_TRADITIONAL_FORMAT; + else + output_bfd->flags &= ~BFD_TRADITIONAL_FORMAT; + break; + + case lang_target_statement_enum: + current_target = statement->target_statement.target; + break; + default: + break; + } +} + +/* Open all the input files. */ + +static void +open_input_bfds (s, force) + lang_statement_union_type *s; + boolean force; +{ + for (; s != (lang_statement_union_type *) NULL; s = s->next) + { + switch (s->header.type) + { + case lang_constructors_statement_enum: + open_input_bfds (constructor_list.head, force); + break; + case lang_output_section_statement_enum: + open_input_bfds (s->output_section_statement.children.head, force); + break; + case lang_wild_statement_enum: + /* Maybe we should load the file's symbols */ + if (s->wild_statement.filename + && ! wildcardp (s->wild_statement.filename)) + (void) lookup_name (s->wild_statement.filename); + open_input_bfds (s->wild_statement.children.head, force); + break; + case lang_group_statement_enum: + { + struct bfd_link_hash_entry *undefs; + + /* We must continually search the entries in the group + until no new symbols are added to the list of undefined + symbols. */ + + do + { + undefs = link_info.hash->undefs_tail; + open_input_bfds (s->group_statement.children.head, true); + } + while (undefs != link_info.hash->undefs_tail); + } + break; + case lang_target_statement_enum: + current_target = s->target_statement.target; + break; + case lang_input_statement_enum: + if (s->input_statement.real == true) + { + lang_statement_list_type add; + + s->input_statement.target = current_target; + + /* If we are being called from within a group, and this + is an archive which has already been searched, then + force it to be researched. */ + if (force + && s->input_statement.loaded + && bfd_check_format (s->input_statement.the_bfd, + bfd_archive)) + s->input_statement.loaded = false; + + lang_list_init (&add); + + load_symbols (&s->input_statement, &add); + + if (add.head != NULL) + { + *add.tail = s->next; + s->next = add.head; + } + } + break; + default: + break; + } + } +} + +/* If there are [COMMONS] statements, put a wild one into the bss section */ + +static void +lang_reasonable_defaults () +{ +#if 0 + lang_output_section_statement_lookup (".text"); + lang_output_section_statement_lookup (".data"); + + default_common_section = + lang_output_section_statement_lookup (".bss"); + + + if (placed_commons == false) + { + lang_wild_statement_type *new = + new_stat (lang_wild_statement, + &default_common_section->children); + + new->section_name = "COMMON"; + new->filename = (char *) NULL; + lang_list_init (&new->children); + } +#endif + +} + +/* + Add the supplied name to the symbol table as an undefined reference. + Remove items from the chain as we open input bfds + */ +typedef struct ldlang_undef_chain_list +{ + struct ldlang_undef_chain_list *next; + char *name; +} ldlang_undef_chain_list_type; + +static ldlang_undef_chain_list_type *ldlang_undef_chain_list_head; + +void +ldlang_add_undef (name) + CONST char *CONST name; +{ + ldlang_undef_chain_list_type *new = + ((ldlang_undef_chain_list_type *) + stat_alloc (sizeof (ldlang_undef_chain_list_type))); + + new->next = ldlang_undef_chain_list_head; + ldlang_undef_chain_list_head = new; + + new->name = buystring (name); +} + +/* Run through the list of undefineds created above and place them + into the linker hash table as undefined symbols belonging to the + script file. +*/ +static void +lang_place_undefineds () +{ + ldlang_undef_chain_list_type *ptr; + + for (ptr = ldlang_undef_chain_list_head; + ptr != (ldlang_undef_chain_list_type *) NULL; + ptr = ptr->next) + { + struct bfd_link_hash_entry *h; + + h = bfd_link_hash_lookup (link_info.hash, ptr->name, true, false, true); + if (h == (struct bfd_link_hash_entry *) NULL) + einfo ("%P%F: bfd_link_hash_lookup failed: %E"); + if (h->type == bfd_link_hash_new) + { + h->type = bfd_link_hash_undefined; + h->u.undef.abfd = NULL; + bfd_link_add_undef (link_info.hash, h); + } + } +} + +/* Open input files and attatch to output sections */ +static void +map_input_to_output_sections (s, target, output_section_statement) + lang_statement_union_type * s; + CONST char *target; + lang_output_section_statement_type * output_section_statement; +{ + for (; s != (lang_statement_union_type *) NULL; s = s->next) + { + switch (s->header.type) + { + + + case lang_wild_statement_enum: + wild (&s->wild_statement, s->wild_statement.section_name, + s->wild_statement.filename, target, + output_section_statement); + + break; + case lang_constructors_statement_enum: + map_input_to_output_sections (constructor_list.head, + target, + output_section_statement); + break; + case lang_output_section_statement_enum: + map_input_to_output_sections (s->output_section_statement.children.head, + target, + &s->output_section_statement); + break; + case lang_output_statement_enum: + break; + case lang_target_statement_enum: + target = s->target_statement.target; + break; + case lang_group_statement_enum: + map_input_to_output_sections (s->group_statement.children.head, + target, + output_section_statement); + break; + case lang_fill_statement_enum: + case lang_input_section_enum: + case lang_object_symbols_statement_enum: + case lang_data_statement_enum: + case lang_reloc_statement_enum: + case lang_padding_statement_enum: + case lang_input_statement_enum: + if (output_section_statement != NULL + && output_section_statement->bfd_section == NULL) + init_os (output_section_statement); + break; + case lang_assignment_statement_enum: + if (output_section_statement != NULL + && output_section_statement->bfd_section == NULL) + init_os (output_section_statement); + + /* Make sure that any sections mentioned in the assignment + are initialized. */ + exp_init_os (s->assignment_statement.exp); + break; + case lang_afile_asection_pair_statement_enum: + FAIL (); + break; + case lang_address_statement_enum: + /* Mark the specified section with the supplied address */ + { + lang_output_section_statement_type *os = + lang_output_section_statement_lookup + (s->address_statement.section_name); + + if (os->bfd_section == NULL) + init_os (os); + os->addr_tree = s->address_statement.address; + } + break; + } + } +} + +static void +print_output_section_statement (output_section_statement) + lang_output_section_statement_type * output_section_statement; +{ + asection *section = output_section_statement->bfd_section; + int len; + + if (output_section_statement != abs_output_section) + { + minfo ("\n%s", output_section_statement->name); + + if (section != NULL) + { + print_dot = section->vma; + + len = strlen (output_section_statement->name); + if (len >= SECTION_NAME_MAP_LENGTH - 1) + { + print_nl (); + len = 0; + } + while (len < SECTION_NAME_MAP_LENGTH) + { + print_space (); + ++len; + } + + minfo ("0x%V %W", section->vma, section->_raw_size); + + if (output_section_statement->load_base != NULL) + { + bfd_vma addr; + + addr = exp_get_abs_int (output_section_statement->load_base, 0, + "load base", lang_final_phase_enum); + minfo (" load address 0x%V", addr); + } + } + + print_nl (); + } + + print_statement_list (output_section_statement->children.head, + output_section_statement); +} + +static void +print_assignment (assignment, output_section) + lang_assignment_statement_type * assignment; + lang_output_section_statement_type * output_section; +{ + int i; + etree_value_type result; + + for (i = 0; i < SECTION_NAME_MAP_LENGTH; i++) + print_space (); + + result = exp_fold_tree (assignment->exp->assign.src, output_section, + lang_final_phase_enum, print_dot, &print_dot); + if (result.valid) + minfo ("0x%V", result.value + result.section->bfd_section->vma); + else + { + minfo ("*undef* "); +#ifdef BFD64 + minfo (" "); +#endif + } + + minfo (" "); + + exp_print_tree (assignment->exp); + + print_nl (); +} + +static void +print_input_statement (statm) + lang_input_statement_type * statm; +{ + if (statm->filename != (char *) NULL) + { + fprintf (config.map_file, "LOAD %s\n", statm->filename); + } +} + +/* Print all symbols defined in a particular section. This is called + via bfd_link_hash_traverse. */ + +static boolean +print_one_symbol (hash_entry, ptr) + struct bfd_link_hash_entry *hash_entry; + PTR ptr; +{ + asection *sec = (asection *) ptr; + + if ((hash_entry->type == bfd_link_hash_defined + || hash_entry->type == bfd_link_hash_defweak) + && sec == hash_entry->u.def.section) + { + int i; + + for (i = 0; i < SECTION_NAME_MAP_LENGTH; i++) + print_space (); + minfo ("0x%V ", + (hash_entry->u.def.value + + hash_entry->u.def.section->output_offset + + hash_entry->u.def.section->output_section->vma)); + + minfo (" %T\n", hash_entry->root.string); + } + + return true; +} + +/* Print information about an input section to the map file. */ + +static void +print_input_section (in) + lang_input_section_type * in; +{ + asection *i = in->section; + bfd_size_type size = i->_cooked_size != 0 ? i->_cooked_size : i->_raw_size; + + if (size != 0) + { + print_space (); + + minfo ("%s", i->name); + + if (i->output_section != NULL) + { + int len; + + len = 1 + strlen (i->name); + if (len >= SECTION_NAME_MAP_LENGTH - 1) + { + print_nl (); + len = 0; + } + while (len < SECTION_NAME_MAP_LENGTH) + { + print_space (); + ++len; + } + + minfo ("0x%V %W %B\n", + i->output_section->vma + i->output_offset, size, + i->owner); + + if (i->_cooked_size != 0 && i->_cooked_size != i->_raw_size) + { + len = SECTION_NAME_MAP_LENGTH + 3; +#ifdef BFD64 + len += 16; +#else + len += 8; +#endif + while (len > 0) + { + print_space (); + --len; + } + + minfo ("%W (size before relaxing)\n", i->_raw_size); + } + + bfd_link_hash_traverse (link_info.hash, print_one_symbol, (PTR) i); + + print_dot = i->output_section->vma + i->output_offset + size; + } + } +} + +static void +print_fill_statement (fill) + lang_fill_statement_type * fill; +{ + fprintf (config.map_file, " FILL mask 0x%x\n", fill->fill); +} + +static void +print_data_statement (data) + lang_data_statement_type * data; +{ + int i; + bfd_vma addr; + bfd_size_type size; + const char *name; + + for (i = 0; i < SECTION_NAME_MAP_LENGTH; i++) + print_space (); + + addr = data->output_vma; + if (data->output_section != NULL) + addr += data->output_section->vma; + + switch (data->type) + { + default: + abort (); + case BYTE: + size = BYTE_SIZE; + name = "BYTE"; + break; + case SHORT: + size = SHORT_SIZE; + name = "SHORT"; + break; + case LONG: + size = LONG_SIZE; + name = "LONG"; + break; + case QUAD: + size = QUAD_SIZE; + name = "QUAD"; + break; + } + + minfo ("0x%V %W %s 0x%v", addr, size, name, data->value); + + if (data->exp->type.node_class != etree_value) + { + print_space (); + exp_print_tree (data->exp); + } + + print_nl (); + + print_dot = addr + size; +} + +/* Print an address statement. These are generated by options like + -Ttext. */ + +static void +print_address_statement (address) + lang_address_statement_type *address; +{ + minfo ("Address of section %s set to ", address->section_name); + exp_print_tree (address->address); + print_nl (); +} + +/* Print a reloc statement. */ + +static void +print_reloc_statement (reloc) + lang_reloc_statement_type *reloc; +{ + int i; + bfd_vma addr; + bfd_size_type size; + + for (i = 0; i < SECTION_NAME_MAP_LENGTH; i++) + print_space (); + + addr = reloc->output_vma; + if (reloc->output_section != NULL) + addr += reloc->output_section->vma; + + size = bfd_get_reloc_size (reloc->howto); + + minfo ("0x%V %W RELOC %s ", addr, size, reloc->howto->name); + + if (reloc->name != NULL) + minfo ("%s+", reloc->name); + else + minfo ("%s+", reloc->section->name); + + exp_print_tree (reloc->addend_exp); + + print_nl (); + + print_dot = addr + size; +} + +static void +print_padding_statement (s) + lang_padding_statement_type *s; +{ + int len; + bfd_vma addr; + + minfo (" *fill*"); + + len = sizeof " *fill*" - 1; + while (len < SECTION_NAME_MAP_LENGTH) + { + print_space (); + ++len; + } + + addr = s->output_offset; + if (s->output_section != NULL) + addr += s->output_section->vma; + minfo ("0x%V %W", addr, s->size); + + if (s->fill != 0) + minfo (" %u", s->fill); + + print_nl (); + + print_dot = addr + s->size; +} + +static void +print_wild_statement (w, os) + lang_wild_statement_type * w; + lang_output_section_statement_type * os; +{ + print_space (); + + if (w->filename != NULL) + minfo ("%s", w->filename); + else + minfo ("*"); + + if (w->section_name != NULL) + minfo ("(%s)", w->section_name); + else + minfo ("(*)"); + + print_nl (); + + print_statement_list (w->children.head, os); +} + +/* Print a group statement. */ + +static void +print_group (s, os) + lang_group_statement_type *s; + lang_output_section_statement_type *os; +{ + fprintf (config.map_file, "START GROUP\n"); + print_statement_list (s->children.head, os); + fprintf (config.map_file, "END GROUP\n"); +} + +/* Print the list of statements in S. + This can be called for any statement type. */ + +static void +print_statement_list (s, os) + lang_statement_union_type *s; + lang_output_section_statement_type *os; +{ + while (s != NULL) + { + print_statement (s, os); + s = s->next; + } +} + +/* Print the first statement in statement list S. + This can be called for any statement type. */ + +static void +print_statement (s, os) + lang_statement_union_type *s; + lang_output_section_statement_type *os; +{ + switch (s->header.type) + { + default: + fprintf (config.map_file, "Fail with %d\n", s->header.type); + FAIL (); + break; + case lang_constructors_statement_enum: + if (constructor_list.head != NULL) + { + minfo (" CONSTRUCTORS\n"); + print_statement_list (constructor_list.head, os); + } + break; + case lang_wild_statement_enum: + print_wild_statement (&s->wild_statement, os); + break; + case lang_address_statement_enum: + print_address_statement (&s->address_statement); + break; + case lang_object_symbols_statement_enum: + minfo (" CREATE_OBJECT_SYMBOLS\n"); + break; + case lang_fill_statement_enum: + print_fill_statement (&s->fill_statement); + break; + case lang_data_statement_enum: + print_data_statement (&s->data_statement); + break; + case lang_reloc_statement_enum: + print_reloc_statement (&s->reloc_statement); + break; + case lang_input_section_enum: + print_input_section (&s->input_section); + break; + case lang_padding_statement_enum: + print_padding_statement (&s->padding_statement); + break; + case lang_output_section_statement_enum: + print_output_section_statement (&s->output_section_statement); + break; + case lang_assignment_statement_enum: + print_assignment (&s->assignment_statement, os); + break; + case lang_target_statement_enum: + fprintf (config.map_file, "TARGET(%s)\n", s->target_statement.target); + break; + case lang_output_statement_enum: + minfo ("OUTPUT(%s", s->output_statement.name); + if (output_target != NULL) + minfo (" %s", output_target); + minfo (")\n"); + break; + case lang_input_statement_enum: + print_input_statement (&s->input_statement); + break; + case lang_group_statement_enum: + print_group (&s->group_statement, os); + break; + case lang_afile_asection_pair_statement_enum: + FAIL (); + break; + } +} + +static void +print_statements () +{ + print_statement_list (statement_list.head, abs_output_section); +} + +/* Print the first N statements in statement list S to STDERR. + If N == 0, nothing is printed. + If N < 0, the entire list is printed. + Intended to be called from GDB. */ + +void +dprint_statement (s, n) + lang_statement_union_type * s; + int n; +{ + FILE *map_save = config.map_file; + + config.map_file = stderr; + + if (n < 0) + print_statement_list (s, abs_output_section); + else + { + while (s && --n >= 0) + { + print_statement (s, abs_output_section); + s = s->next; + } + } + + config.map_file = map_save; +} + +static bfd_vma +insert_pad (this_ptr, fill, power, output_section_statement, dot) + lang_statement_union_type ** this_ptr; + fill_type fill; + unsigned int power; + asection * output_section_statement; + bfd_vma dot; +{ + /* Align this section first to the + input sections requirement, then + to the output section's requirement. + If this alignment is > than any seen before, + then record it too. Perform the alignment by + inserting a magic 'padding' statement. + */ + + unsigned int alignment_needed = align_power (dot, power) - dot; + + if (alignment_needed != 0) + { + lang_statement_union_type *new = + ((lang_statement_union_type *) + stat_alloc (sizeof (lang_padding_statement_type))); + + /* Link into existing chain */ + new->header.next = *this_ptr; + *this_ptr = new; + new->header.type = lang_padding_statement_enum; + new->padding_statement.output_section = output_section_statement; + new->padding_statement.output_offset = + dot - output_section_statement->vma; + new->padding_statement.fill = fill; + new->padding_statement.size = alignment_needed; + } + + + /* Remember the most restrictive alignment */ + if (power > output_section_statement->alignment_power) + { + output_section_statement->alignment_power = power; + } + output_section_statement->_raw_size += alignment_needed; + return alignment_needed + dot; + +} + +/* Work out how much this section will move the dot point */ +static bfd_vma +size_input_section (this_ptr, output_section_statement, fill, dot, relax) + lang_statement_union_type ** this_ptr; + lang_output_section_statement_type * output_section_statement; + fill_type fill; + bfd_vma dot; + boolean relax; +{ + lang_input_section_type *is = &((*this_ptr)->input_section); + asection *i = is->section; + + if (is->ifile->just_syms_flag == false) + { + if (output_section_statement->subsection_alignment != -1) + i->alignment_power = + output_section_statement->subsection_alignment; + + dot = insert_pad (this_ptr, fill, i->alignment_power, + output_section_statement->bfd_section, dot); + + /* Remember where in the output section this input section goes */ + + i->output_offset = dot - output_section_statement->bfd_section->vma; + + /* Mark how big the output section must be to contain this now + */ + if (i->_cooked_size != 0) + dot += i->_cooked_size; + else + dot += i->_raw_size; + output_section_statement->bfd_section->_raw_size = dot - output_section_statement->bfd_section->vma; + } + else + { + i->output_offset = i->vma - output_section_statement->bfd_section->vma; + } + + return dot; +} + +/* This variable indicates whether bfd_relax_section should be called + again. */ + +static boolean relax_again; + +/* Set the sizes for all the output sections. */ + +bfd_vma +lang_size_sections (s, output_section_statement, prev, fill, dot, relax) + lang_statement_union_type * s; + lang_output_section_statement_type * output_section_statement; + lang_statement_union_type ** prev; + fill_type fill; + bfd_vma dot; + boolean relax; +{ + /* Size up the sections from their constituent parts */ + for (; s != (lang_statement_union_type *) NULL; s = s->next) + { + switch (s->header.type) + { + + case lang_output_section_statement_enum: + { + bfd_vma after; + lang_output_section_statement_type *os = &s->output_section_statement; + + if (os->bfd_section == NULL) + { + /* This section was never actually created. */ + break; + } + + /* If this is a COFF shared library section, use the size and + address from the input section. FIXME: This is COFF + specific; it would be cleaner if there were some other way + to do this, but nothing simple comes to mind. */ + if ((os->bfd_section->flags & SEC_COFF_SHARED_LIBRARY) != 0) + { + asection *input; + + if (os->children.head == NULL + || os->children.head->next != NULL + || os->children.head->header.type != lang_input_section_enum) + einfo ("%P%X: Internal error on COFF shared library section %s", + os->name); + + input = os->children.head->input_section.section; + bfd_set_section_vma (os->bfd_section->owner, + os->bfd_section, + bfd_section_vma (input->owner, input)); + os->bfd_section->_raw_size = input->_raw_size; + break; + } + + if (bfd_is_abs_section (os->bfd_section)) + { + /* No matter what happens, an abs section starts at zero */ + ASSERT (os->bfd_section->vma == 0); + } + else + { + if (os->addr_tree == (etree_type *) NULL) + { + /* No address specified for this section, get one + from the region specification + */ + if (os->region == (lang_memory_region_type *) NULL) + { + os->region = lang_memory_region_lookup ("*default*"); + } + dot = os->region->current; + if (os->section_alignment == -1) + { + bfd_vma olddot; + + olddot = dot; + dot = align_power (dot, os->bfd_section->alignment_power); + if (dot != olddot && config.warn_section_align) + einfo ("%P: warning: changing start of section %s by %u bytes\n", + os->name, (unsigned int) (dot - olddot)); + } + } + else + { + etree_value_type r; + + r = exp_fold_tree (os->addr_tree, + abs_output_section, + lang_allocating_phase_enum, + dot, &dot); + if (r.valid == false) + { + einfo ("%F%S: non constant address expression for section %s\n", + os->name); + } + dot = r.value + r.section->bfd_section->vma; + } + /* The section starts here */ + /* First, align to what the section needs */ + + if (os->section_alignment != -1) + dot = align_power (dot, os->section_alignment); + + bfd_set_section_vma (0, os->bfd_section, dot); + + os->bfd_section->output_offset = 0; + } + + (void) lang_size_sections (os->children.head, os, &os->children.head, + os->fill, dot, relax); + /* Ignore the size of the input sections, use the vma and size to */ + /* align against */ + + after = ALIGN_N (os->bfd_section->vma + + os->bfd_section->_raw_size, + /* The coercion here is important, see ld.h. */ + (bfd_vma) os->block_value); + + if (bfd_is_abs_section (os->bfd_section)) + ASSERT (after == os->bfd_section->vma); + else + os->bfd_section->_raw_size = after - os->bfd_section->vma; + dot = os->bfd_section->vma + os->bfd_section->_raw_size; + os->processed = true; + + /* Replace into region ? */ + if (os->region != (lang_memory_region_type *) NULL) + { + os->region->current = dot; + /* Make sure this isn't silly. */ + if (os->region->current < os->region->origin + || (os->region->current - os->region->origin + > os->region->length)) + { + if (os->addr_tree != (etree_type *) NULL) + { + einfo ("%X%P: address 0x%v of %B section %s is not within region %s\n", + os->region->current, + os->bfd_section->owner, + os->bfd_section->name, + os->region->name); + } + else + { + einfo ("%X%P: region %s is full (%B section %s)\n", + os->region->name, + os->bfd_section->owner, + os->bfd_section->name); + } + /* Reset the region pointer. */ + os->region->current = os->region->origin; + } + } + } + break; + + case lang_constructors_statement_enum: + dot = lang_size_sections (constructor_list.head, + output_section_statement, + &s->wild_statement.children.head, + fill, + dot, relax); + break; + + case lang_data_statement_enum: + { + unsigned int size = 0; + + s->data_statement.output_vma = dot - output_section_statement->bfd_section->vma; + s->data_statement.output_section = + output_section_statement->bfd_section; + + switch (s->data_statement.type) + { + case QUAD: + size = QUAD_SIZE; + break; + case LONG: + size = LONG_SIZE; + break; + case SHORT: + size = SHORT_SIZE; + break; + case BYTE: + size = BYTE_SIZE; + break; + + } + dot += size; + output_section_statement->bfd_section->_raw_size += size; + /* The output section gets contents, and then we inspect for + any flags set in the input script which override any ALLOC */ + output_section_statement->bfd_section->flags |= SEC_HAS_CONTENTS; + if (!(output_section_statement->flags & SEC_NEVER_LOAD)) { + output_section_statement->bfd_section->flags |= SEC_ALLOC | SEC_LOAD; + } + } + break; + + case lang_reloc_statement_enum: + { + int size; + + s->reloc_statement.output_vma = + dot - output_section_statement->bfd_section->vma; + s->reloc_statement.output_section = + output_section_statement->bfd_section; + size = bfd_get_reloc_size (s->reloc_statement.howto); + dot += size; + output_section_statement->bfd_section->_raw_size += size; + } + break; + + case lang_wild_statement_enum: + + dot = lang_size_sections (s->wild_statement.children.head, + output_section_statement, + &s->wild_statement.children.head, + + fill, dot, relax); + + break; + + case lang_object_symbols_statement_enum: + link_info.create_object_symbols_section = + output_section_statement->bfd_section; + break; + case lang_output_statement_enum: + case lang_target_statement_enum: + break; + case lang_input_section_enum: + { + asection *i; + + i = (*prev)->input_section.section; + if (! relax) + { + if (i->_cooked_size == 0) + i->_cooked_size = i->_raw_size; + } + else + { + boolean again; + + if (! bfd_relax_section (i->owner, i, &link_info, &again)) + einfo ("%P%F: can't relax section: %E\n"); + if (again) + relax_again = true; + } + dot = size_input_section (prev, + output_section_statement, + output_section_statement->fill, + dot, relax); + } + break; + case lang_input_statement_enum: + break; + case lang_fill_statement_enum: + s->fill_statement.output_section = output_section_statement->bfd_section; + + fill = s->fill_statement.fill; + break; + case lang_assignment_statement_enum: + { + bfd_vma newdot = dot; + + exp_fold_tree (s->assignment_statement.exp, + output_section_statement, + lang_allocating_phase_enum, + dot, + &newdot); + + if (newdot != dot && !relax) + { + /* The assignment changed dot. Insert a pad. */ + if (output_section_statement == abs_output_section) + { + /* If we don't have an output section, then just adjust + the default memory address. */ + lang_memory_region_lookup ("*default*")->current = newdot; + } + else + { + lang_statement_union_type *new = + ((lang_statement_union_type *) + stat_alloc (sizeof (lang_padding_statement_type))); + + /* Link into existing chain */ + new->header.next = *prev; + *prev = new; + new->header.type = lang_padding_statement_enum; + new->padding_statement.output_section = + output_section_statement->bfd_section; + new->padding_statement.output_offset = + dot - output_section_statement->bfd_section->vma; + new->padding_statement.fill = fill; + new->padding_statement.size = newdot - dot; + output_section_statement->bfd_section->_raw_size += + new->padding_statement.size; + } + + dot = newdot; + } + } + break; + + case lang_padding_statement_enum: + /* If we are relaxing, and this is not the first pass, some + padding statements may have been inserted during previous + passes. We may have to move the padding statement to a new + location if dot has a different value at this point in this + pass than it did at this point in the previous pass. */ + s->padding_statement.output_offset = + dot - output_section_statement->bfd_section->vma; + dot += s->padding_statement.size; + output_section_statement->bfd_section->_raw_size += + s->padding_statement.size; + break; + + case lang_group_statement_enum: + dot = lang_size_sections (s->group_statement.children.head, + output_section_statement, + &s->group_statement.children.head, + fill, dot, relax); + break; + + default: + FAIL (); + break; + + /* This can only get here when relaxing is turned on */ + + case lang_address_statement_enum: + break; + } + prev = &s->header.next; + } + return dot; +} + +bfd_vma +lang_do_assignments (s, output_section_statement, fill, dot) + lang_statement_union_type * s; + lang_output_section_statement_type * output_section_statement; + fill_type fill; + bfd_vma dot; +{ + for (; s != (lang_statement_union_type *) NULL; s = s->next) + { + switch (s->header.type) + { + case lang_constructors_statement_enum: + dot = lang_do_assignments (constructor_list.head, + output_section_statement, + fill, + dot); + break; + + case lang_output_section_statement_enum: + { + lang_output_section_statement_type *os = + &(s->output_section_statement); + + if (os->bfd_section != NULL) + { + dot = os->bfd_section->vma; + (void) lang_do_assignments (os->children.head, os, + os->fill, dot); + dot = os->bfd_section->vma + os->bfd_section->_raw_size; + } + if (os->load_base) + { + /* If nothing has been placed into the output section then + it won't have a bfd_section. */ + if (os->bfd_section) + { + os->bfd_section->lma + = exp_get_abs_int(os->load_base, 0,"load base", lang_final_phase_enum); + } + } + } + break; + case lang_wild_statement_enum: + + dot = lang_do_assignments (s->wild_statement.children.head, + output_section_statement, + fill, dot); + + break; + + case lang_object_symbols_statement_enum: + case lang_output_statement_enum: + case lang_target_statement_enum: +#if 0 + case lang_common_statement_enum: +#endif + break; + case lang_data_statement_enum: + { + etree_value_type value; + + value = exp_fold_tree (s->data_statement.exp, + abs_output_section, + lang_final_phase_enum, dot, &dot); + s->data_statement.value = value.value; + if (value.valid == false) + einfo ("%F%P: invalid data statement\n"); + } + switch (s->data_statement.type) + { + case QUAD: + dot += QUAD_SIZE; + break; + case LONG: + dot += LONG_SIZE; + break; + case SHORT: + dot += SHORT_SIZE; + break; + case BYTE: + dot += BYTE_SIZE; + break; + } + break; + + case lang_reloc_statement_enum: + { + etree_value_type value; + + value = exp_fold_tree (s->reloc_statement.addend_exp, + abs_output_section, + lang_final_phase_enum, dot, &dot); + s->reloc_statement.addend_value = value.value; + if (value.valid == false) + einfo ("%F%P: invalid reloc statement\n"); + } + dot += bfd_get_reloc_size (s->reloc_statement.howto); + break; + + case lang_input_section_enum: + { + asection *in = s->input_section.section; + + if (in->_cooked_size != 0) + dot += in->_cooked_size; + else + dot += in->_raw_size; + } + break; + + case lang_input_statement_enum: + break; + case lang_fill_statement_enum: + fill = s->fill_statement.fill; + break; + case lang_assignment_statement_enum: + { + exp_fold_tree (s->assignment_statement.exp, + output_section_statement, + lang_final_phase_enum, + dot, + &dot); + } + + break; + case lang_padding_statement_enum: + dot += s->padding_statement.size; + break; + + case lang_group_statement_enum: + dot = lang_do_assignments (s->group_statement.children.head, + output_section_statement, + fill, dot); + + break; + + default: + FAIL (); + break; + case lang_address_statement_enum: + break; + } + + } + return dot; +} + +/* Fix any .startof. or .sizeof. symbols. When the assemblers see the + operator .startof. (section_name), it produces an undefined symbol + .startof.section_name. Similarly, when it sees + .sizeof. (section_name), it produces an undefined symbol + .sizeof.section_name. For all the output sections, we look for + such symbols, and set them to the correct value. */ + +static void +lang_set_startof () +{ + asection *s; + + if (link_info.relocateable) + return; + + for (s = output_bfd->sections; s != NULL; s = s->next) + { + const char *secname; + char *buf; + struct bfd_link_hash_entry *h; + + secname = bfd_get_section_name (output_bfd, s); + buf = xmalloc (10 + strlen (secname)); + + sprintf (buf, ".startof.%s", secname); + h = bfd_link_hash_lookup (link_info.hash, buf, false, false, true); + if (h != NULL && h->type == bfd_link_hash_undefined) + { + h->type = bfd_link_hash_defined; + h->u.def.value = bfd_get_section_vma (output_bfd, s); + h->u.def.section = bfd_abs_section_ptr; + } + + sprintf (buf, ".sizeof.%s", secname); + h = bfd_link_hash_lookup (link_info.hash, buf, false, false, true); + if (h != NULL && h->type == bfd_link_hash_undefined) + { + h->type = bfd_link_hash_defined; + if (s->_cooked_size != 0) + h->u.def.value = s->_cooked_size; + else + h->u.def.value = s->_raw_size; + h->u.def.section = bfd_abs_section_ptr; + } + + free (buf); + } +} + +static void +lang_finish () +{ + struct bfd_link_hash_entry *h; + boolean warn; + + if (link_info.relocateable || link_info.shared) + warn = false; + else + warn = true; + + if (entry_symbol == (char *) NULL) + { + /* No entry has been specified. Look for start, but don't warn + if we don't find it. */ + entry_symbol = "start"; + warn = false; + } + + h = bfd_link_hash_lookup (link_info.hash, entry_symbol, false, false, true); + if (h != (struct bfd_link_hash_entry *) NULL + && (h->type == bfd_link_hash_defined + || h->type == bfd_link_hash_defweak) + && h->u.def.section->output_section != NULL) + { + bfd_vma val; + + val = (h->u.def.value + + bfd_get_section_vma (output_bfd, + h->u.def.section->output_section) + + h->u.def.section->output_offset); + if (! bfd_set_start_address (output_bfd, val)) + einfo ("%P%F:%s: can't set start address\n", entry_symbol); + } + else + { + asection *ts; + + /* Can't find the entry symbol. Use the first address in the + text section. */ + ts = bfd_get_section_by_name (output_bfd, ".text"); + if (ts != (asection *) NULL) + { + if (warn) + einfo ("%P: warning: cannot find entry symbol %s; defaulting to %V\n", + entry_symbol, bfd_get_section_vma (output_bfd, ts)); + if (! bfd_set_start_address (output_bfd, + bfd_get_section_vma (output_bfd, ts))) + einfo ("%P%F: can't set start address\n"); + } + else + { + if (warn) + einfo ("%P: warning: cannot find entry symbol %s; not setting start address\n", + entry_symbol); + } + } +} + +/* Check that the architecture of all the input files is compatible + with the output file. Also call the backend to let it do any + other checking that is needed. */ + +static void +lang_check () +{ + lang_statement_union_type *file; + bfd *input_bfd; + CONST bfd_arch_info_type *compatible; + + for (file = file_chain.head; + file != (lang_statement_union_type *) NULL; + file = file->input_statement.next) + { + input_bfd = file->input_statement.the_bfd; + compatible = bfd_arch_get_compatible (input_bfd, + output_bfd); + if (compatible == NULL) + einfo ("%P: warning: %s architecture of input file `%B' is incompatible with %s output\n", + bfd_printable_name (input_bfd), input_bfd, + bfd_printable_name (output_bfd)); + + else + bfd_merge_private_bfd_data (input_bfd, output_bfd); + } +} + +/* Look through all the global common symbols and attach them to the + correct section. The -sort-common command line switch may be used + to roughly sort the entries by size. */ + +static void +lang_common () +{ + if (link_info.relocateable + && ! command_line.force_common_definition) + return; + + if (! config.sort_common) + bfd_link_hash_traverse (link_info.hash, lang_one_common, (PTR) NULL); + else + { + int power; + + for (power = 4; power >= 0; power--) + bfd_link_hash_traverse (link_info.hash, lang_one_common, + (PTR) &power); + } +} + +/* Place one common symbol in the correct section. */ + +static boolean +lang_one_common (h, info) + struct bfd_link_hash_entry *h; + PTR info; +{ + unsigned int power_of_two; + bfd_vma size; + asection *section; + + if (h->type != bfd_link_hash_common) + return true; + + size = h->u.c.size; + power_of_two = h->u.c.p->alignment_power; + + if (config.sort_common + && power_of_two < (unsigned int) *(int *) info) + return true; + + section = h->u.c.p->section; + + /* Increase the size of the section. */ + section->_raw_size = ALIGN_N (section->_raw_size, + (bfd_size_type) (1 << power_of_two)); + + /* Adjust the alignment if necessary. */ + if (power_of_two > section->alignment_power) + section->alignment_power = power_of_two; + + /* Change the symbol from common to defined. */ + h->type = bfd_link_hash_defined; + h->u.def.section = section; + h->u.def.value = section->_raw_size; + + /* Increase the size of the section. */ + section->_raw_size += size; + + /* Make sure the section is allocated in memory, and make sure that + it is no longer a common section. */ + section->flags |= SEC_ALLOC; + section->flags &= ~ SEC_IS_COMMON; + + if (config.map_file != NULL) + { + static boolean header_printed; + int len; + char *name; + char buf[50]; + + if (! header_printed) + { + minfo ("\nAllocating common symbols\n"); + minfo ("Common symbol size file\n\n"); + header_printed = true; + } + + name = demangle (h->root.string); + minfo ("%s", name); + len = strlen (name); + free (name); + + if (len >= 19) + { + print_nl (); + len = 0; + } + while (len < 20) + { + print_space (); + ++len; + } + + minfo ("0x"); + if (size <= 0xffffffff) + sprintf (buf, "%lx", (unsigned long) size); + else + sprintf_vma (buf, size); + minfo ("%s", buf); + len = strlen (buf); + + while (len < 16) + { + print_space (); + ++len; + } + + minfo ("%B\n", section->owner); + } + + return true; +} + +/* +run through the input files and ensure that every input +section has somewhere to go. If one is found without +a destination then create an input request and place it +into the statement tree. +*/ + +static void +lang_place_orphans () +{ + lang_input_statement_type *file; + + for (file = (lang_input_statement_type *) file_chain.head; + file != (lang_input_statement_type *) NULL; + file = (lang_input_statement_type *) file->next) + { + asection *s; + + for (s = file->the_bfd->sections; + s != (asection *) NULL; + s = s->next) + { + if (s->output_section == (asection *) NULL) + { + /* This section of the file is not attatched, root + around for a sensible place for it to go */ + + if (file->just_syms_flag) + { + /* We are only retrieving symbol values from this + file. We want the symbols to act as though the + values in the file are absolute. */ + s->output_section = bfd_abs_section_ptr; + s->output_offset = s->vma; + } + else if (strcmp (s->name, "COMMON") == 0) + { + /* This is a lonely common section which must have + come from an archive. We attach to the section + with the wildcard. */ + if (! link_info.relocateable + || command_line.force_common_definition) + { + if (default_common_section == NULL) + { +#if 0 + /* This message happens when using the + svr3.ifile linker script, so I have + disabled it. */ + info_msg ("%P: no [COMMON] command, defaulting to .bss\n"); +#endif + default_common_section = + lang_output_section_statement_lookup (".bss"); + + } + wild_doit (&default_common_section->children, s, + default_common_section, file); + } + } + else if (ldemul_place_orphan (file, s)) + ; + else + { + lang_output_section_statement_type *os = + lang_output_section_statement_lookup (s->name); + + wild_doit (&os->children, s, os, file); + } + } + } + } +} + + +void +lang_set_flags (ptr, flags) + int *ptr; + CONST char *flags; +{ + boolean state = false; + + *ptr = 0; + while (*flags) + { + if (*flags == '!') + { + state = false; + flags++; + } + else + state = true; + switch (*flags) + { + case 'R': + /* ptr->flag_read = state; */ + break; + case 'W': + /* ptr->flag_write = state; */ + break; + case 'X': + /* ptr->flag_executable= state;*/ + break; + case 'L': + case 'I': + /* ptr->flag_loadable= state;*/ + break; + default: + einfo ("%P%F: invalid syntax in flags\n"); + break; + } + flags++; + } +} + +/* Call a function on each input file. This function will be called + on an archive, but not on the elements. */ + +void +lang_for_each_input_file (func) + void (*func) PARAMS ((lang_input_statement_type *)); +{ + lang_input_statement_type *f; + + for (f = (lang_input_statement_type *) input_file_chain.head; + f != NULL; + f = (lang_input_statement_type *) f->next_real_file) + func (f); +} + +/* Call a function on each file. The function will be called on all + the elements of an archive which are included in the link, but will + not be called on the archive file itself. */ + +void +lang_for_each_file (func) + void (*func) PARAMS ((lang_input_statement_type *)); +{ + lang_input_statement_type *f; + + for (f = (lang_input_statement_type *) file_chain.head; + f != (lang_input_statement_type *) NULL; + f = (lang_input_statement_type *) f->next) + { + func (f); + } +} + +#if 0 + +/* Not used. */ + +void +lang_for_each_input_section (func) + void (*func) PARAMS ((bfd * ab, asection * as)); +{ + lang_input_statement_type *f; + + for (f = (lang_input_statement_type *) file_chain.head; + f != (lang_input_statement_type *) NULL; + f = (lang_input_statement_type *) f->next) + { + asection *s; + + for (s = f->the_bfd->sections; + s != (asection *) NULL; + s = s->next) + { + func (f->the_bfd, s); + } + } +} + +#endif + +void +ldlang_add_file (entry) + lang_input_statement_type * entry; +{ + bfd **pp; + + lang_statement_append (&file_chain, + (lang_statement_union_type *) entry, + &entry->next); + + /* The BFD linker needs to have a list of all input BFDs involved in + a link. */ + ASSERT (entry->the_bfd->link_next == (bfd *) NULL); + ASSERT (entry->the_bfd != output_bfd); + for (pp = &link_info.input_bfds; + *pp != (bfd *) NULL; + pp = &(*pp)->link_next) + ; + *pp = entry->the_bfd; + entry->the_bfd->usrdata = (PTR) entry; + bfd_set_gp_size (entry->the_bfd, g_switch_value); + + /* Look through the sections and check for any which should not be + included in the link. We need to do this now, so that we can + notice when the backend linker tries to report multiple + definition errors for symbols which are in sections we aren't + going to link. FIXME: It might be better to entirely ignore + symbols which are defined in sections which are going to be + discarded. This would require modifying the backend linker for + each backend which might set the SEC_LINK_ONCE flag. If we do + this, we should probably handle SEC_EXCLUDE in the same way. */ + + bfd_map_over_sections (entry->the_bfd, section_already_linked, (PTR) entry); +} + +void +lang_add_output (name, from_script) + CONST char *name; + int from_script; +{ + /* Make -o on command line override OUTPUT in script. */ + if (had_output_filename == false || !from_script) + { + output_filename = name; + had_output_filename = true; + } +} + + +static lang_output_section_statement_type *current_section; + +static int +topower (x) + int x; +{ + unsigned int i = 1; + int l; + + if (x < 0) + return -1; + + for (l = 0; l < 32; l++) + { + if (i >= (unsigned int) x) + return l; + i <<= 1; + } + + return 0; +} + +void +lang_enter_output_section_statement (output_section_statement_name, + address_exp, sectype, block_value, + align, subalign, ebase) + const char *output_section_statement_name; + etree_type * address_exp; + enum section_type sectype; + bfd_vma block_value; + etree_type *align; + etree_type *subalign; + etree_type *ebase; +{ + lang_output_section_statement_type *os; + + current_section = + os = + lang_output_section_statement_lookup (output_section_statement_name); + + + + /* Add this statement to tree */ + /* add_statement(lang_output_section_statement_enum, + output_section_statement);*/ + /* Make next things chain into subchain of this */ + + if (os->addr_tree == + (etree_type *) NULL) + { + os->addr_tree = + address_exp; + } + os->sectype = sectype; + if (sectype != noload_section) + os->flags = SEC_NO_FLAGS; + else + os->flags = SEC_NEVER_LOAD; + os->block_value = block_value ? block_value : 1; + stat_ptr = &os->children; + + os->subsection_alignment = topower( + exp_get_value_int(subalign, -1, + "subsection alignment", + 0)); + os->section_alignment = topower( + exp_get_value_int(align, -1, + "section alignment", 0)); + + os->load_base = ebase; +} + + +void +lang_final () +{ + lang_output_statement_type *new = + new_stat (lang_output_statement, stat_ptr); + + new->name = output_filename; +} + +/* Reset the current counters in the regions */ +static void +reset_memory_regions () +{ + lang_memory_region_type *p = lang_memory_region_list; + + for (p = lang_memory_region_list; + p != (lang_memory_region_type *) NULL; + p = p->next) + { + p->old_length = (bfd_size_type) (p->current - p->origin); + p->current = p->origin; + } +} + +void +lang_process () +{ + lang_reasonable_defaults (); + current_target = default_target; + + lang_for_each_statement (ldlang_open_output); /* Open the output file */ + + ldemul_create_output_section_statements (); + + /* Add to the hash table all undefineds on the command line */ + lang_place_undefineds (); + + /* Create a bfd for each input file */ + current_target = default_target; + open_input_bfds (statement_list.head, false); + + ldemul_after_open (); + + /* Make sure that we're not mixing architectures. We call this + after all the input files have been opened, but before we do any + other processing, so that any operations merge_private_bfd_data + does on the output file will be known during the rest of the + link. */ + lang_check (); + + /* Build all sets based on the information gathered from the input + files. */ + ldctor_build_sets (); + + /* Size up the common data */ + lang_common (); + + /* Run through the contours of the script and attach input sections + to the correct output sections + */ + map_input_to_output_sections (statement_list.head, (char *) NULL, + (lang_output_section_statement_type *) NULL); + + + /* Find any sections not attached explicitly and handle them */ + lang_place_orphans (); + + ldemul_before_allocation (); + + /* We must record the program headers before we try to fix the + section positions, since they will affect SIZEOF_HEADERS. */ + lang_record_phdrs (); + + /* Now run around and relax if we can */ + if (command_line.relax) + { + /* First time round is a trial run to get the 'worst case' + addresses of the objects if there was no relaxing. */ + lang_size_sections (statement_list.head, + abs_output_section, + &(statement_list.head), 0, (bfd_vma) 0, false); + + /* Keep relaxing until bfd_relax_section gives up. */ + do + { + reset_memory_regions (); + + relax_again = false; + + /* Do all the assignments with our current guesses as to + section sizes. */ + lang_do_assignments (statement_list.head, + abs_output_section, + (fill_type) 0, (bfd_vma) 0); + + /* Perform another relax pass - this time we know where the + globals are, so can make better guess. */ + lang_size_sections (statement_list.head, + abs_output_section, + &(statement_list.head), 0, (bfd_vma) 0, true); + } + while (relax_again); + } + else + { + /* Size up the sections. */ + lang_size_sections (statement_list.head, + abs_output_section, + &(statement_list.head), 0, (bfd_vma) 0, false); + } + + /* See if anything special should be done now we know how big + everything is. */ + ldemul_after_allocation (); + + /* Fix any .startof. or .sizeof. symbols. */ + lang_set_startof (); + + /* Do all the assignments, now that we know the final restingplaces + of all the symbols */ + + lang_do_assignments (statement_list.head, + abs_output_section, + (fill_type) 0, (bfd_vma) 0); + + /* Final stuffs */ + + ldemul_finish (); + lang_finish (); +} + +/* EXPORTED TO YACC */ + +void +lang_add_wild (section_name, filename) + CONST char *CONST section_name; + CONST char *CONST filename; +{ + lang_wild_statement_type *new = new_stat (lang_wild_statement, + stat_ptr); + + if (section_name != (char *) NULL && strcmp (section_name, "COMMON") == 0) + { + placed_commons = true; + } + if (filename != (char *) NULL) + { + lang_has_input_file = true; + } + new->section_name = section_name; + new->filename = filename; + lang_list_init (&new->children); +} + +void +lang_section_start (name, address) + CONST char *name; + etree_type * address; +{ + lang_address_statement_type *ad = new_stat (lang_address_statement, stat_ptr); + + ad->section_name = name; + ad->address = address; +} + +/* Set the start symbol to NAME. CMDLINE is nonzero if this is called + because of a -e argument on the command line, or zero if this is + called by ENTRY in a linker script. Command line arguments take + precedence. */ + +/* WINDOWS_NT. When an entry point has been specified, we will also force + this symbol to be defined by calling ldlang_add_undef (equivalent to + having switch -u entry_name on the command line). The reason we do + this is so that the user doesn't have to because they would have to use + the -u switch if they were specifying an entry point other than + _mainCRTStartup. Specifically, if creating a windows application, entry + point _WinMainCRTStartup must be specified. + What I have found for non console applications (entry not _mainCRTStartup) + is that the .obj that contains mainCRTStartup is brought in since it is + the first encountered in libc.lib and it has other symbols in it which will + be pulled in by the link process. To avoid this, adding -u with the entry + point name specified forces the correct .obj to be used. We can avoid + making the user do this by always adding the entry point name as an + undefined symbol. */ + +void +lang_add_entry (name, cmdline) + CONST char *name; + boolean cmdline; +{ + if (entry_symbol == NULL + || cmdline + || ! entry_from_cmdline) + { + entry_symbol = name; + entry_from_cmdline = cmdline; + } +#if 0 + /* don't do this yet. It seems to work (the executables run), but the + image created is very different from what I was getting before indicating + that something else is being pulled in. When everything else is working, + then try to put this back in to see if it will do the right thing for + other more complicated applications */ + ldlang_add_undef (name); +#endif +} + +void +lang_add_target (name) + CONST char *name; +{ + lang_target_statement_type *new = new_stat (lang_target_statement, + stat_ptr); + + new->target = name; + +} + +void +lang_add_map (name) + CONST char *name; +{ + while (*name) + { + switch (*name) + { + case 'F': + map_option_f = true; + break; + } + name++; + } +} + +void +lang_add_fill (exp) + int exp; +{ + lang_fill_statement_type *new = new_stat (lang_fill_statement, + stat_ptr); + + new->fill = exp; +} + +void +lang_add_data (type, exp) + int type; + union etree_union *exp; +{ + + lang_data_statement_type *new = new_stat (lang_data_statement, + stat_ptr); + + new->exp = exp; + new->type = type; + +} + +/* Create a new reloc statement. RELOC is the BFD relocation type to + generate. HOWTO is the corresponding howto structure (we could + look this up, but the caller has already done so). SECTION is the + section to generate a reloc against, or NAME is the name of the + symbol to generate a reloc against. Exactly one of SECTION and + NAME must be NULL. ADDEND is an expression for the addend. */ + +void +lang_add_reloc (reloc, howto, section, name, addend) + bfd_reloc_code_real_type reloc; + reloc_howto_type *howto; + asection *section; + const char *name; + union etree_union *addend; +{ + lang_reloc_statement_type *p = new_stat (lang_reloc_statement, stat_ptr); + + p->reloc = reloc; + p->howto = howto; + p->section = section; + p->name = name; + p->addend_exp = addend; + + p->addend_value = 0; + p->output_section = NULL; + p->output_vma = 0; +} + +void +lang_add_assignment (exp) + etree_type * exp; +{ + lang_assignment_statement_type *new = new_stat (lang_assignment_statement, + stat_ptr); + + new->exp = exp; +} + +void +lang_add_attribute (attribute) + enum statement_enum attribute; +{ + new_statement (attribute, sizeof (lang_statement_union_type), stat_ptr); +} + +void +lang_startup (name) + CONST char *name; +{ + if (startup_file != (char *) NULL) + { + einfo ("%P%Fmultiple STARTUP files\n"); + } + first_file->filename = name; + first_file->local_sym_name = name; + first_file->real = true; + + startup_file = name; +} + +void +lang_float (maybe) + boolean maybe; +{ + lang_float_flag = maybe; +} + +void +lang_leave_output_section_statement (fill, memspec, phdrs) + bfd_vma fill; + const char *memspec; + struct lang_output_section_phdr_list *phdrs; +{ + current_section->fill = fill; + current_section->region = lang_memory_region_lookup (memspec); + current_section->phdrs = phdrs; + stat_ptr = &statement_list; +} + +/* + Create an absolute symbol with the given name with the value of the + address of first byte of the section named. + + If the symbol already exists, then do nothing. +*/ +void +lang_abs_symbol_at_beginning_of (secname, name) + const char *secname; + const char *name; +{ + struct bfd_link_hash_entry *h; + + h = bfd_link_hash_lookup (link_info.hash, name, true, true, true); + if (h == (struct bfd_link_hash_entry *) NULL) + einfo ("%P%F: bfd_link_hash_lookup failed: %E\n"); + + if (h->type == bfd_link_hash_new + || h->type == bfd_link_hash_undefined) + { + asection *sec; + + h->type = bfd_link_hash_defined; + + sec = bfd_get_section_by_name (output_bfd, secname); + if (sec == (asection *) NULL) + h->u.def.value = 0; + else + h->u.def.value = bfd_get_section_vma (output_bfd, sec); + + h->u.def.section = bfd_abs_section_ptr; + } +} + +/* + Create an absolute symbol with the given name with the value of the + address of the first byte after the end of the section named. + + If the symbol already exists, then do nothing. +*/ +void +lang_abs_symbol_at_end_of (secname, name) + const char *secname; + const char *name; +{ + struct bfd_link_hash_entry *h; + + h = bfd_link_hash_lookup (link_info.hash, name, true, true, true); + if (h == (struct bfd_link_hash_entry *) NULL) + einfo ("%P%F: bfd_link_hash_lookup failed: %E\n"); + + if (h->type == bfd_link_hash_new + || h->type == bfd_link_hash_undefined) + { + asection *sec; + + h->type = bfd_link_hash_defined; + + sec = bfd_get_section_by_name (output_bfd, secname); + if (sec == (asection *) NULL) + h->u.def.value = 0; + else + h->u.def.value = (bfd_get_section_vma (output_bfd, sec) + + bfd_section_size (output_bfd, sec)); + + h->u.def.section = bfd_abs_section_ptr; + } +} + +void +lang_statement_append (list, element, field) + lang_statement_list_type * list; + lang_statement_union_type * element; + lang_statement_union_type ** field; +{ + *(list->tail) = element; + list->tail = field; +} + +/* Set the output format type. -oformat overrides scripts. */ + +void +lang_add_output_format (format, big, little, from_script) + const char *format; + const char *big; + const char *little; + int from_script; +{ + if (output_target == NULL || !from_script) + { + if (command_line.endian == ENDIAN_BIG + && big != NULL) + format = big; + else if (command_line.endian == ENDIAN_LITTLE + && little != NULL) + format = little; + + output_target = format; + } +} + +/* Enter a group. This creates a new lang_group_statement, and sets + stat_ptr to build new statements within the group. */ + +void +lang_enter_group () +{ + lang_group_statement_type *g; + + g = new_stat (lang_group_statement, stat_ptr); + lang_list_init (&g->children); + stat_ptr = &g->children; +} + +/* Leave a group. This just resets stat_ptr to start writing to the + regular list of statements again. Note that this will not work if + groups can occur inside anything else which can adjust stat_ptr, + but currently they can't. */ + +void +lang_leave_group () +{ + stat_ptr = &statement_list; +} + +/* Add a new program header. This is called for each entry in a PHDRS + command in a linker script. */ + +void +lang_new_phdr (name, type, filehdr, phdrs, at, flags) + const char *name; + etree_type *type; + boolean filehdr; + boolean phdrs; + etree_type *at; + etree_type *flags; +{ + struct lang_phdr *n, **pp; + + n = (struct lang_phdr *) stat_alloc (sizeof (struct lang_phdr)); + n->next = NULL; + n->name = name; + n->type = exp_get_value_int (type, 0, "program header type", + lang_final_phase_enum); + n->filehdr = filehdr; + n->phdrs = phdrs; + n->at = at; + n->flags = flags; + + for (pp = &lang_phdr_list; *pp != NULL; pp = &(*pp)->next) + ; + *pp = n; +} + +/* Record the program header information in the output BFD. FIXME: We + should not be calling an ELF specific function here. */ + +static void +lang_record_phdrs () +{ + unsigned int alc; + asection **secs; + struct lang_output_section_phdr_list *last; + struct lang_phdr *l; + lang_statement_union_type *u; + + alc = 10; + secs = (asection **) xmalloc (alc * sizeof (asection *)); + last = NULL; + for (l = lang_phdr_list; l != NULL; l = l->next) + { + unsigned int c; + flagword flags; + bfd_vma at; + + c = 0; + for (u = lang_output_section_statement.head; + u != NULL; + u = u->output_section_statement.next) + { + lang_output_section_statement_type *os; + struct lang_output_section_phdr_list *pl; + + os = &u->output_section_statement; + + pl = os->phdrs; + if (pl != NULL) + last = pl; + else + { + if (os->sectype == noload_section + || os->bfd_section == NULL + || (os->bfd_section->flags & SEC_ALLOC) == 0) + continue; + pl = last; + } + + if (os->bfd_section == NULL) + continue; + + for (; pl != NULL; pl = pl->next) + { + if (strcmp (pl->name, l->name) == 0) + { + if (c >= alc) + { + alc *= 2; + secs = ((asection **) + xrealloc (secs, alc * sizeof (asection *))); + } + secs[c] = os->bfd_section; + ++c; + pl->used = true; + } + } + } + + if (l->flags == NULL) + flags = 0; + else + flags = exp_get_vma (l->flags, 0, "phdr flags", + lang_final_phase_enum); + + if (l->at == NULL) + at = 0; + else + at = exp_get_vma (l->at, 0, "phdr load address", + lang_final_phase_enum); + + if (! bfd_record_phdr (output_bfd, l->type, + l->flags == NULL ? false : true, + flags, + l->at == NULL ? false : true, + at, l->filehdr, l->phdrs, c, secs)) + einfo ("%F%P: bfd_record_phdr failed: %E\n"); + } + + free (secs); + + /* Make sure all the phdr assignments succeeded. */ + for (u = lang_output_section_statement.head; + u != NULL; + u = u->output_section_statement.next) + { + struct lang_output_section_phdr_list *pl; + + if (u->output_section_statement.bfd_section == NULL) + continue; + + for (pl = u->output_section_statement.phdrs; + pl != NULL; + pl = pl->next) + if (! pl->used && strcmp (pl->name, "NONE") != 0) + einfo ("%X%P: section `%s' assigned to non-existent phdr `%s'\n", + u->output_section_statement.name, pl->name); + } +} + +/* Record a list of sections which may not be cross referenced. */ + +void +lang_add_nocrossref (l) + struct lang_nocrossref *l; +{ + struct lang_nocrossrefs *n; + + n = (struct lang_nocrossrefs *) xmalloc (sizeof *n); + n->next = nocrossref_list; + n->list = l; + nocrossref_list = n; + + /* Set notice_all so that we get informed about all symbols. */ + link_info.notice_all = true; +} + +/* Overlay handling. We handle overlays with some static variables. */ + +/* The overlay virtual address. */ +static etree_type *overlay_vma; + +/* The overlay load address. */ +static etree_type *overlay_lma; + +/* Whether nocrossrefs is set for this overlay. */ +static int overlay_nocrossrefs; + +/* An expression for the maximum section size seen so far. */ +static etree_type *overlay_max; + +/* A list of all the sections in this overlay. */ + +struct overlay_list +{ + struct overlay_list *next; + lang_output_section_statement_type *os; +}; + +static struct overlay_list *overlay_list; + +/* Start handling an overlay. */ + +void +lang_enter_overlay (vma_expr, lma_expr, nocrossrefs) + etree_type *vma_expr; + etree_type *lma_expr; + int nocrossrefs; +{ + /* The grammar should prevent nested overlays from occurring. */ + ASSERT (overlay_vma == NULL + && overlay_lma == NULL + && overlay_list == NULL + && overlay_max == NULL); + + overlay_vma = vma_expr; + overlay_lma = lma_expr; + overlay_nocrossrefs = nocrossrefs; +} + +/* Start a section in an overlay. We handle this by calling + lang_enter_output_section_statement with the correct VMA and LMA. */ + +void +lang_enter_overlay_section (name) + const char *name; +{ + struct overlay_list *n; + etree_type *size; + + lang_enter_output_section_statement (name, overlay_vma, normal_section, + 0, 0, 0, overlay_lma); + + /* If this is the first section, then base the VMA and LMA of future + sections on this one. This will work correctly even if `.' is + used in the addresses. */ + if (overlay_list == NULL) + { + overlay_vma = exp_nameop (ADDR, name); + overlay_lma = exp_nameop (LOADADDR, name); + } + + /* Remember the section. */ + n = (struct overlay_list *) xmalloc (sizeof *n); + n->os = current_section; + n->next = overlay_list; + overlay_list = n; + + size = exp_nameop (SIZEOF, name); + + /* Adjust the LMA for the next section. */ + overlay_lma = exp_binop ('+', overlay_lma, size); + + /* Arrange to work out the maximum section end address. */ + if (overlay_max == NULL) + overlay_max = size; + else + overlay_max = exp_binop (MAX, overlay_max, size); +} + +/* Finish a section in an overlay. There isn't any special to do + here. */ + +void +lang_leave_overlay_section (fill, phdrs) + bfd_vma fill; + struct lang_output_section_phdr_list *phdrs; +{ + const char *name; + char *clean, *s2; + const char *s1; + char *buf; + + name = current_section->name; + + lang_leave_output_section_statement (fill, "*default*", phdrs); + + /* Define the magic symbols. */ + + clean = xmalloc (strlen (name) + 1); + s2 = clean; + for (s1 = name; *s1 != '\0'; s1++) + if (isalnum (*s1) || *s1 == '_') + *s2++ = *s1; + *s2 = '\0'; + + buf = xmalloc (strlen (clean) + sizeof "__load_start_"); + sprintf (buf, "__load_start_%s", clean); + lang_add_assignment (exp_assop ('=', buf, + exp_nameop (LOADADDR, name))); + + buf = xmalloc (strlen (clean) + sizeof "__load_stop_"); + sprintf (buf, "__load_stop_%s", clean); + lang_add_assignment (exp_assop ('=', buf, + exp_binop ('+', + exp_nameop (LOADADDR, name), + exp_nameop (SIZEOF, name)))); + + free (clean); +} + +/* Finish an overlay. If there are any overlay wide settings, this + looks through all the sections in the overlay and sets them. */ + +void +lang_leave_overlay (fill, memspec, phdrs) + bfd_vma fill; + const char *memspec; + struct lang_output_section_phdr_list *phdrs; +{ + lang_memory_region_type *region; + struct overlay_list *l; + struct lang_nocrossref *nocrossref; + + if (memspec == NULL) + region = NULL; + else + region = lang_memory_region_lookup (memspec); + + nocrossref = NULL; + + l = overlay_list; + while (l != NULL) + { + struct overlay_list *next; + + if (fill != 0 && l->os->fill == 0) + l->os->fill = fill; + if (region != NULL && l->os->region == NULL) + l->os->region = region; + if (phdrs != NULL && l->os->phdrs == NULL) + l->os->phdrs = phdrs; + + if (overlay_nocrossrefs) + { + struct lang_nocrossref *nc; + + nc = (struct lang_nocrossref *) xmalloc (sizeof *nc); + nc->name = l->os->name; + nc->next = nocrossref; + nocrossref = nc; + } + + next = l->next; + free (l); + l = next; + } + + if (nocrossref != NULL) + lang_add_nocrossref (nocrossref); + + /* Update . for the end of the overlay. */ + lang_add_assignment (exp_assop ('=', ".", + exp_binop ('+', overlay_vma, overlay_max))); + + overlay_vma = NULL; + overlay_lma = NULL; + overlay_nocrossrefs = 0; + overlay_list = NULL; + overlay_max = NULL; +} + +/* Version handling. This is only useful for ELF. */ + +/* This global variable holds the version tree that we build. */ + +struct bfd_elf_version_tree *lang_elf_version_info; + +/* This is called for each variable name or match expression. */ + +struct bfd_elf_version_expr * +lang_new_vers_regex (orig, new) + struct bfd_elf_version_expr *orig; + const char *new; +{ + struct bfd_elf_version_expr *ret; + + ret = (struct bfd_elf_version_expr *) xmalloc (sizeof *ret); + ret->next = orig; + ret->match = new; + return ret; +} + +/* This is called for each set of variable names and match + expressions. */ + +struct bfd_elf_version_tree * +lang_new_vers_node (globals, locals) + struct bfd_elf_version_expr *globals; + struct bfd_elf_version_expr *locals; +{ + struct bfd_elf_version_tree *ret; + + ret = (struct bfd_elf_version_tree *) xmalloc (sizeof *ret); + ret->next = NULL; + ret->name = NULL; + ret->vernum = 0; + ret->globals = globals; + ret->locals = locals; + ret->deps = NULL; + ret->name_indx = (unsigned int) -1; + ret->used = 0; + return ret; +} + +/* This static variable keeps track of version indices. */ + +static int version_index; + +/* This is called when we know the name and dependencies of the + version. */ + +void +lang_register_vers_node (name, version, deps) + const char *name; + struct bfd_elf_version_tree *version; + struct bfd_elf_version_deps *deps; +{ + struct bfd_elf_version_tree *t, **pp; + struct bfd_elf_version_expr *e1; + + /* Make sure this node has a unique name. */ + for (t = lang_elf_version_info; t != NULL; t = t->next) + if (strcmp (t->name, name) == 0) + einfo ("%X%P: duplicate version tag `%s'\n", name); + + /* Check the global and local match names, and make sure there + aren't any duplicates. */ + + for (e1 = version->globals; e1 != NULL; e1 = e1->next) + { + for (t = lang_elf_version_info; t != NULL; t = t->next) + { + struct bfd_elf_version_expr *e2; + + for (e2 = t->globals; e2 != NULL; e2 = e2->next) + if (strcmp (e1->match, e2->match) == 0) + einfo ("%X%P: duplicate expression `%s' in version information\n", + e1->match); + + for (e2 = t->locals; e2 != NULL; e2 = e2->next) + if (strcmp (e1->match, e2->match) == 0) + einfo ("%X%P: duplicate expression `%s' in version information\n", + e1->match); + } + } + + for (e1 = version->locals; e1 != NULL; e1 = e1->next) + { + for (t = lang_elf_version_info; t != NULL; t = t->next) + { + struct bfd_elf_version_expr *e2; + + for (e2 = t->globals; e2 != NULL; e2 = e2->next) + if (strcmp (e1->match, e2->match) == 0) + einfo ("%X%P: duplicate expression `%s' in version information\n", + e1->match); + + for (e2 = t->locals; e2 != NULL; e2 = e2->next) + if (strcmp (e1->match, e2->match) == 0) + einfo ("%X%P: duplicate expression `%s' in version information\n", + e1->match); + } + } + + version->deps = deps; + version->name = name; + ++version_index; + version->vernum = version_index; + + for (pp = &lang_elf_version_info; *pp != NULL; pp = &(*pp)->next) + ; + *pp = version; +} + +/* This is called when we see a version dependency. */ + +struct bfd_elf_version_deps * +lang_add_vers_depend (list, name) + struct bfd_elf_version_deps *list; + const char *name; +{ + struct bfd_elf_version_deps *ret; + struct bfd_elf_version_tree *t; + + ret = (struct bfd_elf_version_deps *) xmalloc (sizeof *ret); + ret->next = list; + + for (t = lang_elf_version_info; t != NULL; t = t->next) + { + if (strcmp (t->name, name) == 0) + { + ret->version_needed = t; + return ret; + } + } + + einfo ("%X%P: unable to find version dependency `%s'\n", name); + + return ret; +} diff --git a/contrib/binutils/ld/ldlang.h b/contrib/binutils/ld/ldlang.h new file mode 100644 index 0000000..492351d --- /dev/null +++ b/contrib/binutils/ld/ldlang.h @@ -0,0 +1,482 @@ +/* ldlang.h - linker command language support + Copyright 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GLD; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#ifndef LDLANG_H +#define LDLANG_H + +typedef enum +{ + lang_input_file_is_l_enum, + lang_input_file_is_symbols_only_enum, + lang_input_file_is_marker_enum, + lang_input_file_is_fake_enum, + lang_input_file_is_search_file_enum, + lang_input_file_is_file_enum +} lang_input_file_enum_type; + +typedef unsigned int fill_type; +typedef struct statement_list +{ + union lang_statement_union *head; + union lang_statement_union **tail; +} lang_statement_list_type; + + +typedef struct memory_region_struct +{ + char *name; + struct memory_region_struct *next; + bfd_vma origin; + bfd_size_type length; + bfd_vma current; + bfd_size_type old_length; + int flags; + boolean had_full_message; +} lang_memory_region_type ; + +typedef struct lang_statement_header_struct +{ + union lang_statement_union *next; + enum statement_enum + { + lang_output_section_statement_enum, + lang_assignment_statement_enum, + lang_input_statement_enum, + lang_address_statement_enum, + lang_wild_statement_enum, + lang_input_section_enum, + lang_object_symbols_statement_enum, + lang_fill_statement_enum, + lang_data_statement_enum, + lang_reloc_statement_enum, + lang_target_statement_enum, + lang_output_statement_enum, + lang_padding_statement_enum, + lang_group_statement_enum, + + lang_afile_asection_pair_statement_enum, + lang_constructors_statement_enum + } type; +} lang_statement_header_type; + + +typedef struct +{ + lang_statement_header_type header; + union etree_union *exp; +} lang_assignment_statement_type; + + +typedef struct lang_target_statement_struct +{ + lang_statement_header_type header; + const char *target; +} lang_target_statement_type; + + +typedef struct lang_output_statement_struct +{ + lang_statement_header_type header; + const char *name; +} lang_output_statement_type; + +/* Section types specified in a linker script. */ + +enum section_type +{ + normal_section, + dsect_section, + copy_section, + noload_section, + info_section, + overlay_section +}; + +/* This structure holds a list of program headers describing segments + in which this section should be placed. */ + +struct lang_output_section_phdr_list +{ + struct lang_output_section_phdr_list *next; + const char *name; + boolean used; +}; + +typedef struct lang_output_section_statement_struct +{ + lang_statement_header_type header; + union etree_union *addr_tree; + lang_statement_list_type children; + const char *memspec; + union lang_statement_union *next; + const char *name; + + boolean processed; + + asection *bfd_section; + int flags; /* Or together of all input sections */ + enum section_type sectype; + struct memory_region_struct *region; + size_t block_value; + fill_type fill; + + int subsection_alignment; /* alignment of components */ + int section_alignment; /* alignment of start of section */ + + union etree_union *load_base; + + struct lang_output_section_phdr_list *phdrs; +} lang_output_section_statement_type; + + +typedef struct +{ + lang_statement_header_type header; +} lang_common_statement_type; + +typedef struct +{ + lang_statement_header_type header; +} lang_object_symbols_statement_type; + +typedef struct +{ + lang_statement_header_type header; + fill_type fill; + int size; + asection *output_section; +} lang_fill_statement_type; + +typedef struct +{ + lang_statement_header_type header; + unsigned int type; + union etree_union *exp; + bfd_vma value; + asection *output_section; + bfd_vma output_vma; +} lang_data_statement_type; + +/* Generate a reloc in the output file. */ + +typedef struct +{ + lang_statement_header_type header; + + /* Reloc to generate. */ + bfd_reloc_code_real_type reloc; + + /* Reloc howto structure. */ + reloc_howto_type *howto; + + /* Section to generate reloc against. Exactly one of section and + name must be NULL. */ + asection *section; + + /* Name of symbol to generate reloc against. Exactly one of section + and name must be NULL. */ + const char *name; + + /* Expression for addend. */ + union etree_union *addend_exp; + + /* Resolved addend. */ + bfd_vma addend_value; + + /* Output section where reloc should be performed. */ + asection *output_section; + + /* VMA within output section. */ + bfd_vma output_vma; +} lang_reloc_statement_type; + +typedef struct lang_input_statement_struct +{ + lang_statement_header_type header; + /* Name of this file. */ + const char *filename; + /* Name to use for the symbol giving address of text start */ + /* Usually the same as filename, but for a file spec'd with -l + this is the -l switch itself rather than the filename. */ + const char *local_sym_name; + + bfd *the_bfd; + + boolean closed; + file_ptr passive_position; + + /* Symbol table of the file. */ + asymbol **asymbols; + unsigned int symbol_count; + + /* Point to the next file - whatever it is, wanders up and down + archives */ + + union lang_statement_union *next; + /* Point to the next file, but skips archive contents */ + union lang_statement_union *next_real_file; + + boolean is_archive; + + /* 1 means search a set of directories for this file. */ + boolean search_dirs_flag; + + /* 1 means this is base file of incremental load. + Do not load this file's text or data. + Also default text_start to after this file's bss. */ + + boolean just_syms_flag; + + /* Whether to search for this entry as a dynamic archive. */ + boolean dynamic; + + /* Whether to include the entire contents of an archive. */ + boolean whole_archive; + + boolean loaded; + + /* unsigned int globals_in_this_file;*/ + const char *target; + boolean real; +} lang_input_statement_type; + +typedef struct +{ + lang_statement_header_type header; + asection *section; + lang_input_statement_type *ifile; + +} lang_input_section_type; + + +typedef struct +{ + lang_statement_header_type header; + asection *section; + union lang_statement_union *file; +} lang_afile_asection_pair_statement_type; + +typedef struct lang_wild_statement_struct +{ + lang_statement_header_type header; + const char *section_name; + const char *filename; + lang_statement_list_type children; +} lang_wild_statement_type; + +typedef struct lang_address_statement_struct +{ + lang_statement_header_type header; + const char *section_name; + union etree_union *address; +} lang_address_statement_type; + +typedef struct +{ + lang_statement_header_type header; + bfd_vma output_offset; + size_t size; + asection *output_section; + fill_type fill; +} lang_padding_statement_type; + +/* A group statement collects a set of libraries together. The + libraries are searched multiple times, until no new undefined + symbols are found. The effect is to search a group of libraries as + though they were a single library. */ + +typedef struct +{ + lang_statement_header_type header; + lang_statement_list_type children; +} lang_group_statement_type; + +typedef union lang_statement_union +{ + lang_statement_header_type header; + union lang_statement_union *next; + lang_wild_statement_type wild_statement; + lang_data_statement_type data_statement; + lang_reloc_statement_type reloc_statement; + lang_address_statement_type address_statement; + lang_output_section_statement_type output_section_statement; + lang_afile_asection_pair_statement_type afile_asection_pair_statement; + lang_assignment_statement_type assignment_statement; + lang_input_statement_type input_statement; + lang_target_statement_type target_statement; + lang_output_statement_type output_statement; + lang_input_section_type input_section; + lang_common_statement_type common_statement; + lang_object_symbols_statement_type object_symbols_statement; + lang_fill_statement_type fill_statement; + lang_padding_statement_type padding_statement; + lang_group_statement_type group_statement; +} lang_statement_union_type; + +/* This structure holds information about a program header, from the + PHDRS command in the linker script. */ + +struct lang_phdr +{ + struct lang_phdr *next; + const char *name; + unsigned long type; + boolean filehdr; + boolean phdrs; + etree_type *at; + etree_type *flags; +}; + +/* This structure is used to hold a list of sections which may not + cross reference each other. */ + +struct lang_nocrossref +{ + struct lang_nocrossref *next; + const char *name; +}; + +/* The list of nocrossref lists. */ + +struct lang_nocrossrefs +{ + struct lang_nocrossrefs *next; + struct lang_nocrossref *list; +}; + +extern struct lang_nocrossrefs *nocrossref_list; + +extern lang_output_section_statement_type *abs_output_section; +extern boolean lang_has_input_file; +extern etree_type *base; +extern lang_statement_list_type *stat_ptr; +extern boolean delete_output_file_on_failure; + +extern const char *entry_symbol; +extern boolean entry_from_cmdline; + +extern void lang_init PARAMS ((void)); +extern struct memory_region_struct *lang_memory_region_lookup + PARAMS ((const char *const)); +extern void lang_map PARAMS ((void)); +extern void lang_set_flags PARAMS ((int *, const char *)); +extern void lang_add_output PARAMS ((const char *, int from_script)); +extern void lang_enter_output_section_statement + PARAMS ((const char *output_section_statement_name, + etree_type * address_exp, + enum section_type sectype, + bfd_vma block_value, + etree_type *align, + etree_type *subalign, + etree_type *)); +extern void lang_final PARAMS ((void)); +extern void lang_process PARAMS ((void)); +extern void lang_section_start PARAMS ((const char *, union etree_union *)); +extern void lang_add_entry PARAMS ((const char *, boolean)); +extern void lang_add_target PARAMS ((const char *)); +extern void lang_add_wild PARAMS ((const char *const , const char *const)); +extern void lang_add_map PARAMS ((const char *)); +extern void lang_add_fill PARAMS ((int)); +extern void lang_add_assignment PARAMS ((union etree_union *)); +extern void lang_add_attribute PARAMS ((enum statement_enum)); +extern void lang_startup PARAMS ((const char *)); +extern void lang_float PARAMS ((enum bfd_boolean)); +extern void lang_leave_output_section_statement + PARAMS ((bfd_vma, const char *, struct lang_output_section_phdr_list *)); +extern void lang_abs_symbol_at_end_of PARAMS ((const char *, const char *)); +extern void lang_abs_symbol_at_beginning_of PARAMS ((const char *, + const char *)); +extern void lang_statement_append PARAMS ((struct statement_list *, + union lang_statement_union *, + union lang_statement_union **)); +extern void lang_for_each_input_file + PARAMS ((void (*dothis) (lang_input_statement_type *))); +extern void lang_for_each_file + PARAMS ((void (*dothis) (lang_input_statement_type *))); +extern bfd_vma lang_do_assignments + PARAMS ((lang_statement_union_type * s, + lang_output_section_statement_type *output_section_statement, + fill_type fill, + bfd_vma dot)); + +#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \ + extern lang_statement_list_type file_chain; \ + lang_input_statement_type *statement; \ + for (statement = (lang_input_statement_type *)file_chain.head;\ + statement != (lang_input_statement_type *)NULL; \ + statement = (lang_input_statement_type *)statement->next)\ + +extern void lang_process PARAMS ((void)); +extern void ldlang_add_file PARAMS ((lang_input_statement_type *)); +extern lang_output_section_statement_type *lang_output_section_find + PARAMS ((const char * const)); +extern lang_input_statement_type *lang_add_input_file + PARAMS ((const char *name, lang_input_file_enum_type file_type, + const char *target)); +extern void lang_add_keepsyms_file PARAMS ((const char *filename)); +extern lang_output_section_statement_type * + lang_output_section_statement_lookup PARAMS ((const char * const name)); +extern void ldlang_add_undef PARAMS ((const char *const name)); +extern void lang_add_output_format PARAMS ((const char *, const char *, + const char *, int from_script)); +extern void lang_list_init PARAMS ((lang_statement_list_type*)); +extern void lang_add_data PARAMS ((int type, union etree_union *)); +extern void lang_add_reloc + PARAMS ((bfd_reloc_code_real_type reloc, reloc_howto_type *howto, + asection *section, const char *name, union etree_union *addend)); +extern void lang_for_each_statement + PARAMS ((void (*func) (lang_statement_union_type *))); +extern PTR stat_alloc PARAMS ((size_t size)); +extern void dprint_statement PARAMS ((lang_statement_union_type *, int)); +extern bfd_vma lang_size_sections + PARAMS ((lang_statement_union_type *s, + lang_output_section_statement_type *output_section_statement, + lang_statement_union_type **prev, fill_type fill, + bfd_vma dot, boolean relax)); +extern void lang_enter_group PARAMS ((void)); +extern void lang_leave_group PARAMS ((void)); +extern void wild_doit + PARAMS ((lang_statement_list_type *ptr, asection *section, + lang_output_section_statement_type *output, + lang_input_statement_type *file)); +extern void lang_new_phdr + PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *, + etree_type *)); +extern void lang_add_nocrossref PARAMS ((struct lang_nocrossref *)); +extern void lang_enter_overlay PARAMS ((etree_type *, etree_type *, int)); +extern void lang_enter_overlay_section PARAMS ((const char *)); +extern void lang_leave_overlay_section + PARAMS ((bfd_vma, struct lang_output_section_phdr_list *)); +extern void lang_leave_overlay + PARAMS ((bfd_vma, const char *, struct lang_output_section_phdr_list *)); + +extern struct bfd_elf_version_tree *lang_elf_version_info; + +extern struct bfd_elf_version_expr *lang_new_vers_regex + PARAMS ((struct bfd_elf_version_expr *, const char *)); +extern struct bfd_elf_version_tree *lang_new_vers_node + PARAMS ((struct bfd_elf_version_expr *, struct bfd_elf_version_expr *)); +extern struct bfd_elf_version_deps *lang_add_vers_depend + PARAMS ((struct bfd_elf_version_deps *, const char *)); +extern void lang_register_vers_node + PARAMS ((const char *, struct bfd_elf_version_tree *, + struct bfd_elf_version_deps *)); + +#endif diff --git a/contrib/binutils/ld/ldlex.h b/contrib/binutils/ld/ldlex.h new file mode 100644 index 0000000..f824ec8 --- /dev/null +++ b/contrib/binutils/ld/ldlex.h @@ -0,0 +1,62 @@ +/* ldlex.h - + Copyright 1991, 92, 93, 94, 95, 1997 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GLD; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef LDLEX_H +#define LDLEX_H + +#include <stdio.h> + +/* The initial parser states. */ +typedef enum input_enum { + input_selected, /* We've set the initial state. */ + input_script, + input_mri_script, + input_version_script, + input_defsym +} input_type; + +extern input_type parser_input; + +extern int hex_mode; +extern unsigned int lineno; +extern const char *lex_string; + +/* In ldlex.l. */ +extern int yylex PARAMS ((void)); +extern void lex_push_file PARAMS ((FILE *, const char *)); +extern void lex_redirect PARAMS ((const char *)); +extern void ldlex_script PARAMS ((void)); +extern void ldlex_mri_script PARAMS ((void)); +extern void ldlex_version_script PARAMS ((void)); +extern void ldlex_version_file PARAMS ((void)); +extern void ldlex_defsym PARAMS ((void)); +extern void ldlex_expression PARAMS ((void)); +extern void ldlex_both PARAMS ((void)); +extern void ldlex_command PARAMS ((void)); +extern void ldlex_popstate PARAMS ((void)); + +/* In lexsup.c. */ +extern int lex_input PARAMS ((void)); +extern void lex_unput PARAMS ((int)); +#ifndef yywrap +extern int yywrap PARAMS ((void)); +#endif +extern void parse_args PARAMS ((int, char **)); + +#endif diff --git a/contrib/binutils/ld/ldlex.l b/contrib/binutils/ld/ldlex.l new file mode 100644 index 0000000..60089c6 --- /dev/null +++ b/contrib/binutils/ld/ldlex.l @@ -0,0 +1,633 @@ +%{ + +/* Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* +This was written by steve chamberlain + sac@cygnus.com +*/ + + +#include <ansidecl.h> +#include <stdio.h> +#include <ctype.h> + +#ifdef MPW +/* Prevent enum redefinition problems. */ +#define TRUE_FALSE_ALREADY_DEFINED +#endif /* MPW */ + +#include "bfd.h" +#include "sysdep.h" +#include "ld.h" +#include "ldgram.h" +#include "ldmisc.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldfile.h" +#include "ldlex.h" +#include "ldmain.h" + +/* The type of top-level parser input. + yylex and yyparse (indirectly) both check this. */ +input_type parser_input; + +/* Radix to use for bfd_scan_vma -- 0 (default to base 10) or 16. */ +int hex_mode; + +/* Line number in the current input file. + (FIXME Actually, it doesn't appear to get reset for each file?) */ +unsigned int lineno = 1; + +/* The string we are currently lexing, or NULL if we are reading a + file. */ +const char *lex_string = NULL; + +/* Support for flex reading from more than one input file (stream). + `include_stack' is flex's input state for each open file; + `file_name_stack' is the file names. `lineno_stack' is the current + line numbers. + + If `include_stack_ptr' is 0, we haven't started reading anything yet. + Otherwise, stack elements 0 through `include_stack_ptr - 1' are valid. */ + +#undef YY_INPUT +#define YY_INPUT(buf,result,max_size) yy_input(buf, &result, max_size) + +#define MAX_INCLUDE_DEPTH 10 +static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; +static const char *file_name_stack[MAX_INCLUDE_DEPTH]; +static unsigned int lineno_stack[MAX_INCLUDE_DEPTH]; +static unsigned int include_stack_ptr = 0; + +static YY_BUFFER_STATE yy_create_string_buffer PARAMS ((const char *string, + size_t size)); +static void yy_input PARAMS ((char *, int *result, int max_size)); + +static void comment PARAMS ((void)); +static void lex_warn_invalid PARAMS ((char *where, char *what)); + +/* STATES + EXPRESSION definitely in an expression + SCRIPT definitely in a script + BOTH either EXPRESSION or SCRIPT + DEFSYMEXP in an argument to -defsym + MRI in an MRI script + VERS_START starting a Sun style mapfile + VERS_SCRIPT a Sun style mapfile + VERS_NODE a node within a Sun style mapfile +*/ +#define RTOKEN(x) { yylval.token = x; return x; } + +/* Some versions of flex want this. */ +#ifndef yywrap +int yywrap () { return 1; } +#endif +%} + +%a 4000 +%o 5000 + +CMDFILENAMECHAR [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\-\~] +CMDFILENAMECHAR1 [_a-zA-Z0-9\/\.\\_\+\$\:\[\]\\\,\=\&\!\<\>\~] +FILENAMECHAR1 [_a-zA-Z\/\.\\\$\_\~] +SYMBOLCHARN [_a-zA-Z\/\.\\\$\_\~0-9] +FILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~] +WILDCHAR [_a-zA-Z0-9\/\.\-\_\+\=\$\:\[\]\\\,\~\?\*] +WHITE [ \t\n\r]+ + +NOCFILENAMECHAR [_a-zA-Z0-9\/\.\-\_\+\$\:\[\]\\\~] + +V_TAG [.$_a-zA-Z][._a-zA-Z0-9]* +V_IDENTIFIER [*?$_a-zA-Z][*?_a-zA-Z0-9]* + +%s SCRIPT +%s EXPRESSION +%s BOTH +%s DEFSYMEXP +%s MRI +%s VERS_START +%s VERS_SCRIPT +%s VERS_NODE +%% + + if (parser_input != input_selected) + { + /* The first token of the input determines the initial parser state. */ + input_type t = parser_input; + parser_input = input_selected; + switch (t) + { + case input_script: return INPUT_SCRIPT; break; + case input_mri_script: return INPUT_MRI_SCRIPT; break; + case input_version_script: return INPUT_VERSION_SCRIPT; break; + case input_defsym: return INPUT_DEFSYM; break; + default: abort (); + } + } + +<BOTH,SCRIPT,EXPRESSION>"/*" { comment(); } + + +<DEFSYMEXP>"-" { RTOKEN('-');} +<DEFSYMEXP>"+" { RTOKEN('+');} +<DEFSYMEXP>{FILENAMECHAR1}{SYMBOLCHARN}* { yylval.name = buystring(yytext); return NAME; } +<DEFSYMEXP>"=" { RTOKEN('='); } + +<MRI,EXPRESSION>"$"([0-9A-Fa-f])+ { + yylval.integer = bfd_scan_vma (yytext+1, 0,16); + return INT; + } + +<MRI,EXPRESSION>([0-9A-Fa-f])+(H|h|X|x|B|b|O|o|D|d) { + int ibase ; + switch (yytext[yyleng-1]) { + case 'X': + case 'x': + case 'H': + case 'h': + ibase = 16; + break; + case 'O': + case 'o': + ibase = 8; + break; + case 'B': + case 'b': + ibase = 2; + break; + default: + ibase = 10; + } + yylval.integer = bfd_scan_vma (yytext, 0, + ibase); + return INT; + } +<SCRIPT,DEFSYMEXP,MRI,BOTH,EXPRESSION>"$"?"0x"?([0-9A-Fa-f])+(M|K|m|k)? { + yylval.integer = bfd_scan_vma (yytext, 0, + hex_mode); + if (yytext[yyleng-1]=='M' + || yytext[yyleng-1] == 'm') { + yylval.integer *= 1024*1024; + } + if (yytext[yyleng-1]=='K' + || yytext[yyleng-1]=='k') { + yylval.integer *= 1024; + } + return INT; + } +<BOTH,SCRIPT,EXPRESSION,MRI>"]" { RTOKEN(']');} +<BOTH,SCRIPT,EXPRESSION,MRI>"[" { RTOKEN('[');} +<BOTH,SCRIPT,EXPRESSION,MRI>"<<=" { RTOKEN(LSHIFTEQ);} +<BOTH,SCRIPT,EXPRESSION,MRI>">>=" { RTOKEN(RSHIFTEQ);} +<BOTH,SCRIPT,EXPRESSION,MRI>"||" { RTOKEN(OROR);} +<BOTH,SCRIPT,EXPRESSION,MRI>"==" { RTOKEN(EQ);} +<BOTH,SCRIPT,EXPRESSION,MRI>"!=" { RTOKEN(NE);} +<BOTH,SCRIPT,EXPRESSION,MRI>">=" { RTOKEN(GE);} +<BOTH,SCRIPT,EXPRESSION,MRI>"<=" { RTOKEN(LE);} +<BOTH,SCRIPT,EXPRESSION,MRI>"<<" { RTOKEN(LSHIFT);} +<BOTH,SCRIPT,EXPRESSION,MRI>">>" { RTOKEN(RSHIFT);} +<BOTH,SCRIPT,EXPRESSION,MRI>"+=" { RTOKEN(PLUSEQ);} +<BOTH,SCRIPT,EXPRESSION,MRI>"-=" { RTOKEN(MINUSEQ);} +<BOTH,SCRIPT,EXPRESSION,MRI>"*=" { RTOKEN(MULTEQ);} +<BOTH,SCRIPT,EXPRESSION,MRI>"/=" { RTOKEN(DIVEQ);} +<BOTH,SCRIPT,EXPRESSION,MRI>"&=" { RTOKEN(ANDEQ);} +<BOTH,SCRIPT,EXPRESSION,MRI>"|=" { RTOKEN(OREQ);} +<BOTH,SCRIPT,EXPRESSION,MRI>"&&" { RTOKEN(ANDAND);} +<BOTH,SCRIPT,EXPRESSION,MRI>">" { RTOKEN('>');} +<BOTH,SCRIPT,EXPRESSION,MRI>"," { RTOKEN(',');} +<BOTH,SCRIPT,EXPRESSION,MRI>"&" { RTOKEN('&');} +<BOTH,SCRIPT,EXPRESSION,MRI>"|" { RTOKEN('|');} +<BOTH,SCRIPT,EXPRESSION,MRI>"~" { RTOKEN('~');} +<BOTH,SCRIPT,EXPRESSION,MRI>"!" { RTOKEN('!');} +<BOTH,SCRIPT,EXPRESSION,MRI>"?" { RTOKEN('?');} +<BOTH,SCRIPT,EXPRESSION,MRI>"*" { RTOKEN('*');} +<BOTH,SCRIPT,EXPRESSION,MRI>"+" { RTOKEN('+');} +<BOTH,SCRIPT,EXPRESSION,MRI>"-" { RTOKEN('-');} +<BOTH,SCRIPT,EXPRESSION,MRI>"/" { RTOKEN('/');} +<BOTH,SCRIPT,EXPRESSION,MRI>"%" { RTOKEN('%');} +<BOTH,SCRIPT,EXPRESSION,MRI>"<" { RTOKEN('<');} +<BOTH,SCRIPT,EXPRESSION,MRI>"=" { RTOKEN('=');} +<BOTH,SCRIPT,EXPRESSION,MRI>"}" { RTOKEN('}') ; } +<BOTH,SCRIPT,EXPRESSION,MRI>"{" { RTOKEN('{'); } +<BOTH,SCRIPT,EXPRESSION,MRI>")" { RTOKEN(')');} +<BOTH,SCRIPT,EXPRESSION,MRI>"(" { RTOKEN('(');} +<BOTH,SCRIPT,EXPRESSION,MRI>":" { RTOKEN(':'); } +<BOTH,SCRIPT,EXPRESSION,MRI>";" { RTOKEN(';');} +<BOTH,SCRIPT>"MEMORY" { RTOKEN(MEMORY);} +<BOTH,SCRIPT>"ORIGIN" { RTOKEN(ORIGIN);} +<BOTH,SCRIPT>"VERSION" { RTOKEN(VERSION);} +<EXPRESSION,BOTH,SCRIPT>"BLOCK" { RTOKEN(BLOCK);} +<EXPRESSION,BOTH,SCRIPT>"BIND" { RTOKEN(BIND);} +<BOTH,SCRIPT>"LENGTH" { RTOKEN(LENGTH);} +<EXPRESSION,BOTH,SCRIPT>"ALIGN" { RTOKEN(ALIGN_K);} +<EXPRESSION,BOTH,SCRIPT>"ADDR" { RTOKEN(ADDR);} +<EXPRESSION,BOTH,SCRIPT>"LOADADDR" { RTOKEN(LOADADDR);} +<EXPRESSION,BOTH>"MAX" { RTOKEN(MAX); } +<EXPRESSION,BOTH>"MIN" { RTOKEN(MIN); } +<BOTH,SCRIPT>"ENTRY" { RTOKEN(ENTRY);} +<EXPRESSION,BOTH,SCRIPT>"NEXT" { RTOKEN(NEXT);} +<EXPRESSION,BOTH,SCRIPT>"sizeof_headers" { RTOKEN(SIZEOF_HEADERS);} +<EXPRESSION,BOTH,SCRIPT>"SIZEOF_HEADERS" { RTOKEN(SIZEOF_HEADERS);} +<BOTH,SCRIPT>"MAP" { RTOKEN(MAP);} +<EXPRESSION,BOTH,SCRIPT>"SIZEOF" { RTOKEN(SIZEOF);} +<BOTH,SCRIPT>"TARGET" { RTOKEN(TARGET_K);} +<BOTH,SCRIPT>"SEARCH_DIR" { RTOKEN(SEARCH_DIR);} +<BOTH,SCRIPT>"OUTPUT" { RTOKEN(OUTPUT);} +<BOTH,SCRIPT>"INPUT" { RTOKEN(INPUT);} +<EXPRESSION,BOTH,SCRIPT>"GROUP" { RTOKEN(GROUP);} +<EXPRESSION,BOTH,SCRIPT>"DEFINED" { RTOKEN(DEFINED);} +<BOTH,SCRIPT>"CREATE_OBJECT_SYMBOLS" { RTOKEN(CREATE_OBJECT_SYMBOLS);} +<BOTH,SCRIPT>"CONSTRUCTORS" { RTOKEN( CONSTRUCTORS);} +<BOTH,SCRIPT>"FORCE_COMMON_ALLOCATION" { RTOKEN(FORCE_COMMON_ALLOCATION);} +<BOTH,SCRIPT>"SECTIONS" { RTOKEN(SECTIONS);} +<BOTH,SCRIPT>"FILL" { RTOKEN(FILL);} +<BOTH,SCRIPT>"STARTUP" { RTOKEN(STARTUP);} +<BOTH,SCRIPT>"OUTPUT_FORMAT" { RTOKEN(OUTPUT_FORMAT);} +<BOTH,SCRIPT>"OUTPUT_ARCH" { RTOKEN( OUTPUT_ARCH);} +<BOTH,SCRIPT>"HLL" { RTOKEN(HLL);} +<BOTH,SCRIPT>"SYSLIB" { RTOKEN(SYSLIB);} +<BOTH,SCRIPT>"FLOAT" { RTOKEN(FLOAT);} +<BOTH,SCRIPT>"QUAD" { RTOKEN( QUAD);} +<BOTH,SCRIPT>"LONG" { RTOKEN( LONG);} +<BOTH,SCRIPT>"SHORT" { RTOKEN( SHORT);} +<BOTH,SCRIPT>"BYTE" { RTOKEN( BYTE);} +<BOTH,SCRIPT>"NOFLOAT" { RTOKEN(NOFLOAT);} +<EXPRESSION,BOTH,SCRIPT>"NOCROSSREFS" { RTOKEN(NOCROSSREFS);} +<BOTH,SCRIPT>"OVERLAY" { RTOKEN(OVERLAY); } +<EXPRESSION,BOTH,SCRIPT>"NOLOAD" { RTOKEN(NOLOAD);} +<EXPRESSION,BOTH,SCRIPT>"DSECT" { RTOKEN(DSECT);} +<EXPRESSION,BOTH,SCRIPT>"COPY" { RTOKEN(COPY);} +<EXPRESSION,BOTH,SCRIPT>"INFO" { RTOKEN(INFO);} +<EXPRESSION,BOTH,SCRIPT>"OVERLAY" { RTOKEN(OVERLAY);} +<BOTH,SCRIPT>"o" { RTOKEN(ORIGIN);} +<BOTH,SCRIPT>"org" { RTOKEN(ORIGIN);} +<BOTH,SCRIPT>"l" { RTOKEN( LENGTH);} +<BOTH,SCRIPT>"len" { RTOKEN( LENGTH);} +<BOTH,SCRIPT>"INCLUDE" { RTOKEN(INCLUDE);} +<BOTH,SCRIPT>"PHDRS" { RTOKEN (PHDRS); } +<EXPRESSION,BOTH,SCRIPT>"AT" { RTOKEN(AT);} +<EXPRESSION,BOTH,SCRIPT>"PROVIDE" { RTOKEN(PROVIDE); } +<MRI>"#".*\n?\r? { ++ lineno; } +<MRI>"\n" { ++ lineno; RTOKEN(NEWLINE); } +<MRI>"\r" { ++ lineno; RTOKEN(NEWLINE); } +<MRI>"*".* { /* Mri comment line */ } +<MRI>";".* { /* Mri comment line */ } +<MRI>"END" { RTOKEN(ENDWORD); } +<MRI>"ALIGNMOD" { RTOKEN(ALIGNMOD);} +<MRI>"ALIGN" { RTOKEN(ALIGN_K);} +<MRI>"CHIP" { RTOKEN(CHIP); } +<MRI>"BASE" { RTOKEN(BASE); } +<MRI>"ALIAS" { RTOKEN(ALIAS); } +<MRI>"TRUNCATE" { RTOKEN(TRUNCATE); } +<MRI>"LOAD" { RTOKEN(LOAD); } +<MRI>"PUBLIC" { RTOKEN(PUBLIC); } +<MRI>"ORDER" { RTOKEN(ORDER); } +<MRI>"NAME" { RTOKEN(NAMEWORD); } +<MRI>"FORMAT" { RTOKEN(FORMAT); } +<MRI>"CASE" { RTOKEN(CASE); } +<MRI>"EXTERN" { RTOKEN(EXTERN); } +<MRI>"START" { RTOKEN(START); } +<MRI>"LIST".* { RTOKEN(LIST); /* LIST and ignore to end of line */ } +<MRI>"SECT" { RTOKEN(SECT); } +<EXPRESSION,BOTH,SCRIPT,MRI>"ABSOLUTE" { RTOKEN(ABSOLUTE); } +<MRI>"end" { RTOKEN(ENDWORD); } +<MRI>"alignmod" { RTOKEN(ALIGNMOD);} +<MRI>"align" { RTOKEN(ALIGN_K);} +<MRI>"chip" { RTOKEN(CHIP); } +<MRI>"base" { RTOKEN(BASE); } +<MRI>"alias" { RTOKEN(ALIAS); } +<MRI>"truncate" { RTOKEN(TRUNCATE); } +<MRI>"load" { RTOKEN(LOAD); } +<MRI>"public" { RTOKEN(PUBLIC); } +<MRI>"order" { RTOKEN(ORDER); } +<MRI>"name" { RTOKEN(NAMEWORD); } +<MRI>"format" { RTOKEN(FORMAT); } +<MRI>"case" { RTOKEN(CASE); } +<MRI>"extern" { RTOKEN(EXTERN); } +<MRI>"start" { RTOKEN(START); } +<MRI>"list".* { RTOKEN(LIST); /* LIST and ignore to end of line */ } +<MRI>"sect" { RTOKEN(SECT); } +<EXPRESSION,BOTH,SCRIPT,MRI>"absolute" { RTOKEN(ABSOLUTE); } + +<MRI>{FILENAMECHAR1}{NOCFILENAMECHAR}* { +/* Filename without commas, needed to parse mri stuff */ + yylval.name = buystring(yytext); + return NAME; + } + + +<BOTH,EXPRESSION>{FILENAMECHAR1}{FILENAMECHAR}* { + yylval.name = buystring(yytext); + return NAME; + } +<BOTH,EXPRESSION>"-l"{FILENAMECHAR}+ { + yylval.name = buystring (yytext + 2); + return LNAME; + } +<SCRIPT>{WILDCHAR}* { yylval.name = buystring(yytext); return NAME; } + +<EXPRESSION,BOTH,SCRIPT>"\""[^\"]*"\"" { + /* No matter the state, quotes + give what's inside */ + yylval.name = buystring(yytext+1); + yylval.name[yyleng-2] = 0; + return NAME; + } +<BOTH,SCRIPT,EXPRESSION>"\n" { lineno++;} +<BOTH,SCRIPT,EXPRESSION>"\r" { lineno++;} +<MRI,BOTH,SCRIPT,EXPRESSION>[ \t] + +<VERS_NODE,VERS_SCRIPT>[:,;] { return *yytext; } + +<VERS_NODE>global { RTOKEN(GLOBAL); } + +<VERS_NODE>local { RTOKEN(LOCAL); } + +<VERS_NODE>{V_IDENTIFIER} { yylval.name = buystring (yytext); + return VERS_IDENTIFIER; } + +<VERS_SCRIPT>{V_TAG} { yylval.name = buystring (yytext); + return VERS_TAG; } + +<VERS_START>"{" { BEGIN(VERS_SCRIPT); return *yytext; } + +<VERS_SCRIPT>"{" { BEGIN(VERS_NODE); return *yytext; } +<VERS_SCRIPT,VERS_NODE>"}" { BEGIN(VERS_SCRIPT); return *yytext; } + +<VERS_START,VERS_NODE,VERS_SCRIPT>[\n\r] { lineno++; } + +<VERS_START,VERS_NODE,VERS_SCRIPT>#.* { /* Eat up comments */ } + +<VERS_START,VERS_NODE,VERS_SCRIPT>[ \t]+ { /* Eat up whitespace */ } + +<<EOF>> { + include_stack_ptr--; + + if (include_stack_ptr == 0) + { + yyterminate(); + } + else + { + yy_switch_to_buffer(include_stack[include_stack_ptr]); + + } + BEGIN(SCRIPT); + ldfile_input_filename = file_name_stack[include_stack_ptr - 1]; + lineno = lineno_stack[include_stack_ptr - 1]; + + return END; +} + +<SCRIPT,MRI,VERS_START,VERS_SCRIPT,VERS_NODE>. lex_warn_invalid(" in script", yytext); +<EXPRESSION,DEFSYMEXP,BOTH>. lex_warn_invalid(" in expression", yytext); + +%% + + +/* Switch flex to reading script file NAME, open on FILE, + saving the current input info on the include stack. */ + +void +lex_push_file (file, name) + FILE *file; + const char *name; +{ + if (include_stack_ptr >= MAX_INCLUDE_DEPTH) + { + einfo("%F:includes nested too deeply\n"); + } + file_name_stack[include_stack_ptr] = name; + lineno_stack[include_stack_ptr] = 1; + include_stack[include_stack_ptr] = YY_CURRENT_BUFFER; + + include_stack_ptr++; + yyin = file; + yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); + BEGIN (SCRIPT); +} + +/* Return a newly created flex input buffer containing STRING, + which is SIZE bytes long. */ + +static YY_BUFFER_STATE +yy_create_string_buffer (string, size) + CONST char *string; + size_t size; +{ + YY_BUFFER_STATE b; + + /* Calls to m-alloc get turned by sed into xm-alloc. */ + b = (YY_BUFFER_STATE) malloc (sizeof (struct yy_buffer_state)); + b->yy_input_file = 0; + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + we need to put in 2 end-of-buffer characters. */ + b->yy_ch_buf = (char *) malloc ((unsigned) (b->yy_buf_size + 3)); + + b->yy_ch_buf[0] = '\n'; + strcpy (b->yy_ch_buf+1, string); + b->yy_ch_buf[size+1] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[size+2] = YY_END_OF_BUFFER_CHAR; + b->yy_n_chars = size+1; + b->yy_buf_pos = &b->yy_ch_buf[1]; + + /* flex 2.4.7 changed the interface. FIXME: We should not be using + a flex internal interface in the first place! */ +#ifdef YY_BUFFER_NEW + b->yy_buffer_status = YY_BUFFER_NEW; +#else + b->yy_eof_status = EOF_NOT_SEEN; +#endif + + return b; +} + +/* Switch flex to reading from STRING, saving the current input info + on the include stack. */ + +void +lex_redirect (string) + CONST char *string; +{ + YY_BUFFER_STATE tmp; + + yy_init = 0; + if (include_stack_ptr >= MAX_INCLUDE_DEPTH) + { + einfo("%F: macros nested too deeply\n"); + } + file_name_stack[include_stack_ptr] = "redirect"; + lineno_stack[include_stack_ptr] = 0; + include_stack[include_stack_ptr] = YY_CURRENT_BUFFER; + include_stack_ptr++; + tmp = yy_create_string_buffer (string, strlen (string)); + yy_switch_to_buffer (tmp); + BEGIN (SCRIPT); +} + +/* Functions to switch to a different flex start condition, + saving the current start condition on `state_stack'. */ + +static int state_stack[MAX_INCLUDE_DEPTH * 2]; +static int *state_stack_p = state_stack; + +void +ldlex_script () +{ + *(state_stack_p)++ = yy_start; + BEGIN (SCRIPT); +} + +void +ldlex_mri_script () +{ + *(state_stack_p)++ = yy_start; + BEGIN (MRI); +} + +void +ldlex_version_script () +{ + *(state_stack_p)++ = yy_start; + BEGIN (VERS_START); +} + +void +ldlex_version_file () +{ + *(state_stack_p)++ = yy_start; + BEGIN (VERS_SCRIPT); +} + +void +ldlex_defsym () +{ + *(state_stack_p)++ = yy_start; + BEGIN (DEFSYMEXP); +} + +void +ldlex_expression () +{ + *(state_stack_p)++ = yy_start; + BEGIN (EXPRESSION); +} + +void +ldlex_both () +{ + *(state_stack_p)++ = yy_start; + BEGIN (BOTH); +} + +void +ldlex_popstate () +{ + yy_start = *(--state_stack_p); +} + + +/* Place up to MAX_SIZE characters in BUF and return in *RESULT + either the number of characters read, or 0 to indicate EOF. */ + +static void +yy_input (buf, result, max_size) + char *buf; + int *result; + int max_size; +{ + *result = 0; + if (yy_current_buffer->yy_input_file) + { + if (yyin) + { + *result = read (fileno (yyin), (char *) buf, max_size); + if (*result < 0) + einfo ("%F%P: read in flex scanner failed"); + } + } +} + +/* Eat the rest of a C-style comment. */ + +static void +comment () +{ + int c; + + while (1) + { + c = input(); + while (c != '*' && c != EOF) + { + if (c == '\n' || c == '\r') + lineno++; + c = input(); + } + + if (c == '*') + { + c = input(); + while (c == '*') + c = input(); + if (c == '/') + break; /* found the end */ + } + + if (c == '\n' || c == '\r') + lineno++; + + if (c == EOF) + { + einfo( "%F%P: EOF in comment\n"); + break; + } + } +} + +/* Warn the user about a garbage character WHAT in the input + in context WHERE. */ + +static void +lex_warn_invalid (where, what) + char *where, *what; +{ + char buf[5]; + + /* If we have found an input file whose format we do not recognize, + and we are therefore treating it as a linker script, and we find + an invalid character, then most likely this is a real object file + of some different format. Treat it as such. */ + if (ldfile_assumed_script) + { + bfd_set_error (bfd_error_file_not_recognized); + einfo ("%F%s: file not recognized: %E\n", ldfile_input_filename); + } + + if (! isprint ((unsigned char) *what)) + { + sprintf (buf, "\\%03o", (unsigned int) *what); + what = buf; + } + + einfo ("%P:%S: ignoring invalid character `%s'%s\n", what, where); +} diff --git a/contrib/binutils/ld/ldmain.c b/contrib/binutils/ld/ldmain.c new file mode 100644 index 0000000..94b9b57 --- /dev/null +++ b/contrib/binutils/ld/ldmain.c @@ -0,0 +1,1271 @@ +/* Main program of GNU linker. + Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Written by Steve Chamberlain steve@cygnus.com + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include <stdio.h> +#include <ctype.h> +#include "libiberty.h" +#include "progress.h" +#include "bfdlink.h" + +#include "ld.h" +#include "ldmain.h" +#include "ldmisc.h" +#include "ldwrite.h" +#include "ldgram.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldemul.h" +#include "ldlex.h" +#include "ldfile.h" +#include "ldctor.h" + +/* Somewhere above, sys/stat.h got included . . . . */ +#if !defined(S_ISDIR) && defined(S_IFDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +#include <string.h> + +#ifdef HAVE_SBRK +#ifdef NEED_DECLARATION_SBRK +extern PTR sbrk (); +#endif +#endif + +static char *get_emulation PARAMS ((int, char **)); +static void set_scripts_dir PARAMS ((void)); + +/* EXPORTS */ + +char *default_target; +const char *output_filename = "a.out"; + +/* Name this program was invoked by. */ +char *program_name; + +/* The file that we're creating */ +bfd *output_bfd = 0; + +/* Set by -G argument, for MIPS ECOFF target. */ +int g_switch_value = 8; + +/* Nonzero means print names of input files as processed. */ +boolean trace_files; + +/* Nonzero means same, but note open failures, too. */ +boolean trace_file_tries; + +/* Nonzero means version number was printed, so exit successfully + instead of complaining if no input files are given. */ +boolean version_printed; + +/* Nonzero means link in every member of an archive. */ +boolean whole_archive; + +args_type command_line; + +ld_config_type config; + +static void remove_output PARAMS ((void)); +static boolean check_for_scripts_dir PARAMS ((char *dir)); +static boolean add_archive_element PARAMS ((struct bfd_link_info *, bfd *, + const char *)); +static boolean multiple_definition PARAMS ((struct bfd_link_info *, + const char *, + bfd *, asection *, bfd_vma, + bfd *, asection *, bfd_vma)); +static boolean multiple_common PARAMS ((struct bfd_link_info *, + const char *, bfd *, + enum bfd_link_hash_type, bfd_vma, + bfd *, enum bfd_link_hash_type, + bfd_vma)); +static boolean add_to_set PARAMS ((struct bfd_link_info *, + struct bfd_link_hash_entry *, + bfd_reloc_code_real_type, + bfd *, asection *, bfd_vma)); +static boolean constructor_callback PARAMS ((struct bfd_link_info *, + boolean constructor, + const char *name, + bfd *, asection *, bfd_vma)); +static boolean warning_callback PARAMS ((struct bfd_link_info *, + const char *, const char *, bfd *, + asection *, bfd_vma)); +static void warning_find_reloc PARAMS ((bfd *, asection *, PTR)); +static boolean undefined_symbol PARAMS ((struct bfd_link_info *, + const char *, bfd *, + asection *, bfd_vma)); +static boolean reloc_overflow PARAMS ((struct bfd_link_info *, const char *, + const char *, bfd_vma, + bfd *, asection *, bfd_vma)); +static boolean reloc_dangerous PARAMS ((struct bfd_link_info *, const char *, + bfd *, asection *, bfd_vma)); +static boolean unattached_reloc PARAMS ((struct bfd_link_info *, + const char *, bfd *, asection *, + bfd_vma)); +static boolean notice PARAMS ((struct bfd_link_info *, const char *, + bfd *, asection *, bfd_vma)); + +static struct bfd_link_callbacks link_callbacks = +{ + add_archive_element, + multiple_definition, + multiple_common, + add_to_set, + constructor_callback, + warning_callback, + undefined_symbol, + reloc_overflow, + reloc_dangerous, + unattached_reloc, + notice +}; + +struct bfd_link_info link_info; + +static void +remove_output () +{ + if (output_filename) + { + if (output_bfd && output_bfd->iostream) + fclose((FILE *)(output_bfd->iostream)); + if (delete_output_file_on_failure) + unlink (output_filename); + } +} + +int +main (argc, argv) + int argc; + char **argv; +{ + char *emulation; + long start_time = get_run_time (); + + program_name = argv[0]; + xmalloc_set_program_name (program_name); + + START_PROGRESS (program_name, 0); + + bfd_init (); + + bfd_set_error_program_name (program_name); + + xatexit (remove_output); + + /* Set the default BFD target based on the configured target. Doing + this permits the linker to be configured for a particular target, + and linked against a shared BFD library which was configured for + a different target. The macro TARGET is defined by Makefile. */ + if (! bfd_set_default_target (TARGET)) + { + einfo ("%X%P: can't set BFD default target to `%s': %E\n", TARGET); + xexit (1); + } + + /* Initialize the data about options. */ + trace_files = trace_file_tries = version_printed = false; + whole_archive = false; + config.build_constructors = true; + config.dynamic_link = false; + command_line.force_common_definition = false; + command_line.interpreter = NULL; + command_line.rpath = NULL; + + link_info.callbacks = &link_callbacks; + link_info.relocateable = false; + link_info.shared = false; + link_info.symbolic = false; + link_info.static_link = false; + link_info.traditional_format = false; + link_info.strip = strip_none; + link_info.discard = discard_none; + link_info.keep_memory = true; + link_info.input_bfds = NULL; + link_info.create_object_symbols_section = NULL; + link_info.hash = NULL; + link_info.keep_hash = NULL; + link_info.notice_all = false; + link_info.notice_hash = NULL; + link_info.wrap_hash = NULL; + + ldfile_add_arch (""); + + config.make_executable = true; + force_make_executable = false; + config.magic_demand_paged = true; + config.text_read_only = true; + config.make_executable = true; + + emulation = get_emulation (argc, argv); + ldemul_choose_mode (emulation); + default_target = ldemul_choose_target (); + lang_init (); + ldemul_before_parse (); + lang_has_input_file = false; + parse_args (argc, argv); + + ldemul_set_symbols (); + + if (link_info.relocateable) + { + if (command_line.relax) + einfo ("%P%F: -relax and -r may not be used together\n"); + if (link_info.shared) + einfo ("%P%F: -r and -shared may not be used together\n"); + } + + /* Treat ld -r -s as ld -r -S -x (i.e., strip all local symbols). I + don't see how else this can be handled, since in this case we + must preserve all externally visible symbols. */ + if (link_info.relocateable && link_info.strip == strip_all) + { + link_info.strip = strip_debugger; + if (link_info.discard == discard_none) + link_info.discard = discard_all; + } + + /* This essentially adds another -L directory so this must be done after + the -L's in argv have been processed. */ + set_scripts_dir (); + + if (had_script == false) + { + /* Read the emulation's appropriate default script. */ + int isfile; + char *s = ldemul_get_script (&isfile); + + if (isfile) + ldfile_open_command_file (s); + else + { + if (trace_file_tries) + { + info_msg ("using internal linker script:\n"); + info_msg ("==================================================\n"); + info_msg (s); + info_msg ("\n==================================================\n"); + } + lex_string = s; + lex_redirect (s); + } + parser_input = input_script; + yyparse (); + lex_string = NULL; + } + + lang_final (); + + if (lang_has_input_file == false) + { + if (version_printed) + xexit (0); + einfo ("%P%F: no input files\n"); + } + + if (trace_files) + { + info_msg ("%P: mode %s\n", emulation); + } + + ldemul_after_parse (); + + + if (config.map_filename) + { + if (strcmp (config.map_filename, "-") == 0) + { + config.map_file = stdout; + } + else + { + config.map_file = fopen (config.map_filename, FOPEN_WT); + if (config.map_file == (FILE *) NULL) + { + bfd_set_error (bfd_error_system_call); + einfo ("%P%F: cannot open map file %s: %E\n", + config.map_filename); + } + } + } + + + lang_process (); + + /* Print error messages for any missing symbols, for any warning + symbols, and possibly multiple definitions */ + + + if (config.text_read_only) + { + /* Look for a text section and mark the readonly attribute in it */ + asection *found = bfd_get_section_by_name (output_bfd, ".text"); + + if (found != (asection *) NULL) + { + found->flags |= SEC_READONLY; + } + } + + if (link_info.relocateable) + output_bfd->flags &= ~EXEC_P; + else + output_bfd->flags |= EXEC_P; + + ldwrite (); + + if (config.map_file != NULL) + lang_map (); + if (command_line.cref) + output_cref (config.map_file != NULL ? config.map_file : stdout); + if (nocrossref_list != NULL) + check_nocrossrefs (); + + /* Even if we're producing relocateable output, some non-fatal errors should + be reported in the exit status. (What non-fatal errors, if any, do we + want to ignore for relocateable output?) */ + + if (config.make_executable == false && force_make_executable == false) + { + if (trace_files == true) + { + einfo ("%P: link errors found, deleting executable `%s'\n", + output_filename); + } + + /* The file will be removed by remove_output. */ + + xexit (1); + } + else + { + if (! bfd_close (output_bfd)) + einfo ("%F%B: final close failed: %E\n", output_bfd); + + /* If the --force-exe-suffix is enabled, and we're making an + executable file and it doesn't end in .exe, copy it to one which does. */ + + if (! link_info.relocateable && command_line.force_exe_suffix) + { + int len = strlen (output_filename); + if (len < 4 + || (strcasecmp (output_filename + len - 4, ".exe") != 0 + && strcasecmp (output_filename + len - 4, ".dll") != 0)) + { + FILE *src; + FILE *dst; + const int bsize = 4096; + char *buf = xmalloc (bsize); + int l; + char *dst_name = xmalloc (len + 5); + strcpy (dst_name, output_filename); + strcat (dst_name, ".exe"); + src = fopen (output_filename, FOPEN_RB); + dst = fopen (dst_name, FOPEN_WB); + + if (!src) + einfo ("%X%P: unable to open for source of copy `%s'\n", output_filename); + if (!dst) + einfo ("%X%P: unable to open for destination of copy `%s'\n", dst_name); + while ((l = fread (buf, 1, bsize, src)) > 0) + { + int done = fwrite (buf, 1, l, dst); + if (done != l) + { + einfo ("%P: Error writing file `%s'\n", dst_name); + } + } + fclose (src); + if (fclose (dst) == EOF) + { + einfo ("%P: Error closing file `%s'\n", dst_name); + } + free (dst_name); + free (buf); + } + } + } + + END_PROGRESS (program_name); + + if (config.stats) + { + extern char **environ; +#ifdef HAVE_SBRK + char *lim = (char *) sbrk (0); +#endif + long run_time = get_run_time () - start_time; + + fprintf (stderr, "%s: total time in link: %ld.%06ld\n", + program_name, run_time / 1000000, run_time % 1000000); +#ifdef HAVE_SBRK + fprintf (stderr, "%s: data size %ld\n", program_name, + (long) (lim - (char *) &environ)); +#endif + } + + /* Prevent remove_output from doing anything, after a successful link. */ + output_filename = NULL; + + xexit (0); + return 0; +} + +/* We need to find any explicitly given emulation in order to initialize the + state that's needed by the lex&yacc argument parser (parse_args). */ + +static char * +get_emulation (argc, argv) + int argc; + char **argv; +{ + char *emulation; + int i; + + emulation = getenv (EMULATION_ENVIRON); + if (emulation == NULL) + emulation = DEFAULT_EMULATION; + + for (i = 1; i < argc; i++) + { + if (!strncmp (argv[i], "-m", 2)) + { + if (argv[i][2] == '\0') + { + /* -m EMUL */ + if (i < argc - 1) + { + emulation = argv[i + 1]; + i++; + } + else + { + einfo("%P%F: missing argument to -m\n"); + } + } + else if (strcmp (argv[i], "-mips1") == 0 + || strcmp (argv[i], "-mips2") == 0 + || strcmp (argv[i], "-mips3") == 0 + || strcmp (argv[i], "-mips4") == 0) + { + /* FIXME: The arguments -mips1, -mips2 and -mips3 are + passed to the linker by some MIPS compilers. They + generally tell the linker to use a slightly different + library path. Perhaps someday these should be + implemented as emulations; until then, we just ignore + the arguments and hope that nobody ever creates + emulations named ips1, ips2 or ips3. */ + } + else if (strcmp (argv[i], "-m486") == 0) + { + /* FIXME: The argument -m486 is passed to the linker on + some Linux systems. Hope that nobody creates an + emulation named 486. */ + } + else + { + /* -mEMUL */ + emulation = &argv[i][2]; + } + } + } + + return emulation; +} + +/* If directory DIR contains an "ldscripts" subdirectory, + add DIR to the library search path and return true, + else return false. */ + +static boolean +check_for_scripts_dir (dir) + char *dir; +{ + size_t dirlen; + char *buf; + struct stat s; + boolean res; + + dirlen = strlen (dir); + /* sizeof counts the terminating NUL. */ + buf = (char *) xmalloc (dirlen + sizeof("/ldscripts")); + sprintf (buf, "%s/ldscripts", dir); + + res = stat (buf, &s) == 0 && S_ISDIR (s.st_mode); + free (buf); + if (res) + ldfile_add_library_path (dir, false); + return res; +} + +/* Set the default directory for finding script files. + Libraries will be searched for here too, but that's ok. + We look for the "ldscripts" directory in: + + SCRIPTDIR (passed from Makefile) + the dir where this program is (for using it from the build tree) + the dir where this program is/../lib (for installing the tool suite elsewhere) */ + +static void +set_scripts_dir () +{ + char *end, *dir; + size_t dirlen; + + if (check_for_scripts_dir (SCRIPTDIR)) + return; /* We've been installed normally. */ + + /* Look for "ldscripts" in the dir where our binary is. */ + end = strrchr (program_name, '/'); + + if (end == NULL) + { + /* Don't look for ldscripts in the current directory. There is + too much potential for confusion. */ + return; + } + + dirlen = end - program_name; + /* Make a copy of program_name in dir. + Leave room for later "/../lib". */ + dir = (char *) xmalloc (dirlen + 8); + strncpy (dir, program_name, dirlen); + dir[dirlen] = '\0'; + + if (check_for_scripts_dir (dir)) + return; /* Don't free dir. */ + + /* Look for "ldscripts" in <the dir where our binary is>/../lib. */ + strcpy (dir + dirlen, "/../lib"); + if (check_for_scripts_dir (dir)) + return; + + free (dir); /* Well, we tried. */ +} + +void +add_ysym (name) + const char *name; +{ + if (link_info.notice_hash == (struct bfd_hash_table *) NULL) + { + link_info.notice_hash = ((struct bfd_hash_table *) + xmalloc (sizeof (struct bfd_hash_table))); + if (! bfd_hash_table_init_n (link_info.notice_hash, + bfd_hash_newfunc, + 61)) + einfo ("%P%F: bfd_hash_table_init failed: %E\n"); + } + + if (bfd_hash_lookup (link_info.notice_hash, name, true, true) + == (struct bfd_hash_entry *) NULL) + einfo ("%P%F: bfd_hash_lookup failed: %E\n"); +} + +/* Record a symbol to be wrapped, from the --wrap option. */ + +void +add_wrap (name) + const char *name; +{ + if (link_info.wrap_hash == NULL) + { + link_info.wrap_hash = ((struct bfd_hash_table *) + xmalloc (sizeof (struct bfd_hash_table))); + if (! bfd_hash_table_init_n (link_info.wrap_hash, + bfd_hash_newfunc, + 61)) + einfo ("%P%F: bfd_hash_table_init failed: %E\n"); + } + if (bfd_hash_lookup (link_info.wrap_hash, name, true, true) == NULL) + einfo ("%P%F: bfd_hash_lookup failed: %E\n"); +} + +/* Handle the -retain-symbols-file option. */ + +void +add_keepsyms_file (filename) + const char *filename; +{ + FILE *file; + char *buf; + size_t bufsize; + int c; + + if (link_info.strip == strip_some) + einfo ("%X%P: error: duplicate retain-symbols-file\n"); + + file = fopen (filename, "r"); + if (file == (FILE *) NULL) + { + bfd_set_error (bfd_error_system_call); + einfo ("%X%P: %s: %E\n", filename); + return; + } + + link_info.keep_hash = ((struct bfd_hash_table *) + xmalloc (sizeof (struct bfd_hash_table))); + if (! bfd_hash_table_init (link_info.keep_hash, bfd_hash_newfunc)) + einfo ("%P%F: bfd_hash_table_init failed: %E\n"); + + bufsize = 100; + buf = (char *) xmalloc (bufsize); + + c = getc (file); + while (c != EOF) + { + while (isspace (c)) + c = getc (file); + + if (c != EOF) + { + size_t len = 0; + + while (! isspace (c) && c != EOF) + { + buf[len] = c; + ++len; + if (len >= bufsize) + { + bufsize *= 2; + buf = xrealloc (buf, bufsize); + } + c = getc (file); + } + + buf[len] = '\0'; + + if (bfd_hash_lookup (link_info.keep_hash, buf, true, true) + == (struct bfd_hash_entry *) NULL) + einfo ("%P%F: bfd_hash_lookup for insertion failed: %E\n"); + } + } + + if (link_info.strip != strip_none) + einfo ("%P: `-retain-symbols-file' overrides `-s' and `-S'\n"); + + link_info.strip = strip_some; +} + +/* Callbacks from the BFD linker routines. */ + +/* This is called when BFD has decided to include an archive member in + a link. */ + +/*ARGSUSED*/ +static boolean +add_archive_element (info, abfd, name) + struct bfd_link_info *info; + bfd *abfd; + const char *name; +{ + lang_input_statement_type *input; + + input = ((lang_input_statement_type *) + xmalloc (sizeof (lang_input_statement_type))); + input->filename = abfd->filename; + input->local_sym_name = abfd->filename; + input->the_bfd = abfd; + input->asymbols = NULL; + input->next = NULL; + input->just_syms_flag = false; + input->loaded = false; + input->search_dirs_flag = false; + + /* FIXME: The following fields are not set: header.next, + header.type, closed, passive_position, symbol_count, + next_real_file, is_archive, target, real. This bit of code is + from the old decode_library_subfile function. I don't know + whether any of those fields matters. */ + + ldlang_add_file (input); + + if (config.map_file != (FILE *) NULL) + { + static boolean header_printed; + struct bfd_link_hash_entry *h; + bfd *from; + int len; + + h = bfd_link_hash_lookup (link_info.hash, name, false, false, true); + + if (h == NULL) + from = NULL; + else + { + switch (h->type) + { + default: + from = NULL; + break; + + case bfd_link_hash_defined: + case bfd_link_hash_defweak: + from = h->u.def.section->owner; + break; + + case bfd_link_hash_undefined: + case bfd_link_hash_undefweak: + from = h->u.undef.abfd; + break; + + case bfd_link_hash_common: + from = h->u.c.p->section->owner; + break; + } + } + + if (! header_printed) + { + char buf[100]; + + sprintf (buf, "%-29s %s\n\n", "Archive member included", + "because of file (symbol)"); + minfo ("%s", buf); + header_printed = true; + } + + if (bfd_my_archive (abfd) == NULL) + { + minfo ("%s", bfd_get_filename (abfd)); + len = strlen (bfd_get_filename (abfd)); + } + else + { + minfo ("%s(%s)", bfd_get_filename (bfd_my_archive (abfd)), + bfd_get_filename (abfd)); + len = (strlen (bfd_get_filename (bfd_my_archive (abfd))) + + strlen (bfd_get_filename (abfd)) + + 2); + } + + if (len >= 29) + { + print_nl (); + len = 0; + } + while (len < 30) + { + print_space (); + ++len; + } + + if (from != NULL) + minfo ("%B ", from); + if (h != NULL) + minfo ("(%T)\n", h->root.string); + else + minfo ("(%s)\n", name); + } + + if (trace_files || trace_file_tries) + info_msg ("%I\n", input); + + return true; +} + +/* This is called when BFD has discovered a symbol which is defined + multiple times. */ + +/*ARGSUSED*/ +static boolean +multiple_definition (info, name, obfd, osec, oval, nbfd, nsec, nval) + struct bfd_link_info *info; + const char *name; + bfd *obfd; + asection *osec; + bfd_vma oval; + bfd *nbfd; + asection *nsec; + bfd_vma nval; +{ + /* If either section has the output_section field set to + bfd_abs_section_ptr, it means that the section is being + discarded, and this is not really a multiple definition at all. + FIXME: It would be cleaner to somehow ignore symbols defined in + sections which are being discarded. */ + if ((osec->output_section != NULL + && ! bfd_is_abs_section (osec) + && bfd_is_abs_section (osec->output_section)) + || (nsec->output_section != NULL + && ! bfd_is_abs_section (nsec) + && bfd_is_abs_section (nsec->output_section))) + return true; + + einfo ("%X%C: multiple definition of `%T'\n", + nbfd, nsec, nval, name); + if (obfd != (bfd *) NULL) + einfo ("%D: first defined here\n", obfd, osec, oval); + return true; +} + +/* This is called when there is a definition of a common symbol, or + when a common symbol is found for a symbol that is already defined, + or when two common symbols are found. We only do something if + -warn-common was used. */ + +/*ARGSUSED*/ +static boolean +multiple_common (info, name, obfd, otype, osize, nbfd, ntype, nsize) + struct bfd_link_info *info; + const char *name; + bfd *obfd; + enum bfd_link_hash_type otype; + bfd_vma osize; + bfd *nbfd; + enum bfd_link_hash_type ntype; + bfd_vma nsize; +{ + if (! config.warn_common) + return true; + + if (ntype == bfd_link_hash_defined + || ntype == bfd_link_hash_defweak + || ntype == bfd_link_hash_indirect) + { + ASSERT (otype == bfd_link_hash_common); + einfo ("%B: warning: definition of `%T' overriding common\n", + nbfd, name); + if (obfd != NULL) + einfo ("%B: warning: common is here\n", obfd); + } + else if (otype == bfd_link_hash_defined + || otype == bfd_link_hash_defweak + || otype == bfd_link_hash_indirect) + { + ASSERT (ntype == bfd_link_hash_common); + einfo ("%B: warning: common of `%T' overridden by definition\n", + nbfd, name); + if (obfd != NULL) + einfo ("%B: warning: defined here\n", obfd); + } + else + { + ASSERT (otype == bfd_link_hash_common && ntype == bfd_link_hash_common); + if (osize > nsize) + { + einfo ("%B: warning: common of `%T' overridden by larger common\n", + nbfd, name); + if (obfd != NULL) + einfo ("%B: warning: larger common is here\n", obfd); + } + else if (nsize > osize) + { + einfo ("%B: warning: common of `%T' overriding smaller common\n", + nbfd, name); + if (obfd != NULL) + einfo ("%B: warning: smaller common is here\n", obfd); + } + else + { + einfo ("%B: warning: multiple common of `%T'\n", nbfd, name); + if (obfd != NULL) + einfo ("%B: warning: previous common is here\n", obfd); + } + } + + return true; +} + +/* This is called when BFD has discovered a set element. H is the + entry in the linker hash table for the set. SECTION and VALUE + represent a value which should be added to the set. */ + +/*ARGSUSED*/ +static boolean +add_to_set (info, h, reloc, abfd, section, value) + struct bfd_link_info *info; + struct bfd_link_hash_entry *h; + bfd_reloc_code_real_type reloc; + bfd *abfd; + asection *section; + bfd_vma value; +{ + if (config.warn_constructors) + einfo ("%P: warning: global constructor %s used\n", + h->root.string); + + if (! config.build_constructors) + return true; + + ldctor_add_set_entry (h, reloc, (const char *) NULL, section, value); + + if (h->type == bfd_link_hash_new) + { + h->type = bfd_link_hash_undefined; + h->u.undef.abfd = abfd; + /* We don't call bfd_link_add_undef to add this to the list of + undefined symbols because we are going to define it + ourselves. */ + } + + return true; +} + +/* This is called when BFD has discovered a constructor. This is only + called for some object file formats--those which do not handle + constructors in some more clever fashion. This is similar to + adding an element to a set, but less general. */ + +static boolean +constructor_callback (info, constructor, name, abfd, section, value) + struct bfd_link_info *info; + boolean constructor; + const char *name; + bfd *abfd; + asection *section; + bfd_vma value; +{ + char *s; + struct bfd_link_hash_entry *h; + char set_name[1 + sizeof "__CTOR_LIST__"]; + + if (config.warn_constructors) + einfo ("%P: warning: global constructor %s used\n", name); + + if (! config.build_constructors) + return true; + + /* Ensure that BFD_RELOC_CTOR exists now, so that we can give a + useful error message. */ + if (bfd_reloc_type_lookup (output_bfd, BFD_RELOC_CTOR) == NULL + && (link_info.relocateable + || bfd_reloc_type_lookup (abfd, BFD_RELOC_CTOR) == NULL)) + einfo ("%P%F: BFD backend error: BFD_RELOC_CTOR unsupported\n"); + + s = set_name; + if (bfd_get_symbol_leading_char (abfd) != '\0') + *s++ = bfd_get_symbol_leading_char (abfd); + if (constructor) + strcpy (s, "__CTOR_LIST__"); + else + strcpy (s, "__DTOR_LIST__"); + + h = bfd_link_hash_lookup (info->hash, set_name, true, true, true); + if (h == (struct bfd_link_hash_entry *) NULL) + einfo ("%P%F: bfd_link_hash_lookup failed: %E\n"); + if (h->type == bfd_link_hash_new) + { + h->type = bfd_link_hash_undefined; + h->u.undef.abfd = abfd; + /* We don't call bfd_link_add_undef to add this to the list of + undefined symbols because we are going to define it + ourselves. */ + } + + ldctor_add_set_entry (h, BFD_RELOC_CTOR, name, section, value); + return true; +} + +/* A structure used by warning_callback to pass information through + bfd_map_over_sections. */ + +struct warning_callback_info +{ + boolean found; + const char *warning; + const char *symbol; + asymbol **asymbols; +}; + +/* This is called when there is a reference to a warning symbol. */ + +/*ARGSUSED*/ +static boolean +warning_callback (info, warning, symbol, abfd, section, address) + struct bfd_link_info *info; + const char *warning; + const char *symbol; + bfd *abfd; + asection *section; + bfd_vma address; +{ + /* This is a hack to support warn_multiple_gp. FIXME: This should + have a cleaner interface, but what? */ + if (! config.warn_multiple_gp + && strcmp (warning, "using multiple gp values") == 0) + return true; + + if (section != NULL) + einfo ("%C: %s\n", abfd, section, address, warning); + else if (abfd == NULL) + einfo ("%P: %s\n", warning); + else if (symbol == NULL) + einfo ("%B: %s\n", abfd, warning); + else + { + lang_input_statement_type *entry; + asymbol **asymbols; + struct warning_callback_info info; + + /* Look through the relocs to see if we can find a plausible + address. */ + + entry = (lang_input_statement_type *) abfd->usrdata; + if (entry != NULL && entry->asymbols != NULL) + asymbols = entry->asymbols; + else + { + long symsize; + long symbol_count; + + symsize = bfd_get_symtab_upper_bound (abfd); + if (symsize < 0) + einfo ("%B%F: could not read symbols: %E\n", abfd); + asymbols = (asymbol **) xmalloc (symsize); + symbol_count = bfd_canonicalize_symtab (abfd, asymbols); + if (symbol_count < 0) + einfo ("%B%F: could not read symbols: %E\n", abfd); + if (entry != NULL) + { + entry->asymbols = asymbols; + entry->symbol_count = symbol_count; + } + } + + info.found = false; + info.warning = warning; + info.symbol = symbol; + info.asymbols = asymbols; + bfd_map_over_sections (abfd, warning_find_reloc, (PTR) &info); + + if (! info.found) + einfo ("%B: %s\n", abfd, warning); + + if (entry == NULL) + free (asymbols); + } + + return true; +} + +/* This is called by warning_callback for each section. It checks the + relocs of the section to see if it can find a reference to the + symbol which triggered the warning. If it can, it uses the reloc + to give an error message with a file and line number. */ + +static void +warning_find_reloc (abfd, sec, iarg) + bfd *abfd; + asection *sec; + PTR iarg; +{ + struct warning_callback_info *info = (struct warning_callback_info *) iarg; + long relsize; + arelent **relpp; + long relcount; + arelent **p, **pend; + + if (info->found) + return; + + relsize = bfd_get_reloc_upper_bound (abfd, sec); + if (relsize < 0) + einfo ("%B%F: could not read relocs: %E\n", abfd); + if (relsize == 0) + return; + + relpp = (arelent **) xmalloc (relsize); + relcount = bfd_canonicalize_reloc (abfd, sec, relpp, info->asymbols); + if (relcount < 0) + einfo ("%B%F: could not read relocs: %E\n", abfd); + + p = relpp; + pend = p + relcount; + for (; p < pend && *p != NULL; p++) + { + arelent *q = *p; + + if (q->sym_ptr_ptr != NULL + && *q->sym_ptr_ptr != NULL + && strcmp (bfd_asymbol_name (*q->sym_ptr_ptr), info->symbol) == 0) + { + /* We found a reloc for the symbol we are looking for. */ + einfo ("%C: %s\n", abfd, sec, q->address, info->warning); + info->found = true; + break; + } + } + + free (relpp); +} + +/* This is called when an undefined symbol is found. */ + +/*ARGSUSED*/ +static boolean +undefined_symbol (info, name, abfd, section, address) + struct bfd_link_info *info; + const char *name; + bfd *abfd; + asection *section; + bfd_vma address; +{ + static char *error_name; + static unsigned int error_count; + +#define MAX_ERRORS_IN_A_ROW 5 + + if (config.warn_once) + { + static struct bfd_hash_table *hash; + + /* Only warn once about a particular undefined symbol. */ + + if (hash == NULL) + { + hash = ((struct bfd_hash_table *) + xmalloc (sizeof (struct bfd_hash_table))); + if (! bfd_hash_table_init (hash, bfd_hash_newfunc)) + einfo ("%F%P: bfd_hash_table_init failed: %E\n"); + } + + if (bfd_hash_lookup (hash, name, false, false) != NULL) + return true; + + if (bfd_hash_lookup (hash, name, true, true) == NULL) + einfo ("%F%P: bfd_hash_lookup failed: %E\n"); + } + + /* We never print more than a reasonable number of errors in a row + for a single symbol. */ + if (error_name != (char *) NULL + && strcmp (name, error_name) == 0) + ++error_count; + else + { + error_count = 0; + if (error_name != (char *) NULL) + free (error_name); + error_name = buystring (name); + } + + if (section != NULL) + { + if (error_count < MAX_ERRORS_IN_A_ROW) + einfo ("%X%C: undefined reference to `%T'\n", + abfd, section, address, name); + else if (error_count == MAX_ERRORS_IN_A_ROW) + einfo ("%D: more undefined references to `%T' follow\n", + abfd, section, address, name); + } + else + { + if (error_count < MAX_ERRORS_IN_A_ROW) + einfo ("%X%B: undefined reference to `%T'\n", + abfd, name); + else if (error_count == MAX_ERRORS_IN_A_ROW) + einfo ("%B: more undefined references to `%T' follow\n", + abfd, name); + } + + return true; +} + +/* This is called when a reloc overflows. */ + +/*ARGSUSED*/ +static boolean +reloc_overflow (info, name, reloc_name, addend, abfd, section, address) + struct bfd_link_info *info; + const char *name; + const char *reloc_name; + bfd_vma addend; + bfd *abfd; + asection *section; + bfd_vma address; +{ + if (abfd == (bfd *) NULL) + einfo ("%P%X: generated"); + else + einfo ("%X%C:", abfd, section, address); + einfo (" relocation truncated to fit: %s %T", reloc_name, name); + if (addend != 0) + einfo ("+%v", addend); + einfo ("\n"); + return true; +} + +/* This is called when a dangerous relocation is made. */ + +/*ARGSUSED*/ +static boolean +reloc_dangerous (info, message, abfd, section, address) + struct bfd_link_info *info; + const char *message; + bfd *abfd; + asection *section; + bfd_vma address; +{ + if (abfd == (bfd *) NULL) + einfo ("%P%X: generated"); + else + einfo ("%X%C:", abfd, section, address); + einfo ("dangerous relocation: %s\n", message); + return true; +} + +/* This is called when a reloc is being generated attached to a symbol + that is not being output. */ + +/*ARGSUSED*/ +static boolean +unattached_reloc (info, name, abfd, section, address) + struct bfd_link_info *info; + const char *name; + bfd *abfd; + asection *section; + bfd_vma address; +{ + if (abfd == (bfd *) NULL) + einfo ("%P%X: generated"); + else + einfo ("%X%C:", abfd, section, address); + einfo (" reloc refers to symbol `%T' which is not being output\n", name); + return true; +} + +/* This is called if link_info.notice_all is set, or when a symbol in + link_info.notice_hash is found. Symbols are put in notice_hash + using the -y option. */ + +static boolean +notice (info, name, abfd, section, value) + struct bfd_link_info *info; + const char *name; + bfd *abfd; + asection *section; + bfd_vma value; +{ + if (! info->notice_all + || (info->notice_hash != NULL + && bfd_hash_lookup (info->notice_hash, name, false, false) != NULL)) + einfo ("%B: %s %s\n", abfd, + bfd_is_und_section (section) ? "reference to" : "definition of", + name); + + if (command_line.cref || nocrossref_list != NULL) + add_cref (name, abfd, section, value); + + return true; +} diff --git a/contrib/binutils/ld/ldmain.h b/contrib/binutils/ld/ldmain.h new file mode 100644 index 0000000..5c5f38b --- /dev/null +++ b/contrib/binutils/ld/ldmain.h @@ -0,0 +1,38 @@ +/* ldmain.h - + Copyright 1991, 1992, 1993 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GLD; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef LDMAIN_H +#define LDMAIN_H + +extern char *program_name; +extern bfd *output_bfd; +extern char *default_target; +extern boolean trace_files; +extern boolean trace_file_tries; +extern boolean version_printed; +extern boolean whole_archive; +extern int g_switch_value; +extern const char *output_filename; +extern struct bfd_link_info link_info; + +extern void add_ysym PARAMS ((const char *)); +extern void add_wrap PARAMS ((const char *)); +extern void add_keepsyms_file PARAMS ((const char *filename)); + +#endif diff --git a/contrib/binutils/ld/ldmisc.c b/contrib/binutils/ld/ldmisc.c new file mode 100644 index 0000000..282ce22 --- /dev/null +++ b/contrib/binutils/ld/ldmisc.c @@ -0,0 +1,534 @@ +/* ldmisc.c + Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Written by Steve Chamberlain of Cygnus Support. + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libiberty.h" +#include "demangle.h" + +#ifdef ANSI_PROTOTYPES +#include <stdarg.h> +#define USE_STDARG 1 +#else +#include <varargs.h> +#define USE_STDARG 0 +#endif + +#include "ld.h" +#include "ldmisc.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldgram.h" +#include "ldlex.h" +#include "ldmain.h" +#include "ldfile.h" + +static void vfinfo PARAMS ((FILE *, const char *, va_list)); + +/* + %% literal % + %F error is fatal + %P print program name + %S print script file and linenumber + %E current bfd error or errno + %I filename from a lang_input_statement_type + %B filename from a bfd + %T symbol name + %X no object output, fail return + %V hex bfd_vma + %v hex bfd_vma, no leading zeros + %W hex bfd_vma with 0x with no leading zeros taking up 8 spaces + %C clever filename:linenumber with function + %D like %C, but no function name + %G like %D, but only function name + %R info about a relent + %s arbitrary string, like printf + %d integer, like printf + %u integer, like printf +*/ + +char * +demangle (string) + const char *string; +{ + char *res; + + if (output_bfd != NULL + && bfd_get_symbol_leading_char (output_bfd) == string[0]) + ++string; + + /* This is a hack for better error reporting on XCOFF, or the MS PE */ + /* format. Xcoff has a single '.', while the NT PE for PPC has '..'. */ + /* So we remove all of them. */ + while(string[0] == '.') + ++string; + + res = cplus_demangle (string, DMGL_ANSI | DMGL_PARAMS); + return res ? res : xstrdup (string); +} + +static void +vfinfo (fp, fmt, arg) + FILE *fp; + const char *fmt; + va_list arg; +{ + boolean fatal = false; + + while (*fmt != '\0') + { + while (*fmt != '%' && *fmt != '\0') + { + putc (*fmt, fp); + fmt++; + } + + if (*fmt == '%') + { + fmt ++; + switch (*fmt++) + { + default: + fprintf (fp,"%%%c", fmt[-1]); + break; + + case '%': + /* literal % */ + putc ('%', fp); + break; + + case 'X': + /* no object output, fail return */ + config.make_executable = false; + break; + + case 'V': + /* hex bfd_vma */ + { + bfd_vma value = va_arg (arg, bfd_vma); + fprintf_vma (fp, value); + } + break; + + case 'v': + /* hex bfd_vma, no leading zeros */ + { + char buf[100]; + char *p = buf; + bfd_vma value = va_arg (arg, bfd_vma); + sprintf_vma (p, value); + while (*p == '0') + p++; + if (!*p) + p--; + fputs (p, fp); + } + break; + + case 'W': + /* hex bfd_vma with 0x with no leading zeroes taking up + 8 spaces. */ + { + char buf[100]; + bfd_vma value; + char *p; + int len; + + value = va_arg (arg, bfd_vma); + sprintf_vma (buf, value); + for (p = buf; *p == '0'; ++p) + ; + if (*p == '\0') + --p; + len = strlen (p); + while (len < 8) + { + putc (' ', fp); + ++len; + } + fprintf (fp, "0x%s", p); + } + break; + + case 'T': + /* Symbol name. */ + { + const char *name = va_arg (arg, const char *); + + if (name == (const char *) NULL) + fprintf (fp, "no symbol"); + else + { + char *demangled; + + demangled = demangle (name); + fprintf (fp, "%s", demangled); + free (demangled); + } + } + break; + + case 'B': + /* filename from a bfd */ + { + bfd *abfd = va_arg (arg, bfd *); + if (abfd->my_archive) + fprintf (fp, "%s(%s)", abfd->my_archive->filename, + abfd->filename); + else + fprintf (fp, "%s", abfd->filename); + } + break; + + case 'F': + /* error is fatal */ + fatal = true; + break; + + case 'P': + /* print program name */ + fprintf (fp, "%s", program_name); + break; + + case 'E': + /* current bfd error or errno */ + fprintf (fp, bfd_errmsg (bfd_get_error ())); + break; + + case 'I': + /* filename from a lang_input_statement_type */ + { + lang_input_statement_type *i; + + i = va_arg (arg, lang_input_statement_type *); + if (bfd_my_archive (i->the_bfd) != NULL) + fprintf (fp, "(%s)", + bfd_get_filename (bfd_my_archive (i->the_bfd))); + fprintf (fp, "%s", i->local_sym_name); + if (bfd_my_archive (i->the_bfd) == NULL + && strcmp (i->local_sym_name, i->filename) != 0) + fprintf (fp, " (%s)", i->filename); + } + break; + + case 'S': + /* print script file and linenumber */ + if (parsing_defsym) + fprintf (fp, "--defsym %s", lex_string); + else if (ldfile_input_filename != NULL) + fprintf (fp, "%s:%u", ldfile_input_filename, lineno); + else + fprintf (fp, "built in linker script:%u", lineno); + break; + + case 'R': + /* Print all that's interesting about a relent */ + { + arelent *relent = va_arg (arg, arelent *); + + finfo (fp, "%s+0x%v (type %s)", + (*(relent->sym_ptr_ptr))->name, + relent->addend, + relent->howto->name); + } + break; + + case 'C': + case 'D': + case 'G': + /* Clever filename:linenumber with function name if possible, + or section name as a last resort. The arguments are a BFD, + a section, and an offset. */ + { + static bfd *last_bfd; + static char *last_file = NULL; + static char *last_function = NULL; + bfd *abfd; + asection *section; + bfd_vma offset; + lang_input_statement_type *entry; + asymbol **asymbols; + const char *filename; + const char *functionname; + unsigned int linenumber; + boolean discard_last; + + abfd = va_arg (arg, bfd *); + section = va_arg (arg, asection *); + offset = va_arg (arg, bfd_vma); + + entry = (lang_input_statement_type *) abfd->usrdata; + if (entry != (lang_input_statement_type *) NULL + && entry->asymbols != (asymbol **) NULL) + asymbols = entry->asymbols; + else + { + long symsize; + long symbol_count; + + symsize = bfd_get_symtab_upper_bound (abfd); + if (symsize < 0) + einfo ("%B%F: could not read symbols\n", abfd); + asymbols = (asymbol **) xmalloc (symsize); + symbol_count = bfd_canonicalize_symtab (abfd, asymbols); + if (symbol_count < 0) + einfo ("%B%F: could not read symbols\n", abfd); + if (entry != (lang_input_statement_type *) NULL) + { + entry->asymbols = asymbols; + entry->symbol_count = symbol_count; + } + } + + discard_last = true; + if (bfd_find_nearest_line (abfd, section, asymbols, offset, + &filename, &functionname, + &linenumber)) + { + if (functionname != NULL && fmt[-1] == 'G') + { + finfo (fp, "%B:", abfd); + if (filename != NULL + && strcmp (filename, bfd_get_filename (abfd)) != 0) + fprintf (fp, "%s:", filename); + finfo (fp, "%T", functionname); + } + else if (functionname != NULL && fmt[-1] == 'C') + { + if (filename == (char *) NULL) + filename = abfd->filename; + + if (last_bfd == NULL + || last_file == NULL + || last_function == NULL + || last_bfd != abfd + || strcmp (last_file, filename) != 0 + || strcmp (last_function, functionname) != 0) + { + /* We use abfd->filename in this initial line, + in case filename is a .h file or something + similarly unhelpful. */ + finfo (fp, "%B: In function `%T':\n", + abfd, functionname); + + last_bfd = abfd; + if (last_file != NULL) + free (last_file); + last_file = buystring (filename); + if (last_function != NULL) + free (last_function); + last_function = buystring (functionname); + } + discard_last = false; + if (linenumber != 0) + fprintf (fp, "%s:%u", filename, linenumber); + else + finfo (fp, "%s(%s+0x%v)", filename, section->name, + offset); + } + else if (filename == NULL + || strcmp (filename, abfd->filename) == 0) + { + finfo (fp, "%B(%s+0x%v)", abfd, section->name, offset); + if (linenumber != 0) + finfo (fp, ":%u", linenumber); + } + else if (linenumber != 0) + finfo (fp, "%B:%s:%u", abfd, filename, linenumber); + else + finfo (fp, "%B(%s+0x%v):%s", abfd, section->name, offset, + filename); + } + else + finfo (fp, "%B(%s+0x%v)", abfd, section->name, offset); + + if (discard_last) + { + last_bfd = NULL; + if (last_file != NULL) + { + free (last_file); + last_file = NULL; + } + if (last_function != NULL) + { + free (last_function); + last_function = NULL; + } + } + } + break; + + case 's': + /* arbitrary string, like printf */ + fprintf (fp, "%s", va_arg (arg, char *)); + break; + + case 'd': + /* integer, like printf */ + fprintf (fp, "%d", va_arg (arg, int)); + break; + + case 'u': + /* unsigned integer, like printf */ + fprintf (fp, "%u", va_arg (arg, unsigned int)); + break; + } + } + } + + if (fatal == true) + xexit(1); +} + +/* Format info message and print on stdout. */ + +/* (You would think this should be called just "info", but then you + would hosed by LynxOS, which defines that name in its libc.) */ + +void +#if USE_STDARG +info_msg (const char *fmt, ...) +#else +info_msg (va_alist) + va_dcl +#endif +{ + va_list arg; + +#if ! USE_STDARG + const char *fmt; + + va_start (arg); + fmt = va_arg (arg, const char *); +#else + va_start (arg, fmt); +#endif + + vfinfo (stdout, fmt, arg); + va_end (arg); +} + +/* ('e' for error.) Format info message and print on stderr. */ + +void +#if USE_STDARG +einfo (const char *fmt, ...) +#else +einfo (va_alist) + va_dcl +#endif +{ + va_list arg; + +#if ! USE_STDARG + const char *fmt; + + va_start (arg); + fmt = va_arg (arg, const char *); +#else + va_start (arg, fmt); +#endif + + vfinfo (stderr, fmt, arg); + va_end (arg); +} + +void +info_assert (file, line) + const char *file; + unsigned int line; +{ + einfo ("%F%P: internal error %s %d\n", file, line); +} + +char * +buystring (x) + CONST char *CONST x; +{ + size_t l = strlen(x)+1; + char *r = xmalloc(l); + memcpy(r, x,l); + return r; +} + +/* ('m' for map) Format info message and print on map. */ + +void +#if USE_STDARG +minfo (const char *fmt, ...) +#else +minfo (va_alist) + va_dcl +#endif +{ + va_list arg; + +#if ! USE_STDARG + const char *fmt; + va_start (arg); + fmt = va_arg (arg, const char *); +#else + va_start (arg, fmt); +#endif + + vfinfo (config.map_file, fmt, arg); + va_end (arg); +} + +void +#if USE_STDARG +finfo (FILE *file, const char *fmt, ...) +#else +finfo (va_alist) + va_dcl +#endif +{ + va_list arg; + +#if ! USE_STDARG + FILE *file; + const char *fmt; + + va_start (arg); + file = va_arg (arg, FILE *); + fmt = va_arg (arg, const char *); +#else + va_start (arg, fmt); +#endif + + vfinfo (file, fmt, arg); + va_end (arg); +} + +/* Functions to print the link map. */ + +void +print_space () +{ + fprintf (config.map_file, " "); +} + +void +print_nl () +{ + fprintf (config.map_file, "\n"); +} diff --git a/contrib/binutils/ld/ldmisc.h b/contrib/binutils/ld/ldmisc.h new file mode 100644 index 0000000..f0073a7 --- /dev/null +++ b/contrib/binutils/ld/ldmisc.h @@ -0,0 +1,56 @@ +/* ldmisc.h - + Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GLD; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef LDMISC_H +#define LDMISC_H + +#ifdef ANSI_PROTOTYPES +extern void einfo PARAMS ((const char *, ...)); +extern void minfo PARAMS ((const char *, ...)); +extern void info_msg PARAMS ((const char *, ...)); +extern void finfo PARAMS ((FILE *, const char *, ...)); +#else +/* VARARGS*/ +extern void einfo (); +/* VARARGS*/ +extern void minfo (); +/* VARARGS*/ +extern void info_msg (); +/*VARARGS*/ +extern void finfo (); +#endif + +extern void info_assert PARAMS ((const char *, unsigned int)); +extern void yyerror PARAMS ((const char *)); +extern PTR xmalloc PARAMS ((size_t)); +extern PTR xrealloc PARAMS ((PTR, size_t)); +extern void xexit PARAMS ((int)); +extern char *buystring PARAMS ((CONST char *CONST)); + +#define ASSERT(x) \ +do { if (!(x)) info_assert(__FILE__,__LINE__); } while (0) + +#define FAIL() \ +do { info_assert(__FILE__,__LINE__); } while (0) + +extern void print_space PARAMS ((void)); +extern void print_nl PARAMS ((void)); +extern char *demangle PARAMS ((const char *)); + +#endif diff --git a/contrib/binutils/ld/ldver.c b/contrib/binutils/ld/ldver.c new file mode 100644 index 0000000..e8dc0b8 --- /dev/null +++ b/contrib/binutils/ld/ldver.c @@ -0,0 +1,49 @@ +/* ldver.c -- Print linker version. + Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. + +This file is part of GLD, the Gnu Linker. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include <stdio.h> +#include "bfd.h" +#include "sysdep.h" + +#include "ld.h" +#include "ldver.h" +#include "ldemul.h" +#include "ldmain.h" + +const char *ld_program_version = "2.8.1"; + +void +ldversion (noisy) + int noisy; +{ + fprintf (stdout, "GNU ld version %s (with BFD %s)\n", + ld_program_version, BFD_VERSION); + + if (noisy) + { + ld_emulation_xfer_type **ptr = ld_emulations; + + printf (" Supported emulations:\n"); + while (*ptr) + { + printf (" %s\n", (*ptr)->emulation_name); + ptr++; + } + } +} diff --git a/contrib/binutils/ld/ldver.h b/contrib/binutils/ld/ldver.h new file mode 100644 index 0000000..697b6bc --- /dev/null +++ b/contrib/binutils/ld/ldver.h @@ -0,0 +1,22 @@ +/* ldver.h -- Header file for ldver.c. + Copyright (C) 1991, 92, 93, 95, 1996 Free Software Foundation, Inc. + +This file is part of GLD, the Gnu Linker. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +extern const char *ld_program_version; + +void ldversion PARAMS ((int)); diff --git a/contrib/binutils/ld/ldwrite.c b/contrib/binutils/ld/ldwrite.c new file mode 100644 index 0000000..b4d47a0 --- /dev/null +++ b/contrib/binutils/ld/ldwrite.c @@ -0,0 +1,490 @@ +/* ldwrite.c -- write out the linked file + Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + Written by Steve Chamberlain sac@cygnus.com + +This file is part of GLD, the Gnu Linker. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" +#include "libiberty.h" + +#include "ld.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldwrite.h" +#include "ldmisc.h" +#include "ldgram.h" +#include "ldmain.h" + +static void build_link_order PARAMS ((lang_statement_union_type *)); +static asection *clone_section PARAMS ((bfd *, asection *, int *)); +static void split_sections PARAMS ((bfd *, struct bfd_link_info *)); + +/* Build link_order structures for the BFD linker. */ + +static void +build_link_order (statement) + lang_statement_union_type *statement; +{ + switch (statement->header.type) + { + case lang_data_statement_enum: + { + asection *output_section; + struct bfd_link_order *link_order; + bfd_vma value; + + output_section = statement->data_statement.output_section; + ASSERT (output_section->owner == output_bfd); + + link_order = bfd_new_link_order (output_bfd, output_section); + if (link_order == NULL) + einfo ("%P%F: bfd_new_link_order failed\n"); + + link_order->type = bfd_data_link_order; + link_order->offset = statement->data_statement.output_vma; + link_order->u.data.contents = (bfd_byte *) xmalloc (QUAD_SIZE); + + value = statement->data_statement.value; + + /* If the endianness of the output BFD is not known, then we + base the endianness of the data on the first input file. + By convention, the bfd_put routines for an unknown + endianness are big endian, so we must swap here if the + input file is little endian. */ + if (! bfd_big_endian (output_bfd) + && ! bfd_little_endian (output_bfd)) + { + boolean swap; + + swap = false; + if (command_line.endian == ENDIAN_LITTLE) + swap = true; + else if (command_line.endian == ENDIAN_UNSET) + { + LANG_FOR_EACH_INPUT_STATEMENT (s) + { + if (s->the_bfd != NULL) + { + if (bfd_little_endian (s->the_bfd)) + swap = true; + break; + } + } + } + + if (swap) + { + bfd_byte buffer[8]; + + switch (statement->data_statement.type) + { + case QUAD: + bfd_putl64 (value, buffer); + value = bfd_getb64 (buffer); + break; + case LONG: + bfd_putl32 (value, buffer); + value = bfd_getb32 (buffer); + break; + case SHORT: + bfd_putl16 (value, buffer); + value = bfd_getb16 (buffer); + break; + case BYTE: + break; + default: + abort (); + } + } + } + + ASSERT (output_section->owner == output_bfd); + switch (statement->data_statement.type) + { + case QUAD: + bfd_put_64 (output_bfd, value, link_order->u.data.contents); + link_order->size = QUAD_SIZE; + break; + case LONG: + bfd_put_32 (output_bfd, value, link_order->u.data.contents); + link_order->size = LONG_SIZE; + break; + case SHORT: + bfd_put_16 (output_bfd, value, link_order->u.data.contents); + link_order->size = SHORT_SIZE; + break; + case BYTE: + bfd_put_8 (output_bfd, value, link_order->u.data.contents); + link_order->size = BYTE_SIZE; + break; + default: + abort (); + } + } + break; + + case lang_reloc_statement_enum: + { + lang_reloc_statement_type *rs; + asection *output_section; + struct bfd_link_order *link_order; + + rs = &statement->reloc_statement; + + output_section = rs->output_section; + ASSERT (output_section->owner == output_bfd); + + link_order = bfd_new_link_order (output_bfd, output_section); + if (link_order == NULL) + einfo ("%P%F: bfd_new_link_order failed\n"); + + link_order->offset = rs->output_vma; + link_order->size = bfd_get_reloc_size (rs->howto); + + link_order->u.reloc.p = + ((struct bfd_link_order_reloc *) + xmalloc (sizeof (struct bfd_link_order_reloc))); + + link_order->u.reloc.p->reloc = rs->reloc; + link_order->u.reloc.p->addend = rs->addend_value; + + if (rs->name == NULL) + { + link_order->type = bfd_section_reloc_link_order; + if (rs->section->owner == output_bfd) + link_order->u.reloc.p->u.section = rs->section; + else + { + link_order->u.reloc.p->u.section = rs->section->output_section; + link_order->u.reloc.p->addend += rs->section->output_offset; + } + } + else + { + link_order->type = bfd_symbol_reloc_link_order; + link_order->u.reloc.p->u.name = rs->name; + } + } + break; + + case lang_input_section_enum: + /* Create a new link_order in the output section with this + attached */ + if (statement->input_section.ifile->just_syms_flag == false) + { + asection *i = statement->input_section.section; + asection *output_section = i->output_section; + + ASSERT (output_section->owner == output_bfd); + + if ((output_section->flags & SEC_HAS_CONTENTS) != 0) + { + struct bfd_link_order *link_order; + + link_order = bfd_new_link_order (output_bfd, output_section); + + if (i->flags & SEC_NEVER_LOAD) + { + /* We've got a never load section inside one which + is going to be output, we'll change it into a + fill link_order */ + link_order->type = bfd_fill_link_order; + link_order->u.fill.value = 0; + } + else + { + link_order->type = bfd_indirect_link_order; + link_order->u.indirect.section = i; + ASSERT (i->output_section == output_section); + } + if (i->_cooked_size) + link_order->size = i->_cooked_size; + else + link_order->size = bfd_get_section_size_before_reloc (i); + link_order->offset = i->output_offset; + } + } + break; + + case lang_padding_statement_enum: + /* Make a new link_order with the right filler */ + { + asection *output_section; + struct bfd_link_order *link_order; + + output_section = statement->padding_statement.output_section; + ASSERT (statement->padding_statement.output_section->owner + == output_bfd); + if ((output_section->flags & SEC_HAS_CONTENTS) != 0) + { + link_order = bfd_new_link_order (output_bfd, output_section); + link_order->type = bfd_fill_link_order; + link_order->size = statement->padding_statement.size; + link_order->offset = statement->padding_statement.output_offset; + link_order->u.fill.value = statement->padding_statement.fill; + } + } + break; + + default: + /* All the other ones fall through */ + break; + } +} + +/* Call BFD to write out the linked file. */ + + +/**********************************************************************/ + + +/* Wander around the input sections, make sure that + we'll never try and create an output section with more relocs + than will fit.. Do this by always assuming the worst case, and + creating new output sections with all the right bits */ +#define TESTIT 1 +static asection * +clone_section (abfd, s, count) + bfd *abfd; + asection *s; + int *count; +{ +#define SSIZE 8 + char sname[SSIZE]; /* ?? find the name for this size */ + asection *n; + struct bfd_link_hash_entry *h; + /* Invent a section name - use first five + chars of base section name and a digit suffix */ + do + { + unsigned int i; + char b[6]; + for (i = 0; i < sizeof (b) - 1 && s->name[i]; i++) + b[i] = s->name[i]; + b[i] = 0; + sprintf (sname, "%s%d", b, (*count)++); + } + while (bfd_get_section_by_name (abfd, sname)); + + n = bfd_make_section_anyway (abfd, xstrdup (sname)); + + /* Create a symbol of the same name */ + + h = bfd_link_hash_lookup (link_info.hash, + sname, true, true, false); + h->type = bfd_link_hash_defined; + h->u.def.value = 0; + h->u.def.section = n ; + + + n->flags = s->flags; + n->vma = s->vma; + n->user_set_vma = s->user_set_vma; + n->lma = s->lma; + n->_cooked_size = 0; + n->_raw_size = 0; + n->output_offset = s->output_offset; + n->output_section = n; + n->orelocation = 0; + n->reloc_count = 0; + n->alignment_power = s->alignment_power; + return n; +} + +#if TESTING +static void +ds (s) + asection *s; +{ + struct bfd_link_order *l = s->link_order_head; + printf ("vma %x size %x\n", s->vma, s->_raw_size); + while (l) + { + if (l->type == bfd_indirect_link_order) + { + printf ("%8x %s\n", l->offset, l->u.indirect.section->owner->filename); + } + else + { + printf ("%8x something else\n", l->offset); + } + l = l->next; + } + printf ("\n"); +} +dump (s, a1, a2) + char *s; + asection *a1; + asection *a2; +{ + printf ("%s\n", s); + ds (a1); + ds (a2); +} + +static void +sanity_check (abfd) + bfd *abfd; +{ + asection *s; + for (s = abfd->sections; s; s = s->next) + { + struct bfd_link_order *p; + bfd_vma prev = 0; + for (p = s->link_order_head; p; p = p->next) + { + if (p->offset > 100000) + abort (); + if (p->offset < prev) + abort (); + prev = p->offset; + } + } +} +#else +#define sanity_check(a) +#define dump(a, b, c) +#endif + +static void +split_sections (abfd, info) + bfd *abfd; + struct bfd_link_info *info; +{ + asection *original_sec; + int nsecs = abfd->section_count; + sanity_check (abfd); + /* look through all the original sections */ + for (original_sec = abfd->sections; + original_sec && nsecs; + original_sec = original_sec->next, nsecs--) + { + boolean first = true; + int count = 0; + int lines = 0; + int relocs = 0; + struct bfd_link_order **pp; + bfd_vma vma = original_sec->vma; + bfd_vma shift_offset = 0; + asection *cursor = original_sec; + + /* count up the relocations and line entries to see if + anything would be too big to fit */ + for (pp = &(cursor->link_order_head); *pp; pp = &((*pp)->next)) + { + struct bfd_link_order *p = *pp; + int thislines = 0; + int thisrelocs = 0; + if (p->type == bfd_indirect_link_order) + { + asection *sec; + + sec = p->u.indirect.section; + + if (info->strip == strip_none + || info->strip == strip_some) + thislines = sec->lineno_count; + + if (info->relocateable) + thisrelocs = sec->reloc_count; + + } + else if (info->relocateable + && (p->type == bfd_section_reloc_link_order + || p->type == bfd_symbol_reloc_link_order)) + thisrelocs++; + + if (! first + && (thisrelocs + relocs > config.split_by_reloc + || thislines + lines > config.split_by_reloc + || config.split_by_file)) + { + /* create a new section and put this link order and the + following link orders into it */ + struct bfd_link_order *l = p; + asection *n = clone_section (abfd, cursor, &count); + *pp = NULL; /* Snip off link orders from old section */ + n->link_order_head = l; /* attach to new section */ + pp = &n->link_order_head; + + /* change the size of the original section and + update the vma of the new one */ + + dump ("before snip", cursor, n); + + n->_raw_size = cursor->_raw_size - l->offset; + cursor->_raw_size = l->offset; + + vma += cursor->_raw_size; + n->lma = n->vma = vma; + + shift_offset = l->offset; + + /* run down the chain and change the output section to + the right one, update the offsets too */ + + while (l) + { + l->offset -= shift_offset; + if (l->type == bfd_indirect_link_order) + { + l->u.indirect.section->output_section = n; + l->u.indirect.section->output_offset = l->offset; + } + l = l->next; + } + dump ("after snip", cursor, n); + cursor = n; + relocs = thisrelocs; + lines = thislines; + } + else + { + relocs += thisrelocs; + lines += thislines; + } + + first = false; + } + } + sanity_check (abfd); +} +/**********************************************************************/ +void +ldwrite () +{ + /* Reset error indicator, which can typically something like invalid + format from openning up the .o files */ + bfd_set_error (bfd_error_no_error); + lang_for_each_statement (build_link_order); + + if (config.split_by_reloc || config.split_by_file) + split_sections (output_bfd, &link_info); + if (!bfd_final_link (output_bfd, &link_info)) + { + /* If there was an error recorded, print it out. Otherwise assume + an appropriate error message like unknown symbol was printed + out. */ + + if (bfd_get_error () != bfd_error_no_error) + einfo ("%F%P: final link failed: %E\n", output_bfd); + else + xexit(1); + } +} diff --git a/contrib/binutils/ld/ldwrite.h b/contrib/binutils/ld/ldwrite.h new file mode 100644 index 0000000..68d8b52 --- /dev/null +++ b/contrib/binutils/ld/ldwrite.h @@ -0,0 +1,20 @@ +/* ldwrite.h - + Copyright 1991, 1992, 1993 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GLD; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +void ldwrite PARAMS ((void)); diff --git a/contrib/binutils/ld/lexsup.c b/contrib/binutils/ld/lexsup.c new file mode 100644 index 0000000..2ca3d23 --- /dev/null +++ b/contrib/binutils/ld/lexsup.c @@ -0,0 +1,948 @@ +/* Parse options for the GNU linker. + Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libiberty.h" +#include <stdio.h> +#include <string.h> +#include <ctype.h> +#include "getopt.h" +#include "bfdlink.h" +#include "ld.h" +#include "ldmain.h" +#include "ldmisc.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldgram.h" +#include "ldlex.h" +#include "ldfile.h" +#include "ldver.h" +#include "ldemul.h" + +/* Somewhere above, sys/stat.h got included . . . . */ +#if !defined(S_ISDIR) && defined(S_IFDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +/* Omit args to avoid the possibility of clashing with a system header + that might disagree about consts. */ +unsigned long strtoul (); + +static void set_default_dirlist PARAMS ((char *dirlist_ptr)); +static void set_section_start PARAMS ((char *sect, char *valstr)); +static void help PARAMS ((void)); + +/* Non-zero if we are processing a --defsym from the command line. */ +int parsing_defsym = 0; + +/* Codes used for the long options with no short synonyms. 150 isn't + special; it's just an arbitrary non-ASCII char value. */ + +#define OPTION_ASSERT 150 +#define OPTION_CALL_SHARED (OPTION_ASSERT + 1) +#define OPTION_CREF (OPTION_CALL_SHARED + 1) +#define OPTION_DEFSYM (OPTION_CREF + 1) +#define OPTION_DYNAMIC_LINKER (OPTION_DEFSYM + 1) +#define OPTION_EB (OPTION_DYNAMIC_LINKER + 1) +#define OPTION_EL (OPTION_EB + 1) +#define OPTION_EMBEDDED_RELOCS (OPTION_EL + 1) +#define OPTION_EXPORT_DYNAMIC (OPTION_EMBEDDED_RELOCS + 1) +#define OPTION_HELP (OPTION_EXPORT_DYNAMIC + 1) +#define OPTION_IGNORE (OPTION_HELP + 1) +#define OPTION_MAP (OPTION_IGNORE + 1) +#define OPTION_NO_KEEP_MEMORY (OPTION_MAP + 1) +#define OPTION_NOINHIBIT_EXEC (OPTION_NO_KEEP_MEMORY + 1) +#define OPTION_NON_SHARED (OPTION_NOINHIBIT_EXEC + 1) +#define OPTION_NO_WHOLE_ARCHIVE (OPTION_NON_SHARED + 1) +#define OPTION_OFORMAT (OPTION_NO_WHOLE_ARCHIVE + 1) +#define OPTION_RELAX (OPTION_OFORMAT + 1) +#define OPTION_RETAIN_SYMBOLS_FILE (OPTION_RELAX + 1) +#define OPTION_RPATH (OPTION_RETAIN_SYMBOLS_FILE + 1) +#define OPTION_RPATH_LINK (OPTION_RPATH + 1) +#define OPTION_SHARED (OPTION_RPATH_LINK + 1) +#define OPTION_SONAME (OPTION_SHARED + 1) +#define OPTION_SORT_COMMON (OPTION_SONAME + 1) +#define OPTION_STATS (OPTION_SORT_COMMON + 1) +#define OPTION_SYMBOLIC (OPTION_STATS + 1) +#define OPTION_TBSS (OPTION_SYMBOLIC + 1) +#define OPTION_TDATA (OPTION_TBSS + 1) +#define OPTION_TTEXT (OPTION_TDATA + 1) +#define OPTION_TRADITIONAL_FORMAT (OPTION_TTEXT + 1) +#define OPTION_UR (OPTION_TRADITIONAL_FORMAT + 1) +#define OPTION_VERBOSE (OPTION_UR + 1) +#define OPTION_VERSION (OPTION_VERBOSE + 1) +#define OPTION_VERSION_SCRIPT (OPTION_VERSION + 1) +#define OPTION_WARN_COMMON (OPTION_VERSION_SCRIPT + 1) +#define OPTION_WARN_CONSTRUCTORS (OPTION_WARN_COMMON + 1) +#define OPTION_WARN_MULTIPLE_GP (OPTION_WARN_CONSTRUCTORS + 1) +#define OPTION_WARN_ONCE (OPTION_WARN_MULTIPLE_GP + 1) +#define OPTION_WARN_SECTION_ALIGN (OPTION_WARN_ONCE + 1) +#define OPTION_SPLIT_BY_RELOC (OPTION_WARN_SECTION_ALIGN + 1) +#define OPTION_SPLIT_BY_FILE (OPTION_SPLIT_BY_RELOC + 1) +#define OPTION_WHOLE_ARCHIVE (OPTION_SPLIT_BY_FILE + 1) +#define OPTION_WRAP (OPTION_WHOLE_ARCHIVE + 1) +#define OPTION_FORCE_EXE_SUFFIX (OPTION_WRAP + 1) + +/* The long options. This structure is used for both the option + parsing and the help text. */ + +struct ld_option +{ + /* The long option information. */ + struct option opt; + /* The short option with the same meaning ('\0' if none). */ + char shortopt; + /* The name of the argument (NULL if none). */ + const char *arg; + /* The documentation string. If this is NULL, this is a synonym for + the previous option. */ + const char *doc; + enum + { + /* Use one dash before long option name. */ + ONE_DASH, + /* Use two dashes before long option name. */ + TWO_DASHES, + /* Don't mention this option in --help output. */ + NO_HELP + } control; +}; + +static const struct ld_option ld_options[] = +{ + { {NULL, required_argument, NULL, '\0'}, + 'a', "KEYWORD", "Shared library control for HP/UX compatibility", + ONE_DASH }, + { {"architecture", required_argument, NULL, 'A'}, + 'A', "ARCH", "Set architecture" , TWO_DASHES }, + { {"format", required_argument, NULL, 'b'}, + 'b', "TARGET", "Specify target for following input files", TWO_DASHES }, + { {"mri-script", required_argument, NULL, 'c'}, + 'c', "FILE", "Read MRI format linker script", TWO_DASHES }, + { {"dc", no_argument, NULL, 'd'}, + 'd', NULL, "Force common symbols to be defined", ONE_DASH }, + { {"dp", no_argument, NULL, 'd'}, + '\0', NULL, NULL, ONE_DASH }, + { {"entry", required_argument, NULL, 'e'}, + 'e', "ADDRESS", "Set start address", TWO_DASHES }, + { {"export-dynamic", no_argument, NULL, OPTION_EXPORT_DYNAMIC}, + 'E', NULL, "Export all dynamic symbols", TWO_DASHES }, + { {"auxiliary", required_argument, NULL, 'f'}, + 'f', "SHLIB", "Auxiliary filter for shared object symbol table", + TWO_DASHES }, + { {"filter", required_argument, NULL, 'F'}, + 'F', "SHLIB", "Filter for shared object symbol table", TWO_DASHES }, + { {NULL, no_argument, NULL, '\0'}, + 'g', NULL, "Ignored", ONE_DASH }, + { {"gpsize", required_argument, NULL, 'G'}, + 'G', "SIZE", "Small data size (if no size, same as --shared)", + TWO_DASHES }, + { {"soname", required_argument, NULL, OPTION_SONAME}, + 'h', "FILENAME", "Set internal name of shared library", ONE_DASH }, + { {"library", required_argument, NULL, 'l'}, + 'l', "LIBNAME", "Search for library LIBNAME", TWO_DASHES }, + { {"library-path", required_argument, NULL, 'L'}, + 'L', "DIRECTORY", "Add DIRECTORY to library search path", TWO_DASHES }, + { {NULL, required_argument, NULL, '\0'}, + 'm', "EMULATION", "Set emulation", ONE_DASH }, + { {"print-map", no_argument, NULL, 'M'}, + 'M', NULL, "Print map file on standard output", TWO_DASHES }, + { {"nmagic", no_argument, NULL, 'n'}, + 'n', NULL, "Do not page align data", TWO_DASHES }, + { {"omagic", no_argument, NULL, 'N'}, + 'N', NULL, "Do not page align data, do not make text readonly", + TWO_DASHES }, + { {"output", required_argument, NULL, 'o'}, + 'o', "FILE", "Set output file name", TWO_DASHES }, + { {NULL, required_argument, NULL, '\0'}, + 'O', NULL, "Ignored", ONE_DASH }, + { {"relocateable", no_argument, NULL, 'r'}, + 'r', NULL, "Generate relocateable output", TWO_DASHES }, + { {NULL, no_argument, NULL, '\0'}, + 'i', NULL, NULL, ONE_DASH }, + { {"just-symbols", required_argument, NULL, 'R'}, + 'R', "FILE", "Just link symbols (if directory, same as --rpath)", + TWO_DASHES }, + { {"strip-all", no_argument, NULL, 's'}, + 's', NULL, "Strip all symbols", TWO_DASHES }, + { {"strip-debug", no_argument, NULL, 'S'}, + 'S', NULL, "Strip debugging symbols", TWO_DASHES }, + { {"trace", no_argument, NULL, 't'}, + 't', NULL, "Trace file opens", TWO_DASHES }, + { {"script", required_argument, NULL, 'T'}, + 'T', "FILE", "Read linker script", TWO_DASHES }, + { {"undefined", required_argument, NULL, 'u'}, + 'u', "SYMBOL", "Start with undefined reference to SYMBOL", TWO_DASHES }, + { {"version", no_argument, NULL, OPTION_VERSION}, + 'v', NULL, "Print version information", TWO_DASHES }, + { {NULL, no_argument, NULL, '\0'}, + 'V', NULL, "Print version and emulation information", ONE_DASH }, + { {"discard-all", no_argument, NULL, 'x'}, + 'x', NULL, "Discard all local symbols", TWO_DASHES }, + { {"discard-locals", no_argument, NULL, 'X'}, + 'X', NULL, "Discard temporary local symbols", TWO_DASHES }, + { {"trace-symbol", required_argument, NULL, 'y'}, + 'y', "SYMBOL", "Trace mentions of SYMBOL", TWO_DASHES }, + { {NULL, required_argument, NULL, '\0'}, + 'Y', "PATH", "Default search path for Solaris compatibility", ONE_DASH }, + { {NULL, required_argument, NULL, '\0'}, + 'z', "KEYWORD", "Ignored for Solaris compatibility", ONE_DASH }, + { {"start-group", no_argument, NULL, '('}, + '(', NULL, "Start a group", TWO_DASHES }, + { {"end-group", no_argument, NULL, ')'}, + ')', NULL, "End a group", TWO_DASHES }, + { {"assert", required_argument, NULL, OPTION_ASSERT}, + '\0', "KEYWORD", "Ignored for SunOS compatibility", ONE_DASH }, + { {"Bdynamic", no_argument, NULL, OPTION_CALL_SHARED}, + '\0', NULL, "Link against shared libraries", ONE_DASH }, + { {"dy", no_argument, NULL, OPTION_CALL_SHARED}, + '\0', NULL, NULL, ONE_DASH }, + { {"call_shared", no_argument, NULL, OPTION_CALL_SHARED}, + '\0', NULL, NULL, ONE_DASH }, + { {"Bstatic", no_argument, NULL, OPTION_NON_SHARED}, + '\0', NULL, "Do not link against shared libraries", ONE_DASH }, + { {"dn", no_argument, NULL, OPTION_NON_SHARED}, + '\0', NULL, NULL, ONE_DASH }, + { {"non_shared", no_argument, NULL, OPTION_NON_SHARED}, + '\0', NULL, NULL, ONE_DASH }, + { {"static", no_argument, NULL, OPTION_NON_SHARED}, + '\0', NULL, NULL, ONE_DASH }, + { {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC}, + '\0', NULL, "Bind global references locally", ONE_DASH }, + { {"cref", no_argument, NULL, OPTION_CREF}, + '\0', NULL, "Output cross reference table", TWO_DASHES }, + { {"defsym", required_argument, NULL, OPTION_DEFSYM}, + '\0', "SYMBOL=EXPRESSION", "Define a symbol", TWO_DASHES }, + { {"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER}, + '\0', "PROGRAM", "Set the dynamic linker to use", TWO_DASHES }, + { {"EB", no_argument, NULL, OPTION_EB}, + '\0', NULL, "Link big-endian objects", ONE_DASH }, + { {"EL", no_argument, NULL, OPTION_EL}, + '\0', NULL, "Link little-endian objects", ONE_DASH }, + { {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS}, + '\0', NULL, "Generate embedded relocs", TWO_DASHES}, + { {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX}, + '\0', NULL, "Force generation of file with .exe suffix", TWO_DASHES}, + { {"help", no_argument, NULL, OPTION_HELP}, + '\0', NULL, "Print option help", TWO_DASHES }, + { {"Map", required_argument, NULL, OPTION_MAP}, + '\0', "FILE", "Write a map file", ONE_DASH }, + { {"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY}, + '\0', NULL, "Use less memory and more disk I/O", TWO_DASHES }, + { {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE}, + '\0', NULL, "Turn off --whole-archive", TWO_DASHES }, + { {"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC}, + '\0', NULL, "Create an output file even if errors occur", TWO_DASHES }, + { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC}, + '\0', NULL, NULL, NO_HELP }, + { {"oformat", required_argument, NULL, OPTION_OFORMAT}, + '\0', "TARGET", "Specify target of output file", TWO_DASHES }, + { {"qmagic", no_argument, NULL, OPTION_IGNORE}, + '\0', NULL, "Ignored for Linux compatibility", ONE_DASH }, + { {"Qy", no_argument, NULL, OPTION_IGNORE}, + '\0', NULL, "Ignored for SVR4 compatibility", ONE_DASH }, + { {"relax", no_argument, NULL, OPTION_RELAX}, + '\0', NULL, "Relax branches on certain targets", TWO_DASHES }, + { {"retain-symbols-file", required_argument, NULL, + OPTION_RETAIN_SYMBOLS_FILE}, + '\0', "FILE", "Keep only symbols listed in FILE", TWO_DASHES }, + { {"rpath", required_argument, NULL, OPTION_RPATH}, + '\0', "PATH", "Set runtime shared library search path", ONE_DASH }, + { {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK}, + '\0', "PATH", "Set link time shared library search path", ONE_DASH }, + { {"shared", no_argument, NULL, OPTION_SHARED}, + '\0', NULL, "Create a shared library", ONE_DASH }, + { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD. */ + '\0', NULL, NULL, ONE_DASH }, + { {"sort-common", no_argument, NULL, OPTION_SORT_COMMON}, + '\0', NULL, "Sort common symbols by size", TWO_DASHES }, + { {"sort_common", no_argument, NULL, OPTION_SORT_COMMON}, + '\0', NULL, NULL, NO_HELP }, + { {"split-by-file", no_argument, NULL, OPTION_SPLIT_BY_FILE}, + '\0', NULL, "Split output sections for each file", TWO_DASHES }, + { {"split-by-reloc", required_argument, NULL, OPTION_SPLIT_BY_RELOC}, + '\0', "COUNT", "Split output sections every COUNT relocs", TWO_DASHES }, + { {"stats", no_argument, NULL, OPTION_STATS}, + '\0', NULL, "Print memory usage statistics", TWO_DASHES }, + { {"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT}, + '\0', NULL, "Use same format as native linker", TWO_DASHES }, + { {"Tbss", required_argument, NULL, OPTION_TBSS}, + '\0', "ADDRESS", "Set address of .bss section", ONE_DASH }, + { {"Tdata", required_argument, NULL, OPTION_TDATA}, + '\0', "ADDRESS", "Set address of .data section", ONE_DASH }, + { {"Ttext", required_argument, NULL, OPTION_TTEXT}, + '\0', "ADDRESS", "Set address of .text section", ONE_DASH }, + { {"Ur", no_argument, NULL, OPTION_UR}, + '\0', NULL, "Build global constructor/destructor tables", ONE_DASH }, + { {"verbose", no_argument, NULL, OPTION_VERBOSE}, + '\0', NULL, "Output lots of information during link", TWO_DASHES }, + { {"dll-verbose", no_argument, NULL, OPTION_VERBOSE}, /* Linux. */ + '\0', NULL, NULL, NO_HELP }, + { {"version-script", required_argument, NULL, OPTION_VERSION_SCRIPT }, + '\0', "FILE", "Read version information script", TWO_DASHES }, + { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON}, + '\0', NULL, "Warn about duplicate common symbols", TWO_DASHES }, + { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS}, + '\0', NULL, "Warn if global constructors/destructors are seen", + TWO_DASHES }, + { {"warn-multiple-gp", no_argument, NULL, OPTION_WARN_MULTIPLE_GP}, + '\0', NULL, "Warn if the multiple GP values are used", TWO_DASHES }, + { {"warn-once", no_argument, NULL, OPTION_WARN_ONCE}, + '\0', NULL, "Warn only once per undefined symbol", TWO_DASHES }, + { {"warn-section-align", no_argument, NULL, OPTION_WARN_SECTION_ALIGN}, + '\0', NULL, "Warn if start of section changes due to alignment", + TWO_DASHES }, + { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE}, + '\0', NULL, "Include all objects from following archives", TWO_DASHES }, + { {"wrap", required_argument, NULL, OPTION_WRAP}, + '\0', "SYMBOL", "Use wrapper functions for SYMBOL", TWO_DASHES } +}; + +#define OPTION_COUNT (sizeof ld_options / sizeof ld_options[0]) + +void +parse_args (argc, argv) + int argc; + char **argv; +{ + int i, is, il; + int ingroup = 0; + char *default_dirlist = NULL; + char shortopts[OPTION_COUNT * 3 + 2]; + struct option longopts[OPTION_COUNT + 1]; + + /* Starting the short option string with '-' is for programs that + expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. */ + shortopts[0] = '-'; + is = 1; + il = 0; + for (i = 0; i < OPTION_COUNT; i++) + { + if (ld_options[i].shortopt != '\0') + { + shortopts[is] = ld_options[i].shortopt; + ++is; + if (ld_options[i].opt.has_arg == required_argument + || ld_options[i].opt.has_arg == optional_argument) + { + shortopts[is] = ':'; + ++is; + if (ld_options[i].opt.has_arg == optional_argument) + { + shortopts[is] = ':'; + ++is; + } + } + } + if (ld_options[i].opt.name != NULL) + { + longopts[il] = ld_options[i].opt; + ++il; + } + } + shortopts[is] = '\0'; + longopts[il].name = NULL; + + /* The -G option is ambiguous on different platforms. Sometimes it + specifies the largest data size to put into the small data + section. Sometimes it is equivalent to --shared. Unfortunately, + the first form takes an argument, while the second does not. + + We need to permit the --shared form because on some platforms, + such as Solaris, gcc -shared will pass -G to the linker. + + To permit either usage, we look through the argument list. If we + find -G not followed by a number, we change it into --shared. + This will work for most normal cases. */ + for (i = 1; i < argc; i++) + if (strcmp (argv[i], "-G") == 0 + && (i + 1 >= argc + || ! isdigit (argv[i + 1][0]))) + argv[i] = (char *) "--shared"; + + while (1) + { + /* getopt_long_only is like getopt_long, but '-' as well as '--' can + indicate a long option. */ + int longind; + int optc; + + if (ldemul_parse_args (argc, argv)) + continue; + + optc = getopt_long_only (argc, argv, shortopts, longopts, &longind); + + if (optc == -1) + break; + switch (optc) + { + default: + xexit (1); + case 1: /* File name. */ + lang_add_input_file (optarg, lang_input_file_is_file_enum, + (char *) NULL); + break; + + case OPTION_IGNORE: + break; + case 'a': + /* For HP/UX compatibility. Actually -a shared should mean + ``use only shared libraries'' but, then, we don't + currently support shared libraries on HP/UX anyhow. */ + if (strcmp (optarg, "archive") == 0) + config.dynamic_link = false; + else if (strcmp (optarg, "shared") == 0 + || strcmp (optarg, "default") == 0) + config.dynamic_link = true; + else + einfo ("%P%F: unrecognized -a option `%s'\n", optarg); + break; + case OPTION_ASSERT: + /* FIXME: We just ignore these, but we should handle them. */ + if (strcmp (optarg, "definitions") == 0) + ; + else if (strcmp (optarg, "nodefinitions") == 0) + ; + else if (strcmp (optarg, "nosymbolic") == 0) + ; + else if (strcmp (optarg, "pure-text") == 0) + ; + else + einfo ("%P%F: unrecognized -assert option `%s'\n", optarg); + break; + case 'A': + ldfile_add_arch (optarg); + break; + case 'b': + lang_add_target (optarg); + break; + case 'c': + ldfile_open_command_file (optarg); + parser_input = input_mri_script; + yyparse (); + break; + case OPTION_CALL_SHARED: + config.dynamic_link = true; + break; + case OPTION_NON_SHARED: + config.dynamic_link = false; + break; + case OPTION_CREF: + command_line.cref = true; + link_info.notice_all = true; + break; + case 'd': + command_line.force_common_definition = true; + break; + case OPTION_DEFSYM: + lex_string = optarg; + lex_redirect (optarg); + parser_input = input_defsym; + parsing_defsym = 1; + yyparse (); + parsing_defsym = 0; + lex_string = NULL; + break; + case OPTION_DYNAMIC_LINKER: + command_line.interpreter = optarg; + break; + case OPTION_EB: + command_line.endian = ENDIAN_BIG; + break; + case OPTION_EL: + command_line.endian = ENDIAN_LITTLE; + break; + case OPTION_EMBEDDED_RELOCS: + command_line.embedded_relocs = true; + break; + case OPTION_EXPORT_DYNAMIC: + case 'E': /* HP/UX compatibility. */ + command_line.export_dynamic = true; + break; + case 'e': + lang_add_entry (optarg, true); + break; + case 'f': + if (command_line.auxiliary_filters == NULL) + { + command_line.auxiliary_filters = + (char **) xmalloc (2 * sizeof (char *)); + command_line.auxiliary_filters[0] = optarg; + command_line.auxiliary_filters[1] = NULL; + } + else + { + int c; + char **p; + + c = 0; + for (p = command_line.auxiliary_filters; *p != NULL; p++) + ++c; + command_line.auxiliary_filters = + (char **) xrealloc (command_line.auxiliary_filters, + (c + 2) * sizeof (char *)); + command_line.auxiliary_filters[c] = optarg; + command_line.auxiliary_filters[c + 1] = NULL; + } + break; + case 'F': + command_line.filter_shlib = optarg; + break; + case OPTION_FORCE_EXE_SUFFIX: + command_line.force_exe_suffix = true; + break; + case 'G': + { + char *end; + g_switch_value = strtoul (optarg, &end, 0); + if (*end) + einfo ("%P%F: invalid number `%s'\n", optarg); + } + break; + case 'g': + /* Ignore. */ + break; + case OPTION_HELP: + help (); + xexit (0); + break; + case 'L': + ldfile_add_library_path (optarg, true); + break; + case 'l': + lang_add_input_file (optarg, lang_input_file_is_l_enum, + (char *) NULL); + break; + case 'M': + config.map_filename = "-"; + break; + case 'm': + /* Ignore. Was handled in a pre-parse. */ + break; + case OPTION_MAP: + config.map_filename = optarg; + break; + case 'N': + config.text_read_only = false; + config.magic_demand_paged = false; + config.dynamic_link = false; + break; + case 'n': + config.magic_demand_paged = false; + config.dynamic_link = false; + break; + case OPTION_NO_KEEP_MEMORY: + link_info.keep_memory = false; + break; + case OPTION_NOINHIBIT_EXEC: + force_make_executable = true; + break; + case OPTION_NO_WHOLE_ARCHIVE: + whole_archive = false; + break; + case 'O': + /* FIXME "-O<non-digits> <value>" used to set the address of + section <non-digits>. Was this for compatibility with + something, or can we create a new option to do that + (with a syntax similar to -defsym)? + getopt can't handle two args to an option without kludges. */ + break; + case 'o': + lang_add_output (optarg, 0); + break; + case OPTION_OFORMAT: + lang_add_output_format (optarg, (char *) NULL, (char *) NULL, 0); + break; + case 'i': + case 'r': + link_info.relocateable = true; + config.build_constructors = false; + config.magic_demand_paged = false; + config.text_read_only = false; + config.dynamic_link = false; + break; + case 'R': + /* The GNU linker traditionally uses -R to mean to include + only the symbols from a file. The Solaris linker uses -R + to set the path used by the runtime linker to find + libraries. This is the GNU linker -rpath argument. We + try to support both simultaneously by checking the file + named. If it is a directory, rather than a regular file, + we assume -rpath was meant. */ + { + struct stat s; + + if (stat (optarg, &s) >= 0 + && ! S_ISDIR (s.st_mode)) + { + lang_add_input_file (optarg, + lang_input_file_is_symbols_only_enum, + (char *) NULL); + break; + } + } + /* Fall through. */ + case OPTION_RPATH: + if (command_line.rpath == NULL) + command_line.rpath = buystring (optarg); + else + { + char *buf; + + buf = xmalloc (strlen (command_line.rpath) + + strlen (optarg) + + 2); + sprintf (buf, "%s:%s", command_line.rpath, optarg); + free (command_line.rpath); + command_line.rpath = buf; + } + break; + case OPTION_RPATH_LINK: + if (command_line.rpath_link == NULL) + command_line.rpath_link = buystring (optarg); + else + { + char *buf; + + buf = xmalloc (strlen (command_line.rpath_link) + + strlen (optarg) + + 2); + sprintf (buf, "%s:%s", command_line.rpath_link, optarg); + free (command_line.rpath_link); + command_line.rpath_link = buf; + } + break; + case OPTION_RELAX: + command_line.relax = true; + break; + case OPTION_RETAIN_SYMBOLS_FILE: + add_keepsyms_file (optarg); + break; + case 'S': + link_info.strip = strip_debugger; + break; + case 's': + link_info.strip = strip_all; + break; + case OPTION_SHARED: + link_info.shared = true; + break; + case 'h': /* Used on Solaris. */ + case OPTION_SONAME: + command_line.soname = optarg; + break; + case OPTION_SORT_COMMON: + config.sort_common = true; + break; + case OPTION_STATS: + config.stats = true; + break; + case OPTION_SYMBOLIC: + link_info.symbolic = true; + break; + case 't': + trace_files = true; + break; + case 'T': + ldfile_open_command_file (optarg); + parser_input = input_script; + yyparse (); + break; + case OPTION_TBSS: + set_section_start (".bss", optarg); + break; + case OPTION_TDATA: + set_section_start (".data", optarg); + break; + case OPTION_TTEXT: + set_section_start (".text", optarg); + break; + case OPTION_TRADITIONAL_FORMAT: + link_info.traditional_format = true; + break; + case OPTION_UR: + link_info.relocateable = true; + config.build_constructors = true; + config.magic_demand_paged = false; + config.text_read_only = false; + config.dynamic_link = false; + break; + case 'u': + ldlang_add_undef (optarg); + break; + case OPTION_VERBOSE: + ldversion (1); + version_printed = true; + trace_file_tries = true; + break; + case 'v': + ldversion (0); + version_printed = true; + break; + case 'V': + ldversion (1); + version_printed = true; + break; + case OPTION_VERSION: + /* This output is intended to follow the GNU standards document. */ + printf ("GNU ld %s\n", ld_program_version); + printf ("Copyright 1997 Free Software Foundation, Inc.\n"); + printf ("\ +This program is free software; you may redistribute it under the terms of\n\ +the GNU General Public License. This program has absolutely no warranty.\n"); + { + ld_emulation_xfer_type **ptr = ld_emulations; + + printf (" Supported emulations:\n"); + while (*ptr) + { + printf (" %s\n", (*ptr)->emulation_name); + ptr++; + } + } + xexit (0); + break; + case OPTION_VERSION_SCRIPT: + /* This option indicates a small script that only specifies + version information. Read it, but don't assume that + we've seen a linker script. */ + { + boolean hold_had_script; + + hold_had_script = had_script; + ldfile_open_command_file (optarg); + had_script = hold_had_script; + parser_input = input_version_script; + yyparse (); + } + break; + case OPTION_WARN_COMMON: + config.warn_common = true; + break; + case OPTION_WARN_CONSTRUCTORS: + config.warn_constructors = true; + break; + case OPTION_WARN_MULTIPLE_GP: + config.warn_multiple_gp = true; + break; + case OPTION_WARN_ONCE: + config.warn_once = true; + break; + case OPTION_WARN_SECTION_ALIGN: + config.warn_section_align = true; + break; + case OPTION_WHOLE_ARCHIVE: + whole_archive = true; + break; + case OPTION_WRAP: + add_wrap (optarg); + break; + case 'X': + link_info.discard = discard_l; + break; + case 'x': + link_info.discard = discard_all; + break; + case 'Y': + if (strncmp (optarg, "P,", 2) == 0) + optarg += 2; + default_dirlist = xstrdup (optarg); + break; + case 'y': + add_ysym (optarg); + break; + case 'z': + /* We accept and ignore this option for Solaris + compatibility. Actually, on Solaris, optarg is not + ignored. Someday we should handle it correctly. FIXME. */ + break; + case OPTION_SPLIT_BY_RELOC: + config.split_by_reloc = atoi (optarg); + break; + case OPTION_SPLIT_BY_FILE: + config.split_by_file = true; + break; + case '(': + if (ingroup) + { + fprintf (stderr, + "%s: may not nest groups (--help for usage)\n", + program_name); + xexit (1); + } + lang_enter_group (); + ingroup = 1; + break; + case ')': + if (! ingroup) + { + fprintf (stderr, + "%s: group ended before it began (--help for usage)\n", + program_name); + xexit (1); + } + lang_leave_group (); + ingroup = 0; + break; + + } + } + + if (ingroup) + lang_leave_group (); + + if (default_dirlist != NULL) + set_default_dirlist (default_dirlist); + +} + +/* Add the (colon-separated) elements of DIRLIST_PTR to the + library search path. */ + +static void +set_default_dirlist (dirlist_ptr) + char *dirlist_ptr; +{ + char *p; + + while (1) + { + p = strchr (dirlist_ptr, ':'); + if (p != NULL) + *p = '\0'; + if (*dirlist_ptr != '\0') + ldfile_add_library_path (dirlist_ptr, true); + if (p == NULL) + break; + dirlist_ptr = p + 1; + } +} + +static void +set_section_start (sect, valstr) + char *sect, *valstr; +{ + char *end; + unsigned long val = strtoul (valstr, &end, 16); + if (*end) + einfo ("%P%F: invalid hex number `%s'\n", valstr); + lang_section_start (sect, exp_intop (val)); +} + +/* Print help messages for the options. */ + +static void +help () +{ + int i; + const char **targets, **pp; + + printf ("Usage: %s [options] file...\n", program_name); + + printf ("Options:\n"); + for (i = 0; i < OPTION_COUNT; i++) + { + if (ld_options[i].doc != NULL) + { + boolean comma; + int len; + int j; + + printf (" "); + + comma = false; + len = 2; + + j = i; + do + { + if (ld_options[j].shortopt != '\0' + && ld_options[j].control != NO_HELP) + { + printf ("%s-%c", comma ? ", " : "", ld_options[j].shortopt); + len += (comma ? 2 : 0) + 2; + if (ld_options[j].arg != NULL) + { + if (ld_options[j].opt.has_arg != optional_argument) + { + printf (" "); + ++len; + } + printf ("%s", ld_options[j].arg); + len += strlen (ld_options[j].arg); + } + comma = true; + } + ++j; + } + while (j < OPTION_COUNT && ld_options[j].doc == NULL); + + j = i; + do + { + if (ld_options[j].opt.name != NULL + && ld_options[j].control != NO_HELP) + { + printf ("%s-%s%s", + comma ? ", " : "", + ld_options[j].control == TWO_DASHES ? "-" : "", + ld_options[j].opt.name); + len += ((comma ? 2 : 0) + + 1 + + (ld_options[j].control == TWO_DASHES ? 1 : 0) + + strlen (ld_options[j].opt.name)); + if (ld_options[j].arg != NULL) + { + printf (" %s", ld_options[j].arg); + len += 1 + strlen (ld_options[j].arg); + } + comma = true; + } + ++j; + } + while (j < OPTION_COUNT && ld_options[j].doc == NULL); + + if (len >= 30) + { + printf ("\n"); + len = 0; + } + + for (; len < 30; len++) + putchar (' '); + + printf ("%s\n", ld_options[i].doc); + } + } + + printf ("%s: supported targets:", program_name); + targets = bfd_target_list (); + for (pp = targets; *pp != NULL; pp++) + printf (" %s", *pp); + free (targets); + printf ("\n"); + + printf ("%s: supported emulations: ", program_name); + ldemul_list_emulations (stdout); + printf ("\n"); + printf ("\nReport bugs to bug-gnu-utils@prep.ai.mit.edu\n"); +} diff --git a/contrib/binutils/ld/mri.c b/contrib/binutils/ld/mri.c new file mode 100644 index 0000000..d07622a --- /dev/null +++ b/contrib/binutils/ld/mri.c @@ -0,0 +1,377 @@ +/* mri.c -- handle MRI style linker scripts + Copyright (C) 1991, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc. + +This file is part of GLD, the Gnu Linker. + +GLD is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GLD is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GLD; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. */ + + +/* This bit does the tree decoration when MRI style link scripts are parsed */ + +/* + contributed by Steve Chamberlain + sac@cygnus.com + +*/ + +#include "bfd.h" +#include "sysdep.h" +#include "ld.h" +#include "ldexp.h" +#include "ldlang.h" +#include "ldmisc.h" +#include "mri.h" +#include "ldgram.h" +#include "libiberty.h" + +struct section_name_struct { + struct section_name_struct *next; + CONST char *name; + CONST char *alias; + etree_type *vma; + etree_type *align; + etree_type *subalign; + int ok_to_load; +} ; + +unsigned int symbol_truncate = 10000; +struct section_name_struct *order; +struct section_name_struct *only_load; +struct section_name_struct *address; +struct section_name_struct *alias; + +struct section_name_struct *alignment; +struct section_name_struct *subalignment; + +static struct section_name_struct **lookup + PARAMS ((const char *name, struct section_name_struct **list)); +static void mri_add_to_list PARAMS ((struct section_name_struct **list, + const char *name, etree_type *vma, + const char *zalias, etree_type *align, + etree_type *subalign)); + +static struct section_name_struct ** +lookup (name, list) + CONST char *name; + struct section_name_struct **list; +{ + + struct section_name_struct **ptr = list; + while (*ptr) + { + if (strcmp(name, (*ptr)->name) == 0) { + /* If this is a match, delete it, we only keep the last instance + of any name */ + *ptr = (*ptr)->next; + } + else { + ptr = &((*ptr)->next); + } + } + + *ptr = (struct section_name_struct *)xmalloc(sizeof(struct section_name_struct)); + return ptr; +} + +static void +mri_add_to_list (list, name, vma, zalias, align, subalign) + struct section_name_struct **list; + CONST char *name; + etree_type *vma; + CONST char *zalias; + etree_type *align; + etree_type *subalign; +{ + struct section_name_struct **ptr = lookup(name,list); + (*ptr)->name = name; + (*ptr)->vma = vma; + (*ptr)->next = (struct section_name_struct *)NULL; + (*ptr)->ok_to_load = 0; + (*ptr)->alias = zalias; + (*ptr)->align = align; + (*ptr)->subalign = subalign; +} + + +void +mri_output_section (name, vma) + CONST char *name; + etree_type *vma; +{ + mri_add_to_list(&address, name, vma, 0,0,0); +} + +/* if any ABSOLUTE <name> are in the script, only load those files +marked thus */ + +void +mri_only_load (name) + CONST char *name; +{ + mri_add_to_list(&only_load, name, 0, 0,0,0); +} + + +void +mri_base (exp) + etree_type *exp; +{ + base = exp; +} + +static int done_tree = 0; + +void +mri_draw_tree () +{ + if (done_tree) return; + + /* We don't bother with memory regions. */ +#if 0 + /* Create the regions */ + { + lang_memory_region_type *r; + r = lang_memory_region_lookup("long"); + r->current = r->origin = exp_get_vma(base, (bfd_vma)0, "origin", + lang_first_phase_enum); + r->length = (bfd_size_type) exp_get_vma(0, (bfd_vma) ~((bfd_size_type)0), + "length", lang_first_phase_enum); + } +#endif + + /* Now build the statements for the ldlang machine */ + + + /* Attatch the addresses of any which have addresses, and add the + ones not mentioned */ + if (address != (struct section_name_struct *)NULL) { + struct section_name_struct *alist; + struct section_name_struct *olist; + if (order == (struct section_name_struct *)NULL) { + order = address; + } + + for (alist = address; + alist != (struct section_name_struct*)NULL; + alist = alist->next) + { + int done = 0; + for (olist = order; + done == 0 && + olist != (struct section_name_struct *)NULL; + olist = olist->next) + { + if (strcmp(alist->name, olist->name) == 0) + { + olist->vma = alist->vma; + done = 1; + } + } + if (!done) { + /* add this onto end of order list */ + mri_add_to_list(&order, alist->name, alist->vma, 0,0,0); + } + + } + + } + + /* If we're only supposed to load a subset of them in, then prune + the list. */ + + if (only_load != (struct section_name_struct *)NULL) + { + struct section_name_struct *ptr1; + struct section_name_struct *ptr2; + if (order == (struct section_name_struct*)NULL) + order = only_load; + + /* See if this name is in the list, if it is then we can load it + */ + for (ptr1 = only_load; ptr1; ptr1 = ptr1->next) + { + for (ptr2= order; ptr2; ptr2=ptr2->next) + { + if (strcmp(ptr2->name, ptr1->name)==0) { + ptr2->ok_to_load = 1; + } + } + } + } + else + { + /* No only load list, so everything is ok to load */ + struct section_name_struct *ptr; + for (ptr = order; ptr; ptr=ptr->next) { + ptr->ok_to_load = 1; + } + } + + + + /* Create the order of sections to load */ + if (order != (struct section_name_struct *)NULL) + { + /* Been told to output the sections in a certain order */ + struct section_name_struct *p = order; + while (p) + { + struct section_name_struct *aptr; + etree_type *align = 0; + etree_type *subalign = 0; + /* See if an alignment has been specified */ + + for (aptr = alignment; aptr; aptr= aptr->next) + { + if (strcmp(aptr->name, p->name)==0) { + align = aptr->align; + } + } + + for (aptr = subalignment; aptr; aptr= aptr->next) + { + if (strcmp(aptr->name, p->name)==0) { + subalign = aptr->subalign; + } + } + + if (base == 0) { + base = p->vma ? p->vma :exp_nameop(NAME, "."); + } + lang_enter_output_section_statement (p->name, base, + p->ok_to_load ? 0 : noload_section, + 1, align, subalign, + (etree_type *) NULL); + base = 0; + lang_add_wild(p->name, (char *)NULL); + /* If there is an alias for this section, add it too */ + for (aptr = alias; aptr; aptr = aptr->next) { + + if (strcmp(aptr->alias, p->name)== 0) { + lang_add_wild(aptr->name, (char *)NULL); + } + } + + lang_leave_output_section_statement + (0, "*default*", (struct lang_output_section_phdr_list *) NULL); + + p = p->next; + } + } + + + done_tree = 1; + +} +void +mri_load (name) + CONST char *name; +{ + base = 0; + lang_add_input_file(name, + lang_input_file_is_file_enum, (char *)NULL); + /* lang_leave_output_section_statement(0,"*default*");*/ +} + + +void +mri_order (name) + CONST char *name; +{ + mri_add_to_list(&order, name, 0, 0,0,0); +} + +void +mri_alias (want, is, isn) + CONST char *want; + CONST char *is; + int isn; +{ + if (!is) { + /* Some sections are digits - */ + char buf[20]; + sprintf(buf, "%d", isn); + is = xstrdup (buf); + if (is == NULL) + abort (); + } + mri_add_to_list(&alias, is, 0, want,0,0); + +} + + +void +mri_name (name) + CONST char *name; +{ + lang_add_output(name, 1); + +} + + +void +mri_format (name) + CONST char *name; +{ + if (strcmp(name, "S") == 0) + { + lang_add_output_format("srec", (char *) NULL, (char *) NULL, 1); + } + else if (strcmp(name, "IEEE") == 0) + { + lang_add_output_format("ieee", (char *) NULL, (char *) NULL, 1); + } + else if (strcmp(name, "COFF") == 0) + { + lang_add_output_format("coff-m68k", (char *) NULL, (char *) NULL, 1); + } + else { + einfo("%P%F: unknown format type %s\n", name); + } +} + + +void +mri_public (name, exp) + CONST char *name; + etree_type *exp; +{ + lang_add_assignment(exp_assop('=', name, exp)); +} + +void +mri_align (name, exp) + CONST char *name; + etree_type *exp; +{ + mri_add_to_list(&alignment, name,0,0,exp,0); +} + +void +mri_alignmod (name, exp) + CONST char *name; + etree_type *exp; +{ + mri_add_to_list(&subalignment, name,0,0,0,exp); +} + + +void +mri_truncate (exp) + unsigned int exp; +{ + symbol_truncate = exp; +} diff --git a/contrib/binutils/ld/mri.h b/contrib/binutils/ld/mri.h new file mode 100644 index 0000000..dc3f0f3 --- /dev/null +++ b/contrib/binutils/ld/mri.h @@ -0,0 +1,39 @@ +/* mri.h -- header file for MRI scripting functions + Copyright 1993, 95, 1996 Free Software Foundation, Inc. + +This file is part of GLD, the Gnu Linker. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef MRI_H +#define MRI_H + +extern unsigned int symbol_truncate; + +extern void mri_output_section PARAMS ((const char *name, etree_type *vma)); +extern void mri_only_load PARAMS ((const char *name)); +extern void mri_base PARAMS ((etree_type *exp)); +extern void mri_load PARAMS ((const char *name)); +extern void mri_order PARAMS ((const char *name)); +extern void mri_alias PARAMS ((const char *want, const char *is, int isn)); +extern void mri_name PARAMS ((const char *name)); +extern void mri_format PARAMS ((const char *name)); +extern void mri_public PARAMS ((const char *name, etree_type *exp)); +extern void mri_align PARAMS ((const char *name, etree_type *exp)); +extern void mri_alignmod PARAMS ((const char *name, etree_type *exp)); +extern void mri_truncate PARAMS ((unsigned int exp)); +extern void mri_draw_tree PARAMS ((void)); + +#endif diff --git a/contrib/binutils/ld/scripttempl/README b/contrib/binutils/ld/scripttempl/README new file mode 100644 index 0000000..26ad2e9 --- /dev/null +++ b/contrib/binutils/ld/scripttempl/README @@ -0,0 +1,4 @@ +The files in this directory are linker script templates. +genscripts.sh sets some shell variables, then sources +EMULATION.sc, to generate EMULATION.{x,xr,xu,xn,xbn} -- the script +files for default, -r, -Ur, -n, -N. diff --git a/contrib/binutils/ld/scripttempl/alpha.sc b/contrib/binutils/ld/scripttempl/alpha.sc new file mode 100644 index 0000000..44a10c4 --- /dev/null +++ b/contrib/binutils/ld/scripttempl/alpha.sc @@ -0,0 +1,74 @@ +# Linker script for Alpha systems. +# Ian Lance Taylor <ian@cygnus.com>. +# These variables may be overridden by the emulation file. The +# defaults are appropriate for an Alpha running OSF/1. +test -z "$ENTRY" && ENTRY=__start +test -z "$TEXT_START_ADDR" && TEXT_START_ADDR="0x120000000 + SIZEOF_HEADERS" +if test "x$LD_FLAG" = "xn" -o "x$LD_FLAG" = "xN"; then + DATA_ADDR=. +else + test -z "$DATA_ADDR" && DATA_ADDR=0x140000000 +fi +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + ${RELOCATING+. = ${TEXT_START_ADDR};} + .text : { + ${RELOCATING+ _ftext = . }; + ${RELOCATING+ __istart = . }; + ${RELOCATING+ *(.init) } + ${RELOCATING+ LONG (0x6bfa8001)} + ${RELOCATING+ eprol = .}; + *(.text) + ${RELOCATING+ __fstart = . }; + ${RELOCATING+ *(.fini)} + ${RELOCATING+ LONG (0x6bfa8001)} + ${RELOCATING+ _etext = .}; + } + .rdata : { + *(.rdata) + } + .rconst : { + *(.rconst) + } + .pdata : { + ${RELOCATING+ _fpdata = .;} + *(.pdata) + } + ${RELOCATING+. = ${DATA_ADDR};} + .data : { + ${RELOCATING+ _fdata = .;} + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + } + .xdata : { + *(.xdata) + } + ${RELOCATING+ _gp = ALIGN (16) + 0x8000;} + .lit8 : { + *(.lit8) + } + .lita : { + *(.lita) + } + .sdata : { + *(.sdata) + } + ${RELOCATING+ _EDATA = .;} + ${RELOCATING+ _FBSS = .;} + .sbss : { + *(.sbss) + *(.scommon) + } + .bss : { + *(.bss) + *(COMMON) + } + ${RELOCATING+ _end = .;} +} +EOF diff --git a/contrib/binutils/ld/scripttempl/aout.sc b/contrib/binutils/ld/scripttempl/aout.sc new file mode 100644 index 0000000..66cc42d --- /dev/null +++ b/contrib/binutils/ld/scripttempl/aout.sc @@ -0,0 +1,55 @@ +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${STACKZERO+${RELOCATING+${STACKZERO}}} +${SHLIB_PATH+${RELOCATING+${SHLIB_PATH}}} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING+PROVIDE (__stack = 0);} +SECTIONS +{ + ${RELOCATING+. = ${TEXT_START_ADDR};} + .text : + { + CREATE_OBJECT_SYMBOLS + *(.text) + /* The next six sections are for SunOS dynamic linking. The order + is important. */ + *(.dynrel) + *(.hash) + *(.dynsym) + *(.dynstr) + *(.rules) + *(.need) + ${RELOCATING+_etext = .;} + ${RELOCATING+__etext = .;} + ${PAD_TEXT+${RELOCATING+. = ${DATA_ALIGNMENT};}} + } + ${RELOCATING+. = ${DATA_ALIGNMENT};} + .data : + { + /* The first three sections are for SunOS dynamic linking. */ + *(.dynamic) + *(.got) + *(.plt) + *(.data) + *(.linux-dynamic) /* For Linux dynamic linking. */ + ${CONSTRUCTING+CONSTRUCTORS} + ${RELOCATING+_edata = .;} + ${RELOCATING+__edata = .;} + } + .bss : + { + ${RELOCATING+ __bss_start = .}; + *(.bss) + *(COMMON) + ${RELOCATING+_end = ALIGN(4) }; + ${RELOCATING+__end = ALIGN(4) }; + } +} +EOF diff --git a/contrib/binutils/ld/scripttempl/elf.sc b/contrib/binutils/ld/scripttempl/elf.sc new file mode 100644 index 0000000..27f2e9d --- /dev/null +++ b/contrib/binutils/ld/scripttempl/elf.sc @@ -0,0 +1,200 @@ +# +# Unusual variables checked by this code: +# NOP - two byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# OTHER_READONLY_SECTIONS - other than .text .init .rodata ... +# (e.g., .PARISC.milli) +# OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ... +# (e.g., .PARISC.global) +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# EMBEDDED - whether this is for an embedded system. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# +test -z "$ENTRY" && ENTRY=_start +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +if [ -z "$MACHINE" ]; then OUTPUT_ARCH=${ARCH}; else OUTPUT_ARCH=${ARCH}:${MACHINE}; fi +test "$LD_FLAG" = "N" && DATA_ADDR=. +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +PLT=".plt ${RELOCATING-0} : { *(.plt) }" + +# if this is for an embedded system, don't add SIZEOF_HEADERS. +if [ -z "$EMBEDDED" ]; then + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS" +else + test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}" +fi + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${OUTPUT_ARCH}) +ENTRY(${ENTRY}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+/* Do we need any of these for elf? + __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_BASE_ADDRESS};}} + ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}} + ${CREATE_SHLIB-${INTERP}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .gnu.version ${RELOCATING-0} : { *(.gnu.version) } + .gnu.version_d ${RELOCATING-0} : { *(.gnu.version_d) } + .gnu.version_r ${RELOCATING-0} : { *(.gnu.version_r) } + .rel.text ${RELOCATING-0} : + { *(.rel.text) *(.rel.gnu.linkonce.t*) } + .rela.text ${RELOCATING-0} : + { *(.rela.text) *(.rela.gnu.linkonce.t*) } + .rel.data ${RELOCATING-0} : + { *(.rel.data) *(.rel.gnu.linkonce.d*) } + .rela.data ${RELOCATING-0} : + { *(.rela.data) *(.rela.gnu.linkonce.d*) } + .rel.rodata ${RELOCATING-0} : + { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } + .rela.rodata ${RELOCATING-0} : + { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.init ${RELOCATING-0} : { *(.rel.init) } + .rela.init ${RELOCATING-0} : { *(.rela.init) } + .rel.fini ${RELOCATING-0} : { *(.rel.fini) } + .rela.fini ${RELOCATING-0} : { *(.rela.fini) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + .init ${RELOCATING-0} : { *(.init) } =${NOP-0} + ${DATA_PLT-${PLT}} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } =${NOP-0} + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} + .rodata ${RELOCATING-0} : { *(.rodata) *(.gnu.linkonce.r*) } + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${RELOCATING+${OTHER_READONLY_SECTIONS}} + + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + ${RELOCATING+. = ${DATA_ADDR-ALIGN(${MAXPAGESIZE}) + (. & (${MAXPAGESIZE} - 1))};} + + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + *(.gnu.linkonce.d*) + ${CONSTRUCTING+CONSTRUCTORS} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + .ctors ${RELOCATING-0} : + { + ${CONSTRUCTING+${CTOR_START}} + *(.ctors) + ${CONSTRUCTING+${CTOR_END}} + } + .dtors ${RELOCATING-0} : + { + ${CONSTRUCTING+${DTOR_START}} + *(.dtors) + ${CONSTRUCTING+${DTOR_END}} + } + ${DATA_PLT+${PLT}} + .got ${RELOCATING-0} : { *(.got.plt) *(.got) } + .dynamic ${RELOCATING-0} : { *(.dynamic) } + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : { *(.sdata) } + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss) + *(COMMON) + } + ${RELOCATING+_end = . ;} + ${RELOCATING+PROVIDE (end = .);} + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + + ${RELOCATING+${OTHER_RELOCATING_SECTIONS}} + + /* These must appear regardless of ${RELOCATING}. */ + ${OTHER_SECTIONS} +} +EOF diff --git a/contrib/binutils/ld/scripttempl/i386coff.sc b/contrib/binutils/ld/scripttempl/i386coff.sc new file mode 100644 index 0000000..fbb1b79 --- /dev/null +++ b/contrib/binutils/ld/scripttempl/i386coff.sc @@ -0,0 +1,43 @@ +# Linker script for 386 COFF. This works on SVR3.2 and SCO Unix 3.2.2. +# Ian Taylor <ian@cygnus.com>. +test -z "$ENTRY" && ENTRY=_start +# These are substituted in as variables in order to get '}' in a shell +# conditional expansion. +INIT='.init : { *(.init) }' +FINI='.fini : { *(.fini) }' +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +${LIB_SEARCH_DIRS} + +ENTRY(${ENTRY}) + +SECTIONS +{ + .text ${RELOCATING+ SIZEOF_HEADERS} : { + ${RELOCATING+ *(.init)} + *(.text) + ${RELOCATING+ *(.fini)} + ${RELOCATING+ etext = .}; + } + .data ${RELOCATING+ 0x400000 + (. & 0xffc00fff)} : { + *(.data) + ${RELOCATING+ edata = .}; + } + .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : + { + *(.bss) + *(COMMON) + ${RELOCATING+ end = .}; + } + ${RELOCATING- ${INIT}} + ${RELOCATING- ${FINI}} + .stab 0 ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } +} +EOF diff --git a/contrib/binutils/ld/scripttempl/nw.sc b/contrib/binutils/ld/scripttempl/nw.sc new file mode 100644 index 0000000..725522c --- /dev/null +++ b/contrib/binutils/ld/scripttempl/nw.sc @@ -0,0 +1,131 @@ +# +# Unusual variables checked by this code: +# NOP - two byte opcode for no-op (defaults to 0) +# DATA_ADDR - if end-of-text-plus-one-page isn't right for data start +# OTHER_READONLY_SECTIONS - other than .text .init .ctors .rodata ... +# (e.g., .PARISC.milli) +# OTHER_READWRITE_SECTIONS - other than .data .bss .sdata ... +# (e.g., .PARISC.global) +# OTHER_SECTIONS - at the end +# EXECUTABLE_SYMBOLS - symbols that must be defined for an +# executable (e.g., _DYNAMIC_LINK) +# TEXT_START_SYMBOLS - symbols that appear at the start of the +# .text section. +# DATA_START_SYMBOLS - symbols that appear at the start of the +# .data section. +# OTHER_BSS_SYMBOLS - symbols that appear at the start of the +# .bss section besides __bss_start. +# DATA_PLT - .plt should be in data segment, not text segment. +# +# When adding sections, do note that the names of some sections are used +# when specifying the start address of the next. +# +test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT} +test "$LD_FLAG" = "N" && DATA_ADDR=. +INTERP=".interp ${RELOCATING-0} : { *(.interp) }" +PLT=".plt ${RELOCATING-0} : { *(.plt) }" +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}", + "${LITTLE_OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +${RELOCATING+${LIB_SEARCH_DIRS}} +${RELOCATING+/* Do we need any of these for elf? + __DYNAMIC = 0; ${STACKZERO+${STACKZERO}} ${SHLIB_PATH+${SHLIB_PATH}} */} +${RELOCATING+${EXECUTABLE_SYMBOLS}} +${RELOCATING- /* For some reason, the Solaris linker makes bad executables + if gld -r is used and the intermediate file has sections starting + at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld + bug. But for now assigning the zero vmas works. */} +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + ${CREATE_SHLIB-${RELOCATING+. = ${TEXT_START_ADDR} + SIZEOF_HEADERS;}} + ${CREATE_SHLIB+${RELOCATING+. = SIZEOF_HEADERS;}} + ${CREATE_SHLIB-${INTERP}} + .hash ${RELOCATING-0} : { *(.hash) } + .dynsym ${RELOCATING-0} : { *(.dynsym) } + .dynstr ${RELOCATING-0} : { *(.dynstr) } + .rel.text ${RELOCATING-0} : { *(.rel.text) } + .rela.text ${RELOCATING-0} : { *(.rela.text) } + .rel.data ${RELOCATING-0} : { *(.rel.data) } + .rela.data ${RELOCATING-0} : { *(.rela.data) } + .rel.rodata ${RELOCATING-0} : { *(.rel.rodata) } + .rela.rodata ${RELOCATING-0} : { *(.rela.rodata) } + .rel.got ${RELOCATING-0} : { *(.rel.got) } + .rela.got ${RELOCATING-0} : { *(.rela.got) } + .rel.ctors ${RELOCATING-0} : { *(.rel.ctors) } + .rela.ctors ${RELOCATING-0} : { *(.rela.ctors) } + .rel.dtors ${RELOCATING-0} : { *(.rel.dtors) } + .rela.dtors ${RELOCATING-0} : { *(.rela.dtors) } + .rel.bss ${RELOCATING-0} : { *(.rel.bss) } + .rela.bss ${RELOCATING-0} : { *(.rela.bss) } + .rel.plt ${RELOCATING-0} : { *(.rel.plt) } + .rela.plt ${RELOCATING-0} : { *(.rela.plt) } + .init ${RELOCATING-0} : { *(.init) } =${NOP-0} + ${DATA_PLT-${PLT}} + .text ${RELOCATING-0} : + { + ${RELOCATING+${TEXT_START_SYMBOLS}} + *(.text) + ${CONSTRUCTING+ __CTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.ctors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __CTOR_END__ = .;} + ${CONSTRUCTING+ __DTOR_LIST__ = .;} + ${CONSTRUCTING+ LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)} + ${CONSTRUCTING+ *(.dtors)} + ${CONSTRUCTING+ LONG(0)} + ${CONSTRUCTING+ __DTOR_END__ = .;} + } + ${RELOCATING+_etext = .;} + ${RELOCATING+PROVIDE (etext = .);} + .fini ${RELOCATING-0} : { *(.fini) } =${NOP-0} + .ctors ${RELOCATING-0} : { *(.ctors) } + .dtors ${RELOCATING-0} : { *(.dtors) } + .rodata ${RELOCATING-0} : { *(.rodata) } + .rodata1 ${RELOCATING-0} : { *(.rodata1) } + ${RELOCATING+${OTHER_READONLY_SECTIONS}} + + /* Read-write section, merged into data segment: */ + ${RELOCATING+. = ${DATA_ADDR- ALIGN(8) + ${MAXPAGESIZE}};} + .data ${RELOCATING-0} : + { + ${RELOCATING+${DATA_START_SYMBOLS}} + *(.data) + ${CONSTRUCTING+CONSTRUCTORS} + } + .data1 ${RELOCATING-0} : { *(.data1) } + ${RELOCATING+${OTHER_READWRITE_SECTIONS}} + .got ${RELOCATING-0} : { *(.got.plt) *(.got) } + .dynamic ${RELOCATING-0} : { *(.dynamic) } + ${DATA_PLT+${PLT}} + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata ${RELOCATING-0} : { *(.sdata) } + ${RELOCATING+_edata = .;} + ${RELOCATING+PROVIDE (edata = .);} + ${RELOCATING+__bss_start = .;} + ${RELOCATING+${OTHER_BSS_SYMBOLS}} + .sbss ${RELOCATING-0} : { *(.sbss) *(.scommon) } + .bss ${RELOCATING-0} : + { + *(.dynbss) + *(.bss) + *(COMMON) + } + ${RELOCATING+_end = . ;} + ${RELOCATING+PROVIDE (end = .);} + + /* These are needed for ELF backends which have not yet been + converted to the new style linker. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + + /* These must appear regardless of ${RELOCATING}. */ + ${OTHER_SECTIONS} +} +EOF diff --git a/contrib/binutils/ld/scripttempl/pe.sc b/contrib/binutils/ld/scripttempl/pe.sc new file mode 100644 index 0000000..2adc3db --- /dev/null +++ b/contrib/binutils/ld/scripttempl/pe.sc @@ -0,0 +1,112 @@ +# Linker script for PE. + +cat <<EOF +OUTPUT_FORMAT(${OUTPUT_FORMAT}) +${LIB_SEARCH_DIRS} + +ENTRY(_mainCRTStartup) + +SECTIONS +{ + .text ${RELOCATING+ __image_base__ + __section_alignment__ } : + { + ${RELOCATING+ *(.init)} + *(.text) + ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ; + LONG (-1); *(.ctors); *(.ctor); LONG (0); } + ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ; + LONG (-1); *(.dtors); *(.dtor); LONG (0); } + ${RELOCATING+ *(.fini)} + /* ??? Why is .gcc_exc here? */ + ${RELOCATING+ *(.gcc_exc)} + ${RELOCATING+ etext = .;} + /* Grouped section support currently must be explicitly provided for + in the linker script. */ + *(.text\$) + *(.gcc_except_table) + } + + .bss BLOCK(__section_alignment__) : + { + __bss_start__ = . ; + *(.bss) + *(COMMON) + __bss_end__ = . ; + } + .data BLOCK(__section_alignment__) : + { + __data_start__ = . ; + *(.data) + *(.data2) + __data_end__ = . ; + /* Grouped section support currently must be explicitly provided for + in the linker script. */ + *(.data\$) + } + + .rdata BLOCK(__section_alignment__) : + { + *(.rdata) + /* Grouped section support currently must be explicitly provided for + in the linker script. */ + *(.rdata\$) + } + + .edata BLOCK(__section_alignment__) : + { + *(.edata) + } + + /DISCARD/ BLOCK(__section_alignment__) : + { + *(.debug\$S) + *(.debug\$T) + *(.debug\$F) + *(.drectve) + } + + .idata BLOCK(__section_alignment__) : + { + /* This cannot currently be handled with grouped sections. + See pe.em:sort_sections. */ + *(.idata\$2) + *(.idata\$3) + *(.idata\$4) + *(.idata\$5) + *(.idata\$6) + *(.idata\$7) + } + .CRT BLOCK(__section_alignment__) : + { + /* Grouped sections are used to handle .CRT\$foo. */ + *(.CRT\$) + } + .rsrc BLOCK(__section_alignment__) : + { + /* Grouped sections are used to handle .rsrc\$0[12]. */ + *(.rsrc\$) + } + + .endjunk BLOCK(__section_alignment__) : + { + /* end is deprecated, don't use it */ + ${RELOCATING+ end = .;} + ${RELOCATING+ __end__ = .;} + } + + .stab BLOCK(__section_alignment__) ${RELOCATING+(NOLOAD)} : + { + [ .stab ] + } + + .stabstr BLOCK(__section_alignment__) ${RELOCATING+(NOLOAD)} : + { + [ .stabstr ] + } + + .reloc BLOCK(__section_alignment__) : + { + *(.reloc) + } +} +EOF diff --git a/contrib/binutils/ld/scripttempl/sh.sc b/contrib/binutils/ld/scripttempl/sh.sc new file mode 100644 index 0000000..036dd21 --- /dev/null +++ b/contrib/binutils/ld/scripttempl/sh.sc @@ -0,0 +1,59 @@ +TORS=".tors : + { + ___ctors = . ; + *(.ctors) + ___ctors_end = . ; + ___dtors = . ; + *(.dtors) + ___dtors_end = . ; + } > ram" + +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) + +MEMORY +{ + ram : o = 0x1000, l = 512k +} + +SECTIONS +{ + .text : + { + *(.text) + *(.strings) + ${RELOCATING+ _etext = . ; } + } ${RELOCATING+ > ram} + ${CONSTRUCTING+${TORS}} + .data : + { + *(.data) + ${RELOCATING+ _edata = . ; } + } ${RELOCATING+ > ram} + .bss : + { + ${RELOCATING+ _bss_start = . ; } + *(.bss) + *(COMMON) + ${RELOCATING+ _end = . ; } + } ${RELOCATING+ > ram} + .stack ${RELOCATING+ 0x30000 } : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + } ${RELOCATING+ > ram} + .stab 0 ${RELOCATING+(NOLOAD)} : + { + *(.stab) + } + .stabstr 0 ${RELOCATING+(NOLOAD)} : + { + *(.stabstr) + } +} +EOF + + + + diff --git a/contrib/binutils/ld/scripttempl/vanilla.sc b/contrib/binutils/ld/scripttempl/vanilla.sc new file mode 100644 index 0000000..1798480 --- /dev/null +++ b/contrib/binutils/ld/scripttempl/vanilla.sc @@ -0,0 +1 @@ +# Nothing to do. diff --git a/contrib/binutils/ld/scripttempl/z8000.sc b/contrib/binutils/ld/scripttempl/z8000.sc new file mode 100644 index 0000000..2b87930 --- /dev/null +++ b/contrib/binutils/ld/scripttempl/z8000.sc @@ -0,0 +1,54 @@ +cat <<EOF +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH("${OUTPUT_ARCH}") +ENTRY(_start) + +SECTIONS +{ +.text ${BIG+ ${RELOCATING+ 0x0000000}} : { + *(.text) + *(.strings) + *(.rdata) + } + +.ctors ${BIG+ ${RELOCATING+ 0x2000000}} : + { + ${RELOCATING+ ___ctors = . ; } + *(.ctors); + ${RELOCATING+ ___ctors_end = . ; } + ___dtors = . ; + *(.dtors); + ${RELOCATING+ ___dtors_end = . ; } + } + +.data ${BIG+ ${RELOCATING+ 0x3000000}} : { + *(.data) + } + +.bss ${BIG+ ${RELOCATING+ 0x4000000}} : + { + ${RELOCATING+ __start_bss = . ; } + *(.bss); + *(COMMON); + ${RELOCATING+ __end_bss = . ; } + } + +.heap ${BIG+ ${RELOCATING+ 0x5000000}} : { + ${RELOCATING+ __start_heap = . ; } + ${RELOCATING+ . = . + 20k ; } + ${RELOCATING+ __end_heap = . ; } + } + +.stack ${RELOCATING+ 0xf000 } : + { + ${RELOCATING+ _stack = . ; } + *(.stack) + ${RELOCATING+ __stack_top = . ; } + } + +} +EOF + + + + diff --git a/contrib/binutils/ld/sysdep.h b/contrib/binutils/ld/sysdep.h new file mode 100644 index 0000000..a018436 --- /dev/null +++ b/contrib/binutils/ld/sysdep.h @@ -0,0 +1,69 @@ +/* sysdep.h -- handle host dependencies for the GNU linker + Copyright (C) 1995, 96, 1997 Free Software Foundation, Inc. + + This file is part of GLD, the Gnu Linker. + + GLD is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GLD is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GLD; see the file COPYING. If not, write to the Free + Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. */ + +#ifndef LD_SYSDEP_H +#define LD_SYSDEP_H + +#include "ansidecl.h" + +#include "config.h" + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> + +#ifdef HAVE_STRING_H +#include <string.h> +#else +#ifdef HAVE_STRINGS_H +#include <strings.h> +#else +extern char *strchr (); +extern char *strrchr (); +#endif +#endif + +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef USE_BINARY_FOPEN +#include "fopen-bin.h" +#else +#include "fopen-same.h" +#endif + +#ifdef NEED_DECLARATION_STRSTR +extern char *strstr (); +#endif + +#ifdef NEED_DECLARATION_FREE +extern void free (); +#endif + +#ifdef NEED_DECLARATION_GETENV +extern char *getenv (); +#endif + +#endif /* ! defined (LD_SYSDEP_H) */ |