[newlib]
* configure.host (msp430): Add. * libc/include/machine/ieeefp.h: Add MSP430 support. * libc/include/machine/setjmp.h: Likewise. * libc/include/sys/config.h: Likewise. * libc/machine/configure.in (msp430): Add. * libc/machine/configure: Regenerate. * libc/machine/msp430: New directory. [libgloss] * configure.in (msp430*-*-elf): Add. * configure: Regenerate. * msp430: New directory.
This commit is contained in:
153
libgloss/msp430/Makefile.in
Normal file
153
libgloss/msp430/Makefile.in
Normal file
@ -0,0 +1,153 @@
|
||||
# Copyright (c) 2008, 2009, 2011, 2013 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use, modify,
|
||||
# copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
# License. This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
# is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
# are incorporated in the source code or documentation are not subject to the BSD
|
||||
# License and may only be used or replicated with the express permission of
|
||||
# Red Hat, Inc.
|
||||
|
||||
# Makefile for libgloss/msp430.
|
||||
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
objdir = .
|
||||
srcroot = $(srcdir)/../..
|
||||
objroot = $(objdir)/../..
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
host_alias = @host_alias@
|
||||
target_alias = @target_alias@
|
||||
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
tooldir = $(exec_prefix)/$(target_alias)
|
||||
|
||||
# Multilib support variables.
|
||||
# TOP is used instead of MULTI{BUILD,SRC}TOP.
|
||||
MULTIDIRS =
|
||||
MULTISUBDIR =
|
||||
MULTIDO = true
|
||||
MULTICLEAN = true
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
CC = @CC@
|
||||
|
||||
AS = @AS@
|
||||
AR = @AR@
|
||||
LD = @LD@
|
||||
RANLIB = @RANLIB@
|
||||
AR_FLAGS = rc
|
||||
|
||||
OBJDUMP = `if [ -f ${objroot}/../binutils/objdump ] ; \
|
||||
then echo ${objroot}/../binutils/objdump ; \
|
||||
else t='$(program_transform_name)'; echo objdump | sed -e $$t ; fi`
|
||||
OBJCOPY = `if [ -f ${objroot}/../binutils/objcopy ] ; \
|
||||
then echo ${objroot}/../binutils/objcopy ; \
|
||||
else t='$(program_transform_name)'; echo objcopy | sed -e $$t ; fi`
|
||||
|
||||
SCRIPTS = $(srcdir)/msp430.ld $(srcdir)/msp430-sim.ld
|
||||
SCRIPTS += $(srcdir)/msp430xl-sim.ld
|
||||
SCRIPTS += $(srcdir)/msp430F5438A-s.ld
|
||||
SCRIPTS += $(srcdir)/msp430F5438A-l.ld
|
||||
CRT = gcrt0.o crt0.o crtn.o
|
||||
SIM_BSP = libsim.a
|
||||
LIBNOSYS = libnosys.a
|
||||
|
||||
SIM_OBJS = syscalls.o \
|
||||
cio.o \
|
||||
write.o \
|
||||
sbrk.o
|
||||
|
||||
NOSYS_OBJS = nosyscalls.o \
|
||||
cio.o \
|
||||
write.o \
|
||||
sbrk.o
|
||||
|
||||
#### Host specific Makefile fragment comes in here.
|
||||
@host_makefile_frag@
|
||||
|
||||
|
||||
# Override .S.o rule to pass assembler debugging flags
|
||||
.S.o:
|
||||
$(CC) -Wa,-gdwarf2 -Wa,-I$(srcdir) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c $<
|
||||
|
||||
all: $(CRT) $(SIM_BSP) $(LIBNOSYS) copy_scripts_to_objdir
|
||||
|
||||
$(SIM_BSP): $(SIM_OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $?
|
||||
$(RANLIB) $@
|
||||
|
||||
|
||||
$(LIBNOSYS): $(NOSYS_OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $?
|
||||
$(RANLIB) $@
|
||||
|
||||
copy_scripts_to_objdir: $(SCRIPTS)
|
||||
cp $(SCRIPTS) $(objdir)
|
||||
|
||||
# Dependencies
|
||||
|
||||
SDEPS = $(srcdir)/cio.h
|
||||
|
||||
abort.o : $(SDEPS)
|
||||
argv.o : $(SDEPS)
|
||||
argvlen.o : $(SDEPS)
|
||||
chdir.o : $(SDEPS)
|
||||
chmod.o : $(SDEPS)
|
||||
close.o : $(SDEPS)
|
||||
exit.o : $(SDEPS)
|
||||
fstat.o : $(SDEPS)
|
||||
getpid.o : $(SDEPS)
|
||||
gettimeofday.o : $(SDEPS)
|
||||
gcrt0.o: gcrt0.S crt0.S
|
||||
kill.o : $(SDEPS)
|
||||
link.o : $(SDEPS)
|
||||
lseek.o : $(SDEPS)
|
||||
mcount.o : $(SDEPS)
|
||||
open.o : $(SDEPS)
|
||||
read.o : $(SDEPS)
|
||||
sigprocmask.o : $(SDEPS)
|
||||
sleep.o : $(SDEPS)
|
||||
stat.o : $(SDEPS)
|
||||
time.o : $(SDEPS)
|
||||
times.o : $(SDEPS)
|
||||
unlink.o : $(SDEPS)
|
||||
utime.o : $(SDEPS)
|
||||
write.o : $(SDEPS)
|
||||
|
||||
install: $(CRT) $(SIM_BSP) $(LIBNOSYS) $(SCRIPTS)
|
||||
for c in $(CRT) $(SIM_BSP) $(LIBNOSYS); do \
|
||||
$(INSTALL_DATA) $$c $(tooldir)/lib${MULTISUBDIR}/$$c ;\
|
||||
done
|
||||
for c in $(SCRIPTS); do \
|
||||
b=`basename $$c`; \
|
||||
$(INSTALL_DATA) $$c $(tooldir)/lib${MULTISUBDIR}/$$b ;\
|
||||
done
|
||||
|
||||
clean mostlyclean:
|
||||
rm -f *.o *.a
|
||||
|
||||
distclean maintainer-clean realclean: clean
|
||||
rm -f Makefile config.cache config.log config.status
|
||||
|
||||
.PHONY: info dvi doc install-info clean-info
|
||||
info doc dvi:
|
||||
install-info:
|
||||
clean-info:
|
||||
|
||||
Makefile: Makefile.in config.status @host_makefile_frag_path@
|
||||
$(SHELL) config.status
|
||||
|
||||
config.status: configure
|
||||
$(SHELL) config.status --recheck
|
26
libgloss/msp430/cio.c
Normal file
26
libgloss/msp430/cio.c
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
|
||||
*/
|
||||
|
||||
#include "cio.h"
|
||||
|
||||
__CIOBUF__TYPE__ __CIOBUF__;
|
||||
|
||||
void
|
||||
_libgloss_cio_hook (void)
|
||||
{
|
||||
__asm__ __volatile__ (" .global C$$IO$$");
|
||||
__asm__ __volatile__ ("C$$IO$$: nop");
|
||||
}
|
42
libgloss/msp430/cio.h
Normal file
42
libgloss/msp430/cio.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef CIO_BUF_SIZE
|
||||
#define CIO_BUF_SIZE 64
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
unsigned char length[2];
|
||||
unsigned char parms[9];
|
||||
unsigned char buf[CIO_BUF_SIZE];
|
||||
} __CIOBUF__TYPE__;
|
||||
|
||||
extern __CIOBUF__TYPE__ __CIOBUF__;
|
||||
|
||||
extern void _libgloss_cio_hook (void);
|
||||
|
||||
#define CIO_OPEN (0xF0)
|
||||
#define CIO_CLOSE (0xF1)
|
||||
#define CIO_READ (0xF2)
|
||||
#define CIO_WRITE (0xF3)
|
||||
#define CIO_LSEEK (0xF4)
|
||||
#define CIO_UNLINK (0xF5)
|
||||
#define CIO_GETENV (0xF6)
|
||||
#define CIO_RENAME (0xF7)
|
||||
#define CIO_GETTIME (0xF8)
|
||||
#define CIO_GETCLK (0xF9)
|
||||
#define CIO_SYNC (0xFF)
|
||||
|
3815
libgloss/msp430/configure
vendored
Normal file
3815
libgloss/msp430/configure
vendored
Normal file
File diff suppressed because it is too large
Load Diff
67
libgloss/msp430/configure.in
Normal file
67
libgloss/msp430/configure.in
Normal file
@ -0,0 +1,67 @@
|
||||
# Copyright (c) 2008, 2009, 2011, 2013 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use, modify,
|
||||
# copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
# License. This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
# is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
# are incorporated in the source code or documentation are not subject to the BSD
|
||||
# License and may only be used or replicated with the express permission of
|
||||
# Red Hat, Inc.
|
||||
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT(crt0.S)
|
||||
|
||||
if test "${enable_shared}" = "yes" ; then
|
||||
echo "Shared libraries not supported for cross compiling, ignored"
|
||||
fi
|
||||
|
||||
if test "$srcdir" = "." ; then
|
||||
if test "${with_target_subdir}" != "." ; then
|
||||
libgloss_topdir="${srcdir}/${with_multisrctop}../../.."
|
||||
else
|
||||
libgloss_topdir="${srcdir}/${with_multisrctop}../.."
|
||||
fi
|
||||
else
|
||||
libgloss_topdir="${srcdir}/../.."
|
||||
fi
|
||||
AC_CONFIG_AUX_DIR($libgloss_topdir)
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
AC_ARG_PROGRAM
|
||||
|
||||
AC_PROG_INSTALL
|
||||
|
||||
LIB_AC_PROG_CC
|
||||
|
||||
AS=${AS-as}
|
||||
AC_SUBST(AS)
|
||||
AR=${AR-ar}
|
||||
AC_SUBST(AR)
|
||||
LD=${LD-ld}
|
||||
AC_SUBST(LD)
|
||||
AC_PROG_RANLIB
|
||||
LIB_AM_PROG_AS
|
||||
|
||||
host_makefile_frag=${srcdir}/../config/default.mh
|
||||
|
||||
dnl We have to assign the same value to other variables because autoconf
|
||||
dnl doesn't provide a mechanism to substitute a replacement keyword with
|
||||
dnl arbitrary data or pathnames.
|
||||
dnl
|
||||
host_makefile_frag_path=$host_makefile_frag
|
||||
AC_SUBST(host_makefile_frag_path)
|
||||
AC_SUBST_FILE(host_makefile_frag)
|
||||
|
||||
AC_CONFIG_FILES(Makefile,
|
||||
. ${libgloss_topdir}/config-ml.in,
|
||||
srcdir=${srcdir}
|
||||
target=${target}
|
||||
with_multisubdir=${with_multisubdir}
|
||||
ac_configure_args="${ac_configure_args} --enable-multilib"
|
||||
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
|
||||
libgloss_topdir=${libgloss_topdir}
|
||||
)
|
||||
AC_OUTPUT
|
106
libgloss/msp430/crt0.S
Normal file
106
libgloss/msp430/crt0.S
Normal file
@ -0,0 +1,106 @@
|
||||
/* Copyright (c) 2012-2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "memmodel.h"
|
||||
|
||||
.section ".resetvec", "a"
|
||||
__msp430_resetvec_hook:
|
||||
.word __start
|
||||
|
||||
.section ".lowtext", "ax", @progbits
|
||||
.global __start
|
||||
__start:
|
||||
mov_ #__stack, R1
|
||||
|
||||
;; Disable watchdog timer.
|
||||
MOV #0x5a80, &0x15C
|
||||
|
||||
mov_ #__bssstart, R12
|
||||
clr.w R13
|
||||
mov.w #__bsssize, R14
|
||||
#ifdef __MSP430X_LARGE__
|
||||
clr.w R15 ; We assume that __bsssize is never > 64M
|
||||
#endif
|
||||
call_ #memset
|
||||
|
||||
mov_ #__datastart, R12
|
||||
mov_ #__romdatastart, R13
|
||||
|
||||
;; memmove and memcpy do not currently work when src == dst
|
||||
cmp_ R12, R13
|
||||
jeq 1f
|
||||
|
||||
mov.w #__romdatacopysize, R14
|
||||
#ifdef __MSP430X_LARGE__
|
||||
clr.w R15 ; We assume that __romdatacopysize is never > 64M
|
||||
#endif
|
||||
call_ #memmove
|
||||
1:
|
||||
call_ #__msp430_init
|
||||
|
||||
clr.w R12 ; Set argc == 0
|
||||
call_ #main
|
||||
|
||||
call_ #_exit
|
||||
|
||||
.word __msp430_resetvec_hook
|
||||
|
||||
;----------------------------------------
|
||||
|
||||
.global _msp430_run_init_array
|
||||
.type _msp430_run_init_array,@function
|
||||
_msp430_run_init_array:
|
||||
mov_ #__init_array_start, R4
|
||||
mov_ #__init_array_end, R5
|
||||
mov_ #PTRsz, R6
|
||||
br_ #_msp430_run_array
|
||||
|
||||
.global _msp430_run_preinit_array
|
||||
.type _msp430_run_preinit_array,@function
|
||||
_msp430_run_preinit_array:
|
||||
mov_ #__preinit_array_start, R4
|
||||
mov_ #__preinit_array_end, R5
|
||||
mov_ #PTRsz, R6
|
||||
br_ #_msp430_run_array
|
||||
|
||||
.global _msp430_run_fini_array
|
||||
.type _msp430_run_fini_array,@function
|
||||
_msp430_run_fini_array:
|
||||
mov_ #__fini_array_start, R4
|
||||
mov_ #__fini_array_end, R5
|
||||
mov_ #-PTRsz, R6
|
||||
br_ #_msp430_run_array
|
||||
|
||||
_msp430_run_array:
|
||||
cmp_ R4, R5
|
||||
jeq _msp430_run_done
|
||||
mov_ @R4, R7
|
||||
add_ R6, R4
|
||||
call_ @R7
|
||||
br_ _msp430_run_array
|
||||
|
||||
_msp430_run_done:
|
||||
ret_
|
||||
|
||||
;----------------------------------------
|
||||
|
||||
.section .init,"ax"
|
||||
|
||||
.global __msp430_init
|
||||
__msp430_init:
|
||||
|
||||
.section .fini,"ax"
|
||||
|
||||
.global __msp430_fini
|
||||
__msp430_fini:
|
||||
call_ #_msp430_run_fini_array
|
30
libgloss/msp430/crtn.S
Normal file
30
libgloss/msp430/crtn.S
Normal file
@ -0,0 +1,30 @@
|
||||
/* Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "memmodel.h"
|
||||
|
||||
.section .init,"ax"
|
||||
call_ #_msp430_run_preinit_array
|
||||
call_ #_msp430_run_init_array
|
||||
ret_
|
||||
.global __msp430_init_end
|
||||
__msp430_init_end:
|
||||
|
||||
.section .fini,"ax"
|
||||
|
||||
ret_
|
||||
.global __msp430_fini_end
|
||||
__msp430_fini_end:
|
||||
|
||||
.text
|
||||
|
17
libgloss/msp430/gcrt0.S
Normal file
17
libgloss/msp430/gcrt0.S
Normal file
@ -0,0 +1,17 @@
|
||||
/* Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
.text
|
||||
.global _mcount
|
||||
_mcount:
|
||||
ret
|
41
libgloss/msp430/memmodel.h
Normal file
41
libgloss/msp430/memmodel.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* Copyright (c) 2012-2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
/* This file provides macros for various MSP430 instructions
|
||||
which have similar, but not identical, versions when assembling
|
||||
for the LARGE memory model. */
|
||||
|
||||
#ifdef __MSP430X_LARGE__
|
||||
|
||||
#define call_ CALLA
|
||||
#define ret_ RETA
|
||||
#define mov_ MOVA
|
||||
#define movx_ MOVX
|
||||
#define br_ BRA
|
||||
#define cmp_ CMPA
|
||||
#define add_ ADDA
|
||||
#define PTRsz 4
|
||||
|
||||
#else
|
||||
|
||||
#define call_ CALL
|
||||
#define ret_ RET
|
||||
#define mov_ MOV
|
||||
#define movx_ MOV
|
||||
#define br_ BR
|
||||
#define cmp_ CMP
|
||||
#define add_ ADD
|
||||
#define PTRsz 2
|
||||
|
||||
|
||||
#endif
|
194
libgloss/msp430/msp430-sim.ld
Normal file
194
libgloss/msp430/msp430-sim.ld
Normal file
@ -0,0 +1,194 @@
|
||||
/* Copyright (c) 2005,2008,2009,2011,2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
/* Default linker script, for normal executables */
|
||||
OUTPUT_ARCH(msp430)
|
||||
ENTRY(_start)
|
||||
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
|
||||
MEMORY {
|
||||
RAM (w) : ORIGIN = 0x00200, LENGTH = 0x0ee00
|
||||
RESETVEC (w) : ORIGIN = 0x0fffe, LENGTH = 0x00002
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.resetvec :
|
||||
{
|
||||
*(.resetvec)
|
||||
} > RESETVEC
|
||||
|
||||
.rodata : {
|
||||
. = ALIGN(2);
|
||||
*(.plt)
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*)
|
||||
*(.rodata1)
|
||||
*(.eh_frame_hdr)
|
||||
KEEP (*(.eh_frame))
|
||||
KEEP (*(.gcc_except_table)) *(.gcc_except_table.*)
|
||||
PROVIDE (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE (__preinit_array_end = .);
|
||||
PROVIDE (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE (__init_array_end = .);
|
||||
PROVIDE (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE (__fini_array_end = .);
|
||||
LONG(0); /* Sentinel. */
|
||||
|
||||
/* gcc 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 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))
|
||||
|
||||
KEEP (*crtbegin*.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
} > RAM
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(2);
|
||||
PROVIDE (_start = .);
|
||||
*(.lowtext .text .stub .text.* .gnu.linkonce.t.* .text:*)
|
||||
KEEP (*(.text.*personality*))
|
||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||
*(.gnu.warning)
|
||||
*(.interp .hash .dynsym .dynstr .gnu.version*)
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
. = ALIGN(2);
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
} > RAM
|
||||
|
||||
.data : {
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__datastart = .);
|
||||
|
||||
KEEP (*(.jcr))
|
||||
*(.data.rel.ro.local) *(.data.rel.ro*)
|
||||
*(.dynamic)
|
||||
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
KEEP (*(.gnu.linkonce.d.*personality*))
|
||||
SORT(CONSTRUCTORS)
|
||||
*(.data1)
|
||||
*(.got.plt) *(.got)
|
||||
|
||||
/* We want the small data sections together, so single-instruction offsets
|
||||
can access them all, and initialized data all before uninitialized, so
|
||||
we can shorten the on-disk segment size. */
|
||||
. = ALIGN(2);
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.* D_2 D_1)
|
||||
|
||||
. = ALIGN(2);
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
PROVIDE (__dataend = .);
|
||||
} > RAM
|
||||
|
||||
/* Note that crt0 assumes this is a multiple of two; all the
|
||||
start/stop symbols are also assumed word-aligned. */
|
||||
PROVIDE(__romdatastart = LOADADDR(.data));
|
||||
PROVIDE (__romdatacopysize = SIZEOF(.data));
|
||||
|
||||
.bss : {
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__bssstart = .);
|
||||
*(.dynbss)
|
||||
*(.sbss .sbss.*)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
. = ALIGN(2);
|
||||
*(COMMON)
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__bssend = .);
|
||||
_end = .;
|
||||
PROVIDE (end = .);
|
||||
} > RAM
|
||||
PROVIDE (__bsssize = SIZEOF(.bss));
|
||||
|
||||
.stack (ORIGIN (RAM) + LENGTH(RAM)) :
|
||||
{
|
||||
PROVIDE (__stack = .);
|
||||
*(.stack)
|
||||
}
|
||||
|
||||
/* The rest are all not normally part of the runtime image. */
|
||||
|
||||
.MP430.attributes 0 :
|
||||
{
|
||||
KEEP (*(.MSP430.attributes))
|
||||
KEEP (*(.gnu.attributes))
|
||||
KEEP (*(__TI_build_attributes))
|
||||
}
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.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. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.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) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/* DWARF 3 */
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
/* DWARF Extension. */
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
|
||||
/DISCARD/ : { *(.note.GNU-stack) }
|
||||
}
|
188
libgloss/msp430/msp430.ld
Normal file
188
libgloss/msp430/msp430.ld
Normal file
@ -0,0 +1,188 @@
|
||||
/* Copyright (c) 2005,2008,2009,2011,2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
/* Default linker script, for normal executables */
|
||||
OUTPUT_ARCH(msp430)
|
||||
ENTRY(_start)
|
||||
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
|
||||
MEMORY {
|
||||
RAM (w) : ORIGIN = 0x00200, LENGTH = 0x0ee00
|
||||
RESETVEC (w) : ORIGIN = 0x0fffe, LENGTH = 0x00002
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.resetvec :
|
||||
{
|
||||
*(.resetvec)
|
||||
} > RESETVEC
|
||||
|
||||
.rodata : {
|
||||
. = ALIGN(2);
|
||||
*(.plt)
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*)
|
||||
*(.rodata1)
|
||||
*(.eh_frame_hdr)
|
||||
KEEP (*(.eh_frame))
|
||||
KEEP (*(.gcc_except_table)) *(.gcc_except_table.*)
|
||||
PROVIDE (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE (__preinit_array_end = .);
|
||||
PROVIDE (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE (__init_array_end = .);
|
||||
PROVIDE (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE (__fini_array_end = .);
|
||||
LONG(0); /* Sentinel. */
|
||||
|
||||
/* gcc 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 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))
|
||||
|
||||
KEEP (*crtbegin*.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
} > RAM
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(2);
|
||||
PROVIDE (_start = .);
|
||||
*(.lowtext .text .stub .text.* .gnu.linkonce.t.* .text:*)
|
||||
KEEP (*(.text.*personality*))
|
||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||
*(.gnu.warning)
|
||||
*(.interp .hash .dynsym .dynstr .gnu.version*)
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
. = ALIGN(2);
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
} > RAM
|
||||
|
||||
.data : {
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__datastart = .);
|
||||
|
||||
KEEP (*(.jcr))
|
||||
*(.data.rel.ro.local) *(.data.rel.ro*)
|
||||
*(.dynamic)
|
||||
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
KEEP (*(.gnu.linkonce.d.*personality*))
|
||||
SORT(CONSTRUCTORS)
|
||||
*(.data1)
|
||||
*(.got.plt) *(.got)
|
||||
|
||||
/* We want the small data sections together, so single-instruction offsets
|
||||
can access them all, and initialized data all before uninitialized, so
|
||||
we can shorten the on-disk segment size. */
|
||||
. = ALIGN(2);
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.* D_2 D_1)
|
||||
|
||||
. = ALIGN(2);
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
PROVIDE (__dataend = .);
|
||||
} > RAM
|
||||
|
||||
/* Note that crt0 assumes this is a multiple of two; all the
|
||||
start/stop symbols are also assumed word-aligned. */
|
||||
PROVIDE(__romdatastart = LOADADDR(.data));
|
||||
PROVIDE (__romdatacopysize = SIZEOF(.data));
|
||||
|
||||
.bss : {
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__bssstart = .);
|
||||
*(.dynbss)
|
||||
*(.sbss .sbss.*)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
. = ALIGN(2);
|
||||
*(COMMON)
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__bssend = .);
|
||||
_end = .;
|
||||
PROVIDE (end = .);
|
||||
} > RAM
|
||||
PROVIDE (__bsssize = SIZEOF(.bss));
|
||||
|
||||
.stack (ORIGIN (RAM) + LENGTH(RAM)) :
|
||||
{
|
||||
PROVIDE (__stack = .);
|
||||
*(.stack)
|
||||
}
|
||||
|
||||
.MP430.attributes 0 :
|
||||
{
|
||||
KEEP (*(.MSP430.attributes))
|
||||
KEEP (*(.gnu.attributes))
|
||||
KEEP (*(__TI_build_attributes))
|
||||
}
|
||||
|
||||
/* The rest are all not normally part of the runtime image. */
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.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. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.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) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/DISCARD/ : { *(.note.GNU-stack) }
|
||||
}
|
203
libgloss/msp430/msp430F5438A-l.ld
Normal file
203
libgloss/msp430/msp430F5438A-l.ld
Normal file
@ -0,0 +1,203 @@
|
||||
/* Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
/* Default linker script, for normal executables */
|
||||
OUTPUT_ARCH(msp430)
|
||||
ENTRY(_start)
|
||||
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
|
||||
MEMORY {
|
||||
RAM (w) : ORIGIN = 0x01c00, LENGTH = 0x04000
|
||||
LOWROM (w) : ORIGIN = 0x05c00, LENGTH = 0x0a3fe
|
||||
RESETVEC (w) : ORIGIN = 0x0fffe, LENGTH = 0x00002
|
||||
ROM (w) : ORIGIN = 0x10000, LENGTH = 0x35c00
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.resetvec :
|
||||
{
|
||||
*(.resetvec)
|
||||
} > RESETVEC
|
||||
|
||||
.rodata : {
|
||||
. = ALIGN(2);
|
||||
*(.plt)
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*)
|
||||
*(.rodata1)
|
||||
*(.eh_frame_hdr)
|
||||
KEEP (*(.eh_frame))
|
||||
KEEP (*(.gcc_except_table)) *(.gcc_except_table.*)
|
||||
PROVIDE (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE (__preinit_array_end = .);
|
||||
PROVIDE (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE (__init_array_end = .);
|
||||
PROVIDE (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE (__fini_array_end = .);
|
||||
LONG(0); /* Sentinel. */
|
||||
|
||||
/* gcc 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 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))
|
||||
|
||||
KEEP (*crtbegin*.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
} > ROM
|
||||
|
||||
.data : {
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__datastart = .);
|
||||
|
||||
KEEP (*(.jcr))
|
||||
*(.data.rel.ro.local) *(.data.rel.ro*)
|
||||
*(.dynamic)
|
||||
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
KEEP (*(.gnu.linkonce.d.*personality*))
|
||||
SORT(CONSTRUCTORS)
|
||||
*(.data1)
|
||||
*(.got.plt) *(.got)
|
||||
|
||||
/* We want the small data sections together, so single-instruction offsets
|
||||
can access them all, and initialized data all before uninitialized, so
|
||||
we can shorten the on-disk segment size. */
|
||||
. = ALIGN(2);
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.* D_2 D_1)
|
||||
|
||||
. = ALIGN(2);
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
PROVIDE (__dataend = .);
|
||||
} > RAM AT>ROM
|
||||
|
||||
/* Note that crt0 assumes this is a multiple of two; all the
|
||||
start/stop symbols are also assumed word-aligned. */
|
||||
PROVIDE(__romdatastart = LOADADDR(.data));
|
||||
PROVIDE (__romdatacopysize = SIZEOF(.data));
|
||||
|
||||
.bss : {
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__bssstart = .);
|
||||
*(.dynbss)
|
||||
*(.sbss .sbss.*)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
. = ALIGN(2);
|
||||
*(COMMON)
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__bssend = .);
|
||||
_end = .;
|
||||
PROVIDE (end = .);
|
||||
} > RAM
|
||||
PROVIDE (__bsssize = SIZEOF(.bss));
|
||||
|
||||
.stack (ORIGIN (RAM) + LENGTH(RAM)) :
|
||||
{
|
||||
PROVIDE (__stack = .);
|
||||
*(.stack)
|
||||
}
|
||||
|
||||
/* This is just for crt0.S */
|
||||
.lowtext :
|
||||
{
|
||||
PROVIDE (_start = .);
|
||||
. = ALIGN(2);
|
||||
*(.lowtext)
|
||||
} > LOWROM
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(2);
|
||||
*(.text .stub .text.* .gnu.linkonce.t.* .text:*)
|
||||
KEEP (*(.text.*personality*))
|
||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||
*(.gnu.warning)
|
||||
*(.interp .hash .dynsym .dynstr .gnu.version*)
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
. = ALIGN(2);
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
} > ROM
|
||||
|
||||
/* The rest are all not normally part of the runtime image. */
|
||||
|
||||
.MP430.attributes 0 :
|
||||
{
|
||||
KEEP (*(.MSP430.attributes))
|
||||
KEEP (*(.gnu.attributes))
|
||||
KEEP (*(__TI_build_attributes))
|
||||
}
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.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. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.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) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/* DWARF 3 */
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
/* DWARF Extension. */
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
|
||||
/DISCARD/ : { *(.note.GNU-stack) }
|
||||
}
|
189
libgloss/msp430/msp430F5438A-s.ld
Normal file
189
libgloss/msp430/msp430F5438A-s.ld
Normal file
@ -0,0 +1,189 @@
|
||||
/* Copyright (c) 2005,2008,2009,2011,2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
/* Default linker script, for normal executables */
|
||||
OUTPUT_ARCH(msp430)
|
||||
ENTRY(_start)
|
||||
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
|
||||
MEMORY {
|
||||
RAM (w) : ORIGIN = 0x01c00, LENGTH = 0x04000
|
||||
ROM (w) : ORIGIN = 0x05c00, LENGTH = 0x0a3fe
|
||||
RESETVEC (w) : ORIGIN = 0x0fffe, LENGTH = 0x00002
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.resetvec :
|
||||
{
|
||||
*(.resetvec)
|
||||
} > RESETVEC
|
||||
|
||||
.rodata : {
|
||||
. = ALIGN(2);
|
||||
*(.plt)
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*)
|
||||
*(.rodata1)
|
||||
*(.eh_frame_hdr)
|
||||
KEEP (*(.eh_frame))
|
||||
KEEP (*(.gcc_except_table)) *(.gcc_except_table.*)
|
||||
PROVIDE (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE (__preinit_array_end = .);
|
||||
PROVIDE (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE (__init_array_end = .);
|
||||
PROVIDE (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE (__fini_array_end = .);
|
||||
LONG(0); /* Sentinel. */
|
||||
|
||||
/* gcc 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 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))
|
||||
|
||||
KEEP (*crtbegin*.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
} > ROM
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(2);
|
||||
PROVIDE (_start = .);
|
||||
*(.lowtext .text .stub .text.* .gnu.linkonce.t.* .text:*)
|
||||
KEEP (*(.text.*personality*))
|
||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||
*(.gnu.warning)
|
||||
*(.interp .hash .dynsym .dynstr .gnu.version*)
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
. = ALIGN(2);
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
} > ROM
|
||||
|
||||
.data : {
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__datastart = .);
|
||||
|
||||
KEEP (*(.jcr))
|
||||
*(.data.rel.ro.local) *(.data.rel.ro*)
|
||||
*(.dynamic)
|
||||
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
KEEP (*(.gnu.linkonce.d.*personality*))
|
||||
SORT(CONSTRUCTORS)
|
||||
*(.data1)
|
||||
*(.got.plt) *(.got)
|
||||
|
||||
/* We want the small data sections together, so single-instruction offsets
|
||||
can access them all, and initialized data all before uninitialized, so
|
||||
we can shorten the on-disk segment size. */
|
||||
. = ALIGN(2);
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.* D_2 D_1)
|
||||
|
||||
. = ALIGN(2);
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
PROVIDE (__dataend = .);
|
||||
} > RAM AT>ROM
|
||||
|
||||
/* Note that crt0 assumes this is a multiple of two; all the
|
||||
start/stop symbols are also assumed word-aligned. */
|
||||
PROVIDE(__romdatastart = LOADADDR(.data));
|
||||
PROVIDE (__romdatacopysize = SIZEOF(.data));
|
||||
|
||||
.bss : {
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__bssstart = .);
|
||||
*(.dynbss)
|
||||
*(.sbss .sbss.*)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
. = ALIGN(2);
|
||||
*(COMMON)
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__bssend = .);
|
||||
_end = .;
|
||||
PROVIDE (end = .);
|
||||
} > RAM
|
||||
PROVIDE (__bsssize = SIZEOF(.bss));
|
||||
|
||||
.stack (ORIGIN (RAM) + LENGTH(RAM)) :
|
||||
{
|
||||
PROVIDE (__stack = .);
|
||||
*(.stack)
|
||||
}
|
||||
|
||||
.MP430.attributes 0 :
|
||||
{
|
||||
KEEP (*(.MSP430.attributes))
|
||||
KEEP (*(.gnu.attributes))
|
||||
KEEP (*(__TI_build_attributes))
|
||||
}
|
||||
|
||||
/* The rest are all not normally part of the runtime image. */
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.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. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.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) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/DISCARD/ : { *(.note.GNU-stack) }
|
||||
}
|
203
libgloss/msp430/msp430xl-sim.ld
Normal file
203
libgloss/msp430/msp430xl-sim.ld
Normal file
@ -0,0 +1,203 @@
|
||||
/* Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
|
||||
*/
|
||||
|
||||
/* Default linker script, for normal executables */
|
||||
OUTPUT_ARCH(msp430)
|
||||
ENTRY(_start)
|
||||
|
||||
/* Do we need any of these for elf?
|
||||
__DYNAMIC = 0; */
|
||||
|
||||
MEMORY {
|
||||
RAM (rx) : ORIGIN = 0x00200, LENGTH = 0x0ee00
|
||||
LOWROM (w) : ORIGIN = 0x0f000, LENGTH = 0x00800
|
||||
ROM (w) : ORIGIN = 0x10000, LENGTH = 0x80000
|
||||
RESETVEC (w) : ORIGIN = 0x0fffe, LENGTH = 0x00002
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.resetvec :
|
||||
{
|
||||
*(.resetvec)
|
||||
} > RESETVEC
|
||||
|
||||
.rodata : {
|
||||
. = ALIGN(2);
|
||||
*(.plt)
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.* .const .const:*)
|
||||
*(.rodata1)
|
||||
*(.eh_frame_hdr)
|
||||
KEEP (*(.eh_frame))
|
||||
KEEP (*(.gcc_except_table)) *(.gcc_except_table.*)
|
||||
PROVIDE (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array))
|
||||
PROVIDE (__preinit_array_end = .);
|
||||
PROVIDE (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array))
|
||||
PROVIDE (__init_array_end = .);
|
||||
PROVIDE (__fini_array_start = .);
|
||||
KEEP (*(.fini_array))
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
PROVIDE (__fini_array_end = .);
|
||||
LONG(0); /* Sentinel. */
|
||||
|
||||
/* gcc 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 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))
|
||||
|
||||
KEEP (*crtbegin*.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*(.dtors))
|
||||
} > ROM
|
||||
|
||||
.data : {
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__datastart = .);
|
||||
|
||||
KEEP (*(.jcr))
|
||||
*(.data.rel.ro.local) *(.data.rel.ro*)
|
||||
*(.dynamic)
|
||||
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
KEEP (*(.gnu.linkonce.d.*personality*))
|
||||
SORT(CONSTRUCTORS)
|
||||
*(.data1)
|
||||
*(.got.plt) *(.got)
|
||||
|
||||
/* We want the small data sections together, so single-instruction offsets
|
||||
can access them all, and initialized data all before uninitialized, so
|
||||
we can shorten the on-disk segment size. */
|
||||
. = ALIGN(2);
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.* D_2 D_1)
|
||||
|
||||
. = ALIGN(2);
|
||||
_edata = .;
|
||||
PROVIDE (edata = .);
|
||||
PROVIDE (__dataend = .);
|
||||
} > RAM AT>ROM
|
||||
|
||||
/* Note that crt0 assumes this is a multiple of two; all the
|
||||
start/stop symbols are also assumed word-aligned. */
|
||||
PROVIDE(__romdatastart = LOADADDR(.data));
|
||||
PROVIDE (__romdatacopysize = SIZEOF(.data));
|
||||
|
||||
.bss : {
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__bssstart = .);
|
||||
*(.dynbss)
|
||||
*(.sbss .sbss.*)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
. = ALIGN(2);
|
||||
*(COMMON)
|
||||
. = ALIGN(2);
|
||||
PROVIDE (__bssend = .);
|
||||
_end = .;
|
||||
PROVIDE (end = .);
|
||||
} > RAM
|
||||
PROVIDE (__bsssize = SIZEOF(.bss));
|
||||
|
||||
.stack (ORIGIN (RAM) + LENGTH(RAM)) :
|
||||
{
|
||||
PROVIDE (__stack = .);
|
||||
*(.stack)
|
||||
}
|
||||
|
||||
/* This is just for crt0.S */
|
||||
.lowtext :
|
||||
{
|
||||
PROVIDE (_start = .);
|
||||
. = ALIGN(2);
|
||||
*(.lowtext)
|
||||
} > LOWROM
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(2);
|
||||
*(.text .stub .text.* .gnu.linkonce.t.* .text:*)
|
||||
KEEP (*(.text.*personality*))
|
||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||
*(.gnu.warning)
|
||||
*(.interp .hash .dynsym .dynstr .gnu.version*)
|
||||
PROVIDE (__etext = .);
|
||||
PROVIDE (_etext = .);
|
||||
PROVIDE (etext = .);
|
||||
. = ALIGN(2);
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
} > ROM
|
||||
|
||||
/* The rest are all not normally part of the runtime image. */
|
||||
|
||||
.MP430.attributes 0 :
|
||||
{
|
||||
KEEP (*(.MSP430.attributes))
|
||||
KEEP (*(.gnu.attributes))
|
||||
KEEP (*(__TI_build_attributes))
|
||||
}
|
||||
|
||||
/* Stabs debugging sections. */
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.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. */
|
||||
/* DWARF 1 */
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
/* GNU DWARF 1 extensions */
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
/* DWARF 1.1 and DWARF 2 */
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
/* DWARF 2 */
|
||||
.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) }
|
||||
/* SGI/MIPS DWARF 2 extensions */
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
/* DWARF 3 */
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
/* DWARF Extension. */
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
|
||||
/DISCARD/ : { *(.note.GNU-stack) }
|
||||
}
|
69
libgloss/msp430/nosyscalls.S
Normal file
69
libgloss/msp430/nosyscalls.S
Normal file
@ -0,0 +1,69 @@
|
||||
/* Copyright (c) 2012, 2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
/* Empty syscall definitions for when we run on real hardware. */
|
||||
|
||||
#include "../syscall.h"
|
||||
#include "memmodel.h"
|
||||
|
||||
#define ENOSYS 88
|
||||
|
||||
.macro sc,a
|
||||
sc2 \a,\a
|
||||
.endm
|
||||
|
||||
.macro sc2,name,num
|
||||
.weak \name
|
||||
.global \name
|
||||
\name:
|
||||
call_ #__errno
|
||||
movx_ #ENOSYS, @R12
|
||||
MOV.W #-1,R12
|
||||
ret_
|
||||
.endm
|
||||
|
||||
.weak exit
|
||||
.weak _exit
|
||||
.global exit
|
||||
.global _exit
|
||||
exit:
|
||||
_exit:
|
||||
/* For some reason, the board fails to stop at a breakpoint
|
||||
placed on top of a software breakpoint instruction. */
|
||||
/* MOV.B #0,R3 ; this is a software breakpoint instruction */
|
||||
1: br_ #1b
|
||||
|
||||
#define SC(n) sc2 n,SYS_##n
|
||||
|
||||
SC (open)
|
||||
SC (close)
|
||||
SC (read)
|
||||
/* SC (write)*/
|
||||
SC (fstat)
|
||||
SC (lseek)
|
||||
SC (kill)
|
||||
|
||||
.weak isatty
|
||||
.global isatty
|
||||
isatty:
|
||||
.weak _isatty
|
||||
.global _isatty
|
||||
_isatty:
|
||||
MOV #1,R12
|
||||
ret_
|
||||
|
||||
.weak getpid
|
||||
.global getpid
|
||||
getpid:
|
||||
MOV #42,R12
|
||||
ret_
|
33
libgloss/msp430/sbrk.c
Normal file
33
libgloss/msp430/sbrk.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
char *
|
||||
_sbrk (int adj)
|
||||
{
|
||||
extern char end[]; /* Defined in the linker script. */
|
||||
static char * heap = end;
|
||||
char * rv = heap;
|
||||
char * sp = (char *) & sp; /* Stack grows down, heap grows up... */
|
||||
|
||||
if (heap + adj > sp)
|
||||
{
|
||||
#define MESSAGE "Heap and stack collision\n"
|
||||
write (1, MESSAGE, sizeof MESSAGE);
|
||||
abort ();
|
||||
}
|
||||
|
||||
heap += adj;
|
||||
return rv;
|
||||
}
|
||||
|
||||
char * sbrk (int) __attribute__((weak, alias ("_sbrk")));
|
66
libgloss/msp430/syscalls.S
Normal file
66
libgloss/msp430/syscalls.S
Normal file
@ -0,0 +1,66 @@
|
||||
/* Copyright (c) 2012, 2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
/* Be wary: the lower N bits of the *address* of the function
|
||||
determines the syscall used by the simulator. Thus, the addresses
|
||||
listed here depend on the syscall numbers in ../syscalls.h. */
|
||||
|
||||
/* As per the MSP430x200 Family Users Guide, section 1.5, "An
|
||||
instruction fetch from the address range 0x0000 - 0x01FF will reset
|
||||
the device." We take advantage of that to do syscalls in the
|
||||
simulator, by trying to execute specific addresses in that range
|
||||
and letting the simulator catch them while simulating the CALL
|
||||
instruction. In theory, this is an operation that the physical
|
||||
hardware will never attempt to do, so it won't interfere with the
|
||||
simulation's accuracy (i.e. we aren't abusing holes in the opcode
|
||||
map, for example). */
|
||||
|
||||
#include "../syscall.h"
|
||||
#include "memmodel.h"
|
||||
|
||||
.macro sc,a
|
||||
sc2 \a,\a
|
||||
.endm
|
||||
|
||||
.macro sc2,name,num
|
||||
.weak \name
|
||||
.global \name
|
||||
\name = 0x180 + \num
|
||||
.endm
|
||||
|
||||
#define SC(n) sc2 n,SYS_##n
|
||||
|
||||
sc2 _exit,SYS_exit
|
||||
SC (exit)
|
||||
SC (open)
|
||||
SC (close)
|
||||
SC (read)
|
||||
/* SC (write)*/
|
||||
SC (fstat)
|
||||
SC (lseek)
|
||||
SC (kill)
|
||||
|
||||
.weak isatty
|
||||
.global isatty
|
||||
isatty:
|
||||
.weak _isatty
|
||||
.global _isatty
|
||||
_isatty:
|
||||
MOV #1,R12
|
||||
ret_
|
||||
|
||||
.weak getpid
|
||||
.global getpid
|
||||
getpid:
|
||||
MOV #42,R12
|
||||
ret_
|
59
libgloss/msp430/write.c
Normal file
59
libgloss/msp430/write.c
Normal file
@ -0,0 +1,59 @@
|
||||
/* Copyright (c) 2013 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use, modify,
|
||||
copy, or redistribute it subject to the terms and conditions of the BSD
|
||||
License. This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY expressed or implied, including the implied warranties
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. A copy of this license
|
||||
is available at http://www.opensource.org/licenses. Any Red Hat trademarks that
|
||||
are incorporated in the source code or documentation are not subject to the BSD
|
||||
License and may only be used or replicated with the express permission of
|
||||
Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "cio.h"
|
||||
|
||||
static int
|
||||
write_chunk (int fd, char *buf, int len)
|
||||
{
|
||||
__CIOBUF__.length[0] = len;
|
||||
__CIOBUF__.length[1] = len >> 8;
|
||||
__CIOBUF__.parms[0] = CIO_WRITE;
|
||||
__CIOBUF__.parms[1] = fd;
|
||||
__CIOBUF__.parms[2] = fd >> 8;
|
||||
__CIOBUF__.parms[3] = len;
|
||||
__CIOBUF__.parms[4] = len >> 8;
|
||||
memcpy (__CIOBUF__.buf, buf, len);
|
||||
|
||||
_libgloss_cio_hook ();
|
||||
|
||||
return __CIOBUF__.parms[0] + __CIOBUF__.parms[1] * 256;
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
write (int fd, char *buf, int len)
|
||||
{
|
||||
int rv = 0;
|
||||
int c;
|
||||
#if 0
|
||||
if (fd == 2)
|
||||
fprintf (stderr, "%.*s", buf, len);
|
||||
else if (fd == 1)
|
||||
printf ("%.*s", buf, len);
|
||||
#endif
|
||||
while (len > 0)
|
||||
{
|
||||
int l = (len > CIO_BUF_SIZE) ? CIO_BUF_SIZE : len;
|
||||
c = write_chunk (fd, buf, l);
|
||||
if (c < 0)
|
||||
return c;
|
||||
rv += l;
|
||||
len -= l;
|
||||
buf += l;
|
||||
}
|
||||
return c;
|
||||
}
|
Reference in New Issue
Block a user