Merges from Intel.

Chrisb bug fixes.
This commit is contained in:
Steve Chamberlain 1991-04-15 15:27:15 +00:00
parent 9846338e68
commit 99fe455360
9 changed files with 232 additions and 165 deletions

View File

@ -27,7 +27,11 @@
#define GLD960_EMULATION_NAME "gld960" #define GLD960_EMULATION_NAME "gld960"
#define LNK960_EMULATION_NAME "lnk960" #define LNK960_EMULATION_NAME "lnk960"
/* Otherwise default to this emulation */ /* Otherwise default to this emulation */
#ifdef GNU960
#define DEFAULT_EMULATION GLD960_EMULATION_NAME
#else
#define DEFAULT_EMULATION GLD68K_EMULATION_NAME #define DEFAULT_EMULATION GLD68K_EMULATION_NAME
#endif
/* Look in this variable for a target format */ /* Look in this variable for a target format */

View File

@ -1,5 +1,3 @@
/* Copyright (C) 1991 Free Software Foundation, Inc. /* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of GLD, the Gnu Linker. This file is part of GLD, the Gnu Linker.
@ -19,9 +17,9 @@ along with GLD; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* /*
$Id$ * $Id$
* */
*/
/* /*
* clearing house for ld emulation states * clearing house for ld emulation states
*/ */
@ -110,6 +108,10 @@ char *target;
if (strcmp(target,LNK960_EMULATION_NAME)==0) { if (strcmp(target,LNK960_EMULATION_NAME)==0) {
ld_emulation = &ld_lnk960_emulation; ld_emulation = &ld_lnk960_emulation;
} }
else if (strcmp(target,GLD960_EMULATION_NAME)==0) {
ld_emulation = &ld_gld960_emulation;
}
#ifndef GNU960
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;
} }
@ -119,9 +121,7 @@ char *target;
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;
} }
else if (strcmp(target,GLD960_EMULATION_NAME)==0) { #endif
ld_emulation = &ld_gld960_emulation;
}
else { else {
info("%P%F unrecognised emulation mode: %s\n",target); info("%P%F unrecognised emulation mode: %s\n",target);
} }

View File

@ -18,37 +18,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* /*
$Id$ $Id$
$Log$
Revision 1.3 1991/04/14 03:22:11 steve
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
* fish
*
* Revision 1.2 1991/03/15 18:45:55 rich
* foo
*
* Revision 1.1 1991/03/13 00:48:12 chrisb
* Initial revision
*
* Revision 1.4 1991/03/10 09:31:19 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:14:57 sac
* Added RCS keywords and copyrights
*
*/ */
/* /*
@ -80,6 +49,26 @@ extern bfd *output_bfd;
#ifdef GNU960
static void
gld960_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/libbout",""));
}
}
ldfile_output_architecture = bfd_arch_i960;
}
#else /* not GNU960 */
static void gld960_before_parse() static void gld960_before_parse()
{ {
char *env ; char *env ;
@ -94,6 +83,8 @@ static void gld960_before_parse()
ldfile_output_architecture = bfd_arch_i960; ldfile_output_architecture = bfd_arch_i960;
} }
#endif /* GNU960 */
static void static void
gld960_after_parse() gld960_after_parse()
@ -125,12 +116,21 @@ gld960_set_output_arch()
static char * static char *
gld960_choose_target() gld960_choose_target()
{ {
#ifdef GNU960
output_filename = "b.out";
return bfd_make_targ_name(BFD_BOUT_FORMAT,HOST_BYTE_ORDER_BIG_P);
#else
char *from_outside = getenv(TARGET_ENVIRON); char *from_outside = getenv(TARGET_ENVIRON);
output_filename = "b.out"; output_filename = "b.out";
if (from_outside != (char *)NULL) if (from_outside != (char *)NULL)
return from_outside; return from_outside;
return GLD960_TARGET; return GLD960_TARGET;
#endif
} }
static void static void

View File

@ -90,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) { if (option_v == true ) {
info("attempt to open %s failed\n", attempt); info("attempt to open %s %s\n", attempt,
(entry->the_bfd == (bfd *)NULL) ? "failed" : "succeeded" );
} }
return entry->the_bfd; return entry->the_bfd;
} }
@ -249,9 +250,71 @@ char *name;
#ifdef GNU960
static
char *
gnu960_map_archname( name )
char *name;
{
struct tabentry { char *cmd_switch; char *arch; };
static struct tabentry arch_tab[] = {
"", "",
"KA", "ka",
"KB", "kb",
"KC", "mc", /* Synonym for MC */
"MC", "mc",
"CA", "ca",
"SA", "ka", /* Functionally equivalent to KA */
"SB", "kb", /* Functionally equivalent to KB */
NULL, ""
};
struct tabentry *tp;
for ( tp = arch_tab; tp->cmd_switch != NULL; tp++ ){
if ( !strcmp(name,tp->cmd_switch) ){
break;
}
}
if ( tp->cmd_switch == NULL ){
info("%P%F: unknown architecture: %s\n",name);
}
return tp->arch;
}
void
ldfile_add_arch(name)
char *name;
{
search_arch_type *new =
(search_arch_type *)ldmalloc(sizeof(search_arch_type));
if (*name != '\0') {
if (ldfile_output_machine_name[0] != '\0') {
info("%P%F: target architecture respecified\n");
return;
}
ldfile_output_machine_name = name;
}
new->next = (search_arch_type*)NULL;
new->name = gnu960_map_archname( name );
*search_arch_tail_ptr = new;
search_arch_tail_ptr = &new->next;
}
#else /* not GNU960 */
void void
DEFUN(ldfile_add_arch,(in_name), DEFUN(ldfile_add_arch,(in_name),
CONST char *CONST in_name) CONST char * in_name)
{ {
char *name = buystring(in_name); char *name = buystring(in_name);
search_arch_type *new = search_arch_type *new =
@ -269,3 +332,4 @@ DEFUN(ldfile_add_arch,(in_name),
search_arch_tail_ptr = &new->next; search_arch_tail_ptr = &new->next;
} }
#endif

View File

@ -137,7 +137,12 @@ 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);
#ifdef GNU960
check_v960( argc, argv );
#endif
emulation = (char *) getenv(EMULATION_ENVIRON);
/* Initialize the data about options. */ /* Initialize the data about options. */
strip_symbols = STRIP_NONE; strip_symbols = STRIP_NONE;
@ -164,12 +169,16 @@ main (argc, argv)
config.magic_demand_paged = true ; config.magic_demand_paged = true ;
config.make_executable = true; config.make_executable = true;
#ifdef GNU960
ldemul_choose_mode(LNK960_EMULATION_NAME);
#else
if (emulation == (char *)NULL) { if (emulation == (char *)NULL) {
emulation= DEFAULT_EMULATION; emulation= DEFAULT_EMULATION;
} }
ldemul_choose_mode(emulation); ldemul_choose_mode(emulation);
#endif
default_target = ldemul_choose_target(); default_target = ldemul_choose_target();
@ -250,7 +259,7 @@ asymbol **nlist_p;
sym->value = 0; sym->value = 0;
sym->flags = BSF_UNDEFINED; sym->flags = BSF_UNDEFINED;
sym->section = (asection *)NULL; sym->section = (asection *)NULL;
sym->udata =(void *)( sp->srefs_chain); sym->udata =(PTR)( sp->srefs_chain);
sp->srefs_chain = nlist_p; sp->srefs_chain = nlist_p;
} }
/* /*
@ -283,7 +292,7 @@ Q_enter_global_ref (nlist_p)
{ {
asymbol *sym = *nlist_p; asymbol *sym = *nlist_p;
char *name = sym->name; CONST char *name = sym->name;
ldsym_type *sp = ldsym_get (name); ldsym_type *sp = ldsym_get (name);
flagword this_symbol_flags = sym->flags; flagword this_symbol_flags = sym->flags;
@ -356,7 +365,7 @@ Q_enter_global_ref (nlist_p)
sy->value); sy->value);
} }
else { else {
sym->udata =(void *)( sp->sdefs_chain); sym->udata =(PTR)( sp->sdefs_chain);
sp->sdefs_chain = nlist_p; sp->sdefs_chain = nlist_p;
} }
/* A definition overrides a common symbol */ /* A definition overrides a common symbol */
@ -445,6 +454,22 @@ search_library (entry)
} }
#ifdef GNU960
static
boolean
gnu960_check_format (abfd, format)
bfd *abfd;
bfd_format format;
{
boolean retval;
if ((bfd_check_format(abfd,format) == true) && BFD_COFF_FILE_P(abfd)) {
return true;
}
return false;
}
#endif
void void
ldmain_open_file_read_symbol (entry) ldmain_open_file_read_symbol (entry)
struct lang_input_statement_struct *entry; struct lang_input_statement_struct *entry;
@ -455,24 +480,33 @@ struct lang_input_statement_struct *entry;
{ {
ldfile_open_file (entry); ldfile_open_file (entry);
#ifdef GNU960
if (gnu960_check_format(entry->the_bfd, bfd_object))
#else
if (bfd_check_format(entry->the_bfd, bfd_object)) if (bfd_check_format(entry->the_bfd, bfd_object))
#endif
{ {
entry->the_bfd->usrdata = (void*)entry; entry->the_bfd->usrdata = (PTR)entry;
Q_read_entry_symbols (entry->the_bfd, entry); Q_read_entry_symbols (entry->the_bfd, entry);
Q_enter_file_symbols (entry); Q_enter_file_symbols (entry);
} }
#ifdef GNU960
else if (gnu960_check_format(entry->the_bfd, bfd_archive))
#else
else if (bfd_check_format(entry->the_bfd, bfd_archive)) else if (bfd_check_format(entry->the_bfd, bfd_archive))
#endif
{ {
entry->the_bfd->usrdata = (void *)entry; entry->the_bfd->usrdata = (PTR)entry;
entry->subfiles = (lang_input_statement_type *)NULL; entry->subfiles = (lang_input_statement_type *)NULL;
search_library (entry); search_library (entry);
} }
else else
{ {
info("%F%I: malformed input file (not rel or archive) \n", entry); info("%F%B: malformed input file (not rel or archive) \n",
entry->the_bfd);
} }
} }
@ -567,7 +601,11 @@ symdef_library (entry)
bfd *archive_member_bfd = bfd_get_elt_at_index(entry->the_bfd, idx); bfd *archive_member_bfd = bfd_get_elt_at_index(entry->the_bfd, idx);
struct lang_input_statement_struct *archive_member_lang_input_statement_struct; struct lang_input_statement_struct *archive_member_lang_input_statement_struct;
#ifdef GNU960
if (archive_member_bfd && gnu960_check_format(archive_member_bfd, bfd_object))
#else
if (archive_member_bfd && bfd_check_format(archive_member_bfd, bfd_object)) if (archive_member_bfd && bfd_check_format(archive_member_bfd, bfd_object))
#endif
{ {
/* Don't think carefully about any archive member /* Don't think carefully about any archive member
@ -579,7 +617,7 @@ symdef_library (entry)
/* Read the symbol table of the archive member. */ /* Read the symbol table of the archive member. */
if (archive_member_bfd->usrdata != (void *)NULL) { if (archive_member_bfd->usrdata != (PTR)NULL) {
archive_member_lang_input_statement_struct =(lang_input_statement_type *) archive_member_bfd->usrdata; archive_member_lang_input_statement_struct =(lang_input_statement_type *) archive_member_bfd->usrdata;
} }
@ -587,7 +625,7 @@ symdef_library (entry)
archive_member_lang_input_statement_struct = archive_member_lang_input_statement_struct =
decode_library_subfile (entry, archive_member_bfd); decode_library_subfile (entry, archive_member_bfd);
archive_member_bfd->usrdata = (void *) archive_member_lang_input_statement_struct; archive_member_bfd->usrdata = (PTR) archive_member_lang_input_statement_struct;
} }
@ -652,14 +690,18 @@ struct lang_input_statement_struct *entry;
more_to_do = false; more_to_do = false;
while (archive) { while (archive) {
#ifdef GNU960
if (gnu960_check_format(archive, bfd_object))
#else
if (bfd_check_format(archive, bfd_object)) if (bfd_check_format(archive, bfd_object))
#endif
{ {
register struct lang_input_statement_struct *subentry; register struct lang_input_statement_struct *subentry;
subentry = decode_library_subfile (entry, subentry = decode_library_subfile (entry,
archive); archive);
archive->usrdata = (void *) subentry; archive->usrdata = (PTR) subentry;
if (!subentry) return; if (!subentry) return;
if (subentry->loaded == false) { if (subentry->loaded == false) {
Q_read_entry_symbols (archive, subentry); Q_read_entry_symbols (archive, subentry);
@ -742,7 +784,7 @@ struct lang_input_statement_struct *entry;
sp->scoms_chain = sp->srefs_chain; sp->scoms_chain = sp->srefs_chain;
sp->srefs_chain = sp->srefs_chain =
(asymbol **)((*(sp->srefs_chain))->udata); (asymbol **)((*(sp->srefs_chain))->udata);
(*(sp->scoms_chain))->udata = (void*)NULL; (*(sp->scoms_chain))->udata = (PTR)NULL;
(*( sp->scoms_chain))->flags = BSF_FORT_COMM; (*( sp->scoms_chain))->flags = BSF_FORT_COMM;
/* Remember the size of this item */ /* Remember the size of this item */

View File

@ -93,7 +93,7 @@ va_dcl
if (symbol) { if (symbol) {
asection *section = symbol->section; asection *section = symbol->section;
if ((symbol->flags & BSF_UNDEFINED) == 0) { if ((symbol->flags & BSF_UNDEFINED) == 0) {
char *section_name = section == (asection *)NULL ? CONST char *section_name = section == (asection *)NULL ?
"absolute" : section->name; "absolute" : section->name;
fprintf(stderr,"%s (%s)", symbol->name, section_name); fprintf(stderr,"%s (%s)", symbol->name, section_name);
} }
@ -169,8 +169,8 @@ va_dcl
break; break;
case 'C': case 'C':
{ {
char *filename; CONST char *filename;
char *functionname; CONST char *functionname;
unsigned int linenumber; unsigned int linenumber;
bfd *abfd = va_arg(arg, bfd *); bfd *abfd = va_arg(arg, bfd *);
asection *section = va_arg(arg, asection *); asection *section = va_arg(arg, asection *);
@ -235,8 +235,10 @@ unsigned int line;
whose contents concatenate those of S1, S2, S3. */ whose contents concatenate those of S1, S2, S3. */
char * char *
concat (s1, s2, s3) DEFUN(concat, (s1, s2, s3),
char *s1, *s2, *s3; CONST char *s1 AND
CONST char *s2 AND
CONST char *s3)
{ {
size_t len1 = strlen (s1); size_t len1 = strlen (s1);
size_t len2 = strlen (s2); size_t len2 = strlen (s2);

View File

@ -78,8 +78,8 @@ hash_string (key)
/* Get the symbol table entry for the global symbol named KEY. /* Get the symbol table entry for the global symbol named KEY.
Create one if there is none. */ Create one if there is none. */
ldsym_type * ldsym_type *
ldsym_get (key) DEFUN(ldsym_get,(key),
char *key; CONST char *key)
{ {
register int hashval; register int hashval;
register ldsym_type *bp; register ldsym_type *bp;
@ -100,11 +100,7 @@ ldsym_get (key)
bp->srefs_chain = (asymbol **)NULL; bp->srefs_chain = (asymbol **)NULL;
bp->sdefs_chain = (asymbol **)NULL; bp->sdefs_chain = (asymbol **)NULL;
bp->scoms_chain = (asymbol **)NULL; bp->scoms_chain = (asymbol **)NULL;
bp->name = (char *) ldmalloc (strlen (key) + 1); bp->name = buystring(key);
strcpy (bp->name, key);
/* Add the entry to the bucket. */ /* Add the entry to the bucket. */
@ -123,8 +119,8 @@ ldsym_get (key)
/* Like `ldsym_get' but return 0 if the symbol is not already known. */ /* Like `ldsym_get' but return 0 if the symbol is not already known. */
ldsym_type * ldsym_type *
ldsym_get_soft (key) DEFUN(ldsym_get_soft,(key),
char *key; CONST char *key)
{ {
register int hashval; register int hashval;
register ldsym_type *bp; register ldsym_type *bp;
@ -433,8 +429,8 @@ return true if the supplied symbol name is not in the
linker symbol table linker symbol table
*/ */
boolean boolean
ldsym_undefined(sym) DEFUN(ldsym_undefined,(sym),
char *sym; CONST char *sym)
{ {
ldsym_type *from_table = ldsym_get_soft(sym); ldsym_type *from_table = ldsym_get_soft(sym);
if (from_table != (ldsym_type *)NULL) { if (from_table != (ldsym_type *)NULL) {

View File

@ -24,7 +24,7 @@ typedef struct user_symbol_struct
struct user_symbol_struct *link; struct user_symbol_struct *link;
/* Name of this symbol. */ /* Name of this symbol. */
char *name; CONST char *name;
/* Pointer to next symbol in order of symbol creation */ /* Pointer to next symbol in order of symbol creation */
struct user_symbol_struct *next; struct user_symbol_struct *next;

View File

@ -18,47 +18,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* /*
* $Id$ * $Id$
*
* $Log$
* Revision 1.5 1991/04/14 03:22:42 steve
* checkpoint before a merge
*
* Revision 1.4 1991/03/22 23:02:40 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:37 chrisb
* Initial revision
*
* Revision 1.7 1991/03/10 19:15:03 sac
* Took out the abort() which had been put in the wrong place
* Updated the version #.
*
* Revision 1.6 1991/03/10 09:31:41 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:08 sac
* Added support for LONG, SHORT and BYTE keywords in scripts
*
* Revision 1.4 1991/03/06 21:59:34 sac
* Completed G++ support
*
* Revision 1.3 1991/03/06 02:29:52 sac
* Added support for partial linking.
*
* Revision 1.2 1991/02/22 17:15:11 sac
* Added RCS keywords and copyrights
*
*/ */
/* /*
@ -250,7 +209,7 @@ asymbol **symbols;
void *data_area; PTR data_area;
static void static void
copy_and_relocate(statement) copy_and_relocate(statement)
@ -260,65 +219,65 @@ lang_statement_union_type *statement;
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,
statement->data_statement.output_section,
play_area,
statement->data_statement.output_vma,
size);
} }
bfd_set_section_contents(output_bfd,
statement->data_statement.output_section,
play_area,
statement->data_statement.output_vma,
size);
}
break; break;
case lang_input_section_enum: case lang_input_section_enum:
{ {
@ -432,7 +391,7 @@ write_rel()
void void
ldwrite () ldwrite ()
{ {
data_area = (void*) ldmalloc(largest_section); data_area = (PTR) ldmalloc(largest_section);
if (config.relocateable_output == true) if (config.relocateable_output == true)
{ {
write_rel(); write_rel();