Include bfd.h before sysdep.h, so ansidecl and PROTO() get defined first.
authorJohn Gilmore <gnu@cygnus>
Fri, 11 Oct 1991 11:28:27 +0000 (11:28 +0000)
committerJohn Gilmore <gnu@cygnus>
Fri, 11 Oct 1991 11:28:27 +0000 (11:28 +0000)
ld/ldemul.c [new file with mode: 0644]
ld/ldgld960.c
ld/ldgram.y
ld/ldindr.c
ld/ldlang.c
ld/ldlnk960.c
ld/ldmain.c
ld/ldsym.c
ld/ldvanilla.c
ld/ldwarn.c

diff --git a/ld/ldemul.c b/ld/ldemul.c
new file mode 100644 (file)
index 0000000..eafe26c
--- /dev/null
@@ -0,0 +1,147 @@
+/* Copyright (C) 1991 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, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+/*
+ * $Id$ 
+ */
+
+/*
+ * clearing house for ld emulation states 
+ */
+
+#include "bfd.h"
+#include "sysdep.h"
+
+#include "config.h"
+#include "ld.h"
+#include "ldemul.h"
+#include "ldmisc.h"
+
+extern ld_emulation_xfer_type ld_lnk960_emulation;
+extern ld_emulation_xfer_type ld_gldm88kbcs_emulation;
+extern ld_emulation_xfer_type ld_gld_emulation;
+extern ld_emulation_xfer_type ld_vanilla_emulation;
+extern ld_emulation_xfer_type ld_gld68k_emulation;
+extern ld_emulation_xfer_type ld_gld960_emulation;
+extern ld_emulation_xfer_type ld_gld29k_emulation;
+extern ld_emulation_xfer_type ld_gldnews_emulation;
+extern ld_emulation_xfer_type ld_h8300hds_emulation;
+
+
+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_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();
+}
+
+char *
+ldemul_choose_target()
+{
+  return ld_emulation->choose_target();
+}
+
+char *
+ldemul_get_script()
+{
+  return ld_emulation->get_script();
+}
+
+void
+ldemul_choose_mode(target)
+char *target;
+{
+  if (strcmp(target,LNK960_EMULATION_NAME)==0) {
+    ld_emulation = &ld_lnk960_emulation;
+  }
+  else if (strcmp(target,GLD960_EMULATION_NAME)==0) {
+    ld_emulation = &ld_gld960_emulation;
+  }
+  else if (strcmp(target,GLDM88KBCS_EMULATION_NAME)==0) {
+    ld_emulation = &ld_gldm88kbcs_emulation;
+  }
+#ifndef GNU960
+  else if (strcmp(target,GLD_EMULATION_NAME)==0) {
+    ld_emulation = &ld_gld_emulation;
+  }
+  else if (strcmp(target,VANILLA_EMULATION_NAME)==0) {
+    ld_emulation = &ld_vanilla_emulation;
+  }
+  else if (strcmp(target,H8300HDS_EMULATION_NAME)==0) {
+    ld_emulation = &ld_h8300hds_emulation;
+  }
+
+  else if (strcmp(target,GLD68K_EMULATION_NAME)==0) {
+    ld_emulation = &ld_gld68k_emulation;
+  }
+  else if (strcmp(target,GLD29K_EMULATION_NAME)==0) {
+    ld_emulation = &ld_gld29k_emulation;       
+  }
+  else if (strcmp(target,GLDNEWS_EMULATION_NAME)==0) {
+    ld_emulation = &ld_gldnews_emulation;      
+  }
+#endif
+  else {
+    info("%P%F unrecognised emulation mode: %s\n",target);
+  }
+}
+
+
+
index bdb1c7bcceb6ef0df87c20170660f97e14b43f39..f3a3b0cdcf7bd6b3ca34d9418f58f46fe38a29a7 100755 (executable)
@@ -25,8 +25,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  */
 
 
-#include "sysdep.h"
 #include "bfd.h"
+#include "sysdep.h"
 
 
 #include "ld.h"
index 366f9e6abd110ae59d6cd9ec347cf76c235dec80..bd8d0b601ae77e08362157c794353c651bdda89a 100644 (file)
 */
 
 
+#define DONTDECLARE_MALLOC
 
-#include "sysdep.h"
 #include "bfd.h"
+#include "sysdep.h"
 #include "ld.h"    
 #include "ldexp.h"
 #include "ldver.h"
 #include "ldlang.h"
-#include "ld-emul.h"
+#include "ldemul.h"
 #include "ldfile.h"
 #include "ldmisc.h"
+
+
 #define YYDEBUG 1
 
 boolean option_v;
@@ -46,7 +49,7 @@ lang_output_section_statement_type *lang_output_section_statement_lookup();
 #ifdef __STDC__
 
 void lang_add_data(int type, union etree_union *exp);
-void lang_enter_output_section_statement(char *output_section_statement_name, etree_type *address_exp, bfd_vma block_value);
+void lang_enter_output_section_statement(char *output_section_statement_name, etree_type *address_exp, int flags, bfd_vma block_value);
 
 #else
 
@@ -89,7 +92,7 @@ boolean ldgram_had_equals = false;
 }
 
 %type <etree> exp  opt_exp  
-%type <integer> fill_opt opt_block
+%type <integer> fill_opt opt_block opt_type
 %type <name> memspec_opt
 %token <integer> INT  
 %token <name> NAME
@@ -117,10 +120,11 @@ boolean ldgram_had_equals = false;
 %token '{' '}'
 %token SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
 %token SIZEOF_HEADERS
-%token MEMORY 
+%token MEMORY  
+%token NOLOAD DSECT COPY INFO OVERLAY
 %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY 
 %token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S OPTION_sort_common
-%token OPTION_format  OPTION_F OPTION_u
+%token OPTION_format  OPTION_F OPTION_u OPTION_Bstatic OPTION_N
 %token <integer> SIZEOF NEXT ADDR 
 %token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X OPTION_defsym
 %token OPTION_v OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT 
@@ -128,7 +132,7 @@ boolean ldgram_had_equals = false;
 %token <name> OPTION_l OPTION_L  OPTION_T OPTION_Aarch OPTION_Tfile  OPTION_Texp
 %token OPTION_Ur 
 %token ORIGIN FILL OPTION_g
-%token LENGTH    CREATE_OBJECT_SYMBOLS INPUT OUTPUT  
+%token LENGTH    CREATE_OBJECT_SYMBOLS INPUT OUTPUT  CONSTRUCTORS
 %type <token> assign_op 
 
 %type <name>  filename
@@ -158,6 +162,7 @@ command_line_option:
                ifile_list 
                        { ldgram_in_script = false; }
                '}'
+        |      OPTION_Bstatic { }
        |       OPTION_v
                        {       
                        ldversion();
@@ -171,8 +176,11 @@ command_line_option:
                        }
        |       OPTION_n {
                        config.magic_demand_paged = false;
-                       config.make_executable = false;
+                       config.text_read_only = true;
                        }
+        |       OPTION_N {
+                       config.magic_demand_paged = false;
+                       }
         |       OPTION_s {
                        strip_symbols = STRIP_ALL;
                        }
@@ -262,8 +270,8 @@ command_line_option:
         |      NAME
                { lang_add_input_file($1,lang_input_file_is_file_enum,
                                 (char *)NULL); }
-       |       OPTION_c filename script_file
-                       { ldfile_open_command_file($2); }
+       |       OPTION_c filename 
+                       { ldfile_open_command_file($2); } script_file
        |       OPTION_Tfile 
                        { ldfile_open_command_file($1); } script_file
 
@@ -325,6 +333,7 @@ ifile_p1:
        |       low_level_library
        |       floating_point_support
        |       statement_anywhere
+        |       ';'
        |       TARGET_K '(' NAME ')'
                { lang_add_target($3); }
        |       SEARCH_DIR '(' filename ')'
@@ -405,6 +414,10 @@ statement:
        |       statement CREATE_OBJECT_SYMBOLS
                {
                  lang_add_attribute(lang_object_symbols_statement_enum); }
+        |      statement ';'
+        |      statement CONSTRUCTORS
+               {
+                 lang_add_attribute(lang_constructors_statement_enum); }
 
        |       statement input_section_spec
         |       statement length '(' exp ')'
@@ -629,11 +642,11 @@ exp       :
                        { $$ = exp_nameop(SIZEOF_HEADERS,0); }
 
        |       SIZEOF  '('  NAME ')'
-                       { $$ = exp_nameop($1,$3); }
+                       { $$ = exp_nameop(SIZEOF,$3); }
        |       ADDR '(' NAME ')'
-                       { $$ = exp_nameop($1,$3); }
+                       { $$ = exp_nameop(ADDR,$3); }
        |       ALIGN_K '(' exp ')'
-                       { $$ = exp_unop($1,$3); }
+                       { $$ = exp_unop(ALIGN_K,$3); }
        |       NAME
                        { $$ = exp_nameop(NAME,$1); }
        ;
@@ -641,17 +654,26 @@ exp       :
 
 
 
-section:       NAME opt_exp opt_block ':' opt_things'{' 
+section:       NAME opt_exp opt_type opt_block ':' opt_things'{' 
                {
-               lang_enter_output_section_statement($1,$2,$3);
+               lang_enter_output_section_statement($1,$2,$3,$4);
                }
               statement        '}'     fill_opt memspec_opt
                {
-                 lang_leave_output_section_statement($10, $11);
+                 lang_leave_output_section_statement($11, $12);
                }
 
        ;
 
+opt_type:      
+         '(' NOLOAD ')' { $$ = SEC_NO_FLAGS; }
+       | '(' DSECT ')' { $$ = 0; }
+       | '(' COPY ')' { $$ = 0; }
+       | '(' INFO ')' { $$ = 0; }
+       | '(' OVERLAY ')' { $$ = 0; }
+       |    { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; }
+       ;
+
 opt_things: 
        {
 
index 7770e8dc42648effe6ce96cde0b00d47df1537be..834c6275ac75ae0e36f996ef1643a7bc22b3f254 100644 (file)
@@ -12,8 +12,8 @@
 
 
 
-#include "sysdep.h"
 #include "bfd.h"
+#include "sysdep.h"
 #include "ld.h"
 #include "ldsym.h"
 #include "ldmisc.h"
index f472353ab7783e10eca5933baadca2787ecc7851..b7596a0cec53c281899cba80848a51712ce55ffa 100644 (file)
@@ -20,10 +20,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  *
 */
 
-
-
-#include "sysdep.h" 
 #include "bfd.h"
+#include "sysdep.h" 
 
 #include "ld.h"
 #include "ldmain.h"
@@ -766,8 +764,8 @@ lang_reasonable_defaults()
  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 {
-  struct ldlang_undef_chain_list_struct *next;
+typedef struct ldlang_undef_chain_list {
+  struct ldlang_undef_chain_list *next;
   char *name;
 } ldlang_undef_chain_list_type;
 
@@ -1621,10 +1619,6 @@ DEFUN_VOID(lang_relocate_globals)
              {
                produce_warnings(lgs, it);
              }
-         if (lgs->flags & SYM_INDIRECT)
-             {
-               do_indirect(lgs);
-             }
 
          while (ptr != (asymbol **)NULL) {
            asymbol *ref = *ptr;
@@ -1675,9 +1669,8 @@ DEFUN_VOID(lang_check)
   bfd * input_bfd;
   unsigned long input_machine;
   enum bfd_architecture input_architecture;
-CONST  char *out_arch;
-  char *out_arch2;
 
+  CONST  bfd_arch_info_type *compatible;
 
   for (file = file_chain.head;
        file != (lang_statement_union_type *)NULL;
@@ -1688,37 +1681,34 @@ CONST  char *out_arch;
 
        input_bfd = file->input_statement.the_bfd;
 
-       input_machine = bfd_get_machine(input_bfd);
-       input_architecture = bfd_get_architecture(input_bfd);  
+       input_machine = bfd_get_mach(input_bfd);
+       input_architecture = bfd_get_arch(input_bfd);  
 
  
-       /* Inspect the architecture and ensure we're linking like with like */
-       if (!bfd_arch_compatible(input_bfd,
-                                output_bfd,
-                                &ldfile_new_output_architecture,
-                                &ldfile_new_output_machine)) 
-           {
+       /* Inspect the architecture and ensure we're linking like with
+          like */
 
-             /* Result of bfd_printable_arch_mach is not guaranteed to stick
-                around after next call, so we have to copy it.  */
-             out_arch = bfd_printable_arch_mach(ldfile_output_architecture,
-                                                ldfile_output_machine);
-             out_arch2 = ldmalloc (strlen (out_arch)+1);
-             strcpy (out_arch2, out_arch);
+       compatible=bfd_arch_get_compatible(input_bfd,
+                                          output_bfd);
 
-             info("%P: warning, %s architecture of input file `%B' incompatible with %s output\n",
-                  bfd_printable_arch_mach(input_architecture, input_machine),
-                  input_bfd,
-                  out_arch2);
-             free (out_arch2);
+       if (compatible)  
+           {
+             ldfile_output_machine = compatible->mach;
+             ldfile_output_architecture = compatible->arch;
+           }                           
+       else
+           {
 
+             info("%P: warning, %s architecture of input file `%B' incompatible with %s output\n",
+                  bfd_printable_name(input_bfd), input_bfd,
+                  bfd_printable_name(output_bfd));
 
              bfd_set_arch_mach(output_bfd,
                                ldfile_new_output_architecture,
                                ldfile_new_output_machine);
            }
-      }
 
+      }
 }
 
 
@@ -2076,6 +2066,7 @@ ldsym_type *name)
   next->sym= name;
   name->flags |= SYM_CONSTRUCTOR;
   constructor_name_list = next;
+
 }
 
 void
index ff862f99273ca59df16e2c0ee2663ea9cd2d67b8..58a9b8e6085190e2eebcb4700909dc2e748b3e40 100755 (executable)
@@ -27,8 +27,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  * intel coff loader emulation specific stuff
  */
 
-#include "sysdep.h"
 #include "bfd.h"
+#include "sysdep.h"
 
 /*#include "archures.h"*/
 #include "ld.h"
index f3770c07f69c681f560d792ae6b635c27fdfb967..781f8dfc045eefeafa9d53b8cfa7e95274475f24 100644 (file)
@@ -20,13 +20,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  *  Written by Steve Chamberlain steve@cygnus.com
  *
  * $Id$ 
- *
- *
  */
 
-
-#include "sysdep.h"
 #include "bfd.h"
+#include "sysdep.h"
 
 #include "config.h"
 #include "ld.h"
@@ -99,7 +96,7 @@ boolean write_map;
 int unix_relocate;
 #ifdef GNU960
 /* Indicates whether output file will be b.out (default) or coff */
-enum target_flavour_enum output_flavor = BFD_BOUT_FORMAT;
+enum target_flavour output_flavor = BFD_BOUT_FORMAT;
 #endif
 
 /* Force the make_executable to be output, even if there are non-fatal
index 0f5b375cc40daefcd6268b4d26375abe6352ea28..d6d59f7935aee6281fc59ba67bf8970043e94011 100644 (file)
@@ -60,8 +60,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 */
 
-#include "sysdep.h"
 #include "bfd.h"
+#include "sysdep.h"
 
 #include "ld.h"
 #include "ldsym.h"
index 7c72cc3d07dab5c701071aaed618e395de864a5e..0d167270efcb01473d6873627a186ce97902e135 100755 (executable)
@@ -28,8 +28,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  */
 
 
-#include "sysdep.h"
 #include "bfd.h"
+#include "sysdep.h"
 
 
 #include "ld.h"
index c955d7bd094181c450dd934ba3a0a979560b8680..f5670b4e4a689105dffe1a8356db13e50015b145 100644 (file)
@@ -1,5 +1,5 @@
-#include "sysdep.h"
 #include "bfd.h"
+#include "sysdep.h"
 #include "ldsym.h"
 #include "ldwarn.h"
 #include "ldmisc.h"