]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
tic54x/ibmc54xdsp target for ld.
authorTimothy Wall <twall@alum.mit.edu>
Tue, 20 Jun 2000 13:29:07 +0000 (13:29 +0000)
committerTimothy Wall <twall@alum.mit.edu>
Tue, 20 Jun 2000 13:29:07 +0000 (13:29 +0000)
13 files changed:
ld/ChangeLog
ld/Makefile.am
ld/Makefile.in
ld/configure.tgt
ld/emulparams/tic54xcoff.sh [new file with mode: 0644]
ld/emultempl/ticoff.em [new file with mode: 0644]
ld/gen-doc.texi
ld/ld.texinfo
ld/ldgram.y
ld/ldlang.c
ld/scripttempl/tic54xcoff.sc [new file with mode: 0644]
ld/testsuite/ld-checks/asm.s
ld/testsuite/ld-scripts/script.exp

index cc5df5257632da6376b4cfeafccc73f33a30f1fa..2e6e58203a97e1056f999f21c7d954d432f5f02e 100644 (file)
@@ -1,3 +1,14 @@
+2000-06-20  Timothy Wall  <twall@cygnus.com>
+
+       * scripttempl/tic54xcoff.sc: New.
+       * ldlang.c (wild_doit): Propagate SEC_BLOCK flag.
+       * gen-doc.texi: Add flag for TI COFF.
+       * ld.texinfo: Add documentation for TI COFF handling switches.
+       * emultempl/ticoff.em: New. TI COFF handling.
+       * configure.tgt: Add tic54x target.
+       * Makefile.am: Add tic54x target.
+       * Makefile.in: Ditto.
+
 2000-06-20  Alan Modra  <alan@linuxcare.com.au>
 
        * ldmain.c (set_scripts_dir): Correct pointer comparison when
index 814bb9af973967170e127f2dafe877bd34c0f465..ec708dfb0a2bdec0fc3cb8bc0b2e2129fa7f9574 100644 (file)
@@ -221,6 +221,7 @@ ALL_EMULATIONS = \
        esun4.o \
        etic30aout.o \
        etic30coff.o \
+       etic54xcoff.o \
        etic80coff.o \
        evanilla.o \
        evax.o \
@@ -705,6 +706,9 @@ etic30aout.c: $(srcdir)/emulparams/tic30aout.sh \
 etic30coff.c: $(srcdir)/emulparams/tic30coff.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/tic30coff.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} tic30coff "$(tdir_tic30coff)"
+etic54xcoff.c: $(srcdir)/emulparams/tic54xcoff.sh \
+  $(srcdir)/emultempl/ticoff.em $(srcdir)/scripttempl/tic54xcoff.sc ${GEN_DEPENDS}
+       ${GENSCRIPTS} tic54xcoff "$(tdir_tic54xcoff)"
 etic80coff.c: $(srcdir)/emulparams/tic80coff.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/tic80coff.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} tic80coff "$(tdir_tic80coff)"
index b6f9bc121513b9bcc52bc7aa568a03eeea0585ef..fc229e5b73acb98bb0949cc38af3ee18eb9dd266 100644 (file)
@@ -324,6 +324,7 @@ ALL_EMULATIONS = \
        esun4.o \
        etic30aout.o \
        etic30coff.o \
+       etic54xcoff.o \
        etic80coff.o \
        evanilla.o \
        evax.o \
@@ -1404,6 +1405,9 @@ etic30aout.c: $(srcdir)/emulparams/tic30aout.sh \
 etic30coff.c: $(srcdir)/emulparams/tic30coff.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/tic30coff.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} tic30coff "$(tdir_tic30coff)"
+etic54xcoff.c: $(srcdir)/emulparams/tic54xcoff.sh \
+  $(srcdir)/emultempl/ticoff.em $(srcdir)/scripttempl/tic54xcoff.sc ${GEN_DEPENDS}
+       ${GENSCRIPTS} tic54xcoff "$(tdir_tic54xcoff)"
 etic80coff.c: $(srcdir)/emulparams/tic80coff.sh \
   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/tic80coff.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} tic80coff "$(tdir_tic80coff)"
index 7fa41b5f9dc3a5585e46a3c808b6fc69a3e6b330..bf92fbab8e74157c51b7e156ed8dc310e98a0fe9 100644 (file)
@@ -284,6 +284,7 @@ powerpc-*-beos*)    targ_emul=aixppc ;;
 rs6000-*-aix*)         targ_emul=aixrs6 ;;
 tic30-*-*aout*)                targ_emul=tic30aout ;;
 tic30-*-*coff*)                targ_emul=tic30coff ;;
+tic54x-*-* | c54x*-*-*)        targ_emul=tic54xcoff ;;
 tic80-*-*)             targ_emul=tic80coff ;;
 v850-*-*)              targ_emul=v850 ;;
 v850e-*-*)             targ_emul=v850 ;;
diff --git a/ld/emulparams/tic54xcoff.sh b/ld/emulparams/tic54xcoff.sh
new file mode 100644 (file)
index 0000000..70c1ee2
--- /dev/null
@@ -0,0 +1,8 @@
+SCRIPT_NAME=tic54xcoff
+OUTPUT_FORMAT="coff1-c54x"
+ARCH=tic54x
+ENTRY=_c_int00
+TEXT_START_ADDR=0x0080
+TARGET_PAGE_SIZE=0x1000
+TEMPLATE_NAME=ticoff
+OUTPUT_FORMAT_TEMPLATE=tic54x
diff --git a/ld/emultempl/ticoff.em b/ld/emultempl/ticoff.em
new file mode 100644 (file)
index 0000000..21bd35d
--- /dev/null
@@ -0,0 +1,199 @@
+# This shell script emits a C file. -*- C -*-
+# It does some substitutions.
+(echo;echo;echo;echo)>e${EMULATION_NAME}.c # there, now line numbers match ;-)
+cat >>e${EMULATION_NAME}.c <<EOF
+/* This file is part of GLD, the Gnu Linker.
+   Copyright 1999, 2000 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+/* For TI COFF */
+/* Need to determine load and run pages for output sections */ 
+  
+#define TARGET_IS_${EMULATION_NAME}
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "bfdlink.h"
+
+#include "ld.h"
+#include "ldmain.h"
+#include "ldemul.h"
+#include "ldfile.h"
+#include "ldmisc.h"
+
+#include "getopt.h"
+
+static int coff_version;
+
+static void gld_${EMULATION_NAME}_before_parse PARAMS ((void));
+static char *gld_${EMULATION_NAME}_get_script PARAMS ((int *));
+static int gld_${EMULATION_NAME}_parse_args PARAMS ((int, char **));
+static void gld_${EMULATION_NAME}_list_options PARAMS ((FILE *));
+
+/* TI COFF extra command line options */
+#define OPTION_COFF_FORMAT             (300 + 1)
+
+static struct option longopts[] = 
+{
+  /* TI COFF options */
+  {"format", required_argument, NULL, OPTION_COFF_FORMAT },
+  {NULL, no_argument, NULL, 0}
+};
+
+static void
+gld_${EMULATION_NAME}_list_options (file)
+    FILE * file;
+{
+  fprintf (file, _("  --format 0|1|2         Specify which COFF version to use"));
+}                                
+
+static int
+gld_${EMULATION_NAME}_parse_args(argc, argv)
+     int argc;
+     char **argv;
+{
+  int longind;
+  int optc;
+  int prevoptind = optind;
+  int prevopterr = opterr;
+  int wanterror;
+  static int lastoptind = -1;
+
+  if (lastoptind != optind)
+    opterr = 0;
+  wanterror = opterr;
+
+  lastoptind = optind;
+
+  optc = getopt_long_only (argc, argv, "-", longopts, &longind);
+  opterr = prevopterr;
+
+  switch (optc)
+    {
+    default:
+      if (wanterror)
+       xexit (1);
+      optind =  prevoptind;
+      return 0;
+
+    case OPTION_COFF_FORMAT:
+      if ((*optarg == '0' || *optarg == '1' || *optarg == '2')
+          && optarg[1] == '\0')
+      {
+        extern void lang_add_output_format
+          PARAMS ((const char *, const char *, const char *, int));
+        static char buf[] = "coffX-${OUTPUT_FORMAT_TEMPLATE}";
+        coff_version = *optarg - '0';
+        buf[4] = *optarg;
+       lang_add_output_format (buf, NULL, NULL, 0);    
+      }
+      else
+        {
+         einfo (_("%P%F: invalid COFF format version %s\n"), optarg);
+
+        }
+      break;
+    }
+  return 1;
+}
+
+static void
+gld_${EMULATION_NAME}_before_parse()
+{
+#ifndef TARGET_                        /* I.e., if not generic.  */
+  ldfile_set_output_arch ("`echo ${ARCH}`");
+#endif /* not TARGET_ */
+}
+
+static char *
+gld_${EMULATION_NAME}_get_script (isfile)
+     int *isfile;
+EOF
+if test -n "$COMPILE_IN"
+then
+# Scripts compiled in.
+
+# sed commands to quote an ld script as a C string.
+sc='s/["\\]/\\&/g
+s/$/\\n\\/
+1s/^/"/
+$s/$/n"/
+'
+cat >>e${EMULATION_NAME}.c <<EOF
+{                           
+  *isfile = 0;
+  if (link_info.relocateable == true && config.build_constructors == true)
+    return `sed "$sc" ldscripts/${EMULATION_NAME}.xu`;
+  else if (link_info.relocateable == true)
+    return `sed "$sc" ldscripts/${EMULATION_NAME}.xr`;
+  else if (!config.text_read_only)
+    return `sed "$sc" ldscripts/${EMULATION_NAME}.xbn`;
+  else if (!config.magic_demand_paged)
+    return `sed "$sc" ldscripts/${EMULATION_NAME}.xn`;
+  else
+    return `sed "$sc" ldscripts/${EMULATION_NAME}.x`;
+}
+EOF
+
+else
+# Scripts read from the filesystem.
+
+cat >>e${EMULATION_NAME}.c <<EOF
+{                           
+  *isfile = 1;
+
+  if (link_info.relocateable == true && config.build_constructors == true)
+    return "ldscripts/${EMULATION_NAME}.xu";
+  else if (link_info.relocateable == true)
+    return "ldscripts/${EMULATION_NAME}.xr";
+  else if (!config.text_read_only)
+    return "ldscripts/${EMULATION_NAME}.xbn";
+  else if (!config.magic_demand_paged)
+    return "ldscripts/${EMULATION_NAME}.xn";
+  else
+    return "ldscripts/${EMULATION_NAME}.x";
+}
+EOF
+
+fi
+
+cat >>e${EMULATION_NAME}.c <<EOF
+struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation = 
+{
+  gld_${EMULATION_NAME}_before_parse,
+  syslib_default,
+  hll_default,
+  after_parse_default,
+  after_open_default,
+  after_allocation_default,
+  set_output_arch_default,
+  ldemul_default_target,
+  before_allocation_default,
+  gld_${EMULATION_NAME}_get_script,
+  "${EMULATION_NAME}",
+  "${OUTPUT_FORMAT}",
+  NULL, /* finish */
+  NULL, /* create output section statements */
+  NULL, /* open dynamic archive */
+  NULL, /* place orphan */
+  NULL, /* set_symbols */
+  gld_${EMULATION_NAME}_parse_args,
+  NULL, /* unrecognized_file */
+  gld_${EMULATION_NAME}_list_options,
+  NULL, /* recognized file */
+  NULL, /* find_potential_libraries */
+};
+EOF
index 3a367277e50107c09609f3e6f9de92ec97cadf06..8d1acad1ef168adc8f96e8505cfd7313195c917a 100644 (file)
@@ -5,6 +5,7 @@
 @c 2. Specific target machines
 @set H8300
 @set I960
+@set TICOFF
 
 @c 3. Properties of this configuration
 @clear SingleFormat
index 22684c1558fd0c12bf927146761f2a5a320323fa..016914d2f5d22d7c8fc92703c6ef6223375696e5 100644 (file)
@@ -105,6 +105,9 @@ This file documents the @sc{gnu} linker ld version @value{VERSION}.
 @ifset I960
 * i960::                        ld and the Intel 960 family
 @end ifset
+@ifset TICOFF
+* TI COFF::                     ld and the TI COFF
+@end ifset
 @end ifclear
 @ifclear SingleFormat
 * BFD::                         BFD
@@ -3855,6 +3858,9 @@ functionality are not listed.
 * H8/300::                      @code{ld} and the H8/300
 * i960::                        @code{ld} and the Intel 960 family
 * ARM::                                @code{ld} and the ARM family
+@ifset TICOFF
+* TI COFF::                     @code{ld} and TI COFF
+@end ifset
 @end menu
 @end ifset
 
@@ -3995,6 +4001,18 @@ But it also sets the bottom bit of the address, so that it can be
 branched to using a BX instruction, and the program will start
 executing in Thumb mode straight away.
 
+@ifset TICOFF
+@node TI COFF
+@section @code{ld}'s support for various TI COFF versions
+@cindex TI COFF versions
+@kindex --format=@var{version}
+The @samp{--format} switch allows selection of one of the various
+TI COFF versions.  The latest of this writing is 2; versions 0 and 1 are
+also supported.  The TI COFF versions also vary in header byte-order
+format; @code{ld} will read any version or byte order, but the output
+header format depends on the default specified by the specific target.
+@end ifset
+
 @ifclear GENERIC
 @lowersections
 @end ifclear
index 375eb913da7ed4e8c80db2e0d38adc555e42cc28..77fe7969dfe5046971325554f8909cf63fc97c0f 100644 (file)
@@ -619,7 +619,9 @@ memory_spec:                NAME
                attributes_opt ':'
                origin_spec opt_comma length_spec
 
-       ; origin_spec:
+       ;
+
+origin_spec:
        ORIGIN '=' mustbe_exp
                { region->current =
                 region->origin =
index d43140f06b2fa4970b3833e848110fb1dd2df06f..6068f51e39c7c1349c786756678da73a13c7852d 100644 (file)
@@ -1196,6 +1196,13 @@ wild_doit (ptr, section, output, file)
       /* If supplied an aligment, then force it.  */
       if (output->section_alignment != -1)
        output->bfd_section->alignment_power = output->section_alignment;
+
+      if (section->flags & SEC_BLOCK)
+        {
+          section->output_section->flags |= SEC_BLOCK;
+          /* FIXME: This value should really be obtained from the bfd... */
+          output->block_value = 128;
+        }
     }
 }
 
diff --git a/ld/scripttempl/tic54xcoff.sc b/ld/scripttempl/tic54xcoff.sc
new file mode 100644 (file)
index 0000000..d84f928
--- /dev/null
@@ -0,0 +1,52 @@
+# default linker script for c54x, TI COFF(1).
+# patterned after description in TI Aseembler Tools PDF, SPRU102C, 7-53
+test -z "$ENTRY" && ENTRY=_c_int00
+
+cat <<EOF
+OUTPUT_FORMAT("${OUTPUT_FORMAT}")
+OUTPUT_ARCH("${OUTPUT_ARCH}")
+
+MEMORY
+{
+       PAGE 0 : prog (RXI) : ORIGIN = 0x000080, LENGTH = 0xFF00
+       PAGE 1 : data (W) : ORIGIN = 0x000080, LENGTH = 0xFF80
+}
+
+ENTRY(${ENTRY})
+
+SECTIONS                               
+{                                      
+       .text : 
+       {
+               ___text__ = .;
+               *(.text)
+               etext = .;
+               ___etext__ = .;
+       } > prog
+       .data : 
+       {
+               ___data__ = .;
+               __data = .;
+               *(.data)
+               __edata = .;
+               edata = .;
+               ___edata__ = .;
+       } > prog
+       /* all other initialized sections should be allocated here */
+       .cinit : 
+       {
+               *(.cinit)
+       } > prog
+       .bss : 
+       {
+               ___bss__ = .;
+               __bss = .;
+               *(.bss)
+               *(COMMON)
+               __ebss = .;
+               end = .;
+               ___end__ = .;
+       } > data
+       /* all other uninitialized sections should be allocated here */
+}
+EOF
index ad5e177f63be0b544b458bd89bcf462f3a7800e1..86e7310a59a518425331a2931814db2588316348 100644 (file)
@@ -1,9 +1,9 @@
-.text
+ .text
        .global foo
 foo:
        .long 0x12345678
 
-.data
+ .data
        .global bar
 bar:
        .long 0x87654321
index 9b6617412ae821bd4d4da58977e72e1b80282574..94c5d9b7a39fc97bb5981df18e3f666bf22654af 100644 (file)
@@ -24,11 +24,17 @@ proc check_script { } {
            verbose "bad output from nm"
            fail $testname
        } else {
+           set text_end 0x104
+           set data_end 0x1004
+           if [istarget *c54x*-*-*] then {
+               set text_end 0x102
+               set data_end 0x1002
+           }
            if {$nm_output(text_start) != 0x100} {
                send_log "text_start == $nm_output(text_start)\n"
                verbose "text_start == $nm_output(text_start)"
                fail $testname
-           } else { if {$nm_output(text_end) < 0x104 \
+           } else { if {$nm_output(text_end) < $text_end \
                          || $nm_output(text_end) > 0x110} {
                send_log "text_end == $nm_output(text_end)\n"
                verbose "text_end == $nm_output(text_end)"
@@ -37,7 +43,7 @@ proc check_script { } {
                send_log "data_start == $nm_output(data_start)\n"
                verbose "data_start == $nm_output(data_start)"
                fail $testname
-           } else { if {$nm_output(data_end) < 0x1004 \
+           } else { if {$nm_output(data_end) < $data_end \
                         || $nm_output(data_end) > 0x1010} {
                send_log "data_end == $nm_output(data_end)\n"
                verbose "data_end == $nm_output(data_end)"