aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorTimothy Wall <twall@alum.mit.edu>2000-06-20 13:29:07 +0000
committerTimothy Wall <twall@alum.mit.edu>2000-06-20 13:29:07 +0000
commit74459f0e3ead9efad8aa29f2545b53e9c5f9988d (patch)
treecc6e8a64001a4a530b620ca7a1f906cabab653a9 /ld
parent2ab47eed68c82a9a6d055ba3f49ca6a8a1dd2575 (diff)
downloadgdb-74459f0e3ead9efad8aa29f2545b53e9c5f9988d.zip
gdb-74459f0e3ead9efad8aa29f2545b53e9c5f9988d.tar.gz
gdb-74459f0e3ead9efad8aa29f2545b53e9c5f9988d.tar.bz2
tic54x/ibmc54xdsp target for ld.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog11
-rw-r--r--ld/Makefile.am4
-rw-r--r--ld/Makefile.in4
-rw-r--r--ld/configure.tgt1
-rw-r--r--ld/emulparams/tic54xcoff.sh8
-rw-r--r--ld/emultempl/ticoff.em199
-rw-r--r--ld/gen-doc.texi1
-rw-r--r--ld/ld.texinfo18
-rw-r--r--ld/ldgram.y4
-rw-r--r--ld/ldlang.c7
-rw-r--r--ld/scripttempl/tic54xcoff.sc52
-rw-r--r--ld/testsuite/ld-checks/asm.s4
-rw-r--r--ld/testsuite/ld-scripts/script.exp10
13 files changed, 318 insertions, 5 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index cc5df52..2e6e582 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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
diff --git a/ld/Makefile.am b/ld/Makefile.am
index 814bb9a..ec708df 100644
--- a/ld/Makefile.am
+++ b/ld/Makefile.am
@@ -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)"
diff --git a/ld/Makefile.in b/ld/Makefile.in
index b6f9bc1..fc229e5 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -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)"
diff --git a/ld/configure.tgt b/ld/configure.tgt
index 7fa41b5..bf92fba 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -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
index 0000000..70c1ee2
--- /dev/null
+++ b/ld/emulparams/tic54xcoff.sh
@@ -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
index 0000000..21bd35d
--- /dev/null
+++ b/ld/emultempl/ticoff.em
@@ -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
diff --git a/ld/gen-doc.texi b/ld/gen-doc.texi
index 3a36727..8d1acad 100644
--- a/ld/gen-doc.texi
+++ b/ld/gen-doc.texi
@@ -5,6 +5,7 @@
@c 2. Specific target machines
@set H8300
@set I960
+@set TICOFF
@c 3. Properties of this configuration
@clear SingleFormat
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index 22684c1..016914d 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -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
diff --git a/ld/ldgram.y b/ld/ldgram.y
index 375eb91..77fe796 100644
--- a/ld/ldgram.y
+++ b/ld/ldgram.y
@@ -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 =
diff --git a/ld/ldlang.c b/ld/ldlang.c
index d43140f..6068f51 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -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
index 0000000..d84f928
--- /dev/null
+++ b/ld/scripttempl/tic54xcoff.sc
@@ -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
diff --git a/ld/testsuite/ld-checks/asm.s b/ld/testsuite/ld-checks/asm.s
index ad5e177..86e7310 100644
--- a/ld/testsuite/ld-checks/asm.s
+++ b/ld/testsuite/ld-checks/asm.s
@@ -1,9 +1,9 @@
-.text
+ .text
.global foo
foo:
.long 0x12345678
-.data
+ .data
.global bar
bar:
.long 0x87654321
diff --git a/ld/testsuite/ld-scripts/script.exp b/ld/testsuite/ld-scripts/script.exp
index 9b66174..94c5d9b 100644
--- a/ld/testsuite/ld-scripts/script.exp
+++ b/ld/testsuite/ld-scripts/script.exp
@@ -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)"