]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: nltvals: pull target syscalls out into a dedicated source file
authorMike Frysinger <vapier@gentoo.org>
Mon, 1 Nov 2021 05:31:44 +0000 (01:31 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sun, 28 Nov 2021 18:23:57 +0000 (13:23 -0500)
Like we just did for pulling out the errno map, pull out the syscall
maps into a dedicated common file.  Most newlib ports are using the
same syscall map, but not all, which means we have to do a bit more
work to migrate.

This commit adds the maps and switches the ports using the common
default syscall table over to it.  Ports using unique syscall tables
are still using the old targ-map.c logic.

Switching common ports over is easy by checking NL_TARGET, but the
ppc code needs a bit more cleanup here hence its larger diff.

sim/Makefile.am
sim/Makefile.in
sim/README-HACKING
sim/common/Make-common.in
sim/common/gennltvals.py
sim/common/local.mk
sim/common/target-newlib-syscall.c [new file with mode: 0644]
sim/common/target-newlib-syscall.h [new file with mode: 0644]
sim/ppc/Makefile.in

index 909bec00553fd440a6b8f7e1106415fc7718dfb3..c3e7e767c47befc6a8aeb1d9d05f2bfe7bef3c73 100644 (file)
@@ -49,12 +49,9 @@ LINK_FOR_BUILD = $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@
 # into any subdirs.
 SIM_ALL_RECURSIVE_DEPS =
 
-# Generate nltvals.def for newlib/libgloss using devo and build tree.
+# Generate target constants for newlib/libgloss from its source tree.
 # This file is shipped with distributions so we build in the source dir.
 # Use `make nltvals' to rebuild.
-# Note: If gdb releases begin to contain target header files (not a good idea,
-# but if they did ...), nltvals.def coud be generated at build time.
-# An alternative is to slurp in the tables at runtime.
 .PHONY: nltvals
 nltvals:
        $(srccom)/gennltvals.py --cpp "$(CPP)"
index 1dae0a482fb97f229ac775a1235a185641314a7b..250fb491627ebaf16451d4fa3f1387c78e0cf801 100644 (file)
@@ -647,6 +647,7 @@ am_common_libcommon_a_OBJECTS =  \
        common/common_libcommon_a-target-newlib-errno.$(OBJEXT) \
        common/common_libcommon_a-target-newlib-open.$(OBJEXT) \
        common/common_libcommon_a-target-newlib-signal.$(OBJEXT) \
+       common/common_libcommon_a-target-newlib-syscall.$(OBJEXT) \
        common/common_libcommon_a-version.$(OBJEXT)
 common_libcommon_a_OBJECTS = $(am_common_libcommon_a_OBJECTS)
 igen_libigen_a_AR = $(AR) $(ARFLAGS)
@@ -1286,6 +1287,7 @@ common_libcommon_a_SOURCES = \
        common/target-newlib-errno.c \
        common/target-newlib-open.c \
        common/target-newlib-signal.c \
+       common/target-newlib-syscall.c \
        common/version.c
 
 
@@ -1622,6 +1624,8 @@ common/common_libcommon_a-target-newlib-open.$(OBJEXT):  \
        common/$(am__dirstamp) common/$(DEPDIR)/$(am__dirstamp)
 common/common_libcommon_a-target-newlib-signal.$(OBJEXT):  \
        common/$(am__dirstamp) common/$(DEPDIR)/$(am__dirstamp)
+common/common_libcommon_a-target-newlib-syscall.$(OBJEXT):  \
+       common/$(am__dirstamp) common/$(DEPDIR)/$(am__dirstamp)
 common/common_libcommon_a-version.$(OBJEXT): common/$(am__dirstamp) \
        common/$(DEPDIR)/$(am__dirstamp)
 
@@ -1812,6 +1816,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-errno.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-open.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-signal.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common_libcommon_a-version.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@cr16/$(DEPDIR)/gencode.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@d10v/$(DEPDIR)/gencode.Po@am__quote@
@@ -1951,6 +1956,20 @@ common/common_libcommon_a-target-newlib-signal.obj: common/target-newlib-signal.
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common/common_libcommon_a-target-newlib-signal.obj `if test -f 'common/target-newlib-signal.c'; then $(CYGPATH_W) 'common/target-newlib-signal.c'; else $(CYGPATH_W) '$(srcdir)/common/target-newlib-signal.c'; fi`
 
+common/common_libcommon_a-target-newlib-syscall.o: common/target-newlib-syscall.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common/common_libcommon_a-target-newlib-syscall.o -MD -MP -MF common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Tpo -c -o common/common_libcommon_a-target-newlib-syscall.o `test -f 'common/target-newlib-syscall.c' || echo '$(srcdir)/'`common/target-newlib-syscall.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Tpo common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='common/target-newlib-syscall.c' object='common/common_libcommon_a-target-newlib-syscall.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common/common_libcommon_a-target-newlib-syscall.o `test -f 'common/target-newlib-syscall.c' || echo '$(srcdir)/'`common/target-newlib-syscall.c
+
+common/common_libcommon_a-target-newlib-syscall.obj: common/target-newlib-syscall.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common/common_libcommon_a-target-newlib-syscall.obj -MD -MP -MF common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Tpo -c -o common/common_libcommon_a-target-newlib-syscall.obj `if test -f 'common/target-newlib-syscall.c'; then $(CYGPATH_W) 'common/target-newlib-syscall.c'; else $(CYGPATH_W) '$(srcdir)/common/target-newlib-syscall.c'; fi`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Tpo common/$(DEPDIR)/common_libcommon_a-target-newlib-syscall.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='common/target-newlib-syscall.c' object='common/common_libcommon_a-target-newlib-syscall.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o common/common_libcommon_a-target-newlib-syscall.obj `if test -f 'common/target-newlib-syscall.c'; then $(CYGPATH_W) 'common/target-newlib-syscall.c'; else $(CYGPATH_W) '$(srcdir)/common/target-newlib-syscall.c'; fi`
+
 common/common_libcommon_a-version.o: common/version.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(common_libcommon_a_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT common/common_libcommon_a-version.o -MD -MP -MF common/$(DEPDIR)/common_libcommon_a-version.Tpo -c -o common/common_libcommon_a-version.o `test -f 'common/version.c' || echo '$(srcdir)/'`common/version.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) common/$(DEPDIR)/common_libcommon_a-version.Tpo common/$(DEPDIR)/common_libcommon_a-version.Po
@@ -2626,12 +2645,9 @@ uninstall-am: uninstall-armdocDATA uninstall-erc32docDATA \
 .PRECIOUS: Makefile
 
 
-# Generate nltvals.def for newlib/libgloss using devo and build tree.
+# Generate target constants for newlib/libgloss from its source tree.
 # This file is shipped with distributions so we build in the source dir.
 # Use `make nltvals' to rebuild.
-# Note: If gdb releases begin to contain target header files (not a good idea,
-# but if they did ...), nltvals.def coud be generated at build time.
-# An alternative is to slurp in the tables at runtime.
 .PHONY: nltvals
 nltvals:
        $(srccom)/gennltvals.py --cpp "$(CPP)"
index 9bb705e655eb6cf37d756304771cc04ecc8dc5ce..38915bf3bb9446f09f183685babe0dc64ea9e817 100644 (file)
@@ -20,10 +20,7 @@ The common directory contains:
 - common Makefile fragment and configury (e.g. Make-common.in, aclocal.m4).
 
 In addition "common" contains portions of the system call support
-(e.g. callback.c, nltvals.def).
-
-Even though no files are built in this directory, it is still configured
-so support for regenerating nltvals.def is present.
+(e.g. callback.c, target-newlib-*.c).
 \f
 Common Makefile Support
 =======================
@@ -161,8 +158,8 @@ internal state pretty printed from gdb.
 
 FIXME: This can obviously be made more elaborate.  As needed it will be.
 \f
-Rebuilding nltvals.def
-======================
+Rebuilding target-newlib-* files
+================================
 
 Checkout a copy of the SIM and LIBGLOSS modules (Unless you've already
 got one to hand):
@@ -191,17 +188,9 @@ all set!  If the target has a custom syscall table, you need to declare it:
                Add your new processor target (you'll need to grub
                around to find where your syscall.h lives).
 
-       devo/sim/<processor>/Makefile.in
-
-               Add the definition:
-
-                       ``NL_TARGET = -DNL_TARGET_d10v''
-
-               just before the line COMMON_POST_CONFIG_FRAG.
-
        devo/sim/<processor>/*.[ch]
 
-               Include targ-vals.h instead of syscall.h.
+               Include target-newlib-syscall.h instead of syscall.h.
 \f
 Tracing
 =======
@@ -335,8 +324,8 @@ only store the error code when the result is an error.
 
 Keep in mind that the CB_SYS_xxx defines are normalized values with no real
 meaning with respect to the target.  They provide a unique map on the host so
-that it can parse things sanely.  For libgloss, the common/nltvals.def file
-creates the target's system call numbers to the CB_SYS_xxx values.
+that it can parse things sanely.  For libgloss, the common/target-newlib-syscall
+file contains the target's system call numbers to the CB_SYS_xxx values.
 
 To simulate other userspace targets, you really only need to update the maps
 pointers that are part of the callback interface.  So create CB_TARGET_DEFS_MAP
index 9be682e61173f6c149162a20c5257b840a97d614..f834edbec8a8c76153a0c798d061d4fabaf14e72 100644 (file)
@@ -238,7 +238,14 @@ COMMON_OBJS_NAMES = \
        version.o
 COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/common_libcommon_a-%)
 
-LIB_OBJS = modules.o syscall.o targ-map.o $(COMMON_OBJS) $(SIM_OBJS)
+LIB_OBJS = modules.o syscall.o $(COMMON_OBJS) $(SIM_OBJS)
+
+# TODO: Migrate everyone to target-newlib-syscall.o.
+ifeq ($(NL_TARGET),)
+COMMON_OBJS_NAMES += target-newlib-syscall.o
+else
+LIB_OBJS += targ-map.o
+endif
 
 COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS)
 LINK_FOR_BUILD = $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(LDFLAGS_FOR_BUILD) -o $@
@@ -275,9 +282,11 @@ stamp-tvals: gentmap
        $(ECHO_STAMP) targ-vals.h
        $(SILENCE) ./gentmap -h >tmp-tvals.h
        $(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-tvals.h targ-vals.h
+ifneq ($(NL_TARGET),)
        $(ECHO_STAMP) targ-tmap.c
        $(SILENCE) ./gentmap -c >tmp-tmap.c
        $(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-tmap.c targ-map.c
+endif
        $(SILENCE) touch $@
 
 #
@@ -405,8 +414,10 @@ generated_files = \
        $(SIM_EXTRA_DEPS) \
        hw-config.h \
        modules.c \
-       targ-map.c \
        targ-vals.h
+ifneq ($(NL_TARGET),)
+generated_files += targ-map.c
+endif
 
 # Ensure that generated files are created early.  Use order-only
 # dependencies if available.  They require GNU make 3.80 or newer,
index 66ee9c5675365e25874655e652286a1330929c7f..1e98691cb3d512ef7a88bbb73088b5bd55220452 100755 (executable)
@@ -177,15 +177,80 @@ def gen_common(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
              ('fcntl.h', 'sys/fcntl.h', 'sys/_default_fcntl.h'), r'O_[A-Z0-9]*')
 
 
-def gen_targets(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
-    """Generate the target-specific lists."""
+def gen_target_syscall(output_dir: Path, newlib: Path, cpp: str):
+    """Generate the target-specific syscall lists."""
+    target_map_c = output_dir / 'target-newlib-syscall.c'
+    old_lines_c = target_map_c.read_text().splitlines()
+    start_i = end_i = None
+    for i, line in enumerate(old_lines_c):
+        if START_MARKER in line:
+            start_i = i
+        if END_MARKER in line:
+            end_i = i
+    assert start_i and end_i, f'{target_map_c}: Unable to find markers'
+    new_lines_c = old_lines_c[0:start_i + 1]
+    new_lines_c_end = old_lines_c[end_i:]
+
+    target_map_h = output_dir / 'target-newlib-syscall.h'
+    old_lines_h = target_map_h.read_text().splitlines()
+    start_i = end_i = None
+    for i, line in enumerate(old_lines_h):
+        if START_MARKER in line:
+            start_i = i
+        if END_MARKER in line:
+            end_i = i
+    assert start_i and end_i, f'{target_map_h}: Unable to find markers'
+    new_lines_h = old_lines_h[0:start_i + 1]
+    new_lines_h_end = old_lines_h[end_i:]
+
+    headers = ('syscall.h',)
+    pattern = r'SYS_[_a-zA-Z0-9]*'
+
+    # Output the target-specific syscalls.
     for target, subdir in sorted(TARGET_DIRS.items()):
-        gentvals(output_dir, output, cpp, 'sys', newlib / subdir,
-                 ('syscall.h',), r'SYS_[_a-zA-Z0-9]*', target=target)
+        syms = extract_syms(cpp, newlib / subdir, headers, pattern)
+        new_lines_c.append(f'CB_TARGET_DEFS_MAP cb_{target}_syscall_map[] = {{')
+        new_lines_c.extend(
+            f'#ifdef CB_{sym}\n'
+            '  { '
+            f'"{sym[4:]}", CB_{sym}, TARGET_NEWLIB_{target.upper()}_{sym}'
+            ' },\n'
+            '#endif' for sym in sorted(syms))
+        new_lines_c.append('  {NULL, -1, -1},')
+        new_lines_c.append('};\n')
+
+        new_lines_h.append(
+            f'extern CB_TARGET_DEFS_MAP cb_{target}_syscall_map[];')
+        new_lines_h.extend(
+            f'#define TARGET_NEWLIB_{target.upper()}_{sym} {val}'
+            for sym, val in sorted(syms.items()))
+        new_lines_h.append('')
 
     # Then output the common syscall targets.
-    gentvals(output_dir, output, cpp, 'sys', newlib / 'libgloss',
-             ('syscall.h',), r'SYS_[_a-zA-Z0-9]*')
+    syms = extract_syms(cpp, newlib / 'libgloss', headers, pattern)
+    new_lines_c.append(f'CB_TARGET_DEFS_MAP cb_init_syscall_map[] = {{')
+    new_lines_c.extend(
+        f'#ifdef CB_{sym}\n'
+        f'  {{ "{sym[4:]}", CB_{sym}, TARGET_NEWLIB_{sym} }},\n'
+        f'#endif' for sym in sorted(syms))
+    new_lines_c.append('  {NULL, -1, -1},')
+    new_lines_c.append('};')
+
+    new_lines_h.append('extern CB_TARGET_DEFS_MAP cb_init_syscall_map[];')
+    new_lines_h.extend(
+        f'#define TARGET_NEWLIB_{sym} {val}'
+        for sym, val in sorted(syms.items()))
+
+    new_lines_c.extend(new_lines_c_end)
+    target_map_c.write_text('\n'.join(new_lines_c) + '\n')
+
+    new_lines_h.extend(new_lines_h_end)
+    target_map_h.write_text('\n'.join(new_lines_h) + '\n')
+
+
+def gen_targets(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
+    """Generate the target-specific lists."""
+    gen_target_syscall(output_dir, newlib, cpp)
 
 
 def gen(output_dir: Path, output: TextIO, newlib: Path, cpp: str):
index 2fd78264ba1f2a9e69041669840957e24f23a32a..a83b487f32d8c23fd7c801810694bce6466ae4c4 100644 (file)
@@ -40,6 +40,7 @@ noinst_LIBRARIES += %D%/libcommon.a
        %D%/target-newlib-errno.c \
        %D%/target-newlib-open.c \
        %D%/target-newlib-signal.c \
+       %D%/target-newlib-syscall.c \
        %D%/version.c
 
 %D%/version.c: %D%/version.c-stamp ; @true
diff --git a/sim/common/target-newlib-syscall.c b/sim/common/target-newlib-syscall.c
new file mode 100644 (file)
index 0000000..1617ee2
--- /dev/null
@@ -0,0 +1,634 @@
+/* Target syscall mappings for newlib/libgloss environment.
+   Copyright 1995-2021 Free Software Foundation, Inc.
+   Contributed by Mike Frysinger.
+
+   This file is part of simulators.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* This must come before any other includes.  */
+#include "defs.h"
+
+#include "sim/callback.h"
+
+#include "target-newlib-syscall.h"
+
+/* This file is kept up-to-date via the gennltvals.py script.  Do not edit
+   anything between the START & END comment blocks below.  */
+
+  /* gennltvals: START */
+CB_TARGET_DEFS_MAP cb_cr16_syscall_map[] = {
+#ifdef CB_SYS_ARG
+  { "ARG", CB_SYS_ARG, TARGET_NEWLIB_CR16_SYS_ARG },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_CR16_SYS_chdir },
+#endif
+#ifdef CB_SYS_chmod
+  { "chmod", CB_SYS_chmod, TARGET_NEWLIB_CR16_SYS_chmod },
+#endif
+#ifdef CB_SYS_chown
+  { "chown", CB_SYS_chown, TARGET_NEWLIB_CR16_SYS_chown },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_CR16_SYS_close },
+#endif
+#ifdef CB_SYS_create
+  { "create", CB_SYS_create, TARGET_NEWLIB_CR16_SYS_create },
+#endif
+#ifdef CB_SYS_execv
+  { "execv", CB_SYS_execv, TARGET_NEWLIB_CR16_SYS_execv },
+#endif
+#ifdef CB_SYS_execve
+  { "execve", CB_SYS_execve, TARGET_NEWLIB_CR16_SYS_execve },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_CR16_SYS_exit },
+#endif
+#ifdef CB_SYS_fork
+  { "fork", CB_SYS_fork, TARGET_NEWLIB_CR16_SYS_fork },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_CR16_SYS_fstat },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_CR16_SYS_getpid },
+#endif
+#ifdef CB_SYS_isatty
+  { "isatty", CB_SYS_isatty, TARGET_NEWLIB_CR16_SYS_isatty },
+#endif
+#ifdef CB_SYS_kill
+  { "kill", CB_SYS_kill, TARGET_NEWLIB_CR16_SYS_kill },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_CR16_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_CR16_SYS_lseek },
+#endif
+#ifdef CB_SYS_mknod
+  { "mknod", CB_SYS_mknod, TARGET_NEWLIB_CR16_SYS_mknod },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_CR16_SYS_open },
+#endif
+#ifdef CB_SYS_pipe
+  { "pipe", CB_SYS_pipe, TARGET_NEWLIB_CR16_SYS_pipe },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_CR16_SYS_read },
+#endif
+#ifdef CB_SYS_rename
+  { "rename", CB_SYS_rename, TARGET_NEWLIB_CR16_SYS_rename },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_CR16_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_CR16_SYS_time },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_CR16_SYS_unlink },
+#endif
+#ifdef CB_SYS_utime
+  { "utime", CB_SYS_utime, TARGET_NEWLIB_CR16_SYS_utime },
+#endif
+#ifdef CB_SYS_wait
+  { "wait", CB_SYS_wait, TARGET_NEWLIB_CR16_SYS_wait },
+#endif
+#ifdef CB_SYS_wait4
+  { "wait4", CB_SYS_wait4, TARGET_NEWLIB_CR16_SYS_wait4 },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_CR16_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_d10v_syscall_map[] = {
+#ifdef CB_SYS_ARG
+  { "ARG", CB_SYS_ARG, TARGET_NEWLIB_D10V_SYS_ARG },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_D10V_SYS_chdir },
+#endif
+#ifdef CB_SYS_chmod
+  { "chmod", CB_SYS_chmod, TARGET_NEWLIB_D10V_SYS_chmod },
+#endif
+#ifdef CB_SYS_chown
+  { "chown", CB_SYS_chown, TARGET_NEWLIB_D10V_SYS_chown },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_D10V_SYS_close },
+#endif
+#ifdef CB_SYS_creat
+  { "creat", CB_SYS_creat, TARGET_NEWLIB_D10V_SYS_creat },
+#endif
+#ifdef CB_SYS_execv
+  { "execv", CB_SYS_execv, TARGET_NEWLIB_D10V_SYS_execv },
+#endif
+#ifdef CB_SYS_execve
+  { "execve", CB_SYS_execve, TARGET_NEWLIB_D10V_SYS_execve },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_D10V_SYS_exit },
+#endif
+#ifdef CB_SYS_fork
+  { "fork", CB_SYS_fork, TARGET_NEWLIB_D10V_SYS_fork },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_D10V_SYS_fstat },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_D10V_SYS_getpid },
+#endif
+#ifdef CB_SYS_isatty
+  { "isatty", CB_SYS_isatty, TARGET_NEWLIB_D10V_SYS_isatty },
+#endif
+#ifdef CB_SYS_kill
+  { "kill", CB_SYS_kill, TARGET_NEWLIB_D10V_SYS_kill },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_D10V_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_D10V_SYS_lseek },
+#endif
+#ifdef CB_SYS_mknod
+  { "mknod", CB_SYS_mknod, TARGET_NEWLIB_D10V_SYS_mknod },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_D10V_SYS_open },
+#endif
+#ifdef CB_SYS_pipe
+  { "pipe", CB_SYS_pipe, TARGET_NEWLIB_D10V_SYS_pipe },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_D10V_SYS_read },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_D10V_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_D10V_SYS_time },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_D10V_SYS_unlink },
+#endif
+#ifdef CB_SYS_utime
+  { "utime", CB_SYS_utime, TARGET_NEWLIB_D10V_SYS_utime },
+#endif
+#ifdef CB_SYS_wait
+  { "wait", CB_SYS_wait, TARGET_NEWLIB_D10V_SYS_wait },
+#endif
+#ifdef CB_SYS_wait4
+  { "wait4", CB_SYS_wait4, TARGET_NEWLIB_D10V_SYS_wait4 },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_D10V_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_mcore_syscall_map[] = {
+#ifdef CB_SYS_access
+  { "access", CB_SYS_access, TARGET_NEWLIB_MCORE_SYS_access },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_MCORE_SYS_close },
+#endif
+#ifdef CB_SYS_creat
+  { "creat", CB_SYS_creat, TARGET_NEWLIB_MCORE_SYS_creat },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_MCORE_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_MCORE_SYS_lseek },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_MCORE_SYS_open },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_MCORE_SYS_read },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_MCORE_SYS_time },
+#endif
+#ifdef CB_SYS_times
+  { "times", CB_SYS_times, TARGET_NEWLIB_MCORE_SYS_times },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_MCORE_SYS_unlink },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_MCORE_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_riscv_syscall_map[] = {
+#ifdef CB_SYS_access
+  { "access", CB_SYS_access, TARGET_NEWLIB_RISCV_SYS_access },
+#endif
+#ifdef CB_SYS_brk
+  { "brk", CB_SYS_brk, TARGET_NEWLIB_RISCV_SYS_brk },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_RISCV_SYS_chdir },
+#endif
+#ifdef CB_SYS_clock_gettime64
+  { "clock_gettime64", CB_SYS_clock_gettime64, TARGET_NEWLIB_RISCV_SYS_clock_gettime64 },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_RISCV_SYS_close },
+#endif
+#ifdef CB_SYS_dup
+  { "dup", CB_SYS_dup, TARGET_NEWLIB_RISCV_SYS_dup },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_RISCV_SYS_exit },
+#endif
+#ifdef CB_SYS_exit_group
+  { "exit_group", CB_SYS_exit_group, TARGET_NEWLIB_RISCV_SYS_exit_group },
+#endif
+#ifdef CB_SYS_faccessat
+  { "faccessat", CB_SYS_faccessat, TARGET_NEWLIB_RISCV_SYS_faccessat },
+#endif
+#ifdef CB_SYS_fcntl
+  { "fcntl", CB_SYS_fcntl, TARGET_NEWLIB_RISCV_SYS_fcntl },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_RISCV_SYS_fstat },
+#endif
+#ifdef CB_SYS_fstatat
+  { "fstatat", CB_SYS_fstatat, TARGET_NEWLIB_RISCV_SYS_fstatat },
+#endif
+#ifdef CB_SYS_getcwd
+  { "getcwd", CB_SYS_getcwd, TARGET_NEWLIB_RISCV_SYS_getcwd },
+#endif
+#ifdef CB_SYS_getdents
+  { "getdents", CB_SYS_getdents, TARGET_NEWLIB_RISCV_SYS_getdents },
+#endif
+#ifdef CB_SYS_getegid
+  { "getegid", CB_SYS_getegid, TARGET_NEWLIB_RISCV_SYS_getegid },
+#endif
+#ifdef CB_SYS_geteuid
+  { "geteuid", CB_SYS_geteuid, TARGET_NEWLIB_RISCV_SYS_geteuid },
+#endif
+#ifdef CB_SYS_getgid
+  { "getgid", CB_SYS_getgid, TARGET_NEWLIB_RISCV_SYS_getgid },
+#endif
+#ifdef CB_SYS_getmainvars
+  { "getmainvars", CB_SYS_getmainvars, TARGET_NEWLIB_RISCV_SYS_getmainvars },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_RISCV_SYS_getpid },
+#endif
+#ifdef CB_SYS_gettimeofday
+  { "gettimeofday", CB_SYS_gettimeofday, TARGET_NEWLIB_RISCV_SYS_gettimeofday },
+#endif
+#ifdef CB_SYS_getuid
+  { "getuid", CB_SYS_getuid, TARGET_NEWLIB_RISCV_SYS_getuid },
+#endif
+#ifdef CB_SYS_kill
+  { "kill", CB_SYS_kill, TARGET_NEWLIB_RISCV_SYS_kill },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_RISCV_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_RISCV_SYS_lseek },
+#endif
+#ifdef CB_SYS_lstat
+  { "lstat", CB_SYS_lstat, TARGET_NEWLIB_RISCV_SYS_lstat },
+#endif
+#ifdef CB_SYS_mkdir
+  { "mkdir", CB_SYS_mkdir, TARGET_NEWLIB_RISCV_SYS_mkdir },
+#endif
+#ifdef CB_SYS_mmap
+  { "mmap", CB_SYS_mmap, TARGET_NEWLIB_RISCV_SYS_mmap },
+#endif
+#ifdef CB_SYS_mremap
+  { "mremap", CB_SYS_mremap, TARGET_NEWLIB_RISCV_SYS_mremap },
+#endif
+#ifdef CB_SYS_munmap
+  { "munmap", CB_SYS_munmap, TARGET_NEWLIB_RISCV_SYS_munmap },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_RISCV_SYS_open },
+#endif
+#ifdef CB_SYS_openat
+  { "openat", CB_SYS_openat, TARGET_NEWLIB_RISCV_SYS_openat },
+#endif
+#ifdef CB_SYS_pread
+  { "pread", CB_SYS_pread, TARGET_NEWLIB_RISCV_SYS_pread },
+#endif
+#ifdef CB_SYS_pwrite
+  { "pwrite", CB_SYS_pwrite, TARGET_NEWLIB_RISCV_SYS_pwrite },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_RISCV_SYS_read },
+#endif
+#ifdef CB_SYS_rt_sigaction
+  { "rt_sigaction", CB_SYS_rt_sigaction, TARGET_NEWLIB_RISCV_SYS_rt_sigaction },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_RISCV_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_RISCV_SYS_time },
+#endif
+#ifdef CB_SYS_times
+  { "times", CB_SYS_times, TARGET_NEWLIB_RISCV_SYS_times },
+#endif
+#ifdef CB_SYS_uname
+  { "uname", CB_SYS_uname, TARGET_NEWLIB_RISCV_SYS_uname },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_RISCV_SYS_unlink },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_RISCV_SYS_write },
+#endif
+#ifdef CB_SYS_writev
+  { "writev", CB_SYS_writev, TARGET_NEWLIB_RISCV_SYS_writev },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_sh_syscall_map[] = {
+#ifdef CB_SYS_ARG
+  { "ARG", CB_SYS_ARG, TARGET_NEWLIB_SH_SYS_ARG },
+#endif
+#ifdef CB_SYS_argc
+  { "argc", CB_SYS_argc, TARGET_NEWLIB_SH_SYS_argc },
+#endif
+#ifdef CB_SYS_argn
+  { "argn", CB_SYS_argn, TARGET_NEWLIB_SH_SYS_argn },
+#endif
+#ifdef CB_SYS_argnlen
+  { "argnlen", CB_SYS_argnlen, TARGET_NEWLIB_SH_SYS_argnlen },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_SH_SYS_chdir },
+#endif
+#ifdef CB_SYS_chmod
+  { "chmod", CB_SYS_chmod, TARGET_NEWLIB_SH_SYS_chmod },
+#endif
+#ifdef CB_SYS_chown
+  { "chown", CB_SYS_chown, TARGET_NEWLIB_SH_SYS_chown },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_SH_SYS_close },
+#endif
+#ifdef CB_SYS_creat
+  { "creat", CB_SYS_creat, TARGET_NEWLIB_SH_SYS_creat },
+#endif
+#ifdef CB_SYS_execv
+  { "execv", CB_SYS_execv, TARGET_NEWLIB_SH_SYS_execv },
+#endif
+#ifdef CB_SYS_execve
+  { "execve", CB_SYS_execve, TARGET_NEWLIB_SH_SYS_execve },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_SH_SYS_exit },
+#endif
+#ifdef CB_SYS_fork
+  { "fork", CB_SYS_fork, TARGET_NEWLIB_SH_SYS_fork },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_SH_SYS_fstat },
+#endif
+#ifdef CB_SYS_ftruncate
+  { "ftruncate", CB_SYS_ftruncate, TARGET_NEWLIB_SH_SYS_ftruncate },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_SH_SYS_getpid },
+#endif
+#ifdef CB_SYS_isatty
+  { "isatty", CB_SYS_isatty, TARGET_NEWLIB_SH_SYS_isatty },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_SH_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_SH_SYS_lseek },
+#endif
+#ifdef CB_SYS_mknod
+  { "mknod", CB_SYS_mknod, TARGET_NEWLIB_SH_SYS_mknod },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_SH_SYS_open },
+#endif
+#ifdef CB_SYS_pipe
+  { "pipe", CB_SYS_pipe, TARGET_NEWLIB_SH_SYS_pipe },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_SH_SYS_read },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_SH_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_SH_SYS_time },
+#endif
+#ifdef CB_SYS_truncate
+  { "truncate", CB_SYS_truncate, TARGET_NEWLIB_SH_SYS_truncate },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_SH_SYS_unlink },
+#endif
+#ifdef CB_SYS_utime
+  { "utime", CB_SYS_utime, TARGET_NEWLIB_SH_SYS_utime },
+#endif
+#ifdef CB_SYS_wait
+  { "wait", CB_SYS_wait, TARGET_NEWLIB_SH_SYS_wait },
+#endif
+#ifdef CB_SYS_wait4
+  { "wait4", CB_SYS_wait4, TARGET_NEWLIB_SH_SYS_wait4 },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_SH_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_v850_syscall_map[] = {
+#ifdef CB_SYS_ARG
+  { "ARG", CB_SYS_ARG, TARGET_NEWLIB_V850_SYS_ARG },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_V850_SYS_chdir },
+#endif
+#ifdef CB_SYS_chmod
+  { "chmod", CB_SYS_chmod, TARGET_NEWLIB_V850_SYS_chmod },
+#endif
+#ifdef CB_SYS_chown
+  { "chown", CB_SYS_chown, TARGET_NEWLIB_V850_SYS_chown },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_V850_SYS_close },
+#endif
+#ifdef CB_SYS_creat
+  { "creat", CB_SYS_creat, TARGET_NEWLIB_V850_SYS_creat },
+#endif
+#ifdef CB_SYS_execv
+  { "execv", CB_SYS_execv, TARGET_NEWLIB_V850_SYS_execv },
+#endif
+#ifdef CB_SYS_execve
+  { "execve", CB_SYS_execve, TARGET_NEWLIB_V850_SYS_execve },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_V850_SYS_exit },
+#endif
+#ifdef CB_SYS_fork
+  { "fork", CB_SYS_fork, TARGET_NEWLIB_V850_SYS_fork },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_V850_SYS_fstat },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_V850_SYS_getpid },
+#endif
+#ifdef CB_SYS_gettimeofday
+  { "gettimeofday", CB_SYS_gettimeofday, TARGET_NEWLIB_V850_SYS_gettimeofday },
+#endif
+#ifdef CB_SYS_isatty
+  { "isatty", CB_SYS_isatty, TARGET_NEWLIB_V850_SYS_isatty },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_V850_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_V850_SYS_lseek },
+#endif
+#ifdef CB_SYS_mknod
+  { "mknod", CB_SYS_mknod, TARGET_NEWLIB_V850_SYS_mknod },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_V850_SYS_open },
+#endif
+#ifdef CB_SYS_pipe
+  { "pipe", CB_SYS_pipe, TARGET_NEWLIB_V850_SYS_pipe },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_V850_SYS_read },
+#endif
+#ifdef CB_SYS_rename
+  { "rename", CB_SYS_rename, TARGET_NEWLIB_V850_SYS_rename },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_V850_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_V850_SYS_time },
+#endif
+#ifdef CB_SYS_times
+  { "times", CB_SYS_times, TARGET_NEWLIB_V850_SYS_times },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_V850_SYS_unlink },
+#endif
+#ifdef CB_SYS_utime
+  { "utime", CB_SYS_utime, TARGET_NEWLIB_V850_SYS_utime },
+#endif
+#ifdef CB_SYS_wait
+  { "wait", CB_SYS_wait, TARGET_NEWLIB_V850_SYS_wait },
+#endif
+#ifdef CB_SYS_wait4
+  { "wait4", CB_SYS_wait4, TARGET_NEWLIB_V850_SYS_wait4 },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_V850_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+
+CB_TARGET_DEFS_MAP cb_init_syscall_map[] = {
+#ifdef CB_SYS_argc
+  { "argc", CB_SYS_argc, TARGET_NEWLIB_SYS_argc },
+#endif
+#ifdef CB_SYS_argn
+  { "argn", CB_SYS_argn, TARGET_NEWLIB_SYS_argn },
+#endif
+#ifdef CB_SYS_argnlen
+  { "argnlen", CB_SYS_argnlen, TARGET_NEWLIB_SYS_argnlen },
+#endif
+#ifdef CB_SYS_argv
+  { "argv", CB_SYS_argv, TARGET_NEWLIB_SYS_argv },
+#endif
+#ifdef CB_SYS_argvlen
+  { "argvlen", CB_SYS_argvlen, TARGET_NEWLIB_SYS_argvlen },
+#endif
+#ifdef CB_SYS_chdir
+  { "chdir", CB_SYS_chdir, TARGET_NEWLIB_SYS_chdir },
+#endif
+#ifdef CB_SYS_chmod
+  { "chmod", CB_SYS_chmod, TARGET_NEWLIB_SYS_chmod },
+#endif
+#ifdef CB_SYS_close
+  { "close", CB_SYS_close, TARGET_NEWLIB_SYS_close },
+#endif
+#ifdef CB_SYS_exit
+  { "exit", CB_SYS_exit, TARGET_NEWLIB_SYS_exit },
+#endif
+#ifdef CB_SYS_fstat
+  { "fstat", CB_SYS_fstat, TARGET_NEWLIB_SYS_fstat },
+#endif
+#ifdef CB_SYS_getpid
+  { "getpid", CB_SYS_getpid, TARGET_NEWLIB_SYS_getpid },
+#endif
+#ifdef CB_SYS_gettimeofday
+  { "gettimeofday", CB_SYS_gettimeofday, TARGET_NEWLIB_SYS_gettimeofday },
+#endif
+#ifdef CB_SYS_kill
+  { "kill", CB_SYS_kill, TARGET_NEWLIB_SYS_kill },
+#endif
+#ifdef CB_SYS_link
+  { "link", CB_SYS_link, TARGET_NEWLIB_SYS_link },
+#endif
+#ifdef CB_SYS_lseek
+  { "lseek", CB_SYS_lseek, TARGET_NEWLIB_SYS_lseek },
+#endif
+#ifdef CB_SYS_open
+  { "open", CB_SYS_open, TARGET_NEWLIB_SYS_open },
+#endif
+#ifdef CB_SYS_read
+  { "read", CB_SYS_read, TARGET_NEWLIB_SYS_read },
+#endif
+#ifdef CB_SYS_reconfig
+  { "reconfig", CB_SYS_reconfig, TARGET_NEWLIB_SYS_reconfig },
+#endif
+#ifdef CB_SYS_stat
+  { "stat", CB_SYS_stat, TARGET_NEWLIB_SYS_stat },
+#endif
+#ifdef CB_SYS_time
+  { "time", CB_SYS_time, TARGET_NEWLIB_SYS_time },
+#endif
+#ifdef CB_SYS_times
+  { "times", CB_SYS_times, TARGET_NEWLIB_SYS_times },
+#endif
+#ifdef CB_SYS_unlink
+  { "unlink", CB_SYS_unlink, TARGET_NEWLIB_SYS_unlink },
+#endif
+#ifdef CB_SYS_utime
+  { "utime", CB_SYS_utime, TARGET_NEWLIB_SYS_utime },
+#endif
+#ifdef CB_SYS_write
+  { "write", CB_SYS_write, TARGET_NEWLIB_SYS_write },
+#endif
+  {NULL, -1, -1},
+};
+  /* gennltvals: END */
diff --git a/sim/common/target-newlib-syscall.h b/sim/common/target-newlib-syscall.h
new file mode 100644 (file)
index 0000000..fed9da5
--- /dev/null
@@ -0,0 +1,237 @@
+/* Target syscall mappings for newlib/libgloss environment.
+   Copyright 1995-2021 Free Software Foundation, Inc.
+   Contributed by Mike Frysinger.
+
+   This file is part of simulators.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef TARGET_NEWLIB_SYSCALL_H
+#define TARGET_NEWLIB_SYSCALL_H
+
+/* For CB_TARGET_DEFS_MAP.  */
+#include "sim/callback.h"
+
+/* This file is kept up-to-date via the gennltvals.py script.  Do not edit
+   anything between the START & END comment blocks below.  */
+
+  /* gennltvals: START */
+extern CB_TARGET_DEFS_MAP cb_cr16_syscall_map[];
+#define TARGET_NEWLIB_CR16_SYS_ARG 24
+#define TARGET_NEWLIB_CR16_SYS_chdir 12
+#define TARGET_NEWLIB_CR16_SYS_chmod 15
+#define TARGET_NEWLIB_CR16_SYS_chown 16
+#define TARGET_NEWLIB_CR16_SYS_close 0x402
+#define TARGET_NEWLIB_CR16_SYS_create 8
+#define TARGET_NEWLIB_CR16_SYS_execv 11
+#define TARGET_NEWLIB_CR16_SYS_execve 59
+#define TARGET_NEWLIB_CR16_SYS_exit 0x410
+#define TARGET_NEWLIB_CR16_SYS_fork 2
+#define TARGET_NEWLIB_CR16_SYS_fstat 22
+#define TARGET_NEWLIB_CR16_SYS_getpid 20
+#define TARGET_NEWLIB_CR16_SYS_isatty 21
+#define TARGET_NEWLIB_CR16_SYS_kill 60
+#define TARGET_NEWLIB_CR16_SYS_link 9
+#define TARGET_NEWLIB_CR16_SYS_lseek 0x405
+#define TARGET_NEWLIB_CR16_SYS_mknod 14
+#define TARGET_NEWLIB_CR16_SYS_open 0x401
+#define TARGET_NEWLIB_CR16_SYS_pipe 42
+#define TARGET_NEWLIB_CR16_SYS_read 0x403
+#define TARGET_NEWLIB_CR16_SYS_rename 0x406
+#define TARGET_NEWLIB_CR16_SYS_stat 38
+#define TARGET_NEWLIB_CR16_SYS_time 0x300
+#define TARGET_NEWLIB_CR16_SYS_unlink 0x407
+#define TARGET_NEWLIB_CR16_SYS_utime 201
+#define TARGET_NEWLIB_CR16_SYS_wait 202
+#define TARGET_NEWLIB_CR16_SYS_wait4 7
+#define TARGET_NEWLIB_CR16_SYS_write 0x404
+
+extern CB_TARGET_DEFS_MAP cb_d10v_syscall_map[];
+#define TARGET_NEWLIB_D10V_SYS_ARG 24
+#define TARGET_NEWLIB_D10V_SYS_chdir 12
+#define TARGET_NEWLIB_D10V_SYS_chmod 15
+#define TARGET_NEWLIB_D10V_SYS_chown 16
+#define TARGET_NEWLIB_D10V_SYS_close 6
+#define TARGET_NEWLIB_D10V_SYS_creat 8
+#define TARGET_NEWLIB_D10V_SYS_execv 11
+#define TARGET_NEWLIB_D10V_SYS_execve 59
+#define TARGET_NEWLIB_D10V_SYS_exit 1
+#define TARGET_NEWLIB_D10V_SYS_fork 2
+#define TARGET_NEWLIB_D10V_SYS_fstat 22
+#define TARGET_NEWLIB_D10V_SYS_getpid 20
+#define TARGET_NEWLIB_D10V_SYS_isatty 21
+#define TARGET_NEWLIB_D10V_SYS_kill 60
+#define TARGET_NEWLIB_D10V_SYS_link 9
+#define TARGET_NEWLIB_D10V_SYS_lseek 19
+#define TARGET_NEWLIB_D10V_SYS_mknod 14
+#define TARGET_NEWLIB_D10V_SYS_open 5
+#define TARGET_NEWLIB_D10V_SYS_pipe 42
+#define TARGET_NEWLIB_D10V_SYS_read 3
+#define TARGET_NEWLIB_D10V_SYS_stat 38
+#define TARGET_NEWLIB_D10V_SYS_time 23
+#define TARGET_NEWLIB_D10V_SYS_unlink 10
+#define TARGET_NEWLIB_D10V_SYS_utime 201
+#define TARGET_NEWLIB_D10V_SYS_wait 202
+#define TARGET_NEWLIB_D10V_SYS_wait4 7
+#define TARGET_NEWLIB_D10V_SYS_write 4
+
+extern CB_TARGET_DEFS_MAP cb_mcore_syscall_map[];
+#define TARGET_NEWLIB_MCORE_SYS_access 33
+#define TARGET_NEWLIB_MCORE_SYS_close 6
+#define TARGET_NEWLIB_MCORE_SYS_creat 8
+#define TARGET_NEWLIB_MCORE_SYS_link 9
+#define TARGET_NEWLIB_MCORE_SYS_lseek 19
+#define TARGET_NEWLIB_MCORE_SYS_open 5
+#define TARGET_NEWLIB_MCORE_SYS_read 3
+#define TARGET_NEWLIB_MCORE_SYS_time 13
+#define TARGET_NEWLIB_MCORE_SYS_times 43
+#define TARGET_NEWLIB_MCORE_SYS_unlink 10
+#define TARGET_NEWLIB_MCORE_SYS_write 4
+
+extern CB_TARGET_DEFS_MAP cb_riscv_syscall_map[];
+#define TARGET_NEWLIB_RISCV_SYS_access 1033
+#define TARGET_NEWLIB_RISCV_SYS_brk 214
+#define TARGET_NEWLIB_RISCV_SYS_chdir 49
+#define TARGET_NEWLIB_RISCV_SYS_clock_gettime64 403
+#define TARGET_NEWLIB_RISCV_SYS_close 57
+#define TARGET_NEWLIB_RISCV_SYS_dup 23
+#define TARGET_NEWLIB_RISCV_SYS_exit 93
+#define TARGET_NEWLIB_RISCV_SYS_exit_group 94
+#define TARGET_NEWLIB_RISCV_SYS_faccessat 48
+#define TARGET_NEWLIB_RISCV_SYS_fcntl 25
+#define TARGET_NEWLIB_RISCV_SYS_fstat 80
+#define TARGET_NEWLIB_RISCV_SYS_fstatat 79
+#define TARGET_NEWLIB_RISCV_SYS_getcwd 17
+#define TARGET_NEWLIB_RISCV_SYS_getdents 61
+#define TARGET_NEWLIB_RISCV_SYS_getegid 177
+#define TARGET_NEWLIB_RISCV_SYS_geteuid 175
+#define TARGET_NEWLIB_RISCV_SYS_getgid 176
+#define TARGET_NEWLIB_RISCV_SYS_getmainvars 2011
+#define TARGET_NEWLIB_RISCV_SYS_getpid 172
+#define TARGET_NEWLIB_RISCV_SYS_gettimeofday 169
+#define TARGET_NEWLIB_RISCV_SYS_getuid 174
+#define TARGET_NEWLIB_RISCV_SYS_kill 129
+#define TARGET_NEWLIB_RISCV_SYS_link 1025
+#define TARGET_NEWLIB_RISCV_SYS_lseek 62
+#define TARGET_NEWLIB_RISCV_SYS_lstat 1039
+#define TARGET_NEWLIB_RISCV_SYS_mkdir 1030
+#define TARGET_NEWLIB_RISCV_SYS_mmap 222
+#define TARGET_NEWLIB_RISCV_SYS_mremap 216
+#define TARGET_NEWLIB_RISCV_SYS_munmap 215
+#define TARGET_NEWLIB_RISCV_SYS_open 1024
+#define TARGET_NEWLIB_RISCV_SYS_openat 56
+#define TARGET_NEWLIB_RISCV_SYS_pread 67
+#define TARGET_NEWLIB_RISCV_SYS_pwrite 68
+#define TARGET_NEWLIB_RISCV_SYS_read 63
+#define TARGET_NEWLIB_RISCV_SYS_rt_sigaction 134
+#define TARGET_NEWLIB_RISCV_SYS_stat 1038
+#define TARGET_NEWLIB_RISCV_SYS_time 1062
+#define TARGET_NEWLIB_RISCV_SYS_times 153
+#define TARGET_NEWLIB_RISCV_SYS_uname 160
+#define TARGET_NEWLIB_RISCV_SYS_unlink 1026
+#define TARGET_NEWLIB_RISCV_SYS_write 64
+#define TARGET_NEWLIB_RISCV_SYS_writev 66
+
+extern CB_TARGET_DEFS_MAP cb_sh_syscall_map[];
+#define TARGET_NEWLIB_SH_SYS_ARG 24
+#define TARGET_NEWLIB_SH_SYS_argc 172
+#define TARGET_NEWLIB_SH_SYS_argn 174
+#define TARGET_NEWLIB_SH_SYS_argnlen 173
+#define TARGET_NEWLIB_SH_SYS_chdir 12
+#define TARGET_NEWLIB_SH_SYS_chmod 15
+#define TARGET_NEWLIB_SH_SYS_chown 16
+#define TARGET_NEWLIB_SH_SYS_close 6
+#define TARGET_NEWLIB_SH_SYS_creat 8
+#define TARGET_NEWLIB_SH_SYS_execv 11
+#define TARGET_NEWLIB_SH_SYS_execve 59
+#define TARGET_NEWLIB_SH_SYS_exit 1
+#define TARGET_NEWLIB_SH_SYS_fork 2
+#define TARGET_NEWLIB_SH_SYS_fstat 22
+#define TARGET_NEWLIB_SH_SYS_ftruncate 130
+#define TARGET_NEWLIB_SH_SYS_getpid 20
+#define TARGET_NEWLIB_SH_SYS_isatty 21
+#define TARGET_NEWLIB_SH_SYS_link 9
+#define TARGET_NEWLIB_SH_SYS_lseek 19
+#define TARGET_NEWLIB_SH_SYS_mknod 14
+#define TARGET_NEWLIB_SH_SYS_open 5
+#define TARGET_NEWLIB_SH_SYS_pipe 42
+#define TARGET_NEWLIB_SH_SYS_read 3
+#define TARGET_NEWLIB_SH_SYS_stat 38
+#define TARGET_NEWLIB_SH_SYS_time 23
+#define TARGET_NEWLIB_SH_SYS_truncate 129
+#define TARGET_NEWLIB_SH_SYS_unlink 10
+#define TARGET_NEWLIB_SH_SYS_utime 201
+#define TARGET_NEWLIB_SH_SYS_wait 202
+#define TARGET_NEWLIB_SH_SYS_wait4 7
+#define TARGET_NEWLIB_SH_SYS_write 4
+
+extern CB_TARGET_DEFS_MAP cb_v850_syscall_map[];
+#define TARGET_NEWLIB_V850_SYS_ARG 24
+#define TARGET_NEWLIB_V850_SYS_chdir 12
+#define TARGET_NEWLIB_V850_SYS_chmod 15
+#define TARGET_NEWLIB_V850_SYS_chown 16
+#define TARGET_NEWLIB_V850_SYS_close 6
+#define TARGET_NEWLIB_V850_SYS_creat 8
+#define TARGET_NEWLIB_V850_SYS_execv 11
+#define TARGET_NEWLIB_V850_SYS_execve 59
+#define TARGET_NEWLIB_V850_SYS_exit 1
+#define TARGET_NEWLIB_V850_SYS_fork 2
+#define TARGET_NEWLIB_V850_SYS_fstat 22
+#define TARGET_NEWLIB_V850_SYS_getpid 20
+#define TARGET_NEWLIB_V850_SYS_gettimeofday 116
+#define TARGET_NEWLIB_V850_SYS_isatty 21
+#define TARGET_NEWLIB_V850_SYS_link 9
+#define TARGET_NEWLIB_V850_SYS_lseek 19
+#define TARGET_NEWLIB_V850_SYS_mknod 14
+#define TARGET_NEWLIB_V850_SYS_open 5
+#define TARGET_NEWLIB_V850_SYS_pipe 42
+#define TARGET_NEWLIB_V850_SYS_read 3
+#define TARGET_NEWLIB_V850_SYS_rename 134
+#define TARGET_NEWLIB_V850_SYS_stat 38
+#define TARGET_NEWLIB_V850_SYS_time 23
+#define TARGET_NEWLIB_V850_SYS_times 43
+#define TARGET_NEWLIB_V850_SYS_unlink 10
+#define TARGET_NEWLIB_V850_SYS_utime 201
+#define TARGET_NEWLIB_V850_SYS_wait 202
+#define TARGET_NEWLIB_V850_SYS_wait4 7
+#define TARGET_NEWLIB_V850_SYS_write 4
+
+extern CB_TARGET_DEFS_MAP cb_init_syscall_map[];
+#define TARGET_NEWLIB_SYS_argc 22
+#define TARGET_NEWLIB_SYS_argn 24
+#define TARGET_NEWLIB_SYS_argnlen 23
+#define TARGET_NEWLIB_SYS_argv 13
+#define TARGET_NEWLIB_SYS_argvlen 12
+#define TARGET_NEWLIB_SYS_chdir 14
+#define TARGET_NEWLIB_SYS_chmod 16
+#define TARGET_NEWLIB_SYS_close 3
+#define TARGET_NEWLIB_SYS_exit 1
+#define TARGET_NEWLIB_SYS_fstat 10
+#define TARGET_NEWLIB_SYS_getpid 8
+#define TARGET_NEWLIB_SYS_gettimeofday 19
+#define TARGET_NEWLIB_SYS_kill 9
+#define TARGET_NEWLIB_SYS_link 21
+#define TARGET_NEWLIB_SYS_lseek 6
+#define TARGET_NEWLIB_SYS_open 2
+#define TARGET_NEWLIB_SYS_read 4
+#define TARGET_NEWLIB_SYS_reconfig 25
+#define TARGET_NEWLIB_SYS_stat 15
+#define TARGET_NEWLIB_SYS_time 18
+#define TARGET_NEWLIB_SYS_times 20
+#define TARGET_NEWLIB_SYS_unlink 7
+#define TARGET_NEWLIB_SYS_utime 17
+#define TARGET_NEWLIB_SYS_write 5
+  /* gennltvals: END */
+
+#endif
index b9918954f37e1b039fb8fa6216b1afad04404ba8..33d7df953b598b8f43c7c2050bcf478b619aba6d 100644 (file)
@@ -411,9 +411,6 @@ SUPPORT_H = \
         support.h \
         support.c
 
-TARG_VALS_H = \
-        targ-vals.h
-
 INLINE = \
        inline.h \
        inline.c
@@ -429,8 +426,7 @@ BUILT_SRC_WO_CONFIG = \
        support.h support.c \
        pk.h \
        hw.h hw.c \
-       filter_host.c \
-       targ-vals.h targ-map.c targ-vals.def
+       filter_host.c
 
 BUILT_SRC = \
        $(BUILT_SRC_WO_CONFIG) \
@@ -473,6 +469,7 @@ COMMON_OBJS_NAMES = \
        target-newlib-errno.o \
        target-newlib-open.o \
        target-newlib-signal.o \
+       target-newlib-syscall.o \
        version.o
 COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/common_libcommon_a-%)
 
@@ -515,7 +512,7 @@ LIB_OBJ = \
        options.o
 
 
-GDB_OBJ = gdb-sim.o sim_calls.o targ-map.o
+GDB_OBJ = gdb-sim.o sim_calls.o
 
 HW_SRC = @sim_hw_src@
 HW_OBJ = @sim_hw_obj@
@@ -598,30 +595,6 @@ itable.o: itable.c $(ITABLE_H)
 
 mon.o: mon.c $(BASICS_H) $(CPU_H) $(MON_H)
 
-# GDB after 4.16 expects the default_callback structure to be setup.
-# As a kludge, build the common stuff here for now.
-gentmap: $(srcdir)/../common/gentmap.c Makefile targ-vals.def
-       $(ECHO_CCLD) $(LINK_FOR_BUILD) -I. -I../common -I$(srcdir)/../common \
-               $(srcdir)/../common/gentmap.c -DUSE_CONFIG_H
-
-targ-vals.def: $(srcdir)/../common/nltvals.def
-       $(ECHO_GEN) cat $(srcdir)/../common/nltvals.def > tmp-vals.def
-       $(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-vals.def targ-vals.def
-
-targ-vals.h: stamp-vals ; @true
-stamp-vals: Makefile gentmap $(srcroot)/move-if-change
-       $(ECHO_GEN) ./gentmap -h > tmp-vals.h
-       $(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-vals.h targ-vals.h
-       $(SILENCE) touch $@
-
-targ-map.c: stamp-map; @true
-stamp-map: Makefile gentmap $(srcroot)/move-if-change
-       $(ECHO_GEN) ./gentmap -c > tmp-map.c
-       $(SILENCE) $(SHELL) $(srcroot)/move-if-change tmp-map.c targ-map.c
-       $(SILENCE) touch $@
-
-targ-map.o: targ-map.c $(ANSIDECL_H) $(GDB_CALLBACK_H) $(TARG_VALS_H)
-
 sim-fpu.o: $(srcdir)/../common/sim-fpu.c $(CONFIG_H)
        $(ECHO_CC) $(CC) -c $(STD_CFLAGS) -DHAVE_CONFIG_H $(srcdir)/../common/sim-fpu.c 
 
@@ -838,8 +811,7 @@ TAGS: $(BUILT_SRC)
        etags $(srcdir)/*.h $(srcdir)/*.c $(BUILT_SRC)
 
 clean mostlyclean:
-       rm -f tmp-* *.[oasi] core psim$(EXEEXT) run$(EXEEXT) igen dgen $(BUILT_SRC_WO_CONFIG) gentmap
-       rm -f stamp-vals targ-vals.h stamp-map targ-map.c
+       rm -f tmp-* *.[oasi] core psim$(EXEEXT) run$(EXEEXT) igen dgen $(BUILT_SRC_WO_CONFIG)
 
 distclean realclean: clean
        rm -f TAGS Makefile config.cache config.status config.h defines.h stamp-h config.log