| 1 | /* Copyright (C) 1991 Free Software Foundation, Inc. |
| 2 | |
| 3 | This file is part of GLD, the Gnu Linker. |
| 4 | |
| 5 | GLD is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; either version 1, or (at your option) |
| 8 | any later version. |
| 9 | |
| 10 | GLD is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with GLD; see the file COPYING. If not, write to |
| 17 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 18 | |
| 19 | /* |
| 20 | $Id$ |
| 21 | */ |
| 22 | |
| 23 | /* |
| 24 | * emulate the Intels port of gld |
| 25 | */ |
| 26 | |
| 27 | |
| 28 | #include "sysdep.h" |
| 29 | #include "bfd.h" |
| 30 | |
| 31 | |
| 32 | #include "ld.h" |
| 33 | #include "config.h" |
| 34 | #include "ld-emul.h" |
| 35 | #include "ldfile.h" |
| 36 | #include "ldmisc.h" |
| 37 | |
| 38 | |
| 39 | /* IMPORTS */ |
| 40 | extern char *output_filename; |
| 41 | extern boolean lang_float_flag; |
| 42 | |
| 43 | |
| 44 | extern enum bfd_architecture ldfile_output_architecture; |
| 45 | extern unsigned long ldfile_output_machine; |
| 46 | extern char *ldfile_output_machine_name; |
| 47 | |
| 48 | extern bfd *output_bfd; |
| 49 | |
| 50 | |
| 51 | |
| 52 | #ifdef GNU960 |
| 53 | |
| 54 | static void |
| 55 | gld960_before_parse() |
| 56 | { |
| 57 | static char *env_variables[] = { "G960LIB", "G960BASE", 0 }; |
| 58 | char **p; |
| 59 | char *env ; |
| 60 | |
| 61 | for ( p = env_variables; *p; p++ ){ |
| 62 | env = (char *) getenv(*p); |
| 63 | if (env) { |
| 64 | ldfile_add_library_path(concat(env,"/lib/libbout","")); |
| 65 | } |
| 66 | } |
| 67 | ldfile_output_architecture = bfd_arch_i960; |
| 68 | } |
| 69 | |
| 70 | #else /* not GNU960 */ |
| 71 | |
| 72 | static void gld960_before_parse() |
| 73 | { |
| 74 | char *env ; |
| 75 | env = getenv("G960LIB"); |
| 76 | if (env) { |
| 77 | ldfile_add_library_path(env); |
| 78 | } |
| 79 | env = getenv("G960BASE"); |
| 80 | if (env) { |
| 81 | ldfile_add_library_path(concat(env,"/lib","")); |
| 82 | } |
| 83 | ldfile_output_architecture = bfd_arch_i960; |
| 84 | } |
| 85 | |
| 86 | #endif /* GNU960 */ |
| 87 | |
| 88 | |
| 89 | static void |
| 90 | gld960_after_parse() |
| 91 | { |
| 92 | |
| 93 | } |
| 94 | |
| 95 | static void |
| 96 | gld960_after_allocation() |
| 97 | { |
| 98 | |
| 99 | } |
| 100 | |
| 101 | static void |
| 102 | gld960_before_allocation() |
| 103 | { |
| 104 | |
| 105 | } |
| 106 | |
| 107 | |
| 108 | static void |
| 109 | gld960_set_output_arch() |
| 110 | { |
| 111 | /* Set the output architecture and machine if possible */ |
| 112 | unsigned long machine = 0; |
| 113 | bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine); |
| 114 | } |
| 115 | |
| 116 | static char * |
| 117 | gld960_choose_target() |
| 118 | { |
| 119 | #ifdef GNU960 |
| 120 | |
| 121 | output_filename = "b.out"; |
| 122 | return bfd_make_targ_name(BFD_BOUT_FORMAT,HOST_BYTE_ORDER_BIG_P); |
| 123 | |
| 124 | #else |
| 125 | |
| 126 | char *from_outside = getenv(TARGET_ENVIRON); |
| 127 | output_filename = "b.out"; |
| 128 | |
| 129 | if (from_outside != (char *)NULL) |
| 130 | return from_outside; |
| 131 | return GLD960_TARGET; |
| 132 | |
| 133 | #endif |
| 134 | } |
| 135 | |
| 136 | static void |
| 137 | gld960_syslib() |
| 138 | { |
| 139 | info("%S SYSLIB ignored\n"); |
| 140 | } |
| 141 | |
| 142 | static void |
| 143 | gld960_hll() |
| 144 | { |
| 145 | info("%S HLL ignored\n"); |
| 146 | } |
| 147 | |
| 148 | |
| 149 | static char *script = |
| 150 | #include "ld-gld960.x" |
| 151 | ; |
| 152 | |
| 153 | |
| 154 | static char * |
| 155 | gld960_get_script() |
| 156 | { |
| 157 | return script; |
| 158 | } |
| 159 | |
| 160 | struct ld_emulation_xfer_struct ld_gld960_emulation = |
| 161 | { |
| 162 | gld960_before_parse, |
| 163 | gld960_syslib, |
| 164 | gld960_hll, |
| 165 | gld960_after_parse, |
| 166 | gld960_after_allocation, |
| 167 | gld960_set_output_arch, |
| 168 | gld960_choose_target, |
| 169 | gld960_before_allocation, |
| 170 | gld960_get_script, |
| 171 | }; |