Index: freebsd/bin/stty/cchar.c
===================================================================
--- freebsd/bin/stty/cchar.c	(revision f6c52e086dbc0e7101ea4e03a84005dd2811ad42)
+++ freebsd/bin/stty/cchar.c	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -1,4 +1,7 @@
 #include <machine/rtems-bsd-user-space.h>
 
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,4 +41,7 @@
 __FBSDID("$FreeBSD$");
 
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
 #include <sys/types.h>
 
@@ -48,4 +54,7 @@
 #include "stty.h"
 #include "extern.h"
+#ifdef __rtems__
+#include "rtems-bsd-stty-cchar-data.h"
+#endif /* __rtems__ */
 
 static int c_cchar(const void *, const void *);
Index: freebsd/bin/stty/gfmt.c
===================================================================
--- freebsd/bin/stty/gfmt.c	(revision f6c52e086dbc0e7101ea4e03a84005dd2811ad42)
+++ freebsd/bin/stty/gfmt.c	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -1,4 +1,7 @@
 #include <machine/rtems-bsd-user-space.h>
 
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,4 +41,7 @@
 __FBSDID("$FreeBSD$");
 
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
 #include <sys/types.h>
 
Index: freebsd/bin/stty/key.c
===================================================================
--- freebsd/bin/stty/key.c	(revision f6c52e086dbc0e7101ea4e03a84005dd2811ad42)
+++ freebsd/bin/stty/key.c	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -1,4 +1,7 @@
 #include <machine/rtems-bsd-user-space.h>
 
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,4 +41,7 @@
 __FBSDID("$FreeBSD$");
 
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
 #include <sys/types.h>
 
@@ -97,4 +103,7 @@
 	{ "tty",	f_tty,		0 },
 };
+#ifdef __rtems__
+#include "rtems-bsd-stty-key-data.h"
+#endif /* __rtems__ */
 
 static int
Index: freebsd/bin/stty/modes.c
===================================================================
--- freebsd/bin/stty/modes.c	(revision f6c52e086dbc0e7101ea4e03a84005dd2811ad42)
+++ freebsd/bin/stty/modes.c	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -1,4 +1,7 @@
 #include <machine/rtems-bsd-user-space.h>
 
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,8 +41,14 @@
 __FBSDID("$FreeBSD$");
 
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
 #include <sys/types.h>
 #include <stddef.h>
 #include <string.h>
 #include "stty.h"
+#ifdef __rtems__
+#include "rtems-bsd-stty-modes-data.h"
+#endif /* __rtems__ */
 
 int msearch(char ***, struct info *);
Index: freebsd/bin/stty/print.c
===================================================================
--- freebsd/bin/stty/print.c	(revision f6c52e086dbc0e7101ea4e03a84005dd2811ad42)
+++ freebsd/bin/stty/print.c	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -1,4 +1,7 @@
 #include <machine/rtems-bsd-user-space.h>
 
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,4 +41,7 @@
 __FBSDID("$FreeBSD$");
 
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
 #include <sys/types.h>
 
@@ -46,4 +52,7 @@
 #include "stty.h"
 #include "extern.h"
+#ifdef __rtems__
+#include "rtems-bsd-stty-print-data.h"
+#endif /* __rtems__ */
 
 static void  binit(const char *);
Index: freebsd/bin/stty/rtems-bsd-stty-cchar-data.h
===================================================================
--- freebsd/bin/stty/rtems-bsd-stty-cchar-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
+++ freebsd/bin/stty/rtems-bsd-stty-cchar-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* cchar.c */
Index: freebsd/bin/stty/rtems-bsd-stty-data.h
===================================================================
--- freebsd/bin/stty/rtems-bsd-stty-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
+++ freebsd/bin/stty/rtems-bsd-stty-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -0,0 +1,11 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+/* cchar.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, extern struct cchar cchars1[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, extern struct cchar cchars2[]);
+/* gfmt.c */
+/* key.c */
+/* modes.c */
+/* print.c */
+/* stty.c */
+/* util.c */
Index: freebsd/bin/stty/rtems-bsd-stty-gfmt-data.h
===================================================================
--- freebsd/bin/stty/rtems-bsd-stty-gfmt-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
+++ freebsd/bin/stty/rtems-bsd-stty-gfmt-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* gfmt.c */
Index: freebsd/bin/stty/rtems-bsd-stty-key-data.h
===================================================================
--- freebsd/bin/stty/rtems-bsd-stty-key-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
+++ freebsd/bin/stty/rtems-bsd-stty-key-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* key.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, static struct key keys[20]);
Index: freebsd/bin/stty/rtems-bsd-stty-modes-data.h
===================================================================
--- freebsd/bin/stty/rtems-bsd-stty-modes-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
+++ freebsd/bin/stty/rtems-bsd-stty-modes-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* modes.c */
Index: freebsd/bin/stty/rtems-bsd-stty-namespace.h
===================================================================
--- freebsd/bin/stty/rtems-bsd-stty-namespace.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
+++ freebsd/bin/stty/rtems-bsd-stty-namespace.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -0,0 +1,34 @@
+/* generated by userspace-header-gen.py */
+/* cchar.c */
+#define cchars1 _bsd_stty_cchars1
+#define cchars2 _bsd_stty_cchars2
+#define csearch _bsd_stty_csearch
+/* gfmt.c */
+#define gread _bsd_stty_gread
+#define gprint _bsd_stty_gprint
+/* key.c */
+#define f_tty _bsd_stty_f_tty
+#define f_speed _bsd_stty_f_speed
+#define f_size _bsd_stty_f_size
+#define f_sane _bsd_stty_f_sane
+#define f_rows _bsd_stty_f_rows
+#define f_raw _bsd_stty_f_raw
+#define f_ospeed _bsd_stty_f_ospeed
+#define f_nl _bsd_stty_f_nl
+#define f_ispeed _bsd_stty_f_ispeed
+#define f_extproc _bsd_stty_f_extproc
+#define f_everything _bsd_stty_f_everything
+#define f_ek _bsd_stty_f_ek
+#define f_dec _bsd_stty_f_dec
+#define f_columns _bsd_stty_f_columns
+#define f_cbreak _bsd_stty_f_cbreak
+#define f_all _bsd_stty_f_all
+#define ksearch _bsd_stty_ksearch
+/* modes.c */
+#define msearch _bsd_stty_msearch
+/* print.c */
+#define print _bsd_stty_print
+/* stty.c */
+#define usage _bsd_stty_usage
+/* util.c */
+#define checkredirect _bsd_stty_checkredirect
Index: freebsd/bin/stty/rtems-bsd-stty-print-data.h
===================================================================
--- freebsd/bin/stty/rtems-bsd-stty-print-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
+++ freebsd/bin/stty/rtems-bsd-stty-print-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -0,0 +1,6 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* print.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, static int col);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, static char const *label);
Index: freebsd/bin/stty/rtems-bsd-stty-stty-data.h
===================================================================
--- freebsd/bin/stty/rtems-bsd-stty-stty-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
+++ freebsd/bin/stty/rtems-bsd-stty-stty-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* stty.c */
Index: freebsd/bin/stty/rtems-bsd-stty-util-data.h
===================================================================
--- freebsd/bin/stty/rtems-bsd-stty-util-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
+++ freebsd/bin/stty/rtems-bsd-stty-util-data.h	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* util.c */
Index: freebsd/bin/stty/stty.c
===================================================================
--- freebsd/bin/stty/stty.c	(revision f6c52e086dbc0e7101ea4e03a84005dd2811ad42)
+++ freebsd/bin/stty/stty.c	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -1,4 +1,7 @@
 #include <machine/rtems-bsd-user-space.h>
 
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
 /*-
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -44,4 +47,10 @@
 __FBSDID("$FreeBSD$");
 
+#ifdef __rtems__
+#define __need_getopt_newlib
+#include <getopt.h>
+#include <machine/rtems-bsd-program.h>
+#include <machine/rtems-bsd-commands.h>
+#endif /* __rtems__ */
 #include <sys/types.h>
 
@@ -58,5 +67,31 @@
 #include "stty.h"
 #include "extern.h"
-
+#ifdef __rtems__
+#include "rtems-bsd-stty-stty-data.h"
+#endif /* __rtems__ */
+
+#ifdef __rtems__
+static int main(int argc, char *argv[]);
+
+RTEMS_LINKER_RWSET(bsd_prog_stty, char);
+
+int
+rtems_bsd_command_stty(int argc, char *argv[])
+{
+  int exit_code;
+  void *data_begin;
+  size_t data_size;
+
+  data_begin = RTEMS_LINKER_SET_BEGIN(bsd_prog_stty);
+  data_size = RTEMS_LINKER_SET_SIZE(bsd_prog_stty);
+
+  rtems_bsd_program_lock();
+  exit_code = rtems_bsd_program_call_main_with_data_restore("stty",
+      main, argc, argv, data_begin, data_size);
+  rtems_bsd_program_unlock();
+
+  return exit_code;
+}
+#endif /* __rtems__ */
 int
 main(int argc, char *argv[])
@@ -66,4 +101,13 @@
 	int ch;
 	const char *file, *errstr = NULL;
+#ifdef __rtems__
+	struct getopt_data getopt_data;
+	memset(&getopt_data, 0, sizeof(getopt_data));
+#define optind getopt_data.optind
+#define optarg getopt_data.optarg
+#define opterr getopt_data.opterr
+#define optopt getopt_data.optopt
+#define getopt(argc, argv, opt) getopt_r(argc, argv, "+" opt, &getopt_data)
+#endif /* __rtems__ */
 
 	fmt = NOTSET;
@@ -73,5 +117,9 @@
 	opterr = 0;
 	while (optind < argc &&
+#ifndef __rtems__
 	    strspn(argv[optind], "-aefg") == strlen(argv[optind]) &&
+#else /* __rtems__ */
+	    strspn(argv[optind == 0 ? 1 : optind], "-aefg") == strlen(argv[optind == 0 ? 1 : optind]) &&
+#endif /* __rtems__ */
 	    (ch = getopt(argc, argv, "aef:g")) != -1)
 		switch(ch) {
Index: freebsd/bin/stty/util.c
===================================================================
--- freebsd/bin/stty/util.c	(revision f6c52e086dbc0e7101ea4e03a84005dd2811ad42)
+++ freebsd/bin/stty/util.c	(revision 567cce1260cb6b07a662275ae8238c28ab611761)
@@ -1,4 +1,7 @@
 #include <machine/rtems-bsd-user-space.h>
 
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -38,4 +41,7 @@
 __FBSDID("$FreeBSD$");
 
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -48,4 +54,7 @@
 #include "stty.h"
 #include "extern.h"
+#ifdef __rtems__
+#include "rtems-bsd-stty-util-data.h"
+#endif /* __rtems__ */
 
 /*
