Chrisb bug fixes.
#define GLD960_EMULATION_NAME "gld960"
#define LNK960_EMULATION_NAME "lnk960"
/* Otherwise default to this emulation */
+#ifdef GNU960
+#define DEFAULT_EMULATION GLD960_EMULATION_NAME
+#else
#define DEFAULT_EMULATION GLD68K_EMULATION_NAME
+#endif
/* Look in this variable for a target format */
-
-
/* Copyright (C) 1991 Free Software Foundation, Inc.
This file is part of GLD, the Gnu Linker.
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
- $Id$
- *
-*/
+ * $Id$
+ */
+
/*
* clearing house for ld emulation states
*/
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;
+ }
+#ifndef GNU960
else if (strcmp(target,GLD_EMULATION_NAME)==0) {
ld_emulation = &ld_gld_emulation;
}
else if (strcmp(target,GLD68K_EMULATION_NAME)==0) {
ld_emulation = &ld_gld68k_emulation;
}
- else if (strcmp(target,GLD960_EMULATION_NAME)==0) {
- ld_emulation = &ld_gld960_emulation;
- }
+#endif
else {
info("%P%F unrecognised emulation mode: %s\n",target);
}
/*
$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
- *
*/
/*
+#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()
{
char *env ;
ldfile_output_architecture = bfd_arch_i960;
}
+#endif /* GNU960 */
+
static void
gld960_after_parse()
static char *
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);
output_filename = "b.out";
if (from_outside != (char *)NULL)
return from_outside;
return GLD960_TARGET;
+
+#endif
}
static void
lang_input_statement_type *entry;
{
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);
+ if (option_v == true ) {
+ info("attempt to open %s %s\n", attempt,
+ (entry->the_bfd == (bfd *)NULL) ? "failed" : "succeeded" );
}
return entry->the_bfd;
}
+
+#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
DEFUN(ldfile_add_arch,(in_name),
- CONST char *CONST in_name)
+ CONST char * in_name)
{
char *name = buystring(in_name);
search_arch_type *new =
search_arch_tail_ptr = &new->next;
}
+#endif
char *emulation;
program_name = argv[0];
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. */
strip_symbols = STRIP_NONE;
config.magic_demand_paged = true ;
config.make_executable = true;
+#ifdef GNU960
+ ldemul_choose_mode(LNK960_EMULATION_NAME);
+#else
if (emulation == (char *)NULL) {
emulation= DEFAULT_EMULATION;
}
ldemul_choose_mode(emulation);
+#endif
default_target = ldemul_choose_target();
sym->value = 0;
sym->flags = BSF_UNDEFINED;
sym->section = (asection *)NULL;
- sym->udata =(void *)( sp->srefs_chain);
+ sym->udata =(PTR)( sp->srefs_chain);
sp->srefs_chain = nlist_p;
}
/*
{
asymbol *sym = *nlist_p;
- char *name = sym->name;
+ CONST char *name = sym->name;
ldsym_type *sp = ldsym_get (name);
flagword this_symbol_flags = sym->flags;
sy->value);
}
else {
- sym->udata =(void *)( sp->sdefs_chain);
+ sym->udata =(PTR)( sp->sdefs_chain);
sp->sdefs_chain = nlist_p;
}
/* A definition overrides a common symbol */
}
+#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
ldmain_open_file_read_symbol (entry)
struct lang_input_statement_struct *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))
+#endif
{
- entry->the_bfd->usrdata = (void*)entry;
+ entry->the_bfd->usrdata = (PTR)entry;
Q_read_entry_symbols (entry->the_bfd, 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))
+#endif
{
- entry->the_bfd->usrdata = (void *)entry;
+ entry->the_bfd->usrdata = (PTR)entry;
entry->subfiles = (lang_input_statement_type *)NULL;
search_library (entry);
}
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);
}
}
bfd *archive_member_bfd = bfd_get_elt_at_index(entry->the_bfd, idx);
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))
+#endif
{
/* Don't think carefully about any 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 =
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;
}
more_to_do = false;
while (archive) {
+#ifdef GNU960
+ if (gnu960_check_format(archive, bfd_object))
+#else
if (bfd_check_format(archive, bfd_object))
+#endif
{
register struct lang_input_statement_struct *subentry;
subentry = decode_library_subfile (entry,
archive);
- archive->usrdata = (void *) subentry;
+ archive->usrdata = (PTR) subentry;
if (!subentry) return;
if (subentry->loaded == false) {
Q_read_entry_symbols (archive, subentry);
sp->scoms_chain = sp->srefs_chain;
sp->srefs_chain =
(asymbol **)((*(sp->srefs_chain))->udata);
- (*(sp->scoms_chain))->udata = (void*)NULL;
+ (*(sp->scoms_chain))->udata = (PTR)NULL;
(*( sp->scoms_chain))->flags = BSF_FORT_COMM;
/* Remember the size of this item */
if (symbol) {
asection *section = symbol->section;
if ((symbol->flags & BSF_UNDEFINED) == 0) {
- char *section_name = section == (asection *)NULL ?
+ CONST char *section_name = section == (asection *)NULL ?
"absolute" : section->name;
fprintf(stderr,"%s (%s)", symbol->name, section_name);
}
break;
case 'C':
{
- char *filename;
- char *functionname;
+ CONST char *filename;
+ CONST char *functionname;
unsigned int linenumber;
bfd *abfd = va_arg(arg, bfd *);
asection *section = va_arg(arg, asection *);
whose contents concatenate those of S1, S2, S3. */
char *
-concat (s1, s2, s3)
- char *s1, *s2, *s3;
+DEFUN(concat, (s1, s2, s3),
+ CONST char *s1 AND
+ CONST char *s2 AND
+ CONST char *s3)
{
size_t len1 = strlen (s1);
size_t len2 = strlen (s2);
/* Get the symbol table entry for the global symbol named KEY.
Create one if there is none. */
ldsym_type *
-ldsym_get (key)
- char *key;
+DEFUN(ldsym_get,(key),
+ CONST char *key)
{
register int hashval;
register ldsym_type *bp;
bp->srefs_chain = (asymbol **)NULL;
bp->sdefs_chain = (asymbol **)NULL;
bp->scoms_chain = (asymbol **)NULL;
- bp->name = (char *) ldmalloc (strlen (key) + 1);
- strcpy (bp->name, key);
-
-
-
+ bp->name = buystring(key);
/* Add the entry to the bucket. */
/* Like `ldsym_get' but return 0 if the symbol is not already known. */
ldsym_type *
-ldsym_get_soft (key)
- char *key;
+DEFUN(ldsym_get_soft,(key),
+ CONST char *key)
{
register int hashval;
register ldsym_type *bp;
linker symbol table
*/
boolean
-ldsym_undefined(sym)
-char *sym;
+DEFUN(ldsym_undefined,(sym),
+ CONST char *sym)
{
ldsym_type *from_table = ldsym_get_soft(sym);
if (from_table != (ldsym_type *)NULL) {
struct user_symbol_struct *link;
/* Name of this symbol. */
- char *name;
+ CONST char *name;
/* Pointer to next symbol in order of symbol creation */
struct user_symbol_struct *next;
/*
* $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
- *
*/
/*
-void *data_area;
+PTR data_area;
static void
copy_and_relocate(statement)
case lang_fill_statement_enum:
{
#if 0
- bfd_byte play_area[SHORT_SIZE];
- unsigned int i;
- bfd_putshort(output_bfd, statement->fill_statement.fill, play_area);
- /* Write out all entire shorts */
- for (i = 0;
- i < statement->fill_statement.size - SHORT_SIZE + 1;
- i+= SHORT_SIZE)
- {
- bfd_set_section_contents(output_bfd,
- statement->fill_statement.output_section,
- play_area,
- statement->data_statement.output_offset +i,
- SHORT_SIZE);
+ bfd_byte play_area[SHORT_SIZE];
+ unsigned int i;
+ bfd_putshort(output_bfd, statement->fill_statement.fill, play_area);
+ /* Write out all entire shorts */
+ for (i = 0;
+ i < statement->fill_statement.size - SHORT_SIZE + 1;
+ i+= SHORT_SIZE)
+ {
+ bfd_set_section_contents(output_bfd,
+ statement->fill_statement.output_section,
+ play_area,
+ statement->data_statement.output_offset +i,
+ SHORT_SIZE);
- }
+ }
- /* Now write any remaining byte */
- if (i < statement->fill_statement.size)
- {
- bfd_set_section_contents(output_bfd,
- statement->fill_statement.output_section,
- play_area,
- statement->data_statement.output_offset +i,
- 1);
+ /* Now write any remaining byte */
+ if (i < statement->fill_statement.size)
+ {
+ bfd_set_section_contents(output_bfd,
+ statement->fill_statement.output_section,
+ play_area,
+ statement->data_statement.output_offset +i,
+ 1);
- }
+ }
#endif
- }
+ }
break;
case lang_data_statement_enum:
- {
- bfd_vma value = statement->data_statement.value;
- bfd_byte play_area[LONG_SIZE];
- unsigned int size;
- switch (statement->data_statement.type) {
- case LONG:
- bfd_putlong(output_bfd, value, play_area);
- size = LONG_SIZE;
- break;
- case SHORT:
- bfd_putshort(output_bfd, value, play_area);
- size = SHORT_SIZE;
- break;
- case BYTE:
- bfd_putchar(output_bfd, value, play_area);
- size = BYTE_SIZE;
- break;
- }
+ {
+ bfd_vma value = statement->data_statement.value;
+ bfd_byte play_area[LONG_SIZE];
+ unsigned int size;
+ switch (statement->data_statement.type) {
+ case LONG:
+ bfd_putlong(output_bfd, value, play_area);
+ size = LONG_SIZE;
+ break;
+ case SHORT:
+ bfd_putshort(output_bfd, value, play_area);
+ size = SHORT_SIZE;
+ break;
+ case BYTE:
+ bfd_putchar(output_bfd, value, play_area);
+ size = BYTE_SIZE;
+ 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;
case lang_input_section_enum:
{
void
ldwrite ()
{
- data_area = (void*) ldmalloc(largest_section);
+ data_area = (PTR) ldmalloc(largest_section);
if (config.relocateable_output == true)
{
write_rel();