aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ld/ldemul.c147
-rwxr-xr-xld/ldgld960.c2
-rw-r--r--ld/ldgram.y54
-rw-r--r--ld/ldindr.c2
-rw-r--r--ld/ldlang.c53
-rwxr-xr-xld/ldlnk960.c2
-rw-r--r--ld/ldmain.c7
-rw-r--r--ld/ldsym.c2
-rwxr-xr-xld/ldvanilla.c2
-rw-r--r--ld/ldwarn.c2
10 files changed, 215 insertions, 58 deletions
diff --git a/ld/ldemul.c b/ld/ldemul.c
new file mode 100644
index 0000000..eafe26c
--- /dev/null
+++ b/ld/ldemul.c
@@ -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);
+ }
+}
+
+
+
diff --git a/ld/ldgld960.c b/ld/ldgld960.c
index bdb1c7b..f3a3b0c 100755
--- a/ld/ldgld960.c
+++ b/ld/ldgld960.c
@@ -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"
diff --git a/ld/ldgram.y b/ld/ldgram.y
index 366f9e6..bd8d0b6 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -14,16 +14,19 @@
*/
+#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:
{
diff --git a/ld/ldindr.c b/ld/ldindr.c
index 7770e8d..834c627 100644
--- a/ld/ldindr.c
+++ b/ld/ldindr.c
@@ -12,8 +12,8 @@
-#include "sysdep.h"
#include "bfd.h"
+#include "sysdep.h"
#include "ld.h"
#include "ldsym.h"
#include "ldmisc.h"
diff --git a/ld/ldlang.c b/ld/ldlang.c
index f472353..b7596a0 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -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
diff --git a/ld/ldlnk960.c b/ld/ldlnk960.c
index ff862f9..58a9b8e 100755
--- a/ld/ldlnk960.c
+++ b/ld/ldlnk960.c
@@ -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"
diff --git a/ld/ldmain.c b/ld/ldmain.c
index f3770c0..781f8df 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -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
diff --git a/ld/ldsym.c b/ld/ldsym.c
index 0f5b375..d6d59f7 100644
--- a/ld/ldsym.c
+++ b/ld/ldsym.c
@@ -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"
diff --git a/ld/ldvanilla.c b/ld/ldvanilla.c
index 7c72cc3..0d16727 100755
--- a/ld/ldvanilla.c
+++ b/ld/ldvanilla.c
@@ -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"
diff --git a/ld/ldwarn.c b/ld/ldwarn.c
index c955d7b..f5670b4 100644
--- a/ld/ldwarn.c
+++ b/ld/ldwarn.c
@@ -1,5 +1,5 @@
-#include "sysdep.h"
#include "bfd.h"
+#include "sysdep.h"
#include "ldsym.h"
#include "ldwarn.h"
#include "ldmisc.h"