From: Steve Chamberlain Date: Mon, 15 Apr 1991 15:27:15 +0000 (+0000) Subject: Merges from Intel. X-Git-Tag: gdb-4_18~24552 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99fe4553606e9be16e0d3878070086ba0c629d77;p=external%2Fbinutils.git Merges from Intel. Chrisb bug fixes. --- diff --git a/ld/config.h b/ld/config.h index d5fab1b..43e205e 100644 --- a/ld/config.h +++ b/ld/config.h @@ -27,7 +27,11 @@ #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 */ diff --git a/ld/ld-emul.c b/ld/ld-emul.c index 70ee76f..82ebc42 100755 --- a/ld/ld-emul.c +++ b/ld/ld-emul.c @@ -1,5 +1,3 @@ - - /* Copyright (C) 1991 Free Software Foundation, Inc. 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. */ /* - $Id$ - * -*/ + * $Id$ + */ + /* * clearing house for ld emulation states */ @@ -110,6 +108,10 @@ 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; + } +#ifndef GNU960 else if (strcmp(target,GLD_EMULATION_NAME)==0) { ld_emulation = &ld_gld_emulation; } @@ -119,9 +121,7 @@ char *target; 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); } diff --git a/ld/ld-gld960.c b/ld/ld-gld960.c index fb90310..5aed97e 100755 --- a/ld/ld-gld960.c +++ b/ld/ld-gld960.c @@ -18,37 +18,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* $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() { char *env ; @@ -94,6 +83,8 @@ static void gld960_before_parse() ldfile_output_architecture = bfd_arch_i960; } +#endif /* GNU960 */ + static void gld960_after_parse() @@ -125,12 +116,21 @@ gld960_set_output_arch() 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 diff --git a/ld/ldfile.c b/ld/ldfile.c index f996b93..2a0380c 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -90,8 +90,9 @@ char *attempt; 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; } @@ -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 DEFUN(ldfile_add_arch,(in_name), - CONST char *CONST in_name) + CONST char * in_name) { char *name = buystring(in_name); search_arch_type *new = @@ -269,3 +332,4 @@ DEFUN(ldfile_add_arch,(in_name), search_arch_tail_ptr = &new->next; } +#endif diff --git a/ld/ldmain.c b/ld/ldmain.c index 168a736..6fb9bdb 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -137,7 +137,12 @@ main (argc, argv) 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; @@ -164,12 +169,16 @@ main (argc, argv) 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(); @@ -250,7 +259,7 @@ asymbol **nlist_p; 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; } /* @@ -283,7 +292,7 @@ Q_enter_global_ref (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; @@ -356,7 +365,7 @@ Q_enter_global_ref (nlist_p) 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 */ @@ -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 ldmain_open_file_read_symbol (entry) struct lang_input_statement_struct *entry; @@ -455,24 +480,33 @@ 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); } } @@ -567,7 +601,11 @@ symdef_library (entry) 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 @@ -579,7 +617,7 @@ symdef_library (entry) /* 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; } @@ -587,7 +625,7 @@ symdef_library (entry) 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; } @@ -652,14 +690,18 @@ struct lang_input_statement_struct *entry; 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); @@ -742,7 +784,7 @@ struct lang_input_statement_struct *entry; 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 */ diff --git a/ld/ldmisc.c b/ld/ldmisc.c index f7fc9e9..9ae7515 100644 --- a/ld/ldmisc.c +++ b/ld/ldmisc.c @@ -93,7 +93,7 @@ va_dcl 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); } @@ -169,8 +169,8 @@ va_dcl 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 *); @@ -235,8 +235,10 @@ unsigned int line; 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); diff --git a/ld/ldsym.c b/ld/ldsym.c index 5f3a929..6199c1b 100644 --- a/ld/ldsym.c +++ b/ld/ldsym.c @@ -78,8 +78,8 @@ hash_string (key) /* 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; @@ -100,11 +100,7 @@ ldsym_get (key) 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. */ @@ -123,8 +119,8 @@ ldsym_get (key) /* 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; @@ -433,8 +429,8 @@ return true if the supplied symbol name is not in the 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) { diff --git a/ld/ldsym.h b/ld/ldsym.h index aeeae31..9229ea0 100644 --- a/ld/ldsym.h +++ b/ld/ldsym.h @@ -24,7 +24,7 @@ typedef struct user_symbol_struct 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; diff --git a/ld/ldwrite.c b/ld/ldwrite.c index 9beac30..93f03dc 100644 --- a/ld/ldwrite.c +++ b/ld/ldwrite.c @@ -18,47 +18,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * $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 copy_and_relocate(statement) @@ -260,65 +219,65 @@ lang_statement_union_type *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: { @@ -432,7 +391,7 @@ write_rel() void ldwrite () { - data_area = (void*) ldmalloc(largest_section); + data_area = (PTR) ldmalloc(largest_section); if (config.relocateable_output == true) { write_rel();