From 7bc4a0d7a8bd7199ed22f0ecf1eb17c2225f265e Mon Sep 17 00:00:00 2001 From: Steve Chamberlain Date: Mon, 15 Jul 1991 23:43:26 +0000 Subject: [PATCH] Fixed a few bugs, added 29k coff support. --- ld/config.h | 2 + ld/configure | 29 ++++++++++--- ld/ldlang.c | 112 ++++++++++++++++++++++++++++----------------------- 3 files changed, 86 insertions(+), 57 deletions(-) diff --git a/ld/config.h b/ld/config.h index 07cbad64073..931c8bf2d6e 100644 --- a/ld/config.h +++ b/ld/config.h @@ -26,6 +26,7 @@ #define GLDM88KBCS_EMULATION_NAME "gldm88kbcs" #define GLD68K_EMULATION_NAME "gld68k" #define GLD960_EMULATION_NAME "gld960" +#define GLD29K_EMULATION_NAME "gld29k" #define LNK960_EMULATION_NAME "lnk960" /* Otherwise default to this emulation */ #ifndef DEFAULT_EMULATION @@ -45,6 +46,7 @@ #define GLD960_TARGET "b.out.big" #define VANILLA_TARGET "a.out-sunos-big" #define GLDM88KBCS_TARGET "m88kbcs" +#define GLD29K_TARGET "coff-a29k-big" diff --git a/ld/configure b/ld/configure index ba073e13bee..4386ff660f9 100755 --- a/ld/configure +++ b/ld/configure @@ -50,7 +50,9 @@ symbolic_link='ln -s' progname=$0 # clear some things potentially inherited from environment. + ansi= +clib= defaulttargets= destdir= fatal= @@ -71,6 +73,9 @@ do -ansi | +ansi) ansi=true ;; + -clib | +c*) + clib=clib + ;; -destdir=* | +destdir=* | +destdi=* | +destd=* | +dest=* | +des=* | +de=* | +d=*) destdir=`echo ${arg} | sed 's/[+-]d[a-z]*=//'` ;; @@ -182,7 +187,7 @@ fi # any existing configure script. configdirs= -srctrigger=ldversion.c +srctrigger=ldver.c srcname="linker" ## end of common part. @@ -540,7 +545,7 @@ for configdir in ${configdirs} ; do if [ -n "${commons}" ] ; then if [ -d ${configdir} ] ; then (cd ${configdir} ; - ./configure ${commons} ${verbose} ${forcesubdirs} ${removing}) \ + ./configure ${commons} ${verbose} ${forcesubdirs} ${removing} "+destdir=${destdir}") \ | sed 's/^/ /' else echo Warning: directory \"${configdir}\" is missing. @@ -551,7 +556,7 @@ for configdir in ${configdirs} ; do for host in ${specifics} ; do echo Configuring target specific directory ${configdir}.${host}... (cd ${configdir}.${host} ; - ./configure ${host} ${verbose} ${forcesubdirs} ${removing}) \ + ./configure ${host} ${verbose} ${forcesubdirs} ${removing} "+destdir=${destdir}") \ | sed 's/^/ /' done # for host in specifics fi # if there are any specifics @@ -576,7 +581,7 @@ for configdir in ${configdirs} ; do if [ -n "${commons}" ] ; then if [ -d ${configdir} ] ; then (cd ${configdir} ; - ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} ${commons}) \ + ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} ${commons} "+destdir=${destdir}") \ | sed 's/^/ /' else echo Warning: directory \"${configdir}\" is missing. @@ -587,7 +592,7 @@ for configdir in ${configdirs} ; do for target in ${specifics} ; do echo Configuring target specific directory ${configdir}.${target}... (cd ${configdir}.${target} ; - ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} "+target=${target}") \ + ./configure ${hosts} ${verbose} ${forcesubdirs} ${removing} "+target=${target}" "+destdir=${destdir}") \ | sed 's/^/ /' done fi # if any specifics @@ -598,7 +603,19 @@ exit 0 # # $Log$ -# Revision 1.12 1991/05/27 20:54:42 rich +# Revision 1.14 1991/07/15 23:43:20 steve +# Fixed a few bugs, added 29k coff support. +# +# Revision 1.13 1991/06/12 21:24:30 rich +# correctly propogate destdir +# +# Revision 1.17 1991/06/09 20:39:58 rich +# Added +clib option. +# +# Revision 1.16 1991/05/27 21:04:21 rich +# Removed clib for now. +# +# Revision 1.15 1991/05/27 20:54:24 rich # fixed a bug in multiple targets # # Revision 1.14 1991/05/22 01:44:04 rich diff --git a/ld/ldlang.c b/ld/ldlang.c index 00d1e168d6b..d77a7134eb1 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -28,7 +28,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "ld.h" #include "ldmain.h" #include "ldsym.h" -#include "ldgramtb.h" +#include "ldgram.h" #include "ldlang.h" #include "ldexp.h" @@ -431,7 +431,7 @@ DEFUN(lang_output_section_statement_lookup,(name), static void DEFUN(print_flags, (outfile, ignore_flags), FILE *outfile AND - lang_section_flags_type *ignore_flags) + int *ignore_flags) { fprintf(outfile,"("); #if 0 @@ -492,7 +492,8 @@ DEFUN(init_os,(s), s->name); } s->bfd_section->output_section = s->bfd_section; - s->bfd_section->flags = SEC_NO_FLAGS; +/* s->bfd_section->flags = s->flags;*/ + /* We initialize an output sections output offset to minus its own */ /* vma to allow us to output a section through itself */ s->bfd_section->output_offset = 0; @@ -913,6 +914,14 @@ DEFUN(print_output_section_statement,(output_section_statement), printf("%s flags", output_section_statement->region->name); print_flags(stdout, &output_section_statement->flags); #endif + if (section->flags & SEC_LOAD) + printf("load "); + if (section->flags & SEC_ALLOC) + printf("alloc "); + if (section->flags & SEC_RELOC) + printf("reloc "); + if (section->flags & SEC_HAS_CONTENTS) + printf("contents "); } else { @@ -1247,9 +1256,12 @@ DEFUN(size_input_section, (this_ptr, output_section_statement, fill, dot), dot = insert_pad(this_ptr, fill, i->alignment_power, output_section_statement->bfd_section, dot); - /* remember the largest size so we can malloc the largest area */ - /* needed for the output stage */ - if (i->size > largest_section) { + /* remember the largest size so we can malloc the largest area + needed for the output stage. Only remember the size of sections + which we will actually allocate */ + if (((i->flags & + (SEC_HAS_CONTENTS | SEC_LOAD)) == (SEC_HAS_CONTENTS | SEC_LOAD)) + && (i->size > largest_section)) { largest_section = i->size; } @@ -1611,55 +1623,53 @@ static void DEFUN_VOID(lang_check) { lang_statement_union_type *file; - unsigned long max_machine = bfd_get_machine(output_bfd); - unsigned long max_machine_seen = 0; + bfd * input_bfd; unsigned long input_machine; + enum bfd_architecture input_architecture; char *out_arch, *out_arch2; + for (file = file_chain.head; file != (lang_statement_union_type *)NULL; file=file->input_statement.next) { + unsigned long ldfile_new_output_machine; + enum bfd_architecture ldfile_new_output_architecture; + input_bfd = file->input_statement.the_bfd; + input_machine = bfd_get_machine(input_bfd); - - if ( input_machine > max_machine_seen ){ - max_machine_seen = input_machine; - } + input_architecture = bfd_get_architecture(input_bfd); + /* Inspect the architecture and ensure we're linking like with like */ - if ( (input_machine > max_machine) - || !bfd_arch_compatible( input_bfd, - output_bfd, - &ldfile_output_architecture, - NULL)) { - enum bfd_architecture this_architecture = - bfd_get_architecture(file->input_statement.the_bfd); - unsigned long this_machine = - - bfd_get_machine(file->input_statement.the_bfd); - - /* Result of bfd_printable_arch_mach is not guaranteed to stick - around after next call, so we have to copy it. */ - out_arch = bfd_printable_arch_mach(ldfile_output_architecture, - ldfile_output_machine); - out_arch2 = ldmalloc (strlen (out_arch)+1); - strcpy (out_arch2, out_arch); - - info("%P: warning, %s architecture of input file `%B' incompatible with %s output\n", - bfd_printable_arch_mach(this_architecture, this_machine), - input_bfd, - out_arch2); - free (out_arch2); - ldfile_output_architecture = this_architecture; - ldfile_output_machine = this_machine; - bfd_set_arch_mach(output_bfd, - ldfile_output_architecture, - ldfile_output_machine); - } + if (!bfd_arch_compatible(input_bfd, + output_bfd, + &ldfile_new_output_architecture, + &ldfile_new_output_machine)) + { + + /* Result of bfd_printable_arch_mach is not guaranteed to stick + around after next call, so we have to copy it. */ + out_arch = bfd_printable_arch_mach(ldfile_output_architecture, + ldfile_output_machine); + out_arch2 = ldmalloc (strlen (out_arch)+1); + strcpy (out_arch2, out_arch); + + info("%P: warning, %s architecture of input file `%B' incompatible with %s output\n", + bfd_printable_arch_mach(input_architecture, input_machine), + input_bfd, + out_arch2); + free (out_arch2); + + + bfd_set_arch_mach(output_bfd, + ldfile_new_output_architecture, + ldfile_new_output_machine); + } } - bfd_set_arch_mach(output_bfd,ldfile_output_architecture,max_machine_seen); + } @@ -1816,14 +1826,11 @@ DEFUN_VOID(lang_place_orphans) void DEFUN(lang_set_flags,(ptr, flags), - lang_section_flags_type *ptr AND + int *ptr AND CONST char *flags) { boolean state = true; - ptr->flag_read = false; - ptr->flag_write = false; - ptr->flag_executable = false; - ptr->flag_loadable= false; +*ptr= 0; while (*flags) { if (*flags == '!') { @@ -1833,17 +1840,17 @@ DEFUN(lang_set_flags,(ptr, flags), else state = true; switch (*flags) { case 'R': - ptr->flag_read = state; +/* ptr->flag_read = state; */ break; case 'W': - ptr->flag_write = state; +/* ptr->flag_write = state; */ break; case 'X': - ptr->flag_executable= state; +/* ptr->flag_executable= state;*/ break; case 'L': case 'I': - ptr->flag_loadable= state; +/* ptr->flag_loadable= state;*/ break; default: info("%P%F illegal syntax in flags\n"); @@ -1918,9 +1925,11 @@ void DEFUN(lang_enter_output_section_statement, (output_section_statement_name, address_exp, + flags, block_value), char *output_section_statement_name AND etree_type *address_exp AND + int flags AND bfd_vma block_value) { lang_output_section_statement_type *os; @@ -1939,6 +1948,7 @@ DEFUN(lang_enter_output_section_statement, os->addr_tree = address_exp; } + os->flags = flags; os->block_value = block_value; stat_ptr = & os->children; -- 2.30.2