checkpoint before a merge

This commit is contained in:
Steve Chamberlain 1991-04-14 03:22:42 +00:00
parent da56abdf49
commit 1418c83b39
20 changed files with 1342 additions and 1609 deletions

View File

@ -22,6 +22,7 @@
#define EMULATION_ENVIRON "LDEMULATION" #define EMULATION_ENVIRON "LDEMULATION"
/* If in there look for the strings: */ /* If in there look for the strings: */
#define GLD_EMULATION_NAME "gld" #define GLD_EMULATION_NAME "gld"
#define VANILLA_EMULATION_NAME "vanilla"
#define GLD68K_EMULATION_NAME "gld68k" #define GLD68K_EMULATION_NAME "gld68k"
#define GLD960_EMULATION_NAME "gld960" #define GLD960_EMULATION_NAME "gld960"
#define LNK960_EMULATION_NAME "lnk960" #define LNK960_EMULATION_NAME "lnk960"
@ -36,6 +37,7 @@
#define GLD68K_TARGET "a.out-generic-big" #define GLD68K_TARGET "a.out-generic-big"
#define LNK960_TARGET "coff-Intel-big" #define LNK960_TARGET "coff-Intel-big"
#define GLD960_TARGET "b.out.big" #define GLD960_TARGET "b.out.big"
#define VANILLA_TARGET "a.out-generic-big"

View File

@ -36,6 +36,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
extern ld_emulation_xfer_type ld_lnk960_emulation; extern ld_emulation_xfer_type ld_lnk960_emulation;
extern ld_emulation_xfer_type ld_gld_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_gld68k_emulation;
extern ld_emulation_xfer_type ld_gld960_emulation; extern ld_emulation_xfer_type ld_gld960_emulation;
@ -112,6 +113,9 @@ char *target;
else if (strcmp(target,GLD_EMULATION_NAME)==0) { else if (strcmp(target,GLD_EMULATION_NAME)==0) {
ld_emulation = &ld_gld_emulation; ld_emulation = &ld_gld_emulation;
} }
else if (strcmp(target,VANILLA_EMULATION_NAME)==0) {
ld_emulation = &ld_vanilla_emulation;
}
else if (strcmp(target,GLD68K_EMULATION_NAME)==0) { else if (strcmp(target,GLD68K_EMULATION_NAME)==0) {
ld_emulation = &ld_gld68k_emulation; ld_emulation = &ld_gld68k_emulation;
} }

View File

@ -19,39 +19,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* /*
* $Id$ * $Id$
* *
* $Log$
* Revision 1.2 1991/03/22 23:02:29 steve
* Brought up to sync with Intel again.
*
* Revision 1.2 1991/03/15 18:45:55 rich
* foo
*
* Revision 1.1 1991/03/13 00:48:11 chrisb
* Initial revision
*
* Revision 1.7 1991/03/10 09:31:18 rich
* Modified Files:
* Makefile config.h ld-emul.c ld-emul.h ld-gld.c ld-gld960.c
* ld-lnk960.c ld.h lddigest.c ldexp.c ldexp.h ldfile.c ldfile.h
* ldgram.y ldinfo.h ldlang.c ldlang.h ldlex.h ldlex.l ldmain.c
* ldmain.h ldmisc.c ldmisc.h ldsym.c ldsym.h ldversion.c
* ldversion.h ldwarn.h ldwrite.c ldwrite.h y.tab.h
*
* As of this round of changes, ld now builds on all hosts of (Intel960)
* interest and copy passes my copy test on big endian hosts again.
*
* Revision 1.6 1991/03/09 03:23:12 sac
* Added -Ur loader script.
*
* Revision 1.5 1991/03/06 21:59:29 sac
* Completed G++ support
*
* Revision 1.4 1991/03/06 02:23:34 sac
* Added support for partial linking.
*
* Revision 1.3 1991/02/22 17:14:56 sac
* Added RCS keywords and copyrights
*
*/ */
/* /*
@ -140,95 +107,17 @@ char *ignore;
info("%S HLL ignored\n"); info("%S HLL ignored\n");
} }
static char *gld_script = " \ static char *gld_script =
SEARCH_DIR(/lib) \ #include "ld-gld.x"
SEARCH_DIR(/usr/lib) \ ;
SEARCH_DIR(/usr/local/lib) \
__DYNAMIC = 0; \
SECTIONS \
{ \
.text 0x2020 BLOCK(0x2000): \
{ \
CREATE_OBJECT_SYMBOLS \
*(.text) \
_etext = ALIGN( 0x2000); \
} \
.data ALIGN(0x2000) : \
{ \
*(.data) \
___DTOR_LIST__=. ; \
LONG((___CTOR_LIST__ - .)/4 -2) \
*(___DTOR_LIST__) \
LONG(0) \
___CTOR_LIST__=. ; \
LONG((_edata - .)/4 -2) \
*(___CTOR_LIST__) \
LONG(0) \
_edata = .; \
} \
.bss SIZEOF(.data) + ADDR(.data) : \
{ \
*(.bss) \
[COMMON] \
_end=.; \
} \
}";
static char *gld_script_option_Ur =
#include "ld-gld-Ur.x"
;
static char *gld_script_option_Ur = "\ static char *gld_script_option_r =
SEARCH_DIR(/lib) \ #include "ld-gld-r.x"
SEARCH_DIR(/usr/lib) \ ;
SEARCH_DIR(/usr/local/lib) \
SECTIONS \
{ \
.text 0: \
{ \
CREATE_OBJECT_SYMBOLS \
*(.text) \
} \
.data SIZEOF(.text) + ADDR(.text) : \
{ \
*(.data) \
___DTOR_LIST__=. ; \
LONG((___CTOR_LIST__ - .)/4 -2) \
*(___DTOR_LIST__) \
LONG(0) \
___CTOR_LIST__=. ; \
LONG((___end_list__ - .)/4 -2) \
*(___CTOR_LIST__) \
LONG(0) \
___end_list__ = . ; \
} \
.bss SIZEOF(.data) + ADDR(.data) : \
{ \
*(.bss) \
[COMMON] \
} \
} \
";
static char *gld_script_option_r = "\
SEARCH_DIR(/lib) \
SEARCH_DIR(/usr/lib) \
SEARCH_DIR(/usr/local/lib) \
SECTIONS \
{ \
.text 0: \
{ \
CREATE_OBJECT_SYMBOLS \
*(.text) \
} \
.data SIZEOF(.text) + ADDR(.text) : \
{ \
*(.data) \
} \
.bss SIZEOF(.data) + ADDR(.data) : \
{ \
*(.bss) \
[COMMON] \
} \
} \
";
static char *gld_get_script() static char *gld_get_script()
{ {

View File

@ -105,96 +105,16 @@ char *ignore;
info("%S HLL ignored\n"); info("%S HLL ignored\n");
} }
static char *gld68k_script = " \ static char *gld68k_script =
SEARCH_DIR(/lib) \ #include "ld-gld68k.x"
SEARCH_DIR(/usr/lib) \ ;
SEARCH_DIR(/usr/local/lib) \
__DYNAMIC = 0; \
SECTIONS \
{ \
.text 0x2020 BLOCK(0x2000): \
{ \
CREATE_OBJECT_SYMBOLS \
*(.text) \
_etext = ALIGN( 0x2000); \
} \
.data ALIGN(0x20000) : \
{ \
*(.data) \
___DTOR_LIST__=. ; \
LONG((___CTOR_LIST__ - .)/4 -2) \
*(___DTOR_LIST__) \
LONG(0) \
___CTOR_LIST__=. ; \
LONG((_edata - .)/4 -2) \
*(___CTOR_LIST__) \
LONG(0) \
_edata = .; \
} \
.bss SIZEOF(.data) + ADDR(.data) : \
{ \
*(.bss) \
[COMMON] \
_end=.; \
} \
}";
static char *gld68k_script_option_Ur =
static char *gld68k_script_option_Ur = "\ #include "ld-gld68k-Ur.x"
SEARCH_DIR(/lib) \ ;
SEARCH_DIR(/usr/lib) \ static char *gld68k_script_option_r =
SEARCH_DIR(/usr/local/lib) \ #include "ld-gld68k-r.x"
SECTIONS \ ;
{ \
.text 0: \
{ \
CREATE_OBJECT_SYMBOLS \
*(.text) \
} \
.data SIZEOF(.text) + ADDR(.text) : \
{ \
*(.data) \
___DTOR_LIST__=. ; \
LONG((___CTOR_LIST__ - .)/4 -2) \
*(___DTOR_LIST__) \
LONG(0) \
___CTOR_LIST__=. ; \
LONG((___end_list__ - .)/4 -2) \
*(___CTOR_LIST__) \
LONG(0) \
___end_list__ = . ; \
} \
.bss SIZEOF(.data) + ADDR(.data) : \
{ \
*(.bss) \
[COMMON] \
} \
} \
";
static char *gld68k_script_option_r = "\
SEARCH_DIR(/lib) \
SEARCH_DIR(/usr/lib) \
SEARCH_DIR(/usr/local/lib) \
SECTIONS \
{ \
.text 0: \
{ \
CREATE_OBJECT_SYMBOLS \
*(.text) \
} \
.data SIZEOF(.text) + ADDR(.text) : \
{ \
*(.data) \
} \
.bss SIZEOF(.data) + ADDR(.data) : \
{ \
*(.bss) \
[COMMON] \
} \
} \
";
static char *gld68k_get_script() static char *gld68k_get_script()
{ {
extern ld_config_type config; extern ld_config_type config;

View File

@ -20,9 +20,12 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
$Id$ $Id$
$Log$ $Log$
Revision 1.2 1991/03/22 23:02:30 steve Revision 1.3 1991/04/14 03:22:11 steve
Brought up to sync with Intel again. checkpoint before a merge
* Revision 1.2 1991/03/22 23:02:30 steve
* Brought up to sync with Intel again.
*
* Revision 1.3 1991/03/16 22:27:24 rich * Revision 1.3 1991/03/16 22:27:24 rich
* fish * fish
* *
@ -143,31 +146,10 @@ gld960_hll()
} }
static char *script = "\ static char *script =
\ #include "ld-gld960.x"
SECTIONS \ ;
{ \
.text : \
{ \
CREATE_OBJECT_SYMBOLS \
*(.text) \
_etext =.;\
} \
\
.data SIZEOF(.text) + ADDR(.text):\
{ \
\
*(.data) \
_edata = .; \
} \
.bss SIZEOF(.data) + ADDR(.data) : \
{ _bss_start = .;\
*(.bss) \
[COMMON] \
_end = . ; \
} \
} \
";
static char * static char *
gld960_get_script() gld960_get_script()

View File

@ -18,40 +18,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* /*
$Id$ $Id$
$Log$
Revision 1.3 1991/04/08 23:21:26 steve
*** empty log message ***
* Revision 1.2 1991/03/22 23:02:31 steve
* Brought up to sync with Intel again.
*
* Revision 1.2 1991/03/15 18:45:55 rich
* foo
*
* Revision 1.1 1991/03/13 00:48:13 chrisb
* Initial revision
*
* Revision 1.6 1991/03/10 09:31:20 rich
* Modified Files:
* Makefile config.h ld-emul.c ld-emul.h ld-gld.c ld-gld960.c
* ld-lnk960.c ld.h lddigest.c ldexp.c ldexp.h ldfile.c ldfile.h
* ldgram.y ldinfo.h ldlang.c ldlang.h ldlex.h ldlex.l ldmain.c
* ldmain.h ldmisc.c ldmisc.h ldsym.c ldsym.h ldversion.c
* ldversion.h ldwarn.h ldwrite.c ldwrite.h y.tab.h
*
* As of this round of changes, ld now builds on all hosts of (Intel960)
* interest and copy passes my copy test on big endian hosts again.
*
* Revision 1.5 1991/03/09 03:23:47 sac
* Now looks in G960BASE if I960BASE isn't defined.
*
* Revision 1.4 1991/03/06 02:23:35 sac
* Added support for partial linking.
*
* Revision 1.3 1991/02/22 17:14:58 sac
* Added RCS keywords and copyrights
*
*/ */
/* /*
@ -131,6 +97,33 @@ char *name;
#ifdef GNU960
static void
lnk960_before_parse()
{
static char *env_variables[] = { "G960LIB", "G960BASE", 0 };
char **p;
char *env ;
for ( p = env_variables; *p; p++ ){
env = (char *) getenv(*p);
if (env) {
ldfile_add_library_path(concat(env,"/lib/libcoff",""));
}
}
env= (char *) getenv("I960BASE");
if ( env ) {
ldfile_add_library_path(concat(env,"/lib",""));
}
ldfile_output_architecture = bfd_arch_i960;
ldfile_output_machine = bfd_mach_i960_core;
}
#else /* not GNU960 */
static void static void
lnk960_before_parse() lnk960_before_parse()
{ {
@ -149,6 +142,9 @@ lnk960_before_parse()
ldfile_output_machine = bfd_mach_i960_core; ldfile_output_machine = bfd_mach_i960_core;
} }
#endif /* GNU960 */
static void static void
add_on(list, search) add_on(list, search)
lib_list_type *list; lib_list_type *list;
@ -166,7 +162,7 @@ static void lnk960_after_parse()
/* If there has been no arch, default to -KB */ /* If there has been no arch, default to -KB */
if (ldfile_output_machine_name[0] ==0) { if (ldfile_output_machine_name[0] ==0) {
ldfile_add_arch("kb"); ldfile_add_arch("KB");
} }
/* if there has been no hll list then add our own */ /* if there has been no hll list then add our own */
@ -211,6 +207,7 @@ lnk960_after_allocation()
} }
} }
static struct static struct
{ {
unsigned long number; unsigned long number;
@ -255,64 +252,37 @@ lnk960_set_output_arch()
static char * static char *
lnk960_choose_target() lnk960_choose_target()
{ {
#ifdef GNU960
return bfd_make_targ_name(BFD_COFF_FORMAT,HOST_BYTE_ORDER_BIG_P);
#else
char *from_outside = getenv(TARGET_ENVIRON); char *from_outside = getenv(TARGET_ENVIRON);
if (from_outside != (char *)NULL) if (from_outside != (char *)NULL)
return from_outside; return from_outside;
return LNK960_TARGET; return LNK960_TARGET;
#endif
} }
/* The default script if none is offered */ /* The default script if none is offered */
static char *lnk960_script = "\ static char *lnk960_script =
SECTIONS \ #include "ld-lnk960.x"
{ \ ;
.text : \
{ \
*(.text) \
} \
_etext = .;\
.data SIZEOF(.text) + ADDR(.text):\
{ \
*(.data) \
} \
_edata = .; \
.bss SIZEOF(.data) + ADDR(.data) : \
{ \
_bss_start = . ;\
*(.bss) \
[COMMON] \
} \
_end = . ; \
} \
";
static char *lnk960_script_relocateable = "\
SECTIONS \ static char *lnk960_script_relocateable =
{ \ #include "ld-lnk960-r.x"
.text 0x40000000: \ ;
{ \
*(.text) \
} \
.data 0:\
{ \
*(.data) \
} \
.bss SIZEOF(.data) + ADDR(.data) : \
{ \
*(.bss) \
[COMMON] \
} \
} \
";
static char *lnk960_get_script() static char *lnk960_get_script()
{ {
extern ld_config_type config; extern ld_config_type config;
if (config.relocateable_output) { if (config.relocateable_output) {
return lnk960_script_relocateable; return lnk960_script_relocateable;
} }
return lnk960_script; return lnk960_script;
} }
struct ld_emulation_xfer_struct ld_lnk960_emulation = struct ld_emulation_xfer_struct ld_lnk960_emulation =
{ {

29
ld/ld.h
View File

@ -42,20 +42,6 @@ typedef struct user_section_struct {
#define get_userdata(x) ((x)->userdata) #define get_userdata(x) ((x)->userdata)
#define as_output_section_statement(x) ((x)->otheruserdata) #define as_output_section_statement(x) ((x)->otheruserdata)
#if 0
/*
* Structure for communication between do_file_warnings and it's
* helper routines. Will in practice be an array of three of these:
* 0) Current line, 1) Next line, 2) Source file info.
*/
struct line_debug_entry
{
int line;
char *filename;
struct nlist *sym;
};
#endif
/* Which symbols should be stripped (omitted from the output): /* Which symbols should be stripped (omitted from the output):
@ -76,19 +62,8 @@ enum { DISCARD_NONE, DISCARD_ALL, DISCARD_L } discard_locals;
#define ALIGN(this, boundary) ((( (this) + ((boundary) -1)) & (~((boundary)-1)))) #define ALIGN(this, boundary) ((( (this) + ((boundary) -1)) & (~((boundary)-1))))
#if 0
#define FOREACHGLOBALSYMBOL(x) ldsym_type *x; for (x = symbol_head; x; x=x->next)
#define SECTIONLOOP(abfd, ptr) \
asection *ptr; for(ptr = abfd->sections; ptr;ptr=ptr->next)
#endif
typedef struct { typedef struct {
/* 1 => assign space to common symbols even if `relocatable_output'. */ /* 1 => assign space to common symbols even if `relocatable_output'. */
boolean force_common_definition; boolean force_common_definition;
@ -112,10 +87,10 @@ typedef struct
} ld_config_type; } ld_config_type;
#define set_asymbol_chain(x,y) ((x)->udata = (void *)y) #define set_asymbol_chain(x,y) ((x)->udata = (PTR)y)
#define get_asymbol_chain(x) ((asymbol **)((x)->udata)) #define get_asymbol_chain(x) ((asymbol **)((x)->udata))
#define get_loader_symbol(x) ((loader_global_asymbol *)((x)->udata)) #define get_loader_symbol(x) ((loader_global_asymbol *)((x)->udata))
#define set_loader_symbol(x,y) ((x)->udata = (void *)y) #define set_loader_symbol(x,y) ((x)->udata = (PTR)y)

View File

@ -18,34 +18,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* /*
$Id$ $Id$
$Log$
Revision 1.1 1991/03/21 21:28:34 gumby
Initial revision
* Revision 1.1 1991/03/13 00:48:16 chrisb
* Initial revision
*
* Revision 1.6 1991/03/10 09:31:22 rich
* Modified Files:
* Makefile config.h ld-emul.c ld-emul.h ld-gld.c ld-gld960.c
* ld-lnk960.c ld.h lddigest.c ldexp.c ldexp.h ldfile.c ldfile.h
* ldgram.y ldinfo.h ldlang.c ldlang.h ldlex.h ldlex.l ldmain.c
* ldmain.h ldmisc.c ldmisc.h ldsym.c ldsym.h ldversion.c
* ldversion.h ldwarn.h ldwrite.c ldwrite.h y.tab.h
*
* As of this round of changes, ld now builds on all hosts of (Intel960)
* interest and copy passes my copy test on big endian hosts again.
*
* Revision 1.5 1991/03/09 03:25:04 sac
* Added support for LONG, SHORT and BYTE keywords in scripts
*
* Revision 1.4 1991/03/06 02:27:15 sac
* Added LONG, SHORT and BYTE keywords
*
* Revision 1.3 1991/02/22 17:14:59 sac
* Added RCS keywords and copyrights
*
*/ */
/* /*
@ -519,7 +491,7 @@ bfd_vma *dotp;
} }
def->udata = (void *)NULL; def->udata = (PTR)NULL;
def->name = sy->name; def->name = sy->name;
Q_enter_global_ref(def_ptr); Q_enter_global_ref(def_ptr);
} }

View File

@ -19,31 +19,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* /*
$Id$ $Id$
$Log$
Revision 1.1 1991/03/21 21:28:37 gumby
Initial revision
* Revision 1.2 1991/03/15 18:45:55 rich
* foo
*
* Revision 1.1 1991/03/13 00:48:18 chrisb
* Initial revision
*
* Revision 1.4 1991/03/10 09:31:24 rich
* Modified Files:
* Makefile config.h ld-emul.c ld-emul.h ld-gld.c ld-gld960.c
* ld-lnk960.c ld.h lddigest.c ldexp.c ldexp.h ldfile.c ldfile.h
* ldgram.y ldinfo.h ldlang.c ldlang.h ldlex.h ldlex.l ldmain.c
* ldmain.h ldmisc.c ldmisc.h ldsym.c ldsym.h ldversion.c
* ldversion.h ldwarn.h ldwrite.c ldwrite.h y.tab.h
*
* As of this round of changes, ld now builds on all hosts of (Intel960)
* interest and copy passes my copy test on big endian hosts again.
*
* Revision 1.3 1991/02/22 17:15:00 sac
* Added RCS keywords and copyrights
*
*/ */
/* /*
@ -60,11 +35,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ldlang.h" #include "ldlang.h"
#include "ldfile.h" #include "ldfile.h"
#include <ctype.h>
/* EXPORT */ /* EXPORT */
char *ldfile_input_filename; char *ldfile_input_filename;
char *ldfile_output_machine_name; CONST char * ldfile_output_machine_name;
unsigned long ldfile_output_machine; unsigned long ldfile_output_machine;
enum bfd_architecture ldfile_output_architecture; enum bfd_architecture ldfile_output_architecture;
boolean had_script; boolean had_script;
@ -96,6 +69,8 @@ typedef struct search_arch_struct
static search_arch_type *search_arch_head; static search_arch_type *search_arch_head;
static search_arch_type **search_arch_tail_ptr = &search_arch_head; static search_arch_type **search_arch_tail_ptr = &search_arch_head;
void void
ldfile_add_library_path(name) ldfile_add_library_path(name)
char *name; char *name;
@ -115,8 +90,9 @@ char *attempt;
lang_input_statement_type *entry; lang_input_statement_type *entry;
{ {
entry->the_bfd = bfd_openr(attempt, entry->target); entry->the_bfd = bfd_openr(attempt, entry->target);
if (option_v == true && entry->the_bfd == (bfd *)NULL) {
info("attempt to open %s failed\n", attempt);
}
return entry->the_bfd; return entry->the_bfd;
} }
@ -143,11 +119,11 @@ char *suffix;
entry->filename, arch, suffix); entry->filename, arch, suffix);
} }
else { else {
if (entry->filename[0] == '/') { if (entry->filename[0] == '/' || entry->filename[0] == '.') {
strcpy(buffer, entry->filename); strcpy(buffer, entry->filename);
} else { } else {
sprintf(buffer,"%s/%s",search->name, entry->filename); sprintf(buffer,"%s/%s",search->name, entry->filename);
} /* */ }
} }
string = buystring(buffer); string = buystring(buffer);
desc = cached_bfd_openr (string, entry); desc = cached_bfd_openr (string, entry);
@ -178,6 +154,8 @@ lang_input_statement_type *entry;
if (entry->search_dirs_flag) if (entry->search_dirs_flag)
{ {
search_arch_type *arch; search_arch_type *arch;
/* Try to open <filename><suffix> or lib<filename><suffix>.a */
for (arch = search_arch_head; for (arch = search_arch_head;
arch != (search_arch_type *)NULL; arch != (search_arch_type *)NULL;
arch = arch->next) { arch = arch->next) {
@ -213,14 +191,21 @@ char *exten;
FILE *result; FILE *result;
char buff[1000]; char buff[1000];
result = fopen(name, "r"); result = fopen(name, "r");
if (result && option_v == true) { if (option_v == true) {
if (result == (FILE *)NULL) {
info("can't find ");
}
info("%s\n",name); info("%s\n",name);
return result; return result;
} }
sprintf(buff, "%s%s", name, exten); sprintf(buff, "%s%s", name, exten);
result = fopen(buff, "r"); result = fopen(buff, "r");
if (result && option_v == true) { if (option_v == true) {
if (result == (FILE *)NULL) {
info("can't find ");
}
info("%s\n", buff); info("%s\n", buff);
} }
return result; return result;
@ -265,12 +250,14 @@ char *name;
void void
ldfile_add_arch(name) DEFUN(ldfile_add_arch,(in_name),
char *name; CONST char *CONST in_name)
{ {
char *name = buystring(in_name);
search_arch_type *new = search_arch_type *new =
(search_arch_type *)ldmalloc(sizeof(search_arch_type)); (search_arch_type *)ldmalloc(sizeof(search_arch_type));
ldfile_output_machine_name = name;
ldfile_output_machine_name = in_name;
new->name = name; new->name = name;
new->next = (search_arch_type*)NULL; new->next = (search_arch_type*)NULL;

View File

@ -20,7 +20,7 @@
PROTO(void,ldfile_add_arch,(char *)); PROTO(void,ldfile_add_arch,(CONST char *CONST));
PROTO(void,ldfile_add_library_path,(char *)); PROTO(void,ldfile_add_library_path,(char *));
PROTO(void,ldfile_open_command_file,(char *name)); PROTO(void,ldfile_open_command_file,(char *name));
PROTO(void,ldfile_open_file,(struct lang_input_statement_struct *)); PROTO(void,ldfile_open_file,(struct lang_input_statement_struct *));

View File

@ -1,4 +1,4 @@
%{
/* /*
* $Id$ * $Id$
* *
@ -59,10 +59,8 @@ char *current_file;
boolean ldgram_want_filename = true; boolean ldgram_want_filename = true;
boolean had_script = false; boolean had_script = false;
boolean force_make_executable = false; boolean force_make_executable = false;
boolean ldgram_has_inputfile = false;
boolean ldgram_in_expression = false; boolean ldgram_in_expression = false;
boolean ldgram_in_script = false;
boolean ldgram_in_defsym = false; boolean ldgram_in_defsym = false;
/* LOCALS */ /* LOCALS */
@ -114,16 +112,16 @@ boolean ldgram_in_defsym = false;
%token SECTIONS %token SECTIONS
%token '{' '}' %token '{' '}'
%token ALIGNMENT SIZEOF_HEADERS %token ALIGNMENT SIZEOF_HEADERS
%token NEXT SIZEOF ADDR %token NEXT SIZEOF ADDR SCRIPT ENDSCRIPT
%token MEMORY %token MEMORY
%token DSECT NOLOAD COPY INFO OVERLAY %token DSECT NOLOAD COPY INFO OVERLAY
%token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY %token NAME DEFINED TARGET_K SEARCH_DIR MAP ENTRY
%token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S %token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S
%token OPTION_format OPTION_F %token OPTION_format OPTION_F OPTION_u
%token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X %token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X
%token OPTION_v OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT OPTION_defsym %token OPTION_v OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT OPTION_defsym
%token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_A %token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_A OPTION_R
%token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp %token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp
%token OPTION_Ur %token OPTION_Ur
%token ORIGIN FILL OPTION_g %token ORIGIN FILL OPTION_g
@ -152,7 +150,8 @@ command_line:
; ;
command_line_option: command_line_option:
OPTION_v SCRIPT ifile_list ENDSCRIPT
| OPTION_v
{ {
ldversion(); ldversion();
option_v = true; option_v = true;
@ -173,7 +172,10 @@ command_line_option:
| OPTION_S { | OPTION_S {
strip_symbols = STRIP_DEBUGGER; strip_symbols = STRIP_DEBUGGER;
} }
| OPTION_u NAME {
ldlang_add_undef($2);
}
| OPTION_r { | OPTION_r {
config.relocateable_output = true; config.relocateable_output = true;
config.build_constructors = false; config.build_constructors = false;
@ -202,10 +204,10 @@ command_line_option:
{ {
force_make_executable = true; force_make_executable = true;
} }
| OPTION_d { | OPTION_d {
command_line.force_common_definition = true; command_line.force_common_definition = true;
} }
| OPTION_dc | OPTION_dc
{ {
command_line.force_common_definition = true; command_line.force_common_definition = true;
} }
@ -213,23 +215,28 @@ command_line_option:
{ {
/* Ignored */ /* Ignored */
} }
| OPTION_dp | OPTION_dp
{ {
command_line.force_common_definition = true; command_line.force_common_definition = true;
} }
| OPTION_format NAME | OPTION_format NAME
{ {
lang_add_target($2); lang_add_target($2);
} }
| OPTION_Texp | OPTION_Texp
{ hex_mode =true; } {
exp hex_mode =true;
{ lang_section_start($1, $3); }
hex_mode = false; } INT
{
lang_section_start($1,exp_intop($3));
hex_mode = false;
}
| OPTION_Aarch | OPTION_Aarch
{ ldfile_add_arch($1); } {
ldfile_add_arch($1);
}
| OPTION_b NAME | OPTION_b NAME
{ {
lang_add_target($2); lang_add_target($2);
@ -237,21 +244,21 @@ command_line_option:
| OPTION_L | OPTION_L
{ {
ldfile_add_library_path($1); ldfile_add_library_path($1);
} }
| OPTION_F | OPTION_F
{ {
/* Ignore */ /* Ignore */
} }
| NAME
| ifile_p1 { lang_add_input_file($1,lang_input_file_is_file_enum,
| input_list (char *)NULL); }
| OPTION_c filename | OPTION_c filename script_file
{ ldfile_open_command_file($2); } { ldfile_open_command_file($2); }
| OPTION_Tfile | OPTION_Tfile
{ ldfile_open_command_file($1); } { ldfile_open_command_file($1); } script_file
| OPTION_T filename | OPTION_T filename
{ ldfile_open_command_file($2); } { ldfile_open_command_file($2); } script_file
| OPTION_l | OPTION_l
{ {
@ -259,7 +266,7 @@ command_line_option:
lang_input_file_is_l_enum, lang_input_file_is_l_enum,
(char *)NULL); (char *)NULL);
} }
| OPTION_A filename | OPTION_R filename
{ {
lang_add_input_file($2, lang_add_input_file($2,
lang_input_file_is_symbols_only_enum, lang_input_file_is_symbols_only_enum,
@ -268,47 +275,38 @@ command_line_option:
| OPTION_defsym | OPTION_defsym
{ {
ldgram_in_defsym = true; ldgram_in_defsym = true;
ldgram_in_expression = true;
hex_mode = true; hex_mode = true;
} }
assignment assignment
{ {
hex_mode = false; hex_mode = false;
ldgram_in_defsym = false; ldgram_in_defsym = false;
ldgram_in_expression = false;
} }
| '-' NAME
{ info("%P%F Unrecognised option -%s\n", $2); }
; ;
input_section_spec:
NAME
{
lang_add_wild((char *)NULL, $1);
}
| '['
{
current_file = (char *)NULL;
}
file_NAME_list
']'
| NAME
{
current_file =$1;
}
'(' file_NAME_list ')'
| '*'
{
current_file = (char *)NULL;
}
'(' file_NAME_list ')'
;
file_NAME_list:
NAME
{ lang_add_wild($1, current_file); } script_file:
| file_NAME_list opt_comma NAME { ldgram_in_script = true; }
{ lang_add_wild($3, current_file); } ifile_list ENDSCRIPT
{ ldgram_in_script = false; }
;
ifile_list:
ifile_list ifile_p1
|
; ;
@ -360,6 +358,36 @@ statement_anywhere:
| assignment end | assignment end
; ;
file_NAME_list:
NAME
{ lang_add_wild($1, current_file); }
| file_NAME_list opt_comma NAME
{ lang_add_wild($3, 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 ')'
| '*'
{
current_file = (char *)NULL;
}
'(' file_NAME_list ')'
;
statement: statement:
statement assignment end statement assignment end
| statement CREATE_OBJECT_SYMBOLS | statement CREATE_OBJECT_SYMBOLS

File diff suppressed because it is too large Load Diff

View File

@ -60,7 +60,6 @@ union lang_statement_union *next;
lang_address_statement_enum, lang_address_statement_enum,
lang_wild_statement_enum, lang_wild_statement_enum,
lang_input_section_enum, lang_input_section_enum,
lang_common_statement_enum,
lang_object_symbols_statement_enum, lang_object_symbols_statement_enum,
lang_fill_statement_enum, lang_fill_statement_enum,
lang_data_statement_enum, lang_data_statement_enum,
@ -83,13 +82,13 @@ typedef struct
typedef struct lang_target_statement_struct { typedef struct lang_target_statement_struct {
lang_statement_header_type header; lang_statement_header_type header;
char *target; CONST char *target;
} lang_target_statement_type; } lang_target_statement_type;
typedef struct lang_output_statement_struct { typedef struct lang_output_statement_struct {
lang_statement_header_type header; lang_statement_header_type header;
char *name; CONST char *name;
} lang_output_statement_type; } lang_output_statement_type;
@ -98,9 +97,9 @@ typedef struct lang_output_section_statement_struct
lang_statement_header_type header; lang_statement_header_type header;
union etree_union *addr_tree; union etree_union *addr_tree;
lang_statement_list_type children; lang_statement_list_type children;
char *memspec; CONST char *memspec;
union lang_statement_union *next; union lang_statement_union *next;
char *name; CONST char *name;
unsigned long subsection_alignment; unsigned long subsection_alignment;
boolean processed; boolean processed;
@ -122,7 +121,7 @@ typedef struct {
typedef struct { typedef struct {
lang_statement_header_type header; lang_statement_header_type header;
fill_type fill; fill_type fill;
} lang_fill_statement_type; } lang_fill_statement_type;
typedef struct { typedef struct {
@ -141,11 +140,11 @@ typedef struct lang_input_statement_struct
{ {
lang_statement_header_type header; lang_statement_header_type header;
/* Name of this file. */ /* Name of this file. */
char *filename; CONST char *filename;
/* Name to use for the symbol giving address of text start */ /* Name to use for the symbol giving address of text start */
/* Usually the same as filename, but for a file spec'd with -l /* Usually the same as filename, but for a file spec'd with -l
this is the -l switch itself rather than the filename. */ this is the -l switch itself rather than the filename. */
char *local_sym_name; CONST char *local_sym_name;
/* Describe the layout of the contents of the file */ /* Describe the layout of the contents of the file */
@ -165,15 +164,6 @@ typedef struct lang_input_statement_struct
asymbol **asymbols; asymbol **asymbols;
unsigned int symbol_count; unsigned int symbol_count;
/* Next two used only if `relocatable_output' or if needed for */
/* output of undefined reference line numbers. */
/* Text reloc info saved by `write_text' for `coptxtrel'. */
/* Offset in bytes in the output file symbol table
of the first local symbol for this file. Set by `write_file_symbols'. */
int local_syms_offset;
/* For library members only */ /* For library members only */
/* For a library, points to chain of entries for the library members. */ /* For a library, points to chain of entries for the library members. */
@ -187,29 +177,29 @@ typedef struct lang_input_statement_struct
struct lang_input_statement_struct *superfile; struct lang_input_statement_struct *superfile;
/* For library member, points to next entry for next member. */ /* For library member, points to next entry for next member. */
struct lang_input_statement_struct *chain; struct lang_input_statement_struct *chain;
/* Point to the next file - whatever it is, wanders up and down archives */ /* Point to the next file - whatever it is, wanders up and down
archives */
union lang_statement_union *next; union lang_statement_union *next;
/* Point to the next file, but skips archive contents */ /* Point to the next file, but skips archive contents */
union lang_statement_union *next_real_file; union lang_statement_union *next_real_file;
boolean is_archive; boolean is_archive;
/* 1 if file's header has been read into this structure. */
boolean header_read_flag;
/* 1 means search a set of directories for this file. */ /* 1 means search a set of directories for this file. */
boolean search_dirs_flag; boolean search_dirs_flag;
/* 1 means this is base file of incremental load. /* 1 means this is base file of incremental load.
Do not load this file's text or data. Do not load this file's text or data.
Also default text_start to after this file's bss. */ Also default text_start to after this file's bss. */
boolean just_syms_flag; boolean just_syms_flag;
boolean loaded; boolean loaded;
/* unsigned int globals_in_this_file;*/ /* unsigned int globals_in_this_file;*/
char *target; CONST char *target;
boolean real; boolean real;
asection *common_section; asection *common_section;
@ -220,6 +210,7 @@ typedef struct {
lang_statement_header_type header; lang_statement_header_type header;
asection *section; asection *section;
lang_input_statement_type *ifile; lang_input_statement_type *ifile;
} lang_input_section_type; } lang_input_section_type;
@ -231,14 +222,14 @@ typedef struct {
typedef struct lang_wild_statement_struct { typedef struct lang_wild_statement_struct {
lang_statement_header_type header; lang_statement_header_type header;
char *section_name; CONST char *section_name;
char *filename; CONST char *filename;
lang_statement_list_type children; lang_statement_list_type children;
} lang_wild_statement_type; } lang_wild_statement_type;
typedef struct lang_address_statement_struct { typedef struct lang_address_statement_struct {
lang_statement_header_type header; lang_statement_header_type header;
char *section_name; CONST char *section_name;
union etree_union *address; union etree_union *address;
} lang_address_statement_type; } lang_address_statement_type;
@ -273,32 +264,34 @@ typedef union lang_statement_union
PROTO(void,lang_init,(void)); PROTO(void,lang_init,(void));
PROTO(struct memory_region_struct ,*lang_memory_region_lookup,(char *)); PROTO(struct memory_region_struct ,
PROTO(struct lang_output_section_statement_struct *,lang_output_section_find,(char *)); *lang_memory_region_lookup,(CONST
char *CONST));
PROTO(void ,lang_map,(struct _iobuf *));
PROTO(void,lang_set_flags,(lang_section_flags_type *, char *)); PROTO(void ,lang_map,(FILE *));
PROTO(void,lang_add_output,(char *)); PROTO(void,lang_set_flags,(lang_section_flags_type *, CONST char *));
PROTO(void,lang_add_output,(CONST char *));
PROTO(void,lang_final,(void)); PROTO(void,lang_final,(void));
PROTO(struct symbol_cache_entry *,create_symbol,(char *, unsigned int, struct sec_struct *)); PROTO(struct symbol_cache_entry *,create_symbol,(CONST char *, unsigned int, struct sec_struct *));
PROTO(void ,lang_process,(void)); PROTO(void ,lang_process,(void));
PROTO(void ,lang_section_start,(char *, union etree_union *)); PROTO(void ,lang_section_start,(CONST char *, union etree_union *));
PROTO(void,lang_add_entry,(char *)); PROTO(void,lang_add_entry,(CONST char *));
PROTO(void,lang_add_target,(char *)); PROTO(void,lang_add_target,(CONST char *));
PROTO(void,lang_add_wild,(char *, char *)); PROTO(void,lang_add_wild,(CONST char *CONST , CONST char *CONST));
PROTO(void,lang_add_map,(char *)); PROTO(void,lang_add_map,(CONST char *));
PROTO(void,lang_add_fill,(int)); PROTO(void,lang_add_fill,(int));
PROTO(void,lang_add_assignment,(union etree_union *)); PROTO(void,lang_add_assignment,(union etree_union *));
PROTO(void,lang_add_attribute,(enum statement_enum)); PROTO(void,lang_add_attribute,(enum statement_enum));
PROTO(void,lang_startup,(char *)); PROTO(void,lang_startup,(CONST char *));
PROTO(void,lang_float,(enum boolean)); PROTO(void,lang_float,(enum boolean));
PROTO(void,lang_leave_output_section_statement,(bfd_vma, char *)); PROTO(void,lang_leave_output_section_statement,(bfd_vma, CONST char *));
PROTO(void,lang_abs_symbol_at_end_of,(char *, char *)); PROTO(void,lang_abs_symbol_at_end_of,(CONST char *, CONST char *));
PROTO(void,lang_abs_symbol_at_beginning_of,(CONST char *, CONST char *));
PROTO(void,lang_statement_append,(struct statement_list *, union lang_statement_union *, union lang_statement_union **)); PROTO(void,lang_statement_append,(struct statement_list *, union lang_statement_union *, union lang_statement_union **));
PROTO(void, lang_for_each_file,(void (*dothis)(lang_input_statement_type *))); PROTO(void, lang_for_each_file,(void (*dothis)(lang_input_statement_type *)));
#define LANG_FOR_EACH_ASYMBOL(asymbol) \
#define LANG_FOR_EACH_INPUT_STATEMENT(statement) \ #define LANG_FOR_EACH_INPUT_STATEMENT(statement) \
extern lang_statement_list_type file_chain; \ extern lang_statement_list_type file_chain; \
@ -337,11 +330,15 @@ PROTO(void, lang_for_each_file,(void (*dothis)(lang_input_statement_type *)));
PROTO(void, lang_process,(void)); PROTO(void, lang_process,(void));
PROTO(void, ldlang_add_file,(lang_input_statement_type *)); PROTO(void, ldlang_add_file,(lang_input_statement_type *));
PROTO(lang_output_section_statement_type *,lang_output_section_find,()); PROTO(lang_output_section_statement_type
*,lang_output_section_find,(CONST char * CONST));
PROTO(lang_input_statement_type *, PROTO(lang_input_statement_type *,
lang_add_input_file,(char *name, lang_add_input_file,(char *name,
lang_input_file_enum_type file_type, lang_input_file_enum_type file_type,
char *target)); char *target));
PROTO(lang_output_section_statement_type *, PROTO(lang_output_section_statement_type *,
lang_output_section_statement_lookup,(char *name)); lang_output_section_statement_lookup,(CONST char * CONST name));
PROTO(void, ldlang_add_undef,(CONST char *CONST name));

View File

@ -28,7 +28,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*SUPPRESS 529*/ /*SUPPRESS 529*/
/*SUPPRESS 26*/ /*SUPPRESS 26*/
/*SUPPRESS 29*/ /*SUPPRESS 29*/
#define LEXDEBUG #define LEXDEBUG 0
#include "sysdep.h" #include "sysdep.h"
#include "bfd.h" #include "bfd.h"
@ -48,7 +48,7 @@ int debug;
extern boolean ldgram_in_expression; extern boolean ldgram_in_expression;
extern boolean ldgram_in_defsym; extern boolean ldgram_in_defsym;
extern boolean ldgram_in_script;
static char *command_line; static char *command_line;
extern int fgetc(); extern int fgetc();
@ -69,6 +69,8 @@ keyword_type keywords[] =
"SUBSECTION_ALIGN",SUBSECTION_ALIGN, "SUBSECTION_ALIGN",SUBSECTION_ALIGN,
"ADDR",ADDR, "ADDR",ADDR,
"ENTRY",ENTRY, "ENTRY",ENTRY,
"SCRIPT", SCRIPT,
"ENDSCRIPT", ENDSCRIPT,
"NEXT",NEXT, "NEXT",NEXT,
"MAP",MAP, "MAP",MAP,
"SIZEOF",SIZEOF, "SIZEOF",SIZEOF,
@ -101,17 +103,15 @@ static unsigned int have_pushback;
int pushback[NPUSHBACK]; int pushback[NPUSHBACK];
int thischar; int thischar;
extern char *ldfile_input_filename; extern char *ldfile_input_filename;
int donehash = 0;
int int
lex_input() lex_input()
{ {
if (have_pushback > 0) if (have_pushback > 0)
{ {
have_pushback --; have_pushback --;
return thischar = pushback[have_pushback]; return thischar = pushback[have_pushback];
} }
if (ldlex_input_stack) { if (ldlex_input_stack) {
thischar = fgetc(ldlex_input_stack); thischar = fgetc(ldlex_input_stack);
@ -119,14 +119,18 @@ lex_input()
fclose(ldlex_input_stack); fclose(ldlex_input_stack);
ldlex_input_stack = (FILE *)NULL; ldlex_input_stack = (FILE *)NULL;
ldfile_input_filename = (char *)NULL; ldfile_input_filename = (char *)NULL;
thischar = lex_input(); /* First char after script eof is a @ so that we can tell the grammer
that we've eft */
thischar = '@';
} }
} }
else if (command_line && *command_line) { else if (command_line && *command_line) {
thischar = *(command_line++); thischar = *(command_line++);
} }
else thischar = 0; else {
thischar = 0;
}
if(thischar == '\t') thischar = ' '; if(thischar == '\t') thischar = ' ';
if (thischar == '\n') { thischar = ' '; lineno++; } if (thischar == '\n') { thischar = ' '; lineno++; }
return thischar ; return thischar ;
@ -213,7 +217,7 @@ long number(text, base)
char *text; char *text;
int base; int base;
{ {
unsigned long l = 0; unsigned long l = 0;
char *p; char *p;
for (p = text; *p != 0; p++) { for (p = text; *p != 0; p++) {
if (*p == 'K') { if (*p == 'K') {
@ -241,7 +245,7 @@ unsigned long l = 0;
%a 4000 %a 4000
%o 5000 %o 5000
FILENAMECHAR [a-zA-Z0-9\/\.\-\_\+] FILENAMECHAR [a-zA-Z0-9\/\.\-\_\+\=]
FILENAME {FILENAMECHAR}+ FILENAME {FILENAMECHAR}+
@ -249,28 +253,30 @@ WHITE [ \t]+
%% %%
"@" { return ENDSCRIPT; }
"\ -defsym" { return OPTION_defsym; } "\ -defsym\ " { return OPTION_defsym; }
"\ -noinhibit_exec" { return OPTION_noinhibit_exec; } "\ -noinhibit_exec\ " { return OPTION_noinhibit_exec; }
"\ -format" { return OPTION_format; } "\ -format\ " { return OPTION_format; }
"\ -n" { return OPTION_n; } "\ -n\ " { return OPTION_n; }
"\ -r" { return OPTION_r; } "\ -r\ " { return OPTION_r; }
"\ -Ur" { return OPTION_Ur; } "\ -Ur\ " { return OPTION_Ur; }
"\ -o" { return OPTION_o; } "\ -o\ " { return OPTION_o; }
"\ -g" { return OPTION_g; } "\ -g\ " { return OPTION_g; }
"\ -e" { return OPTION_e; } "\ -e\ " { return OPTION_e; }
"\ -b" { return OPTION_b; } "\ -b\ " { return OPTION_b; }
"\ -dc" { return OPTION_dc; } "\ -dc\ " { return OPTION_dc; }
"\ -dp" { return OPTION_dp; } "\ -dp\ " { return OPTION_dp; }
"\ -d" { return OPTION_d; } "\ -d\ " { return OPTION_d; }
"\ -v" { return OPTION_v; } "\ -v\ " { return OPTION_v; }
"\ -M" { return OPTION_M; } "\ -M\ " { return OPTION_M; }
"\ -t" { return OPTION_t; } "\ -t\ " { return OPTION_t; }
"\ -X" { return OPTION_X; } "\ -X\ " { return OPTION_X; }
"\ -x" { return OPTION_x; } "\ -x\ " { return OPTION_x; }
"\ -c" { return OPTION_c; } "\ -c\ " { return OPTION_c; }
"\ -s" { return OPTION_s; } "\ -R\ " { return OPTION_R; }
"\ -S" { return OPTION_S; } "\ -u\ " { return OPTION_u; }
"\ -s\ " { return OPTION_s; }
"\ -S\ " { return OPTION_S; }
"\ -l"{FILENAME} { "\ -l"{FILENAME} {
yylval.name = buystring(yytext+3); yylval.name = buystring(yytext+3);
return OPTION_l; return OPTION_l;
@ -280,15 +286,15 @@ WHITE [ \t]+
yylval.name = buystring(yytext+3); yylval.name = buystring(yytext+3);
return OPTION_L; return OPTION_L;
} }
"\ -Ttext" { "\ -Ttext\ " {
yylval.name = ".text"; yylval.name = ".text";
return OPTION_Texp; return OPTION_Texp;
} }
"\ -Tdata" { "\ -Tdata\ " {
yylval.name = ".data"; yylval.name = ".data";
return OPTION_Texp; return OPTION_Texp;
} }
"\ -Tbss" { "\ -Tbss\ " {
yylval.name = ".bss"; yylval.name = ".bss";
return OPTION_Texp; return OPTION_Texp;
} }
@ -297,14 +303,14 @@ WHITE [ \t]+
yylval.name = buystring(yytext+3); yylval.name = buystring(yytext+3);
return OPTION_Tfile; return OPTION_Tfile;
} }
"\ -T" { "\ -T\ " {
return OPTION_T; return OPTION_T;
} }
"\ -F"{FILENAME} { "\ -F"{FILENAME} {
return OPTION_F; return OPTION_F;
} }
"\ -F" { "\ -F\ " {
return OPTION_F; return OPTION_F;
} }
@ -328,7 +334,6 @@ WHITE [ \t]+
"/=" { RTOKEN(DIVEQ);} "/=" { RTOKEN(DIVEQ);}
"&=" { RTOKEN(ANDEQ);} "&=" { RTOKEN(ANDEQ);}
"|=" { RTOKEN(OREQ);} "|=" { RTOKEN(OREQ);}
"&&" { RTOKEN(ANDAND);} "&&" { RTOKEN(ANDAND);}
">" { RTOKEN('>');} ">" { RTOKEN('>');}
"," { RTOKEN(',');} "," { RTOKEN(',');}
@ -340,7 +345,6 @@ WHITE [ \t]+
"*" { RTOKEN('*');} "*" { RTOKEN('*');}
"%" { RTOKEN('%');} "%" { RTOKEN('%');}
"<" { RTOKEN('<');} "<" { RTOKEN('<');}
"+" { RTOKEN('+');}
">" { RTOKEN('>');} ">" { RTOKEN('>');}
"}" { RTOKEN('}') ; } "}" { RTOKEN('}') ; }
"{" { RTOKEN('{'); } "{" { RTOKEN('{'); }
@ -351,7 +355,7 @@ WHITE [ \t]+
":" { RTOKEN(':'); } ":" { RTOKEN(':'); }
";" { RTOKEN(';');} ";" { RTOKEN(';');}
"-" { RTOKEN('-');} "-" { RTOKEN('-');}
"=" { RTOKEN('=');}
"/*" { "/*" {
@ -412,18 +416,58 @@ WHITE [ \t]+
Tokenize a name, this is really pain, since a name can be a Tokenize a name, this is really pain, since a name can be a
filename or a symbol name. filenames have slashes and stuff whist filename or a symbol name. filenames have slashes and stuff whist
in an expression those things are seperate tokens. We hack this by in an expression those things are seperate tokens. We hack this by
setting lang_in_expression when we are expecting a symbol, so that setting ldlang_in_script when we are expecting a symbol, so that
[/+-] get taken to be seperate tokens. An extra gotcha is [/+-] get taken to be seperate tokens. An extra gotcha is
expressions after defsyms, we only allow +s and -s in a defsym expressions after defsyms, we only allow +s and -s in a defsym
expression, so -defsym foo=bar+9 /file.o is parsed ok. expression, so -defsym foo=bar+9 /file.o is parsed ok.
The more I think about this the more I hate it. I've got a problem
now with the = sign, what should I do ? imagine:
__start=.;
You'd think that was pretty unambiguous wouldn't you. Well it's
not since __start=. is (at the moment) a perfectly valid
filename. And in some cases we don't know what's going on. I'm
going to have to hack this. If we see a '/' before the = sign then
we say we've got an = in a filename, otherwise it's an operator.
(later)
That's it, I've had enough. From now on, an =s on a command line
will be taken to be part of a file name unless its in a defsym,
and an = in a file will be taken to be an operator.
*/ */
int ch; int ch;
keyword_type *k; keyword_type *k;
if (hex_mode) {
ch = yytext[0];
/* Then always read a number */
while (isxdigit(ch)) {
yytext[yyleng++] = ch;
ch = input();
}
yytext[yyleng] = 0;
unput(ch);
yylval.integer = number(yytext,16);
return INT;
}
if (ldfile_input_filename) {
/* We're inside a file */
if (yytext[0]== '=') {
RTOKEN('=');
}
}
/* Otherwise we only notice special things if were in an
expression */
if (ldgram_in_expression) { if (ldgram_in_expression) {
if (yytext[0] != '/' || ldgram_in_defsym == false) { if (yytext[0] != '/' || ldgram_in_defsym == false) {
switch (yytext[0]) { switch (yytext[0]) {
case '/': RTOKEN('/'); case '/': RTOKEN('/');
case '=': RTOKEN('=');
case '+': RTOKEN('+'); case '+': RTOKEN('+');
case '-': RTOKEN('-'); case '-': RTOKEN('-');
} }
@ -433,10 +477,14 @@ WHITE [ \t]+
ch = input(); ch = input();
while (true) while (true)
{ {
if (isalpha(ch) || isdigit(ch) || ch == '.' || ch == '_') { if (isalpha(ch) || isdigit(ch) || ch == '.' || ch == '_' ) {
yytext[yyleng++] = ch; yytext[yyleng++] = ch;
} }
else if (ch == '+' || ch == '-' || ch == '/') { else if (ch == '=' && ldgram_in_script) {
/* An = within a script is always taken to be an operator */
break;
}
else if (ch == '+' || ch == '-' || ch == '/' || ch == '=') {
if (ldgram_in_expression) break; if (ldgram_in_expression) break;
yytext[yyleng++] = ch; yytext[yyleng++] = ch;
} }
@ -447,7 +495,10 @@ WHITE [ \t]+
yytext[yyleng] = 0; yytext[yyleng] = 0;
unput(ch); unput(ch);
/* Filenames of just =signs are tokens */
if (yyleng == 1 && yytext[0] == '=') {
RTOKEN('=');
}
for(k = keywords; k ->name != (char *)NULL; k++) { for(k = keywords; k ->name != (char *)NULL; k++) {
if (strcmp(k->name, yytext)==0) { if (strcmp(k->name, yytext)==0) {

View File

@ -21,36 +21,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
* *
* $Id$ * $Id$
* *
* $Log$
* Revision 1.2 1991/03/22 23:02:36 steve
* Brought up to sync with Intel again.
*
* Revision 1.1 1991/03/13 00:48:27 chrisb
* Initial revision
*
* Revision 1.7 1991/03/10 19:15:45 sac
* Fixed a prototype problem
*
* Revision 1.6 1991/03/10 09:31:32 rich
* Modified Files:
* Makefile config.h ld-emul.c ld-emul.h ld-gld.c ld-gld960.c
* ld-lnk960.c ld.h lddigest.c ldexp.c ldexp.h ldfile.c ldfile.h
* ldgram.y ldinfo.h ldlang.c ldlang.h ldlex.h ldlex.l ldmain.c
* ldmain.h ldmisc.c ldmisc.h ldsym.c ldsym.h ldversion.c
* ldversion.h ldwarn.h ldwrite.c ldwrite.h y.tab.h
*
* As of this round of changes, ld now builds on all hosts of (Intel960)
* interest and copy passes my copy test on big endian hosts again.
*
* Revision 1.5 1991/03/09 03:31:02 sac
* After a fatal info message, the output file is deleted.
*
* Revision 1.4 1991/03/06 02:28:31 sac
* Fixed partial linking and error messages.
*
* Revision 1.3 1991/02/22 17:15:02 sac
* Added RCS keywords and copyrights
*
* *
*/ */
@ -72,7 +42,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* IMPORTS */ /* IMPORTS */
extern boolean lang_has_input_file; extern boolean lang_has_input_file;
extern boolean trace_files;
/* EXPORTS */ /* EXPORTS */
char *default_target; char *default_target;
@ -167,7 +137,6 @@ main (argc, argv)
char *emulation; char *emulation;
program_name = argv[0]; program_name = argv[0];
output_filename = "a.out"; output_filename = "a.out";
emulation = getenv(EMULATION_ENVIRON); emulation = getenv(EMULATION_ENVIRON);
/* Initialize the data about options. */ /* Initialize the data about options. */
@ -198,16 +167,20 @@ main (argc, argv)
if (emulation == (char *)NULL) { if (emulation == (char *)NULL) {
emulation= DEFAULT_EMULATION; emulation= DEFAULT_EMULATION;
} }
ldemul_choose_mode(emulation); ldemul_choose_mode(emulation);
default_target = ldemul_choose_target(); default_target = ldemul_choose_target();
lang_init(); lang_init();
ldemul_before_parse(); ldemul_before_parse();
lang_has_input_file = false; lang_has_input_file = false;
parse_args(argc, argv); parse_args(argc, argv);
lang_final();
if (trace_files) {
info("%P: mode %s\n", emulation);
}
if (lang_has_input_file == false) { if (lang_has_input_file == false) {
info("%P%F: No input files\n"); info("%P%F: No input files\n");
} }
@ -438,7 +411,6 @@ lang_input_statement_type *entry;
if (flag_is_undefined_or_global_or_common(p->flags)) if (flag_is_undefined_or_global_or_common(p->flags))
{ {
Q_enter_global_ref(q); Q_enter_global_ref(q);
} }
ASSERT(p->flags != 0); ASSERT(p->flags != 0);
@ -474,7 +446,7 @@ search_library (entry)
void void
Q_read_file_symbols (entry) ldmain_open_file_read_symbol (entry)
struct lang_input_statement_struct *entry; struct lang_input_statement_struct *entry;
{ {
if (entry->asymbols == (asymbol **)NULL if (entry->asymbols == (asymbol **)NULL
@ -528,7 +500,7 @@ decode_library_subfile (library_entry, subfile_offset)
subentry->next = 0; subentry->next = 0;
subentry->superfile = library_entry; subentry->superfile = library_entry;
subentry->is_archive = false; subentry->is_archive = false;
subentry->header_read_flag = false;
subentry->just_syms_flag = false; subentry->just_syms_flag = false;
subentry->loaded = false; subentry->loaded = false;
subentry->chain = 0; subentry->chain = 0;
@ -773,6 +745,8 @@ struct lang_input_statement_struct *entry;
(*(sp->scoms_chain))->udata = (void*)NULL; (*(sp->scoms_chain))->udata = (void*)NULL;
(*( sp->scoms_chain))->flags = BSF_FORT_COMM; (*( sp->scoms_chain))->flags = BSF_FORT_COMM;
/* Remember the size of this item */
sp->scoms_chain[0]->value = p->value;
commons_pending++; commons_pending++;
undefined_global_sym_count--; undefined_global_sym_count--;
} { } {
@ -803,4 +777,3 @@ struct lang_input_statement_struct *entry;
return false; return false;
} }

View File

@ -32,7 +32,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "ld.h" #include "ld.h"
#include "ldmisc.h" #include "ldmisc.h"
#include "ldlang.h" #include "ldlang.h"
#include "ldlex.h"
/* IMPORTS */ /* IMPORTS */
extern char *program_name; extern char *program_name;
@ -156,14 +156,14 @@ va_dcl
else { else {
int ch; int ch;
int n = 0; int n = 0;
fprintf(stderr,"command (before <"); fprintf(stderr,"command (just before \"");
ch = lex_input(); ch = lex_input();
while (ch != 0 && n < 10) { while (ch != 0 && n < 10) {
fprintf(stderr, "%c", ch); fprintf(stderr, "%c", ch);
ch = lex_input(); ch = lex_input();
n++; n++;
} }
fprintf(stderr,")"); fprintf(stderr,"\")");
} }
break; break;
@ -269,8 +269,8 @@ size_t size;
char *buystring(x) char *DEFUN(buystring,(x),
char *x; CONST char *CONST x)
{ {
size_t l = strlen(x)+1; size_t l = strlen(x)+1;
char *r = ldmalloc(l); char *r = ldmalloc(l);

View File

@ -24,9 +24,9 @@
PROTO(void,info,()); PROTO(void,info,());
PROTO(void,info_assert,(char *, unsigned int)); PROTO(void,info_assert,(char *, unsigned int));
PROTO(void,yyerror,(char *)); PROTO(void,yyerror,(char *));
PROTO(char *,concat,(char *, char *, char *)); PROTO(char *,concat,(CONST char *, CONST char *, CONST char *));
PROTO(char *, ldmalloc,(size_t)); PROTO(char *, ldmalloc,(size_t));
PROTO(char *,buystring,(char *)); PROTO(char *,buystring,(CONST char *CONST));
#define ASSERT(x) \ #define ASSERT(x) \
{ if (!(x)) info_assert(__FILE__,__LINE__); } { if (!(x)) info_assert(__FILE__,__LINE__); }

View File

@ -19,32 +19,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* /*
* $Id$ * $Id$
* *
* $Log$
* Revision 1.3 1991/03/27 02:29:21 steve
* *** empty log message ***
*
* Revision 1.2 1991/03/22 23:02:38 steve
* Brought up to sync with Intel again.
*
* Revision 1.1 1991/03/13 00:48:32 chrisb
* Initial revision
*
* Revision 1.4 1991/03/10 09:31:36 rich
* Modified Files:
* Makefile config.h ld-emul.c ld-emul.h ld-gld.c ld-gld960.c
* ld-lnk960.c ld.h lddigest.c ldexp.c ldexp.h ldfile.c ldfile.h
* ldgram.y ldinfo.h ldlang.c ldlang.h ldlex.h ldlex.l ldmain.c
* ldmain.h ldmisc.c ldmisc.h ldsym.c ldsym.h ldversion.c
* ldversion.h ldwarn.h ldwrite.c ldwrite.h y.tab.h
*
* As of this round of changes, ld now builds on all hosts of (Intel960)
* interest and copy passes my copy test on big endian hosts again.
*
* Revision 1.3 1991/03/06 02:28:56 sac
* Cleaned up
*
* Revision 1.2 1991/02/22 17:15:06 sac
* Added RCS keywords and copyrights
* *
*/ */

View File

@ -47,11 +47,11 @@ typedef struct user_symbol_struct
} ldsym_type; } ldsym_type;
PROTO(ldsym_type *, ldsym_get, (char *)); PROTO(ldsym_type *, ldsym_get, (CONST char *));
PROTO(ldsym_type *, ldsym_get_soft, (char *)); PROTO(ldsym_type *, ldsym_get_soft, (CONST char *));
PROTO(void, ldsym_print_symbol_table,(void)); PROTO(void, ldsym_print_symbol_table,(void));
PROTO(void, ldsym_write, (void)); PROTO(void, ldsym_write, (void));
PROTO(boolean, ldsym_undefined, (char *)); PROTO(boolean, ldsym_undefined, (CONST char *));
#define FOR_EACH_LDSYM(x) \ #define FOR_EACH_LDSYM(x) \
extern ldsym_type *symbol_head; \ extern ldsym_type *symbol_head; \
ldsym_type *x; \ ldsym_type *x; \

View File

@ -20,17 +20,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
* $Id$ * $Id$
* *
* $Log$ * $Log$
* Revision 1.3 1991/03/22 22:32:22 steve * Revision 1.5 1991/04/14 03:22:42 steve
* *** empty log message *** * checkpoint before a merge
* *
* Revision 1.2 1991/03/22 22:31:37 steve * Revision 1.4 1991/03/22 23:02:40 steve
* *** empty log message *** * Brought up to sync with Intel again.
*
* Revision 1.1.1.1 1991/03/21 21:29:05 gumby
* Back from Intel with Steve
*
* Revision 1.1 1991/03/21 21:29:04 gumby
* Initial revision
* *
* Revision 1.2 1991/03/15 18:45:55 rich * Revision 1.2 1991/03/15 18:45:55 rich
* foo * foo
@ -134,7 +128,7 @@ static void perform_relocation(input_bfd,
symbols) symbols)
bfd *input_bfd; bfd *input_bfd;
asection *input_section; asection *input_section;
void *data; PTR data;
asymbol **symbols; asymbol **symbols;
{ {
static asymbol *error_symbol = (asymbol *)NULL; static asymbol *error_symbol = (asymbol *)NULL;
@ -264,104 +258,109 @@ lang_statement_union_type *statement;
{ {
switch (statement->header.type) { switch (statement->header.type) {
case lang_fill_statement_enum: case lang_fill_statement_enum:
{ {
#if 0 #if 0
bfd_byte play_area[SHORT_SIZE]; bfd_byte play_area[SHORT_SIZE];
unsigned int i; unsigned int i;
bfd_putshort(output_bfd, statement->fill_statement.fill, play_area); bfd_putshort(output_bfd, statement->fill_statement.fill, play_area);
/* Write out all entire shorts */ /* Write out all entire shorts */
for (i = 0; for (i = 0;
i < statement->fill_statement.size - SHORT_SIZE + 1; i < statement->fill_statement.size - SHORT_SIZE + 1;
i+= SHORT_SIZE) i+= SHORT_SIZE)
{ {
bfd_set_section_contents(output_bfd, bfd_set_section_contents(output_bfd,
statement->fill_statement.output_section, statement->fill_statement.output_section,
play_area, play_area,
statement->data_statement.output_offset +i, statement->data_statement.output_offset +i,
SHORT_SIZE); SHORT_SIZE);
} }
/* Now write any remaining byte */ /* Now write any remaining byte */
if (i < statement->fill_statement.size) if (i < statement->fill_statement.size)
{ {
bfd_set_section_contents(output_bfd, bfd_set_section_contents(output_bfd,
statement->fill_statement.output_section, statement->fill_statement.output_section,
play_area, play_area,
statement->data_statement.output_offset +i, statement->data_statement.output_offset +i,
1); 1);
} }
#endif #endif
} }
break; break;
case lang_data_statement_enum: case lang_data_statement_enum:
{ {
bfd_vma value = statement->data_statement.value; bfd_vma value = statement->data_statement.value;
bfd_byte play_area[LONG_SIZE]; bfd_byte play_area[LONG_SIZE];
unsigned int size; unsigned int size;
switch (statement->data_statement.type) { switch (statement->data_statement.type) {
case LONG: case LONG:
bfd_putlong(output_bfd, value, play_area); bfd_putlong(output_bfd, value, play_area);
size = LONG_SIZE; size = LONG_SIZE;
break; break;
case SHORT: case SHORT:
bfd_putshort(output_bfd, value, play_area); bfd_putshort(output_bfd, value, play_area);
size = SHORT_SIZE; size = SHORT_SIZE;
break; break;
case BYTE: case BYTE:
bfd_putchar(output_bfd, value, play_area); bfd_putchar(output_bfd, value, play_area);
size = BYTE_SIZE; size = BYTE_SIZE;
break; break;
} }
bfd_set_section_contents(output_bfd, bfd_set_section_contents(output_bfd,
statement->data_statement.output_section, statement->data_statement.output_section,
play_area, play_area,
statement->data_statement.output_vma, statement->data_statement.output_vma,
size); size);
} }
break; break;
case lang_input_section_enum: case lang_input_section_enum:
{ {
asection *i = statement->input_section.section; asection *i = statement->input_section.section;
asection *output_section = i->output_section; asection *output_section = i->output_section;
lang_input_statement_type *ifile = statement->input_section.ifile; lang_input_statement_type *ifile =
bfd *inbfd = ifile->the_bfd; statement->input_section.ifile;
if (output_section->flags & SEC_LOAD && i->size != 0) if (ifile->just_syms_flag == false) {
{ bfd *inbfd = ifile->the_bfd;
if(bfd_get_section_contents(inbfd,
i, if (output_section->flags & SEC_LOAD && i->size != 0)
data_area, {
0L, if(bfd_get_section_contents(inbfd,
i->size) == false) i,
{ data_area,
info("%F%B error reading section contents %E\n", 0L,
inbfd); i->size) == false)
} {
perform_relocation (inbfd, i, data_area, ifile->asymbols); info("%F%B error reading section contents %E\n",
inbfd);
}
perform_relocation (inbfd, i, data_area, ifile->asymbols);
if(bfd_set_section_contents(output_bfd, if(bfd_set_section_contents(output_bfd,
output_section, output_section,
data_area, data_area,
(file_ptr)i->output_offset, (file_ptr)i->output_offset,
i->size) == false) i->size) == false)
{ {
info("%F%B error writing section contents of %E\n", info("%F%B error writing section contents of %E\n",
output_bfd); output_bfd);
} }
}
} }
}
}
break; break;
default: default:
/* All the other ones fall through */ /* All the other ones fall through */
; ;