diff options
author | Nick Clifton <nickc@redhat.com> | 2007-06-29 14:09:34 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2007-06-29 14:09:34 +0000 |
commit | 3d3d428f048cd724b634cb0252dd187f3fabc627 (patch) | |
tree | d6de34240cdc265bc54065744d30ed922c6a974e /ld | |
parent | 7c3e1d1299219f1cefbef1d8987e64d63a30ccc2 (diff) | |
download | gdb-3d3d428f048cd724b634cb0252dd187f3fabc627.zip gdb-3d3d428f048cd724b634cb0252dd187f3fabc627.tar.gz gdb-3d3d428f048cd724b634cb0252dd187f3fabc627.tar.bz2 |
New port: National Semiconductor's CR16
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 12 | ||||
-rw-r--r-- | ld/Makefile.am | 5 | ||||
-rw-r--r-- | ld/Makefile.in | 13 | ||||
-rw-r--r-- | ld/NEWS | 2 | ||||
-rw-r--r-- | ld/configure.tgt | 1 | ||||
-rw-r--r-- | ld/emulparams/elf32cr16.sh | 6 | ||||
-rw-r--r-- | ld/emultempl/cr16elf.em | 92 | ||||
-rw-r--r-- | ld/scripttempl/elf32cr16.sc | 175 |
8 files changed, 302 insertions, 4 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 617a55e..d10cd17 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,15 @@ +2006-06-29 M R Swami Reddy <MR.Swami.Reddy@nsc.com> + + * scripttemp/elf32cr16.sc: Default linker script. + * emulparams/elf32cr16.sh: Emulation script. + * emultempl/cr16elf.em: Emulation script. + * Makefile.am: Add entry to make cr16 target. + * Makefile.in: Regenerate. + * configure.tgt: Specify default and other emulation parameters + for cr16. + * ChangeLog: Added CR16 target entry. + * NEWS: Announce the support for the CR16 new target. + 2007-06-27 Alan Modra <amodra@bigpond.net.au> * pe-dll.c: Rename uses of bfd.next to bfd.archive_next throughout. diff --git a/ld/Makefile.am b/ld/Makefile.am index c30bd28..72dd649 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -157,6 +157,7 @@ ALL_EMULATIONS = \ eelf32b4300.o \ eelf32bfin.o \ eelf32bfinfd.o \ + eelf32cr16.o \ eelf32cr16c.o \ eelf32bmip.o \ eelf32bmipn32.o \ @@ -746,6 +747,10 @@ eelf32b4300.c: $(srcdir)/emulparams/elf32b4300.sh \ $(srcdir)/emulparams/elf32bmip.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} ${GENSCRIPTS} elf32b4300 "$(tdir_elf32b4300)" +eelf32cr16.c: $(srcdir)/emulparams/elf32cr16.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/cr16elf.em \ + $(srcdir)/scripttempl/elf32cr16.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32cr16 "$(tdir_elf32crx)" eelf32cr16c.c: $(srcdir)/emulparams/elf32cr16c.sh \ $(ELF_DEPS) \ $(srcdir)/scripttempl/elf32cr16c.sc ${GEN_DEPENDS} diff --git a/ld/Makefile.in b/ld/Makefile.in index 05fa46b..69b60c1 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -404,6 +404,7 @@ ALL_EMULATIONS = \ eelf32b4300.o \ eelf32bfin.o \ eelf32bfinfd.o \ + eelf32cr16.o \ eelf32cr16c.o \ eelf32bmip.o \ eelf32bmipn32.o \ @@ -734,15 +735,15 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ - echo ' cd $(srcdir) && $(AUTOMAKE) --cygnus '; \ - cd $(srcdir) && $(AUTOMAKE) --cygnus \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ + cd $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --cygnus Makefile + $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -1572,6 +1573,10 @@ eelf32b4300.c: $(srcdir)/emulparams/elf32b4300.sh \ $(srcdir)/emulparams/elf32bmip.sh $(ELF_DEPS) \ $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} ${GENSCRIPTS} elf32b4300 "$(tdir_elf32b4300)" +eelf32cr16.c: $(srcdir)/emulparams/elf32cr16.sh \ + $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/cr16elf.em \ + $(srcdir)/scripttempl/elf32cr16.sc ${GEN_DEPENDS} + ${GENSCRIPTS} elf32cr16 "$(tdir_elf32crx)" eelf32cr16c.c: $(srcdir)/emulparams/elf32cr16c.sh \ $(ELF_DEPS) \ $(srcdir)/scripttempl/elf32cr16c.sc ${GEN_DEPENDS} @@ -1,4 +1,6 @@ -*- text -*- +* Added support for National Semicondutor CompactRISC (ie CR16) target. +* * -l:foo now searches the library path for a filename called foo, without converting it to libfoo.a or libfoo.so. diff --git a/ld/configure.tgt b/ld/configure.tgt index 80383cf..46e05d3 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -121,6 +121,7 @@ bfin-*-linux-uclibc*) targ_emul=elf32bfin; targ_extra_emuls="elf32bfinfd" targ_extra_libpath=$targ_extra_emuls ;; +cr16-*-elf*) targ_emul=elf32cr16 ;; cr16c-*-elf*) targ_emul=elf32cr16c ;; cris-*-*aout*) targ_emul=crisaout diff --git a/ld/emulparams/elf32cr16.sh b/ld/emulparams/elf32cr16.sh new file mode 100644 index 0000000..756d02b --- /dev/null +++ b/ld/emulparams/elf32cr16.sh @@ -0,0 +1,6 @@ +SCRIPT_NAME=elf32cr16 +TEMPLATE_NAME=elf32 +OUTPUT_FORMAT="elf32-cr16" +ARCH=cr16 +ENTRY=_start +EXTRA_EM_FILE=cr16elf diff --git a/ld/emultempl/cr16elf.em b/ld/emultempl/cr16elf.em new file mode 100644 index 0000000..0881634 --- /dev/null +++ b/ld/emultempl/cr16elf.em @@ -0,0 +1,92 @@ +# This shell script emits a C file. -*- C -*- +# Copyright 2007 Free Software Foundation, Inc. +# Contributed by M R Swami Reddy <MR.Swami.Reddy@nsc.com> +# +# This file is part of GLD, the Gnu Linker. +# +# 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. +# + +# This file is sourced from elf32.em, and defines extra cr16-elf +# specific routines. +# +cat >>e${EMULATION_NAME}.c <<EOF + +#include "ldctor.h" + +/* Flag for the emulation-specific "--no-relax" option. */ +static bfd_boolean disable_relaxation = FALSE; + +static void +cr16elf_after_parse (void) +{ + /* Always behave as if called with --sort-common command line + option. + This is to emulate the CRTools' method of keeping variables + of different alignment in separate sections. */ + config.sort_common = TRUE; + + /* Don't create a demand-paged executable, since this feature isn't + meaninful in CR16 embedded systems. Moreover, when magic_demand_paged + is true the link sometimes fails. */ + config.magic_demand_paged = FALSE; +} + +/* This is called after the sections have been attached to output + sections, but before any sizes or addresses have been set. */ + +static void +cr16elf_before_allocation (void) +{ + /* Call the default first. */ + gld${EMULATION_NAME}_before_allocation (); + + /* Enable relaxation by default if the "--no-relax" option was not + specified. This is done here instead of in the before_parse hook + because there is a check in main() to prohibit use of --relax and + -r together. */ + + if (!disable_relaxation) + command_line.relax = TRUE; +} + +EOF + +# Define some shell vars to insert bits of code into the standard elf +# parse_args and list_options functions. +# +PARSE_AND_LIST_PROLOGUE=' +#define OPTION_NO_RELAX 301 +' + +PARSE_AND_LIST_LONGOPTS=' + { "no-relax", no_argument, NULL, OPTION_NO_RELAX}, +' + +PARSE_AND_LIST_OPTIONS=' + fprintf (file, _(" --no-relax Do not relax branches\n")); +' + +PARSE_AND_LIST_ARGS_CASES=' + case OPTION_NO_RELAX: + disable_relaxation = TRUE; + break; +' + +# Put these extra cr16-elf routines in ld_${EMULATION_NAME}_emulation +# +LDEMUL_AFTER_PARSE=cr16elf_after_parse +LDEMUL_BEFORE_ALLOCATION=cr16elf_before_allocation + diff --git a/ld/scripttempl/elf32cr16.sc b/ld/scripttempl/elf32cr16.sc new file mode 100644 index 0000000..2e62fa2 --- /dev/null +++ b/ld/scripttempl/elf32cr16.sc @@ -0,0 +1,175 @@ +# Linker Script for National Semiconductor's CR16-ELF32. + +# The next line should be uncommented if it is desired to link +# without libstart.o and directly enter main. + +# ENTRY=_main + +test -z "$ENTRY" && ENTRY=_start +cat <<EOF + +/* Example Linker Script for linking NS CR16 elf32 files. */ + +/* The next line forces the entry point (${ENTRY} in this script) + to be entered in the output file as an undefined symbol. + It is needed in case the entry point is not called explicitly + (which is the usual case) AND is in an archive. */ + +OUTPUT_FORMAT("${OUTPUT_FORMAT}") +OUTPUT_ARCH(${ARCH}) +EXTERN(${ENTRY}) +ENTRY(${ENTRY}) + +/* Define memory regions. */ +MEMORY +{ + rom : ORIGIN = 0x2, LENGTH = 3M + ram : ORIGIN = 4M, LENGTH = 10M +} + +/* Many sections come in three flavours. There is the 'real' section, + like ".data". Then there are the per-procedure or per-variable + sections, generated by -ffunction-sections and -fdata-sections in GCC, + and useful for --gc-sections, which for a variable "foo" might be + ".data.foo". Then there are the linkonce sections, for which the linker + eliminates duplicates, which are named like ".gnu.linkonce.d.foo". + The exact correspondences are: + + Section Linkonce section + .text .gnu.linkonce.t.foo + .rdata .gnu.linkonce.r.foo + .data .gnu.linkonce.d.foo + .bss .gnu.linkonce.b.foo + .debug_info .gnu.linkonce.wi.foo */ + +SECTIONS +{ + .init : + { + __INIT_START = .; + KEEP (*(.init)) + __INIT_END = .; + } > rom + + .fini : + { + __FINI_START = .; + KEEP (*(.fini)) + __FINI_END = .; + } > rom + + .jcr : + { + KEEP (*(.jcr)) + } > rom + + .text : + { + __TEXT_START = .; + *(.text) *(.text.*) *(.gnu.linkonce.t.*) + __TEXT_END = .; + } > rom + + .rdata : + { + __RDATA_START = .; + *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata*) + __RDATA_END = .; + } > rom + + .ctor ALIGN(4) : + { + __CTOR_START = .; + /* The compiler uses crtbegin.o to find the start + of the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + + KEEP (*crtbegin*.o(.ctors)) + + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + + KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + __CTOR_END = .; + } > rom + + .dtor ALIGN(4) : + { + __DTOR_START = .; + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + __DTOR_END = .; + } > rom + + .data : + { + __DATA_START = .; + *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*) + __DATA_END = .; + } > ram AT > rom + + .bss (NOLOAD) : + { + __BSS_START = .; + *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*) + __BSS_END = .; + } > ram + +/* You may change the sizes of the following sections to fit the actual + size your program requires. + + The heap and stack are aligned to the bus width, as a speed optimization + for accessing data located there. */ + + .heap : + { + . = ALIGN(4); + __HEAP_START = .; + . += 0x2000; __HEAP_MAX = .; + } > ram + + .stack : + { + . = ALIGN(4); + . += 0x6000; + __STACK_START = .; + } > ram + + .istack : + { + . = ALIGN(4); + . += 0x100; + __ISTACK_START = .; + } > ram + + .comment 0 : { *(.comment) } + + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } +} + +__DATA_IMAGE_START = LOADADDR(.data); +EOF |