home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / src / binutils.2 / ld / e_gld960.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-30  |  2.9 KB  |  146 lines

  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.  * emulate the Intels port of  gld
  21.  */
  22.  
  23.  
  24. #include "bfd.h"
  25. #include "sysdep.h"
  26.  
  27.  
  28. #include "ld.h"
  29. #include "config.h"
  30. #include "ldemul.h"
  31. #include "ldfile.h"
  32. #include "ldmisc.h"
  33.  
  34.  
  35. /* IMPORTS */
  36. extern char *output_filename;
  37. extern  boolean lang_float_flag;
  38.  
  39.  
  40. extern enum bfd_architecture ldfile_output_architecture;
  41. extern unsigned long ldfile_output_machine;
  42. extern char *ldfile_output_machine_name;
  43.  
  44. extern bfd *output_bfd;
  45.  
  46.  
  47.  
  48. #ifdef GNU960
  49.  
  50. static void
  51. gld960_before_parse()
  52. {
  53.   static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
  54.   char **p;
  55.   char *env ;
  56.  
  57.   for ( p = env_variables; *p; p++ ){
  58.     env =  (char *) getenv(*p);
  59.     if (env) {
  60.       ldfile_add_library_path(concat(env,"/lib/libbout",""));
  61.     }
  62.   }
  63.   ldfile_output_architecture = bfd_arch_i960;
  64. }
  65.  
  66. #else    /* not GNU960 */
  67.  
  68. static void gld960_before_parse()
  69. {
  70.   char *env ;
  71.   env =  getenv("G960LIB");
  72.   if (env) {
  73.     ldfile_add_library_path(env);
  74.   }
  75.   env = getenv("G960BASE");
  76.   if (env) {
  77.     ldfile_add_library_path(concat(env,"/lib",""));
  78.   }
  79.   ldfile_output_architecture = bfd_arch_i960;
  80. }
  81.  
  82. #endif    /* GNU960 */
  83.  
  84.  
  85. static void
  86. gld960_set_output_arch()
  87. {
  88.   bfd_set_arch_mach(output_bfd, ldfile_output_architecture, bfd_mach_i960_core);
  89. }
  90.  
  91. static char *
  92. gld960_choose_target()
  93. {
  94. #ifdef GNU960
  95.  
  96.   output_filename = "b.out";
  97.   return bfd_make_targ_name(BFD_BOUT_FORMAT, 0);
  98.  
  99. #else
  100.  
  101.   char *from_outside = getenv(TARGET_ENVIRON);
  102.   output_filename = "b.out";
  103.  
  104.   if (from_outside != (char *)NULL)
  105.     return from_outside;
  106.  
  107.   return "b.out.little";
  108.  
  109. #endif
  110. }
  111.  
  112. static char *script = 
  113. #include "gld960.x"
  114. ;
  115.  
  116.   
  117. static char *script_reloc =
  118. #include "gld960.xr"
  119.  ;
  120.  
  121.  
  122. static char *
  123. gld960_get_script()
  124. {
  125.    extern ld_config_type config;
  126.    if (config.relocateable_output)
  127.      return script_reloc;
  128.    return script;
  129.  
  130. }
  131.  
  132. struct ld_emulation_xfer_struct ld_gld960_emulation = 
  133. {
  134.   gld960_before_parse,
  135.   syslib_default,
  136.   hll_default,
  137.   after_parse_default,
  138.   after_allocation_default,
  139.   gld960_set_output_arch,
  140.   gld960_choose_target,
  141.   before_allocation_default,
  142.   gld960_get_script,
  143.   "960",
  144.   ""
  145. };
  146.