[libgloss] * configure.in: Add rl78. * configure: Regenerate. * rl78: New directory
[newlib] * configure.host: Add rl78. * libc/include/machine/ieeefp.h: Add rl78 support. * libc/include/machine/setjmp.h: Add rl78 support. * libc/machine/configure.in: Add rl78. * libc/machine/rl78: New directory.
This commit is contained in:
commit
fea10954a6
160
Makefile.in
Normal file
160
Makefile.in
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
# Copyright (c) 2008, 2009, 2011 Red Hat Inc
|
||||||
|
#
|
||||||
|
# The authors hereby grant permission to use, copy, modify, distribute,
|
||||||
|
# and license this software and its documentation for any purpose, provided
|
||||||
|
# that existing copyright notices are retained in all copies and that this
|
||||||
|
# notice is included verbatim in any distributions. No written agreement,
|
||||||
|
# license, or royalty fee is required for any of the authorized uses.
|
||||||
|
# Modifications to this software may be copyrighted by their authors
|
||||||
|
# and need not follow the licensing terms described here, provided that
|
||||||
|
# the new terms are clearly indicated on the first page of each file where
|
||||||
|
# they apply.
|
||||||
|
|
||||||
|
# Makefile for libgloss/rl78.
|
||||||
|
|
||||||
|
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)/rl78.ld $(srcdir)/rl78-sim.ld
|
||||||
|
CRT = gcrt0.o crt0.o crtn.o
|
||||||
|
SIM_BSP = libsim.a
|
||||||
|
LIBNOSYS = ../libnosys/libnosys.a
|
||||||
|
SIM_OBJS = \
|
||||||
|
sbrk.o \
|
||||||
|
exit.o \
|
||||||
|
open.o \
|
||||||
|
close.o \
|
||||||
|
read.o \
|
||||||
|
write.o \
|
||||||
|
lseek.o \
|
||||||
|
unlink.o \
|
||||||
|
getpid.o \
|
||||||
|
kill.o \
|
||||||
|
fstat.o \
|
||||||
|
argvlen.o \
|
||||||
|
argv.o \
|
||||||
|
chdir.o \
|
||||||
|
stat.o \
|
||||||
|
chmod.o \
|
||||||
|
utime.o \
|
||||||
|
time.o \
|
||||||
|
gettimeofday.o \
|
||||||
|
times.o \
|
||||||
|
link.o \
|
||||||
|
isatty.o \
|
||||||
|
abort.o \
|
||||||
|
mcount.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) copy_scripts_to_objdir
|
||||||
|
|
||||||
|
$(SIM_BSP): $(SIM_OBJS)
|
||||||
|
$(AR) $(ARFLAGS) $@ $?
|
||||||
|
$(RANLIB) $@
|
||||||
|
|
||||||
|
copy_scripts_to_objdir: $(SCRIPTS)
|
||||||
|
cp $(SCRIPTS) $(objdir)
|
||||||
|
|
||||||
|
# Dependencies
|
||||||
|
|
||||||
|
SDEPS = $(srcdir)/rl78-sys.h $(srcdir)/../syscall.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) $(SCRIPTS)
|
||||||
|
for c in $(CRT) $(SIM_BSP); 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
|
50
abort.S
Normal file
50
abort.S
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
.global _abort
|
||||||
|
.type _abort, @function
|
||||||
|
_abort:
|
||||||
|
/* This is for debuggers. The simulator stops here too. */
|
||||||
|
brk
|
||||||
|
|
||||||
|
movw ax, #42
|
||||||
|
push ax
|
||||||
|
SYSCALL(SYS_kill)
|
||||||
|
pop ax
|
||||||
|
|
||||||
|
/* Else, exit. */
|
||||||
|
call !!__exit
|
||||||
|
|
||||||
|
.size _abort, . - _abort
|
||||||
|
|
35
argv.S
Normal file
35
argv.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(argv)
|
35
argvlen.S
Normal file
35
argvlen.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(argvlen)
|
35
chdir.S
Normal file
35
chdir.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(chdir)
|
35
chmod.S
Normal file
35
chmod.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(chmod)
|
35
close.S
Normal file
35
close.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
OK(close)
|
55
configure.in
Normal file
55
configure.in
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
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
|
327
crt0.S
Normal file
327
crt0.S
Normal file
|
@ -0,0 +1,327 @@
|
||||||
|
/* Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
This software is provided by the copyright holders and contributors
|
||||||
|
"AS IS" and any express or implied warranties, including, but not
|
||||||
|
limited to, the implied warranties of merchantability and fitness for
|
||||||
|
a particular purpose are disclaimed. In no event shall Red Hat
|
||||||
|
incorporated be liable for any direct, indirect, incidental, special,
|
||||||
|
exemplary, or consequential damages (including, but not limited to,
|
||||||
|
procurement of substitute goods or services; loss of use, data, or
|
||||||
|
profits; or business interruption) however caused and on any theory of
|
||||||
|
liability, whether in contract, strict liability, or tort (including
|
||||||
|
negligence or otherwise) arising in any way out of the use of this
|
||||||
|
software, even if advised of the possibility of such damage. */
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
.section ".vec","a"
|
||||||
|
.short _start
|
||||||
|
|
||||||
|
.section ".ivec","a"
|
||||||
|
#define IV(x) .weak _##x##_handler | .short _##x##_handler
|
||||||
|
#define IVx() .short 0
|
||||||
|
|
||||||
|
/* To use a vector, simply define a global function named foo_handler()
|
||||||
|
for any IV(foo) listed below (i.e. tm05_handler) */
|
||||||
|
|
||||||
|
.global _interrupt_vector_table
|
||||||
|
_interrupt_vector_table:
|
||||||
|
IV(wdti)
|
||||||
|
IV(lvi)
|
||||||
|
IV(p0)
|
||||||
|
IV(p1)
|
||||||
|
IV(p2)
|
||||||
|
IV(p3)
|
||||||
|
IV(p4)
|
||||||
|
IV(p5)
|
||||||
|
|
||||||
|
IV(st2)
|
||||||
|
IV(sr2)
|
||||||
|
IV(sre2)
|
||||||
|
IV(dma0)
|
||||||
|
IV(dma1)
|
||||||
|
IV(st0)
|
||||||
|
IV(sr0)
|
||||||
|
IV(tm01h)
|
||||||
|
|
||||||
|
IV(st1)
|
||||||
|
IV(sr1)
|
||||||
|
IV(sre1)
|
||||||
|
IV(iica0)
|
||||||
|
IV(tm00)
|
||||||
|
IV(tm01)
|
||||||
|
IV(tm02)
|
||||||
|
IV(tm03)
|
||||||
|
|
||||||
|
IV(ad)
|
||||||
|
IV(rtc)
|
||||||
|
IV(it)
|
||||||
|
IV(kr)
|
||||||
|
IV(st3)
|
||||||
|
IV(sr3)
|
||||||
|
IV(tm13)
|
||||||
|
IV(tm04)
|
||||||
|
|
||||||
|
IV(tm05)
|
||||||
|
IV(tm06)
|
||||||
|
IV(tm07)
|
||||||
|
IV(p6)
|
||||||
|
IV(p7)
|
||||||
|
IV(p8)
|
||||||
|
IV(p9)
|
||||||
|
IV(p10)
|
||||||
|
|
||||||
|
IV(p11)
|
||||||
|
IV(tm10)
|
||||||
|
IV(tm12)
|
||||||
|
IV(sre3)
|
||||||
|
IV(tm13h)
|
||||||
|
IV(md)
|
||||||
|
IV(iica1)
|
||||||
|
IV(fl)
|
||||||
|
|
||||||
|
IV(dma2)
|
||||||
|
IV(dma3)
|
||||||
|
IV(tm14)
|
||||||
|
IV(tm15)
|
||||||
|
IV(tm16)
|
||||||
|
IV(tm17)
|
||||||
|
IVx()
|
||||||
|
IVx()
|
||||||
|
|
||||||
|
IVx()
|
||||||
|
IVx()
|
||||||
|
IVx()
|
||||||
|
IVx()
|
||||||
|
IVx()
|
||||||
|
IV(brk)
|
||||||
|
/* Note: 126 vectors */
|
||||||
|
|
||||||
|
.section ".csstart", "ax"
|
||||||
|
.global __csstart
|
||||||
|
__csstart:
|
||||||
|
br !!_start
|
||||||
|
|
||||||
|
.weak __rl78_option_byte_0
|
||||||
|
.weak __rl78_option_byte_1
|
||||||
|
.weak __rl78_option_byte_2
|
||||||
|
.weak __rl78_option_byte_3
|
||||||
|
__rl78_option_byte_0 = 0x6e
|
||||||
|
__rl78_option_byte_1 = 0xff
|
||||||
|
__rl78_option_byte_2 = 0xe8
|
||||||
|
__rl78_option_byte_3 = 0x85
|
||||||
|
|
||||||
|
.section ".opt", "a"
|
||||||
|
.byte __rl78_option_byte_0
|
||||||
|
.byte __rl78_option_byte_1
|
||||||
|
.byte __rl78_option_byte_2
|
||||||
|
.byte __rl78_option_byte_3
|
||||||
|
|
||||||
|
.text
|
||||||
|
|
||||||
|
.global _start
|
||||||
|
.type _start, @function
|
||||||
|
_start:
|
||||||
|
movw sp, #__stack
|
||||||
|
|
||||||
|
|
||||||
|
;; block move to initialize .data
|
||||||
|
|
||||||
|
;; we're copying from 00:[_romdatastart] to 0F:[_datastart]
|
||||||
|
;; and our data is not in the mirrored area.
|
||||||
|
mov es, #0
|
||||||
|
|
||||||
|
sel rb0 ; bank 0
|
||||||
|
movw hl, #__datastart
|
||||||
|
movw de, #__romdatastart
|
||||||
|
sel rb1 ; bank 1
|
||||||
|
movw ax, #__romdatacopysize
|
||||||
|
shrw ax,1
|
||||||
|
1:
|
||||||
|
cmpw ax, #0
|
||||||
|
bz $1f
|
||||||
|
decw ax
|
||||||
|
sel rb0 ; bank 0
|
||||||
|
movw ax, es:[de]
|
||||||
|
movw [hl], ax
|
||||||
|
incw de
|
||||||
|
incw de
|
||||||
|
incw hl
|
||||||
|
incw hl
|
||||||
|
sel rb1
|
||||||
|
br $1b
|
||||||
|
1:
|
||||||
|
sel rb0 ; bank 0
|
||||||
|
|
||||||
|
|
||||||
|
;; block fill to .bss
|
||||||
|
|
||||||
|
sel rb0 ; bank 0
|
||||||
|
movw hl, #__bssstart
|
||||||
|
movw ax, #0
|
||||||
|
sel rb1 ; bank 1
|
||||||
|
movw ax, #__bsssize
|
||||||
|
shrw ax,1
|
||||||
|
1:
|
||||||
|
cmpw ax, #0
|
||||||
|
bz $1f
|
||||||
|
decw ax
|
||||||
|
sel rb0 ; bank 0
|
||||||
|
movw [hl], ax
|
||||||
|
incw hl
|
||||||
|
incw hl
|
||||||
|
sel rb1
|
||||||
|
br $1b
|
||||||
|
1:
|
||||||
|
sel rb0 ; bank 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
call !!__rl78_init
|
||||||
|
|
||||||
|
#ifdef PROFILE_SUPPORT /* Defined in gcrt0.S. */
|
||||||
|
movw ax, # _start
|
||||||
|
push ax
|
||||||
|
movw ax, # _etext
|
||||||
|
push ax
|
||||||
|
call !!__monstartup
|
||||||
|
#endif
|
||||||
|
|
||||||
|
movw ax, #0
|
||||||
|
push ax /* envp */
|
||||||
|
push ax /* argv */
|
||||||
|
push ax /* argc */
|
||||||
|
call !!_main
|
||||||
|
.LFE2:
|
||||||
|
|
||||||
|
movw ax, r8 ; Save return code.
|
||||||
|
push ax
|
||||||
|
|
||||||
|
#ifdef PROFILE_SUPPORT
|
||||||
|
call !!__mcleanup
|
||||||
|
#endif
|
||||||
|
|
||||||
|
call !!_exit
|
||||||
|
|
||||||
|
.size _start, . - _start
|
||||||
|
|
||||||
|
.global _rl78_run_preinit_array
|
||||||
|
.type _rl78_run_preinit_array,@function
|
||||||
|
_rl78_run_preinit_array:
|
||||||
|
movw hl, #__preinit_array_start
|
||||||
|
movw de, #__preinit_array_end
|
||||||
|
movw bc, #-2
|
||||||
|
br $_rl78_run_inilist
|
||||||
|
|
||||||
|
.global _rl78_run_init_array
|
||||||
|
.type _rl78_run_init_array,@function
|
||||||
|
_rl78_run_init_array:
|
||||||
|
movw hl, #__init_array_start
|
||||||
|
movw de, #__init_array_end
|
||||||
|
movw bc, #2
|
||||||
|
br $_rl78_run_inilist
|
||||||
|
|
||||||
|
.global _rl78_run_fini_array
|
||||||
|
.type _rl78_run_fini_array,@function
|
||||||
|
_rl78_run_fini_array:
|
||||||
|
movw hl, #__fini_array_start
|
||||||
|
movw de, #__fini_array_end
|
||||||
|
movw bc, #-2
|
||||||
|
/* fall through */
|
||||||
|
|
||||||
|
;; HL = start of list
|
||||||
|
;; DE = end of list
|
||||||
|
;; BC = step direction (+2 or -2)
|
||||||
|
_rl78_run_inilist:
|
||||||
|
next_inilist:
|
||||||
|
movw ax, hl
|
||||||
|
cmpw ax, de
|
||||||
|
bz $done_inilist
|
||||||
|
movw ax, [hl]
|
||||||
|
cmpw ax, #-1
|
||||||
|
bz $skip_inilist
|
||||||
|
cmpw ax, #0
|
||||||
|
bz $skip_inilist
|
||||||
|
push ax
|
||||||
|
push bc
|
||||||
|
push de
|
||||||
|
push hl
|
||||||
|
call ax
|
||||||
|
pop hl
|
||||||
|
pop de
|
||||||
|
pop bc
|
||||||
|
pop ax
|
||||||
|
skip_inilist:
|
||||||
|
movw ax, hl
|
||||||
|
addw ax, bc
|
||||||
|
movw hl, ax
|
||||||
|
br $next_inilist
|
||||||
|
done_inilist:
|
||||||
|
ret
|
||||||
|
|
||||||
|
.section .init,"ax"
|
||||||
|
|
||||||
|
.global __rl78_init
|
||||||
|
__rl78_init:
|
||||||
|
|
||||||
|
.section .fini,"ax"
|
||||||
|
|
||||||
|
.global __rl78_fini
|
||||||
|
__rl78_fini:
|
||||||
|
call !!_rl78_run_fini_array
|
||||||
|
|
||||||
|
.section .data
|
||||||
|
.global ___dso_handle
|
||||||
|
.weak ___dso_handle
|
||||||
|
___dso_handle:
|
||||||
|
.long 0
|
||||||
|
|
||||||
|
;;; Provide Dwarf unwinding information that will help GDB stop
|
||||||
|
;;; backtraces at the right place. This is stolen from assembly
|
||||||
|
;;; code generated by GCC with -dA.
|
||||||
|
.section .debug_frame,"",@progbits
|
||||||
|
.Lframe0:
|
||||||
|
.4byte .LECIE0-.LSCIE0 ; Length of Common Information Entry
|
||||||
|
.LSCIE0:
|
||||||
|
.4byte 0xffffffff ; CIE Identifier Tag
|
||||||
|
.byte 0x1 ; CIE Version
|
||||||
|
.ascii "\0" ; CIE Augmentation
|
||||||
|
.uleb128 0x1 ; CIE Code Alignment Factor
|
||||||
|
.sleb128 -1 ; CIE Data Alignment Factor
|
||||||
|
.byte 0xd ; CIE RA Column
|
||||||
|
.byte 0xc ; DW_CFA_def_cfa
|
||||||
|
.uleb128 0xc
|
||||||
|
.uleb128 0x3
|
||||||
|
.byte 0x8d ; DW_CFA_offset, column 0xd
|
||||||
|
.uleb128 0x3
|
||||||
|
.p2align 2
|
||||||
|
.LECIE0:
|
||||||
|
.LSFDE0:
|
||||||
|
.4byte .LEFDE0-.LASFDE0 ; FDE Length
|
||||||
|
.LASFDE0:
|
||||||
|
.4byte .Lframe0 ; FDE CIE offset
|
||||||
|
.4byte _start ; FDE initial location
|
||||||
|
.4byte .LFE2 - _start ; FDE address range
|
||||||
|
.byte 0xf ; DW_CFA_def_cfa_expression
|
||||||
|
.uleb128 1 ; length of expression
|
||||||
|
.byte 0x30 ; DW_OP_lit0
|
||||||
|
.p2align 2
|
||||||
|
.LEFDE0:
|
||||||
|
|
||||||
|
.text
|
47
crtn.S
Normal file
47
crtn.S
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2005,2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
.section .init,"ax"
|
||||||
|
call !!_rl78_run_preinit_array
|
||||||
|
call !!_rl78_run_init_array
|
||||||
|
ret
|
||||||
|
.global __rl78_init_end
|
||||||
|
__rl78_init_end:
|
||||||
|
|
||||||
|
.section .fini,"ax"
|
||||||
|
|
||||||
|
ret
|
||||||
|
.global __rl78_fini_end
|
||||||
|
__rl78_fini_end:
|
||||||
|
|
||||||
|
.text
|
||||||
|
|
43
exit.S
Normal file
43
exit.S
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
.global __exit
|
||||||
|
.type __exit, @function
|
||||||
|
__exit:
|
||||||
|
call !!__rl78_fini
|
||||||
|
mov a, [sp+4]
|
||||||
|
halt
|
||||||
|
SYSCALL(SYS_exit)
|
||||||
|
.size __exit, . - __exit
|
||||||
|
|
35
fstat.S
Normal file
35
fstat.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(fstat)
|
58
gcrt0.S
Normal file
58
gcrt0.S
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/* Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
This software is provided by the copyright holders and contributors
|
||||||
|
"AS IS" and any express or implied warranties, including, but not
|
||||||
|
limited to, the implied warranties of merchantability and fitness for
|
||||||
|
a particular purpose are disclaimed. In no event shall Red Hat
|
||||||
|
incorporated be liable for any direct, indirect, incidental, special,
|
||||||
|
exemplary, or consequential damages (including, but not limited to,
|
||||||
|
procurement of substitute goods or services; loss of use, data, or
|
||||||
|
profits; or business interruption) however caused and on any theory of
|
||||||
|
liability, whether in contract, strict liability, or tort (including
|
||||||
|
negligence or otherwise) arising in any way out of the use of this
|
||||||
|
software, even if advised of the possibility of such damage. */
|
||||||
|
|
||||||
|
#define PROFILE_SUPPORT 1
|
||||||
|
|
||||||
|
#include "crt0.S"
|
||||||
|
|
||||||
|
.global __mcount
|
||||||
|
.type __mcount, @function
|
||||||
|
__mcount:
|
||||||
|
;; When a function is compiled for profiling, gcc creates code
|
||||||
|
;; like this at the start of each profiled function:
|
||||||
|
;;
|
||||||
|
;; .global <func_name>
|
||||||
|
;; <func_name>:
|
||||||
|
;; bsr __mcount
|
||||||
|
;; <...function's prologue...>
|
||||||
|
;; <...function's body...>
|
||||||
|
;;
|
||||||
|
;; We must save all of the argument registers, extract the
|
||||||
|
;; address of <func_name>, call _mcount_internal to do the
|
||||||
|
;; real work and then restore the argument registers before
|
||||||
|
;; returning.
|
||||||
|
|
||||||
|
movw ax, [sp]
|
||||||
|
push ax
|
||||||
|
call !!__mcount_internal
|
||||||
|
pop ax
|
||||||
|
ret
|
||||||
|
|
||||||
|
.size __mcount, . - __mcount
|
36
getpid.S
Normal file
36
getpid.S
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
RET(getpid,42)
|
||||||
|
|
35
gettimeofday.S
Normal file
35
gettimeofday.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(gettimeofday)
|
36
isatty.S
Normal file
36
isatty.S
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/* Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
.global _isatty
|
||||||
|
.weak _isatty
|
||||||
|
_isatty:
|
||||||
|
|
||||||
|
RET(_isatty,1)
|
||||||
|
|
35
kill.S
Normal file
35
kill.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(kill)
|
35
link.S
Normal file
35
link.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(link)
|
35
lseek.S
Normal file
35
lseek.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(lseek)
|
422
mcount.c
Normal file
422
mcount.c
Normal file
|
@ -0,0 +1,422 @@
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1983, 1992, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file implements a subset of the profiling support functions.
|
||||||
|
It has been copied and adapted from mcount.c, gmon.c and gmon.h in
|
||||||
|
the glibc sources.
|
||||||
|
Since we do not have access to a timer interrupt in the simulator
|
||||||
|
the histogram and basic block information is not generated. */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
/* Fraction of text space to allocate for histogram counters here, 1/2. */
|
||||||
|
#define HISTFRACTION 2
|
||||||
|
|
||||||
|
/* Fraction of text space to allocate for from hash buckets.
|
||||||
|
The value of HASHFRACTION is based on the minimum number of bytes
|
||||||
|
of separation between two subroutine call points in the object code.
|
||||||
|
Given MIN_SUBR_SEPARATION bytes of separation the value of
|
||||||
|
HASHFRACTION is calculated as:
|
||||||
|
|
||||||
|
HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof (short) - 1);
|
||||||
|
|
||||||
|
For example, on the VAX, the shortest two call sequence is:
|
||||||
|
|
||||||
|
calls $0,(r0)
|
||||||
|
calls $0,(r0)
|
||||||
|
|
||||||
|
which is separated by only three bytes, thus HASHFRACTION is
|
||||||
|
calculated as:
|
||||||
|
|
||||||
|
HASHFRACTION = 3 / (2 * 2 - 1) = 1
|
||||||
|
|
||||||
|
Note that the division above rounds down, thus if MIN_SUBR_FRACTION
|
||||||
|
is less than three, this algorithm will not work!
|
||||||
|
|
||||||
|
In practice, however, call instructions are rarely at a minimal
|
||||||
|
distance. Hence, we will define HASHFRACTION to be 2 across all
|
||||||
|
architectures. This saves a reasonable amount of space for
|
||||||
|
profiling data structures without (in practice) sacrificing
|
||||||
|
any granularity. */
|
||||||
|
#define HASHFRACTION 2
|
||||||
|
|
||||||
|
/* Percent of text space to allocate for tostructs.
|
||||||
|
This is a heuristic; we will fail with a warning when profiling
|
||||||
|
programs with a very large number of very small functions, but
|
||||||
|
that's normally OK.
|
||||||
|
2 is probably still a good value for normal programs.
|
||||||
|
Profiling a test case with 64000 small functions will work if
|
||||||
|
you raise this value to 3 and link statically (which bloats the
|
||||||
|
text size, thus raising the number of arcs expected by the heuristic). */
|
||||||
|
#define ARCDENSITY 3
|
||||||
|
|
||||||
|
/* Always allocate at least this many tostructs. This hides the
|
||||||
|
inadequacy of the ARCDENSITY heuristic, at least for small programs. */
|
||||||
|
#define MINARCS 50
|
||||||
|
|
||||||
|
/* Maximum number of arcs we want to allow.
|
||||||
|
Used to be max representable value of ARCINDEX minus 2, but now
|
||||||
|
that ARCINDEX is a long, that's too large; we don't really want
|
||||||
|
to allow a 48 gigabyte table.
|
||||||
|
The old value of 1<<16 wasn't high enough in practice for large C++
|
||||||
|
programs; will 1<<20 be adequate for long? FIXME */
|
||||||
|
#define MAXARCS (1L << 20)
|
||||||
|
|
||||||
|
#define SCALE_1_TO_1 0x10000L
|
||||||
|
|
||||||
|
#define GMON_MAGIC "gmon" /* Magic cookie. */
|
||||||
|
#define GMON_VERSION 1 /* Version number. */
|
||||||
|
|
||||||
|
|
||||||
|
/* General rounding functions. */
|
||||||
|
#define ROUNDDOWN(x ,y) (((x) / (y)) * (y))
|
||||||
|
#define ROUNDUP(x, y) ((((x) + (y) - 1) / (y)) * (y))
|
||||||
|
|
||||||
|
struct tostruct
|
||||||
|
{
|
||||||
|
unsigned long selfpc;
|
||||||
|
unsigned long count;
|
||||||
|
unsigned long link;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Possible states of profiling. */
|
||||||
|
enum profiling_state
|
||||||
|
{
|
||||||
|
GMON_PROF_OFF,
|
||||||
|
GMON_PROF_ON,
|
||||||
|
GMON_PROF_BUSY,
|
||||||
|
GMON_PROF_ERROR
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The profiling data structures are housed in this structure. */
|
||||||
|
struct gmonparam
|
||||||
|
{
|
||||||
|
enum profiling_state state;
|
||||||
|
unsigned short * kcount;
|
||||||
|
unsigned long kcountsize;
|
||||||
|
unsigned long * froms;
|
||||||
|
unsigned long fromssize;
|
||||||
|
struct tostruct * tos;
|
||||||
|
unsigned long tossize;
|
||||||
|
long tolimit;
|
||||||
|
unsigned long lowpc;
|
||||||
|
unsigned long highpc;
|
||||||
|
unsigned long textsize;
|
||||||
|
unsigned long hashfraction;
|
||||||
|
long log_hashfraction;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Raw header as it appears in the gmon.out file (without padding).
|
||||||
|
This header always comes first and is then followed by a series
|
||||||
|
records defined below. */
|
||||||
|
struct gmon_hdr
|
||||||
|
{
|
||||||
|
char cookie[4];
|
||||||
|
char version[4];
|
||||||
|
char spare[3 * 4];
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Types of records in this file. */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
GMON_TAG_TIME_HIST = 0,
|
||||||
|
GMON_TAG_CG_ARC = 1,
|
||||||
|
} GMON_Record_Tag;
|
||||||
|
|
||||||
|
struct gmon_cg_arc_record
|
||||||
|
{
|
||||||
|
char tag; /* Set to GMON_TAG_CG_ARC. */
|
||||||
|
char from_pc[sizeof (char *)]; /* Address within caller's body. */
|
||||||
|
char self_pc[sizeof (char *)]; /* Address within callee's body. */
|
||||||
|
char count[4]; /* Number of arc traversals. */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Forward declarations. */
|
||||||
|
void _mcount_internal (unsigned long);
|
||||||
|
void _monstartup (unsigned long, unsigned long);
|
||||||
|
void _mcleanup (void);
|
||||||
|
|
||||||
|
static struct gmonparam _gmonparam;
|
||||||
|
|
||||||
|
void
|
||||||
|
_mcount_internal (unsigned long frompc)
|
||||||
|
{
|
||||||
|
unsigned long selfpc = frompc;
|
||||||
|
unsigned long * frompcindex;
|
||||||
|
struct tostruct * top;
|
||||||
|
struct tostruct * prevtop;
|
||||||
|
struct gmonparam * p;
|
||||||
|
unsigned long toindex;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
p = & _gmonparam;
|
||||||
|
|
||||||
|
/* Check that we are profiling and that we aren't recursively invoked.
|
||||||
|
NB/ This version is not thread-safe. */
|
||||||
|
if (p->state != GMON_PROF_ON)
|
||||||
|
return;
|
||||||
|
p->state = GMON_PROF_BUSY;
|
||||||
|
|
||||||
|
/* Check that frompcindex is a reasonable pc value.
|
||||||
|
For example: signal catchers get called from the stack,
|
||||||
|
not from text space. Too bad. */
|
||||||
|
frompc -= p->lowpc;
|
||||||
|
if (frompc > p->textsize)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
i = frompc >> p->log_hashfraction;
|
||||||
|
|
||||||
|
frompcindex = p->froms + i;
|
||||||
|
toindex = * frompcindex;
|
||||||
|
|
||||||
|
if (toindex == 0)
|
||||||
|
{
|
||||||
|
/* First time traversing this arc. */
|
||||||
|
toindex = ++ p->tos[0].link;
|
||||||
|
if (toindex >= p->tolimit)
|
||||||
|
/* Halt further profiling. */
|
||||||
|
goto overflow;
|
||||||
|
|
||||||
|
* frompcindex = toindex;
|
||||||
|
top = p->tos + toindex;
|
||||||
|
top->selfpc = selfpc;
|
||||||
|
top->count = 1;
|
||||||
|
top->link = 0;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
top = p->tos + toindex;
|
||||||
|
|
||||||
|
if (top->selfpc == selfpc)
|
||||||
|
{
|
||||||
|
/* Arc at front of chain: usual case. */
|
||||||
|
top->count ++;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Have to go looking down chain for it.
|
||||||
|
Top points to what we are looking at,
|
||||||
|
prevtop points to previous top.
|
||||||
|
We know it is not at the head of the chain. */
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (top->link == 0)
|
||||||
|
{
|
||||||
|
/* Top is end of the chain and none of the chain
|
||||||
|
had top->selfpc == selfpc. So we allocate a
|
||||||
|
new tostruct and link it to the head of the
|
||||||
|
chain. */
|
||||||
|
toindex = ++ p->tos[0].link;
|
||||||
|
if (toindex >= p->tolimit)
|
||||||
|
goto overflow;
|
||||||
|
|
||||||
|
top = p->tos + toindex;
|
||||||
|
top->selfpc = selfpc;
|
||||||
|
top->count = 1;
|
||||||
|
top->link = * frompcindex;
|
||||||
|
* frompcindex = toindex;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Otherwise, check the next arc on the chain. */
|
||||||
|
prevtop = top;
|
||||||
|
top = p->tos + top->link;
|
||||||
|
|
||||||
|
if (top->selfpc == selfpc)
|
||||||
|
{
|
||||||
|
/* There it is. Increment its count
|
||||||
|
move it to the head of the chain. */
|
||||||
|
top->count ++;
|
||||||
|
toindex = prevtop->link;
|
||||||
|
prevtop->link = top->link;
|
||||||
|
top->link = * frompcindex;
|
||||||
|
* frompcindex = toindex;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
p->state = GMON_PROF_ON;
|
||||||
|
return;
|
||||||
|
|
||||||
|
overflow:
|
||||||
|
p->state = GMON_PROF_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_monstartup (unsigned long lowpc, unsigned long highpc)
|
||||||
|
{
|
||||||
|
char * cp;
|
||||||
|
struct gmonparam * p = & _gmonparam;
|
||||||
|
|
||||||
|
/* If the calloc() function has been instrumented we must make sure
|
||||||
|
that it is not profiled until we are ready. */
|
||||||
|
p->state = GMON_PROF_BUSY;
|
||||||
|
|
||||||
|
/* Round lowpc and highpc to multiples of the density we're using
|
||||||
|
so the rest of the scaling (here and in gprof) stays in ints. */
|
||||||
|
p->lowpc = ROUNDDOWN (lowpc, HISTFRACTION * sizeof (* p->kcount));
|
||||||
|
p->highpc = ROUNDUP (highpc, HISTFRACTION * sizeof (* p->kcount));
|
||||||
|
p->textsize = p->highpc - p->lowpc;
|
||||||
|
p->kcountsize = ROUNDUP (p->textsize / HISTFRACTION, sizeof (*p->froms));
|
||||||
|
p->hashfraction = HASHFRACTION;
|
||||||
|
p->log_hashfraction = -1;
|
||||||
|
p->log_hashfraction = ffs (p->hashfraction * sizeof (*p->froms)) - 1;
|
||||||
|
p->fromssize = p->textsize / HASHFRACTION;
|
||||||
|
p->tolimit = p->textsize * ARCDENSITY / 100;
|
||||||
|
|
||||||
|
if (p->tolimit < MINARCS)
|
||||||
|
p->tolimit = MINARCS;
|
||||||
|
else if (p->tolimit > MAXARCS)
|
||||||
|
p->tolimit = MAXARCS;
|
||||||
|
|
||||||
|
p->tossize = p->tolimit * sizeof (struct tostruct);
|
||||||
|
|
||||||
|
cp = calloc (p->kcountsize + p->fromssize + p->tossize, 1);
|
||||||
|
if (cp == NULL)
|
||||||
|
{
|
||||||
|
write (2, "monstartup: out of memory\n", 26);
|
||||||
|
p->tos = NULL;
|
||||||
|
p->state = GMON_PROF_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
p->tos = (struct tostruct *) cp;
|
||||||
|
cp += p->tossize;
|
||||||
|
p->kcount = (unsigned short *) cp;
|
||||||
|
cp += p->kcountsize;
|
||||||
|
p->froms = (unsigned long *) cp;
|
||||||
|
|
||||||
|
p->tos[0].link = 0;
|
||||||
|
p->state = GMON_PROF_ON;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
write_call_graph (int fd)
|
||||||
|
{
|
||||||
|
#define NARCS_PER_WRITE 32
|
||||||
|
|
||||||
|
struct gmon_cg_arc_record raw_arc[NARCS_PER_WRITE]
|
||||||
|
__attribute__ ((aligned (__alignof__ (char *))));
|
||||||
|
unsigned long from_index;
|
||||||
|
unsigned long to_index;
|
||||||
|
unsigned long from_len;
|
||||||
|
unsigned long frompc;
|
||||||
|
int nfilled;
|
||||||
|
|
||||||
|
for (nfilled = 0; nfilled < NARCS_PER_WRITE; ++ nfilled)
|
||||||
|
raw_arc[nfilled].tag = GMON_TAG_CG_ARC;
|
||||||
|
|
||||||
|
nfilled = 0;
|
||||||
|
from_len = _gmonparam.fromssize / sizeof (*_gmonparam.froms);
|
||||||
|
|
||||||
|
for (from_index = 0; from_index < from_len; ++from_index)
|
||||||
|
{
|
||||||
|
if (_gmonparam.froms[from_index] == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
frompc = _gmonparam.lowpc;
|
||||||
|
frompc += (from_index * _gmonparam.hashfraction
|
||||||
|
* sizeof (*_gmonparam.froms));
|
||||||
|
|
||||||
|
for (to_index = _gmonparam.froms[from_index];
|
||||||
|
to_index != 0;
|
||||||
|
to_index = _gmonparam.tos[to_index].link)
|
||||||
|
{
|
||||||
|
struct gmon_cg_arc_record * arc = raw_arc + nfilled;
|
||||||
|
|
||||||
|
memcpy (arc->from_pc, & frompc, sizeof (arc->from_pc));
|
||||||
|
memcpy (arc->self_pc, & _gmonparam.tos[to_index].selfpc, sizeof (arc->self_pc));
|
||||||
|
memcpy (arc->count, & _gmonparam.tos[to_index].count, sizeof (arc->count));
|
||||||
|
|
||||||
|
if (++ nfilled == NARCS_PER_WRITE)
|
||||||
|
{
|
||||||
|
write (fd, raw_arc, sizeof raw_arc);
|
||||||
|
nfilled = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nfilled > 0)
|
||||||
|
write (fd, raw_arc, nfilled * sizeof (raw_arc[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
write_gmon (void)
|
||||||
|
{
|
||||||
|
struct gmon_hdr ghdr __attribute__ ((aligned (__alignof__ (int))));
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
fd = open ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY, 0666);
|
||||||
|
if (fd < 0)
|
||||||
|
{
|
||||||
|
write (2, "_mcleanup: could not create gmon.out\n", 37);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write gmon.out header: */
|
||||||
|
memset (& ghdr, '\0', sizeof (ghdr));
|
||||||
|
memcpy (ghdr.cookie, GMON_MAGIC, sizeof (ghdr.cookie));
|
||||||
|
* (unsigned long *) ghdr.version = GMON_VERSION;
|
||||||
|
write (fd, & ghdr, sizeof (ghdr));
|
||||||
|
|
||||||
|
/* We do not have histogram or basic block information,
|
||||||
|
so we do not generate these parts of the gmon.out file. */
|
||||||
|
|
||||||
|
/* Write call-graph. */
|
||||||
|
write_call_graph (fd);
|
||||||
|
|
||||||
|
close (fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_mcleanup (void)
|
||||||
|
{
|
||||||
|
if (_gmonparam.state != GMON_PROF_ERROR)
|
||||||
|
{
|
||||||
|
_gmonparam.state = GMON_PROF_OFF;
|
||||||
|
write_gmon ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Free the memory. */
|
||||||
|
if (_gmonparam.tos != NULL)
|
||||||
|
{
|
||||||
|
free (_gmonparam.tos);
|
||||||
|
_gmonparam.tos = NULL;
|
||||||
|
}
|
||||||
|
}
|
35
open.S
Normal file
35
open.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(open)
|
35
read.S
Normal file
35
read.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(read)
|
224
rl78-sim.ld
Normal file
224
rl78-sim.ld
Normal file
|
@ -0,0 +1,224 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2005,2008,2009,2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Default linker script, for normal executables */
|
||||||
|
OUTPUT_ARCH(rl78)
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
/* Do we need any of these for elf?
|
||||||
|
__DYNAMIC = 0; */
|
||||||
|
|
||||||
|
/* This is for the simulator - 512k flash, 32k ram, no data flash */
|
||||||
|
MEMORY {
|
||||||
|
VEC (r) : ORIGIN = 0x00000, LENGTH = 0x00002
|
||||||
|
IVEC (r) : ORIGIN = 0x00004, LENGTH = 0x0007c
|
||||||
|
OPT (r) : ORIGIN = 0x000c0, LENGTH = 0x00004
|
||||||
|
ROM (r) : ORIGIN = 0x000d8, LENGTH = 0x7ff28
|
||||||
|
RAM (w) : ORIGIN = 0xf8000, LENGTH = 0x07ee0
|
||||||
|
STACK (w) : ORIGIN = 0xffee0, LENGTH = 0x00002
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.vec :
|
||||||
|
{
|
||||||
|
*(.vec)
|
||||||
|
} > VEC
|
||||||
|
.ivec :
|
||||||
|
{
|
||||||
|
*(.ivec)
|
||||||
|
} > IVEC
|
||||||
|
.opt :
|
||||||
|
{
|
||||||
|
*(.opt)
|
||||||
|
} > OPT
|
||||||
|
|
||||||
|
/* CubeSuite always starts at 0xd8. */
|
||||||
|
.csstart : {
|
||||||
|
*(.csstart)
|
||||||
|
} > ROM
|
||||||
|
|
||||||
|
/* For code that must be in the first 64k, or could fill unused
|
||||||
|
space below .rodata. */
|
||||||
|
.lowtext : {
|
||||||
|
*(.plt)
|
||||||
|
*(.lowtext)
|
||||||
|
} > ROM
|
||||||
|
|
||||||
|
.data : {
|
||||||
|
. = ALIGN(2);
|
||||||
|
PROVIDE (__datastart = .);
|
||||||
|
|
||||||
|
KEEP (*(.jcr))
|
||||||
|
*(.data.rel.ro.local) *(.data.rel.ro*)
|
||||||
|
*(.dynamic)
|
||||||
|
|
||||||
|
*(.data D .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 B B_2 B_1 .bss.* .gnu.linkonce.b.*)
|
||||||
|
. = ALIGN(2);
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(2);
|
||||||
|
PROVIDE (__bssend = .);
|
||||||
|
_end = .;
|
||||||
|
PROVIDE (end = .);
|
||||||
|
} > RAM
|
||||||
|
PROVIDE (__bsssize = SIZEOF(.bss));
|
||||||
|
|
||||||
|
.stack (ORIGIN (STACK)) :
|
||||||
|
{
|
||||||
|
PROVIDE (__stack = .);
|
||||||
|
*(.stack)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata (MAX(__romdatastart + __romdatacopysize, 0x1000)) : {
|
||||||
|
. = ALIGN(2);
|
||||||
|
*(.plt)
|
||||||
|
*(.rodata C C_2 C_1 .rodata.* .gnu.linkonce.r.*)
|
||||||
|
*(.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 :
|
||||||
|
{
|
||||||
|
PROVIDE (_start = .);
|
||||||
|
*(.text P .stub .text.* .gnu.linkonce.t.*)
|
||||||
|
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. */
|
||||||
|
|
||||||
|
/* 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) }
|
||||||
|
}
|
84
rl78-sys.h
Normal file
84
rl78-sys.h
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "syscall.h"
|
||||||
|
|
||||||
|
r8 = 0xffef0
|
||||||
|
r9 = 0xffef1
|
||||||
|
r10 = 0xffef2
|
||||||
|
r11 = 0xffef3
|
||||||
|
r12 = 0xffef4
|
||||||
|
r13 = 0xffef5
|
||||||
|
r14 = 0xffef6
|
||||||
|
r15 = 0xffef7
|
||||||
|
r16 = 0xffee8
|
||||||
|
r17 = 0xffee9
|
||||||
|
r18 = 0xffeea
|
||||||
|
r19 = 0xffeeb
|
||||||
|
r20 = 0xffeec
|
||||||
|
r21 = 0xffeed
|
||||||
|
r22 = 0xffeee
|
||||||
|
r23 = 0xffeef
|
||||||
|
|
||||||
|
#define SYS__exit SYS_exit
|
||||||
|
|
||||||
|
.macro syscall_body number
|
||||||
|
/* The RL78 doesn't really have an "interrupt" upcode, just
|
||||||
|
BRK, which we emulate exactly. We use the STOP opcode,
|
||||||
|
which is a breakpoint in the simulator. */
|
||||||
|
mov A, #\number
|
||||||
|
stop
|
||||||
|
ret
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.macro do_syscall name number
|
||||||
|
__\name:
|
||||||
|
.global __\name
|
||||||
|
_\name:
|
||||||
|
.weak _\name
|
||||||
|
syscall_body \number
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.macro syscall_returns name number
|
||||||
|
__\name:
|
||||||
|
.global __\name
|
||||||
|
_\name:
|
||||||
|
.weak _\name
|
||||||
|
mov r8, #\number
|
||||||
|
ret
|
||||||
|
.endm
|
||||||
|
|
||||||
|
#define S(name) do_syscall name, SYS_##name
|
||||||
|
#define SYSCALL(number) syscall_body number
|
||||||
|
#define ERR(name) syscall_returns name, -1
|
||||||
|
#define OK(name) syscall_returns name, 0
|
||||||
|
#define RET(name,val) syscall_returns name, val
|
224
rl78.ld
Normal file
224
rl78.ld
Normal file
|
@ -0,0 +1,224 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2005,2008,2009,2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Default linker script, for normal executables */
|
||||||
|
OUTPUT_ARCH(rl78)
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
/* Do we need any of these for elf?
|
||||||
|
__DYNAMIC = 0; */
|
||||||
|
|
||||||
|
/* This is for an RL78/G13, 64k flash, 4k ram */
|
||||||
|
MEMORY {
|
||||||
|
VEC (r) : ORIGIN = 0x00000, LENGTH = 0x00002
|
||||||
|
IVEC (r) : ORIGIN = 0x00004, LENGTH = 0x0007c
|
||||||
|
OPT (r) : ORIGIN = 0x000c0, LENGTH = 0x00004
|
||||||
|
ROM (r) : ORIGIN = 0x000d8, LENGTH = 0x0ff28
|
||||||
|
RAM (w) : ORIGIN = 0xfef00, LENGTH = 0x00fe0
|
||||||
|
STACK (w) : ORIGIN = 0xffee0, LENGTH = 0x00002
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.vec :
|
||||||
|
{
|
||||||
|
*(.vec)
|
||||||
|
} > VEC
|
||||||
|
.ivec :
|
||||||
|
{
|
||||||
|
*(.ivec)
|
||||||
|
} > IVEC
|
||||||
|
.opt :
|
||||||
|
{
|
||||||
|
*(.opt)
|
||||||
|
} > OPT
|
||||||
|
|
||||||
|
/* CubeSuite always starts at 0xd8. */
|
||||||
|
.csstart : {
|
||||||
|
*(.csstart)
|
||||||
|
} > ROM
|
||||||
|
|
||||||
|
/* For code that must be in the first 64k, or could fill unused
|
||||||
|
space below .rodata. */
|
||||||
|
.lowtext : {
|
||||||
|
*(.plt)
|
||||||
|
*(.lowtext)
|
||||||
|
} > ROM
|
||||||
|
|
||||||
|
.data : {
|
||||||
|
. = ALIGN(2);
|
||||||
|
PROVIDE (__datastart = .);
|
||||||
|
|
||||||
|
KEEP (*(.jcr))
|
||||||
|
*(.data.rel.ro.local) *(.data.rel.ro*)
|
||||||
|
*(.dynamic)
|
||||||
|
|
||||||
|
*(.data D .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 B B_2 B_1 .bss.* .gnu.linkonce.b.*)
|
||||||
|
. = ALIGN(2);
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(2);
|
||||||
|
PROVIDE (__bssend = .);
|
||||||
|
_end = .;
|
||||||
|
PROVIDE (end = .);
|
||||||
|
} > RAM
|
||||||
|
PROVIDE (__bsssize = SIZEOF(.bss));
|
||||||
|
|
||||||
|
.stack (ORIGIN (STACK)) :
|
||||||
|
{
|
||||||
|
PROVIDE (__stack = .);
|
||||||
|
*(.stack)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rodata (MAX(__romdatastart + __romdatacopysize, 0x2000)) : {
|
||||||
|
. = ALIGN(2);
|
||||||
|
*(.plt)
|
||||||
|
*(.rodata C C_2 C_1 .rodata.* .gnu.linkonce.r.*)
|
||||||
|
*(.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 :
|
||||||
|
{
|
||||||
|
PROVIDE (_start = .);
|
||||||
|
*(.text P .stub .text.* .gnu.linkonce.t.*)
|
||||||
|
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. */
|
||||||
|
|
||||||
|
/* 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) }
|
||||||
|
}
|
57
sbrk.c
Normal file
57
sbrk.c
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2005, 2009 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
char *
|
||||||
|
_sbrk (int adj)
|
||||||
|
{
|
||||||
|
extern char end;
|
||||||
|
static char * heap = & end;
|
||||||
|
char * rv = heap;
|
||||||
|
char * heaptop = (char *) &adj;
|
||||||
|
|
||||||
|
heap += adj;
|
||||||
|
|
||||||
|
/* The allocated chunk spans our stack? */
|
||||||
|
if (rv < heaptop && heap > heaptop
|
||||||
|
/* The allocated chunk spans our address space? */
|
||||||
|
|| heap < rv)
|
||||||
|
{
|
||||||
|
errno = ENOMEM;
|
||||||
|
return (char *) -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
char * sbrk (int) __attribute__((weak, alias ("_sbrk")));
|
35
stat.S
Normal file
35
stat.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(stat)
|
35
time.S
Normal file
35
time.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(time)
|
35
times.S
Normal file
35
times.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(times)
|
35
unlink.S
Normal file
35
unlink.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(unlink)
|
35
utime.S
Normal file
35
utime.S
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2011 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rl78-sys.h"
|
||||||
|
|
||||||
|
ERR(utime)
|
107
write.c
Normal file
107
write.c
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2010 Red Hat Incorporated.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
The name of Red Hat Incorporated may not be used to endorse
|
||||||
|
or promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* These definitions are for the RL78/G13, which the simulator
|
||||||
|
simulates. */
|
||||||
|
|
||||||
|
typedef unsigned char UQI __attribute__((mode(QI)));
|
||||||
|
typedef unsigned int UHI __attribute__((mode(HI)));
|
||||||
|
|
||||||
|
#define s8(x) (*(volatile UQI *)(x))
|
||||||
|
#define s16(x) (*(volatile UHI *)(x))
|
||||||
|
|
||||||
|
#define P(x) s8(0xfff00+(x))
|
||||||
|
#define PM(x) s8(0xfff20+(x))
|
||||||
|
|
||||||
|
#define PER0 s8(0xf00f0)
|
||||||
|
|
||||||
|
#define SSR00 s16(0xf0100)
|
||||||
|
#define SMR00 s16(0xf0110)
|
||||||
|
#define SCR00 s16(0xf0118)
|
||||||
|
#define SS0 s16(0xf0122)
|
||||||
|
#define SPS0 s16(0xf0126)
|
||||||
|
#define SO0 s16(0xf0128)
|
||||||
|
#define SOE0 s16(0xf012a)
|
||||||
|
#define SOL0 s16(0xf0134)
|
||||||
|
|
||||||
|
#define SDR00 s16(0xfff10)
|
||||||
|
|
||||||
|
static int initted = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_uart0 ()
|
||||||
|
{
|
||||||
|
initted = 1;
|
||||||
|
|
||||||
|
PER0 = 0xff;
|
||||||
|
SPS0 = 0x0011; /* 16 MHz */
|
||||||
|
SMR00 = 0x0022; /* uart mode */
|
||||||
|
SCR00 = 0x8097; /* 8-N-1 */
|
||||||
|
SDR00 = 0x8a00; /* baud in MSB - 115200 */
|
||||||
|
SOL0 = 0x0000; /* not inverted */
|
||||||
|
SO0 = 0x000f; /* initial value */
|
||||||
|
SOE0 = 0x0001; /* enable TxD0 */
|
||||||
|
P(1) |= 0b00000100;
|
||||||
|
PM(1) &= 0b11111011;
|
||||||
|
SS0 = 0x0001;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tputc (char c)
|
||||||
|
{
|
||||||
|
/* Wait for transmit buffer to be empty. */
|
||||||
|
while (SSR00 & 0x0020)
|
||||||
|
asm("");
|
||||||
|
/* Transmit that byte. */
|
||||||
|
SDR00 = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_write(int fd, char *ptr, int len)
|
||||||
|
{
|
||||||
|
int rv = len;
|
||||||
|
|
||||||
|
if (!initted)
|
||||||
|
init_uart0 ();
|
||||||
|
|
||||||
|
while (len != 0)
|
||||||
|
{
|
||||||
|
if (*ptr == '\n')
|
||||||
|
tputc ('\r');
|
||||||
|
tputc (*ptr);
|
||||||
|
ptr ++;
|
||||||
|
len --;
|
||||||
|
}
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
char * write (int) __attribute__((weak, alias ("_write")));
|
Loading…
Reference in a new issue