summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKurt Bodiker <kurt.bodiker@braintrust-us.com>2018-05-01 10:05:30 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2018-05-01 23:17:29 -0400
commitb9f265377c8a673c6a5bd4f4bab0ac41a075bfde (patch)
tree298398362636d78380554032c54b5e32005f9367
parente5cfb60540c88c92a56bea3417d54c6d9f9b5a98 (diff)
downloadmeta-virtualization-b9f265377c8a673c6a5bd4f4bab0ac41a075bfde.tar.gz
xen: Newlib recipe and patches for Xen stubdoms
Newlib provides a fast, C library optimized for embedded systems. In the case of Xen stubdomains, we are using MiniOS. This Newlib recipe creates static libraries that are cross-compiled against MiniOS, Xen, and LWIP headers and subsequently used during the cross-compilation and linking of PolarSSL, the stubdom specific GMP, TPM Emulator, and the Xen vTPM and vTPM Manager stubdomains. The current Xen source code is hardcoded to fetch a specific version of this package. The patch files originate from the Xen/stubdom source tree. This recipe provides the flexibility to change version or modify the patches. Signed-off-by: Kurt Bodiker <kurt.bodiker@braintrust-us.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
-rw-r--r--recipes-extended/xen/files/newlib-chk.patch155
-rw-r--r--recipes-extended/xen/files/newlib-stdint-size_max-fix-from-1.17.0.patch16
-rw-r--r--recipes-extended/xen/files/newlib.patch727
-rw-r--r--recipes-extended/xen/newlib.inc64
-rw-r--r--recipes-extended/xen/newlib_1.16.0.bb21
5 files changed, 983 insertions, 0 deletions
diff --git a/recipes-extended/xen/files/newlib-chk.patch b/recipes-extended/xen/files/newlib-chk.patch
new file mode 100644
index 00000000..a5d01495
--- /dev/null
+++ b/recipes-extended/xen/files/newlib-chk.patch
@@ -0,0 +1,155 @@
1--- a/newlib/libc/stdio/fprintf_chk.c 1969-12-31 19:00:00.000000000 -0500
2+++ b/newlib/libc/stdio/fprintf_chk.c 2009-02-26 19:02:53.000000000 -0500
3@@ -0,0 +1,21 @@
4+#include <stdarg.h>
5+#include <stdio.h>
6+
7+/*
8+ * Stub implementation of __fprintf_chk adapted from glibc 2.7. This
9+ * doesn't actually implement any buffer overflow protection. It just makes
10+ * the linker happy :)
11+*/
12+int
13+__fprintf_chk (FILE *fp, int flag, const char *format, ...)
14+{
15+ va_list ap;
16+ int done;
17+
18+ va_start (ap, format);
19+ done = vfprintf (fp, format, ap);
20+ va_end (ap);
21+
22+ return done;
23+}
24+
25--- a/newlib/libc/stdio/Makefile.am 2007-08-02 16:23:06.000000000 -0400
26+++ b/newlib/libc/stdio/Makefile.am 2009-02-26 18:14:53.000000000 -0500
27@@ -20,6 +20,7 @@
28 flags.c \
29 fopen.c \
30 fprintf.c \
31+ fprintf_chk.c \
32 fputc.c \
33 fputs.c \
34 fread.c \
35@@ -65,6 +66,7 @@
36 sniprintf.c \
37 snprintf.c \
38 sprintf.c \
39+ sprintf_chk.c \
40 sscanf.c \
41 stdio.c \
42 tmpfile.c \
43--- a/newlib/libc/stdio/Makefile.in 2007-12-19 17:36:38.000000000 -0500
44+++ b/newlib/libc/stdio/Makefile.in 2009-02-26 18:43:52.000000000 -0500
45@@ -63,7 +63,8 @@
46 lib_a-fgets.$(OBJEXT) lib_a-fileno.$(OBJEXT) \
47 lib_a-findfp.$(OBJEXT) lib_a-fiprintf.$(OBJEXT) \
48 lib_a-flags.$(OBJEXT) lib_a-fopen.$(OBJEXT) \
49- lib_a-fprintf.$(OBJEXT) lib_a-fputc.$(OBJEXT) \
50+ lib_a-fprintf.$(OBJEXT) lib_a-fprintf_chk.$(OBJEXT) \
51+ lib_a-fputc.$(OBJEXT) \
52 lib_a-fputs.$(OBJEXT) lib_a-fread.$(OBJEXT) \
53 lib_a-freopen.$(OBJEXT) lib_a-fscanf.$(OBJEXT) \
54 lib_a-fiscanf.$(OBJEXT) lib_a-fseek.$(OBJEXT) \
55@@ -86,6 +87,7 @@
56 lib_a-setvbuf.$(OBJEXT) lib_a-siprintf.$(OBJEXT) \
57 lib_a-siscanf.$(OBJEXT) lib_a-sniprintf.$(OBJEXT) \
58 lib_a-snprintf.$(OBJEXT) lib_a-sprintf.$(OBJEXT) \
59+ lib_a-sprintf_chk.$(OBJEXT) \
60 lib_a-sscanf.$(OBJEXT) lib_a-stdio.$(OBJEXT) \
61 lib_a-tmpfile.$(OBJEXT) lib_a-tmpnam.$(OBJEXT) \
62 lib_a-ungetc.$(OBJEXT) lib_a-vdiprintf.$(OBJEXT) \
63@@ -122,15 +124,15 @@
64 LTLIBRARIES = $(noinst_LTLIBRARIES)
65 am__objects_4 = clearerr.lo fclose.lo fdopen.lo feof.lo ferror.lo \
66 fflush.lo fgetc.lo fgetpos.lo fgets.lo fileno.lo findfp.lo \
67- fiprintf.lo flags.lo fopen.lo fprintf.lo fputc.lo fputs.lo \
68- fread.lo freopen.lo fscanf.lo fiscanf.lo fseek.lo fsetpos.lo \
69+ fiprintf.lo flags.lo fopen.lo fprintf.lo fprintf_chk.lo fputc.lo \
70+ fputs.lo fread.lo freopen.lo fscanf.lo fiscanf.lo fseek.lo fsetpos.lo \
71 ftell.lo fvwrite.lo fwalk.lo fwrite.lo getc.lo getchar.lo \
72 getc_u.lo getchar_u.lo getdelim.lo getline.lo gets.lo \
73 iprintf.lo iscanf.lo makebuf.lo perror.lo printf.lo putc.lo \
74 putchar.lo putc_u.lo putchar_u.lo puts.lo refill.lo remove.lo \
75 rename.lo rewind.lo rget.lo scanf.lo sccl.lo setbuf.lo \
76 setbuffer.lo setlinebuf.lo setvbuf.lo siprintf.lo siscanf.lo \
77- sniprintf.lo snprintf.lo sprintf.lo sscanf.lo stdio.lo \
78+ sniprintf.lo snprintf.lo sprintf.lo sprintf_chk.lo sscanf.lo stdio.lo \
79 tmpfile.lo tmpnam.lo ungetc.lo vdiprintf.lo vdprintf.lo \
80 viprintf.lo viscanf.lo vprintf.lo vscanf.lo vsiprintf.lo \
81 vsiscanf.lo vsnprintf.lo vsniprintf.lo vsprintf.lo vsscanf.lo \
82@@ -344,6 +346,7 @@
83 flags.c \
84 fopen.c \
85 fprintf.c \
86+ fprintf_chk.c \
87 fputc.c \
88 fputs.c \
89 fread.c \
90@@ -389,6 +392,7 @@
91 sniprintf.c \
92 snprintf.c \
93 sprintf.c \
94+ sprintf_chk.c \
95 sscanf.c \
96 stdio.c \
97 tmpfile.c \
98@@ -508,6 +512,7 @@
99 siprintf.def \
100 siscanf.def \
101 sprintf.def \
102+ sprintf_chk.def \
103 sscanf.def \
104 tmpfile.def \
105 tmpnam.def \
106@@ -678,6 +683,12 @@
107 lib_a-fprintf.obj: fprintf.c
108 $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf.obj `if test -f 'fprintf.c'; then $(CYGPATH_W) 'fprintf.c'; else $(CYGPATH_W) '$(srcdir)/fprintf.c'; fi`
109
110+lib_a-fprintf_chk.o: fprintf_chk.c
111+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf_chk.o `test -f 'fprintf_chk.c' || echo '$(srcdir)/'`fprintf_chk.c
112+
113+lib_a-fprintf_chk.obj: fprintf_chk.c
114+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fprintf_chk.obj `if test -f 'fprintf_chk.c'; then $(CYGPATH_W) 'fprintf_chk.c'; else $(CYGPATH_W) '$(srcdir)/fprintf_chk.c'; fi`
115+
116 lib_a-fputc.o: fputc.c
117 $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fputc.o `test -f 'fputc.c' || echo '$(srcdir)/'`fputc.c
118
119@@ -948,6 +959,12 @@
120 lib_a-sprintf.obj: sprintf.c
121 $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf.obj `if test -f 'sprintf.c'; then $(CYGPATH_W) 'sprintf.c'; else $(CYGPATH_W) '$(srcdir)/sprintf.c'; fi`
122
123+lib_a-sprintf_chk.o: sprintf_chk.c
124+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf_chk.o `test -f 'sprintf_chk.c' || echo '$(srcdir)/'`sprintf_chk.c
125+
126+lib_a-sprintf_chk.obj: sprintf_chk.c
127+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf_chk.obj `if test -f 'sprintf_chk.c'; then $(CYGPATH_W) 'sprintf_chk.c'; else $(CYGPATH_W) '$(srcdir)/sprintf_chk.c'; fi`
128+
129 lib_a-sscanf.o: sscanf.c
130 $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sscanf.o `test -f 'sscanf.c' || echo '$(srcdir)/'`sscanf.c
131
132--- a/newlib/libc/stdio/sprintf_chk.c 1969-12-31 19:00:00.000000000 -0500
133+++ b/newlib/libc/stdio/sprintf_chk.c 2009-02-26 19:02:26.000000000 -0500
134@@ -0,0 +1,21 @@
135+#include <stdarg.h>
136+#include <stdio.h>
137+
138+/*
139+ * Stub implementation of __sprintf_chk adapted from glibc 2.7. This
140+ * doesn't actually implement any buffer overflow protection. It just makes
141+ * the linker happy :)
142+*/
143+int
144+__sprintf_chk (char *s, int flags, size_t slen, const char *format, ...)
145+{
146+ va_list arg;
147+ int done;
148+
149+ va_start (arg, format);
150+ done = vsprintf (s, format, arg);
151+ va_end (arg);
152+
153+ return done;
154+}
155+
diff --git a/recipes-extended/xen/files/newlib-stdint-size_max-fix-from-1.17.0.patch b/recipes-extended/xen/files/newlib-stdint-size_max-fix-from-1.17.0.patch
new file mode 100644
index 00000000..3610d646
--- /dev/null
+++ b/recipes-extended/xen/files/newlib-stdint-size_max-fix-from-1.17.0.patch
@@ -0,0 +1,16 @@
1--- a/newlib/libc/include/stdint.h.orig 2006-08-17 00:39:43.000000000 +0300
2+++ b/newlib/libc/include/stdint.h 2009-08-25 17:33:23.000000000 +0300
3@@ -348,8 +348,11 @@
4 #endif
5
6 /* This must match size_t in stddef.h, currently long unsigned int */
7-#define SIZE_MIN (-__STDINT_EXP(LONG_MAX) - 1L)
8-#define SIZE_MAX __STDINT_EXP(LONG_MAX)
9+#ifdef __SIZE_MAX__
10+#define SIZE_MAX __SIZE_MAX__
11+#else
12+#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)
13+#endif
14
15 /* This must match sig_atomic_t in <signal.h> (currently int) */
16 #define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1)
diff --git a/recipes-extended/xen/files/newlib.patch b/recipes-extended/xen/files/newlib.patch
new file mode 100644
index 00000000..dbf409a2
--- /dev/null
+++ b/recipes-extended/xen/files/newlib.patch
@@ -0,0 +1,727 @@
1There is a mix between longs and long longs.
2
3Index: newlib/libc/include/inttypes.h
4===================================================================
5RCS file: /cvs/src/src/newlib/libc/include/inttypes.h,v
6retrieving revision 1.3
7diff -u -p -r1.3 inttypes.h
8--- a/newlib/libc/include/inttypes.h 16 Dec 2005 19:03:12 -0000 1.3
9+++ b/newlib/libc/include/inttypes.h 8 Nov 2007 16:32:44 -0000
10@@ -163,12 +163,12 @@
11
12
13 /* 64-bit types */
14-#if __have_longlong64
15-#define __PRI64(x) __STRINGIFY(ll##x)
16-#define __SCN64(x) __STRINGIFY(ll##x)
17-#elif __have_long64
18+#if __have_long64
19 #define __PRI64(x) __STRINGIFY(l##x)
20 #define __SCN64(x) __STRINGIFY(l##x)
21+#elif __have_longlong64
22+#define __PRI64(x) __STRINGIFY(ll##x)
23+#define __SCN64(x) __STRINGIFY(ll##x)
24 #else
25 #define __PRI64(x) __STRINGIFY(x)
26 #define __SCN64(x) __STRINGIFY(x)
27@@ -217,12 +217,12 @@
28 #endif
29
30 /* max-bit types */
31-#if __have_longlong64
32-#define __PRIMAX(x) __STRINGIFY(ll##x)
33-#define __SCNMAX(x) __STRINGIFY(ll##x)
34-#elif __have_long64
35+#if __have_long64
36 #define __PRIMAX(x) __STRINGIFY(l##x)
37 #define __SCNMAX(x) __STRINGIFY(l##x)
38+#elif __have_longlong64
39+#define __PRIMAX(x) __STRINGIFY(ll##x)
40+#define __SCNMAX(x) __STRINGIFY(ll##x)
41 #else
42 #define __PRIMAX(x) __STRINGIFY(x)
43 #define __SCNMAX(x) __STRINGIFY(x)
44@@ -242,12 +242,12 @@
45 #define SCNxMAX __SCNMAX(x)
46
47 /* ptr types */
48-#if __have_longlong64
49-#define __PRIPTR(x) __STRINGIFY(ll##x)
50-#define __SCNPTR(x) __STRINGIFY(ll##x)
51-#elif __have_long64
52+#if __have_long64
53 #define __PRIPTR(x) __STRINGIFY(l##x)
54 #define __SCNPTR(x) __STRINGIFY(l##x)
55+#elif __have_longlong64
56+#define __PRIPTR(x) __STRINGIFY(ll##x)
57+#define __SCNPTR(x) __STRINGIFY(ll##x)
58 #else
59 #define __PRIPTR(x) __STRINGIFY(x)
60 #define __SCNPTR(x) __STRINGIFY(x)
61
62We don't want u?int32_t to be long as our code assume in a lot of places to be
63int.
64
65Index: newlib/libc/include/stdint.h
66===================================================================
67RCS file: /cvs/src/src/newlib/libc/include/stdint.h,v
68retrieving revision 1.10
69diff -u -p -r1.10 stdint.h
70--- a/newlib/libc/include/stdint.h 16 Aug 2006 21:39:43 -0000 1.10
71+++ b/newlib/libc/include/stdint.h 12 Feb 2008 13:07:52 -0000
72@@ -38,7 +38,7 @@ extern "C" {
73 #if __STDINT_EXP(LONG_MAX) > 0x7fffffff
74 #define __have_long64 1
75 #elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
76-#define __have_long32 1
77+/* #define __have_long32 1 */
78 #endif
79
80 #if __STDINT_EXP(SCHAR_MAX) == 0x7f
81
82Define the basic ia64 jump buffer
83
84Index: newlib/libc/include/sys/config.h
85===================================================================
86RCS file: /cvs/src/src/newlib/libc/include/sys/config.h,v
87retrieving revision 1.47
88diff -u -p -r1.47 config.h
89--- a/newlib/libc/include/sys/config.h 15 Mar 2007 21:32:12 -0000 1.47
90+++ b/newlib/libc/include/sys/config.h 8 Nov 2007 16:32:44 -0000
91@@ -71,6 +71,10 @@
92 #endif
93 #endif
94
95+#ifndef __DYNAMIC_REENT__
96+#define __DYNAMIC_REENT__
97+#endif
98+
99 #ifdef __mn10200__
100 #define __SMALL_BITFIELDS
101 #endif
102
103Dynamic pointer to our reentrancy zone
104
105Index: newlib/libc/reent/getreent.c
106===================================================================
107RCS file: /cvs/src/src/newlib/libc/reent/getreent.c,v
108retrieving revision 1.2
109diff -u -p -r1.2 getreent.c
110--- a/newlib/libc/reent/getreent.c 7 Sep 2007 00:45:55 -0000 1.2
111+++ b/newlib/libc/reent/getreent.c 8 Nov 2007 16:32:44 -0000
112@@ -3,12 +3,20 @@
113 #include <_ansi.h>
114 #include <reent.h>
115
116+#define weak_alias(name, aliasname) \
117+ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
118+
119 #ifdef __getreent
120 #undef __getreent
121 #endif
122+#ifdef __libc_getreent
123+#undef __libc_getreent
124+#endif
125
126 struct _reent *
127-_DEFUN_VOID(__getreent)
128+__libc_getreent (void)
129 {
130 return _impure_ptr;
131 }
132+weak_alias(__libc_getreent,__getreent)
133+
134
135We can't provide a red zone in mini-os.
136
137Index: newlib/libc/machine/x86_64/memcpy.S
138===================================================================
139RCS file: /cvs/src/src/newlib/libc/machine/x86_64/memcpy.S,v
140retrieving revision 1.1
141diff -u -p -r1.1 memcpy.S
142--- a/newlib/libc/machine/x86_64/memcpy.S 28 Aug 2007 21:56:49 -0000 1.1
143+++ b/newlib/libc/machine/x86_64/memcpy.S 8 Nov 2007 16:32:44 -0000
144@@ -30,10 +30,18 @@ quadword_aligned:
145 cmpq $256, rdx
146 jb quadword_copy
147
148+#if 1
149+ subq $32, rsp
150+ movq rax, 24 (rsp)
151+ movq r12, 16 (rsp)
152+ movq r13, 8 (rsp)
153+ movq r14, 0 (rsp)
154+#else
155 movq rax, -8 (rsp)
156 movq r12, -16 (rsp)
157 movq r13, -24 (rsp)
158 movq r14, -32 (rsp)
159+#endif
160
161 movq rdx, rcx /* Copy 128 bytes at a time with minimum cache polution */
162 shrq $7, rcx
163@@ -89,10 +97,18 @@ loop:
164 movq rdx, rcx
165 andq $127, rcx
166 rep movsb
167+#if 1
168+ movq 24 (rsp), rax
169+ movq 16 (rsp), r12
170+ movq 8 (rsp), r13
171+ movq 0 (rsp), r14
172+ addq $32, rsp
173+#else
174 movq -8 (rsp), rax
175 movq -16 (rsp), r12
176 movq -24 (rsp), r13
177 movq -32 (rsp), r14
178+#endif
179 ret
180
181
182--- a/newlib/libc/machine/x86_64/x86_64mach.h.orig 2008-07-11 14:57:23.062269000 +0100
183+++ b/newlib/libc/machine/x86_64/x86_64mach.h 2008-07-11 14:58:01.262503000 +0100
184@@ -22,81 +22,81 @@
185
186 #define REG(x) CONCAT1(__REG_PREFIX__, x)
187
188-#define rax REG(rax)
189-#define rbx REG(rbx)
190-#define rcx REG(rcx)
191-#define rdx REG(rdx)
192-#define rsi REG(rsi)
193-#define rdi REG(rdi)
194-#define rbp REG(rbp)
195-#define rsp REG(rsp)
196-
197-#define r8 REG(r8)
198-#define r9 REG(r9)
199-#define r10 REG(r10)
200-#define r11 REG(r11)
201-#define r12 REG(r12)
202-#define r13 REG(r13)
203-#define r14 REG(r14)
204-#define r15 REG(r15)
205-
206-#define eax REG(eax)
207-#define ebx REG(ebx)
208-#define ecx REG(ecx)
209-#define edx REG(edx)
210-#define esi REG(esi)
211-#define edi REG(edi)
212-#define ebp REG(ebp)
213-#define esp REG(esp)
214-
215-#define st0 REG(st)
216-#define st1 REG(st(1))
217-#define st2 REG(st(2))
218-#define st3 REG(st(3))
219-#define st4 REG(st(4))
220-#define st5 REG(st(5))
221-#define st6 REG(st(6))
222-#define st7 REG(st(7))
223-
224-#define ax REG(ax)
225-#define bx REG(bx)
226-#define cx REG(cx)
227-#define dx REG(dx)
228-
229-#define ah REG(ah)
230-#define bh REG(bh)
231-#define ch REG(ch)
232-#define dh REG(dh)
233-
234-#define al REG(al)
235-#define bl REG(bl)
236-#define cl REG(cl)
237-#define dl REG(dl)
238-
239-#define sil REG(sil)
240-
241-#define mm1 REG(mm1)
242-#define mm2 REG(mm2)
243-#define mm3 REG(mm3)
244-#define mm4 REG(mm4)
245-#define mm5 REG(mm5)
246-#define mm6 REG(mm6)
247-#define mm7 REG(mm7)
248-
249-#define xmm0 REG(xmm0)
250-#define xmm1 REG(xmm1)
251-#define xmm2 REG(xmm2)
252-#define xmm3 REG(xmm3)
253-#define xmm4 REG(xmm4)
254-#define xmm5 REG(xmm5)
255-#define xmm6 REG(xmm6)
256-#define xmm7 REG(xmm7)
257-
258-#define cr0 REG(cr0)
259-#define cr1 REG(cr1)
260-#define cr2 REG(cr2)
261-#define cr3 REG(cr3)
262-#define cr4 REG(cr4)
263+#define rax %rax
264+#define rbx %rbx
265+#define rcx %rcx
266+#define rdx %rdx
267+#define rsi %rsi
268+#define rdi %rdi
269+#define rbp %rbp
270+#define rsp %rsp
271+
272+#define r8 %r8
273+#define r9 %r9
274+#define r10 %r10
275+#define r11 %r11
276+#define r12 %r12
277+#define r13 %r13
278+#define r14 %r14
279+#define r15 %r15
280+
281+#define eax %eax
282+#define ebx %ebx
283+#define ecx %ecx
284+#define edx %edx
285+#define esi %esi
286+#define edi %edi
287+#define ebp %ebp
288+#define esp %esp
289+
290+#define st0 %st
291+#define st1 %st(1)
292+#define st2 %st(2)
293+#define st3 %st(3)
294+#define st4 %st(4)
295+#define st5 %st(5)
296+#define st6 %st(6)
297+#define st7 %st(7)
298+
299+#define ax %ax
300+#define bx %bx
301+#define cx %cx
302+#define dx %dx
303+
304+#define ah %ah
305+#define bh %bh
306+#define ch %ch
307+#define dh %dh
308+
309+#define al %al
310+#define bl %bl
311+#define cl %cl
312+#define dl %dl
313+
314+#define sil %sil
315+
316+#define mm1 %mm1
317+#define mm2 %mm2
318+#define mm3 %mm3
319+#define mm4 %mm4
320+#define mm5 %mm5
321+#define mm6 %mm6
322+#define mm7 %mm7
323+
324+#define xmm0 %xmm0
325+#define xmm1 %xmm1
326+#define xmm2 %xmm2
327+#define xmm3 %xmm3
328+#define xmm4 %xmm4
329+#define xmm5 %xmm5
330+#define xmm6 %xmm6
331+#define xmm7 %xmm7
332+
333+#define cr0 %cr0
334+#define cr1 %cr1
335+#define cr2 %cr2
336+#define cr3 %cr3
337+#define cr4 %cr4
338
339 #ifdef _I386MACH_NEED_SOTYPE_FUNCTION
340 #define SOTYPE_FUNCTION(sym) .type SYM(sym),@function
341--- a/newlib/libc/machine/x86_64/memcpy.S.orig 2008-07-11 15:12:27.494693000 +0100
342+++ b/newlib/libc/machine/x86_64/memcpy.S 2008-07-11 15:12:29.448706000 +0100
343@@ -60,14 +60,14 @@
344 movq 48 (rsi), r13
345 movq 56 (rsi), r14
346
347- movntiq rax, (rdi)
348- movntiq r8 , 8 (rdi)
349- movntiq r9 , 16 (rdi)
350- movntiq r10, 24 (rdi)
351- movntiq r11, 32 (rdi)
352- movntiq r12, 40 (rdi)
353- movntiq r13, 48 (rdi)
354- movntiq r14, 56 (rdi)
355+ movnti rax, (rdi)
356+ movnti r8 , 8 (rdi)
357+ movnti r9 , 16 (rdi)
358+ movnti r10, 24 (rdi)
359+ movnti r11, 32 (rdi)
360+ movnti r12, 40 (rdi)
361+ movnti r13, 48 (rdi)
362+ movnti r14, 56 (rdi)
363
364 movq 64 (rsi), rax
365 movq 72 (rsi), r8
366@@ -78,14 +78,14 @@
367 movq 112 (rsi), r13
368 movq 120 (rsi), r14
369
370- movntiq rax, 64 (rdi)
371- movntiq r8 , 72 (rdi)
372- movntiq r9 , 80 (rdi)
373- movntiq r10, 88 (rdi)
374- movntiq r11, 96 (rdi)
375- movntiq r12, 104 (rdi)
376- movntiq r13, 112 (rdi)
377- movntiq r14, 120 (rdi)
378+ movnti rax, 64 (rdi)
379+ movnti r8 , 72 (rdi)
380+ movnti r9 , 80 (rdi)
381+ movnti r10, 88 (rdi)
382+ movnti r11, 96 (rdi)
383+ movnti r12, 104 (rdi)
384+ movnti r13, 112 (rdi)
385+ movnti r14, 120 (rdi)
386
387 leaq 128 (rsi), rsi
388 leaq 128 (rdi), rdi
389--- a/newlib/libc/machine/i386/i386mach.h 2000-08-28 18:50:06.000000000 +0100
390+++ b/newlib/libc/machine/i386/i386mach.h 2008-07-11 15:17:13.874409000 +0100
391@@ -27,46 +27,46 @@
392
393 #define REG(x) CONCAT1(__REG_PREFIX__, x)
394
395-#define eax REG(eax)
396-#define ebx REG(ebx)
397-#define ecx REG(ecx)
398-#define edx REG(edx)
399-#define esi REG(esi)
400-#define edi REG(edi)
401-#define ebp REG(ebp)
402-#define esp REG(esp)
403-
404-#define st0 REG(st)
405-#define st1 REG(st(1))
406-#define st2 REG(st(2))
407-#define st3 REG(st(3))
408-#define st4 REG(st(4))
409-#define st5 REG(st(5))
410-#define st6 REG(st(6))
411-#define st7 REG(st(7))
412-
413-#define ax REG(ax)
414-#define bx REG(bx)
415-#define cx REG(cx)
416-#define dx REG(dx)
417-
418-#define ah REG(ah)
419-#define bh REG(bh)
420-#define ch REG(ch)
421-#define dh REG(dh)
422-
423-#define al REG(al)
424-#define bl REG(bl)
425-#define cl REG(cl)
426-#define dl REG(dl)
427-
428-#define mm1 REG(mm1)
429-#define mm2 REG(mm2)
430-#define mm3 REG(mm3)
431-#define mm4 REG(mm4)
432-#define mm5 REG(mm5)
433-#define mm6 REG(mm6)
434-#define mm7 REG(mm7)
435+#define eax %eax
436+#define ebx %ebx
437+#define ecx %ecx
438+#define edx %edx
439+#define esi %esi
440+#define edi %edi
441+#define ebp %ebp
442+#define esp %esp
443+
444+#define st0 %st
445+#define st1 %st(1)
446+#define st2 %st(2)
447+#define st3 %st(3)
448+#define st4 %st(4)
449+#define st5 %st(5)
450+#define st6 %st(6)
451+#define st7 %st(7)
452+
453+#define ax %ax
454+#define bx %bx
455+#define cx %cx
456+#define dx %dx
457+
458+#define ah %ah
459+#define bh %bh
460+#define ch %ch
461+#define dh %dh
462+
463+#define al %al
464+#define bl %bl
465+#define cl %cl
466+#define dl %dl
467+
468+#define mm1 %mm1
469+#define mm2 %mm2
470+#define mm3 %mm3
471+#define mm4 %mm4
472+#define mm5 %mm5
473+#define mm6 %mm6
474+#define mm7 %mm7
475
476 #ifdef _I386MACH_NEED_SOTYPE_FUNCTION
477 #define SOTYPE_FUNCTION(sym) .type SYM(sym),@function
478--- a/newlib/libc/machine/x86_64/memset.S 2007-08-28 22:56:49.000000000 +0100
479+++ b/newlib/libc/machine/x86_64/memset.S 2008-07-11 15:16:59.098320000 +0100
480@@ -40,22 +40,22 @@
481
482 .p2align 4
483 loop:
484- movntiq rax, (rdi)
485- movntiq rax, 8 (rdi)
486- movntiq rax, 16 (rdi)
487- movntiq rax, 24 (rdi)
488- movntiq rax, 32 (rdi)
489- movntiq rax, 40 (rdi)
490- movntiq rax, 48 (rdi)
491- movntiq rax, 56 (rdi)
492- movntiq rax, 64 (rdi)
493- movntiq rax, 72 (rdi)
494- movntiq rax, 80 (rdi)
495- movntiq rax, 88 (rdi)
496- movntiq rax, 96 (rdi)
497- movntiq rax, 104 (rdi)
498- movntiq rax, 112 (rdi)
499- movntiq rax, 120 (rdi)
500+ movnti rax, (rdi)
501+ movnti rax, 8 (rdi)
502+ movnti rax, 16 (rdi)
503+ movnti rax, 24 (rdi)
504+ movnti rax, 32 (rdi)
505+ movnti rax, 40 (rdi)
506+ movnti rax, 48 (rdi)
507+ movnti rax, 56 (rdi)
508+ movnti rax, 64 (rdi)
509+ movnti rax, 72 (rdi)
510+ movnti rax, 80 (rdi)
511+ movnti rax, 88 (rdi)
512+ movnti rax, 96 (rdi)
513+ movnti rax, 104 (rdi)
514+ movnti rax, 112 (rdi)
515+ movnti rax, 120 (rdi)
516
517 leaq 128 (rdi), rdi
518
519--- a/newlib/libm/machine/i386/i386mach.h.orig 2008-07-11 15:30:37.367227000 +0100
520+++ b/newlib/libm/machine/i386/i386mach.h 2008-07-11 15:30:55.232337000 +0100
521@@ -27,46 +27,46 @@
522
523 #define REG(x) CONCAT1(__REG_PREFIX__, x)
524
525-#define eax REG(eax)
526-#define ebx REG(ebx)
527-#define ecx REG(ecx)
528-#define edx REG(edx)
529-#define esi REG(esi)
530-#define edi REG(edi)
531-#define ebp REG(ebp)
532-#define esp REG(esp)
533-
534-#define st0 REG(st)
535-#define st1 REG(st(1))
536-#define st2 REG(st(2))
537-#define st3 REG(st(3))
538-#define st4 REG(st(4))
539-#define st5 REG(st(5))
540-#define st6 REG(st(6))
541-#define st7 REG(st(7))
542-
543-#define ax REG(ax)
544-#define bx REG(bx)
545-#define cx REG(cx)
546-#define dx REG(dx)
547-
548-#define ah REG(ah)
549-#define bh REG(bh)
550-#define ch REG(ch)
551-#define dh REG(dh)
552-
553-#define al REG(al)
554-#define bl REG(bl)
555-#define cl REG(cl)
556-#define dl REG(dl)
557-
558-#define mm1 REG(mm1)
559-#define mm2 REG(mm2)
560-#define mm3 REG(mm3)
561-#define mm4 REG(mm4)
562-#define mm5 REG(mm5)
563-#define mm6 REG(mm6)
564-#define mm7 REG(mm7)
565+#define eax %eax
566+#define ebx %ebx
567+#define ecx %ecx
568+#define edx %edx
569+#define esi %esi
570+#define edi %edi
571+#define ebp %ebp
572+#define esp %esp
573+
574+#define st0 %st
575+#define st1 %st(1)
576+#define st2 %st(2)
577+#define st3 %st(3)
578+#define st4 %st(4)
579+#define st5 %st(5)
580+#define st6 %st(6)
581+#define st7 %st(7)
582+
583+#define ax %ax
584+#define bx %bx
585+#define cx %cx
586+#define dx %dx
587+
588+#define ah %ah
589+#define bh %bh
590+#define ch %ch
591+#define dh %dh
592+
593+#define al %al
594+#define bl %bl
595+#define cl %cl
596+#define dl %dl
597+
598+#define mm1 %mm1
599+#define mm2 %mm2
600+#define mm3 %mm3
601+#define mm4 %mm4
602+#define mm5 %mm5
603+#define mm6 %mm6
604+#define mm7 %mm7
605
606 #ifdef _I386MACH_NEED_SOTYPE_FUNCTION
607 #define SOTYPE_FUNCTION(sym) .type SYM(sym),@function
608
609
610We want to have a 64bit offsets libc even on 32bit platforms.
611
612--- ./newlib/configure.host.orig 2008-08-07 16:01:17.801946000 +0100
613+++ ./newlib/configure.host 2008-08-07 16:01:34.181064000 +0100
614@@ -317,6 +317,8 @@
615 oext=lo
616 lpfx=
617 aext=la ;;
618+ i[34567]86-xen-elf)
619+ stdio64_dir=stdio64 ;;
620 *) ;; #shared library not supported for ${host}
621 esac
622
623--- a/newlib/libc/include/sys/_types.h.orig 2008-08-07 15:22:44.925008000 +0100
624+++ b/newlib/libc/include/sys/_types.h 2008-08-07 15:22:50.824044000 +0100
625@@ -13,8 +13,12 @@
626 #include <sys/lock.h>
627
628 #ifndef __off_t_defined
629+#ifdef __MINIOS__
630+typedef long long _off_t;
631+#else
632 typedef long _off_t;
633 #endif
634+#endif
635
636 #if defined(__rtems__)
637 /* device numbers are 32-bit major and and 32-bit minor */
638--- ./newlib/libc/include/sys/config.h.orig 2008-08-07 14:43:25.915866000 +0100
639+++ ./newlib/libc/include/sys/config.h 2008-08-07 14:44:13.508154000 +0100
640@@ -69,6 +69,10 @@
641 /* we use some glibc header files so turn on glibc large file feature */
642 #define _LARGEFILE64_SOURCE 1
643 #endif
644+#ifdef __MINIOS__
645+#define __LARGE64_FILES 1
646+#define _LARGEFILE64_SOURCE 1
647+#endif
648 #endif
649
650 #ifndef __DYNAMIC_REENT__
651--- ./newlib/libc/include/sys/_default_fcntl.h.orig 2008-08-07 15:08:22.377836000 +0100
652+++ ./newlib/libc/include/sys/_default_fcntl.h 2008-08-07 15:08:31.651890000 +0100
653@@ -170,7 +170,11 @@
654 /* Provide _<systemcall> prototypes for functions provided by some versions
655 of newlib. */
656 #ifdef _COMPILING_NEWLIB
657-extern int _open _PARAMS ((const char *, int, ...));
658+extern int _open _PARAMS ((const char *, int, ...))
659+#ifdef __MINIOS__
660+ asm("open64")
661+#endif
662+ ;
663 extern int _fcntl _PARAMS ((int, int, ...));
664 #ifdef __LARGE64_FILES
665 extern int _open64 _PARAMS ((const char *, int, ...));
666--- ./newlib/libc/include/sys/unistd.h.orig 2008-08-07 15:09:36.449280000 +0100
667+++ ./newlib/libc/include/sys/unistd.h 2008-08-07 15:09:51.210370000 +0100
668@@ -101,7 +101,11 @@
669 int _EXFUN(link, (const char *__path1, const char *__path2 ));
670 int _EXFUN(nice, (int __nice_value ));
671 #if !defined(__INSIDE_CYGWIN__)
672-off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
673+off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ))
674+#ifdef __MINIOS__
675+ asm("lseek64")
676+#endif
677+ ;
678 #endif
679 #if defined(__SPU__)
680 #define F_ULOCK 0
681--- ./newlib/libc/include/sys/stat.h.orig 2008-08-07 16:08:50.495116000 +0100
682+++ ./newlib/libc/include/sys/stat.h 2008-08-07 16:10:21.799753000 +0100
683@@ -49,6 +49,9 @@
684 long st_spare4[2];
685 #endif
686 };
687+#ifdef __MINIOS__
688+#define stat64 stat
689+#endif
690 #endif
691
692 #define _IFMT 0170000 /* type of file */
693@@ -132,7 +135,11 @@
694 /* Provide prototypes for most of the _<systemcall> names that are
695 provided in newlib for some compilers. */
696 #ifdef _COMPILING_NEWLIB
697-int _EXFUN(_fstat,( int __fd, struct stat *__sbuf ));
698+int _EXFUN(_fstat,( int __fd, struct stat *__sbuf ))
699+#ifdef __MINIOS__
700+ asm("fstat64")
701+#endif
702+ ;
703 int _EXFUN(_stat,( const char *__path, struct stat *__sbuf ));
704 #ifdef __LARGE64_FILES
705 struct stat64;
706--- ./newlib/libc/include/_syslist.h.orig 2008-08-07 16:24:19.122605000 +0100
707+++ ./newlib/libc/include/_syslist.h 2008-08-07 16:24:21.548628000 +0100
708@@ -14,6 +14,7 @@
709 #define _kill kill
710 #define _link link
711 #define _lseek lseek
712+#define _lseek64 lseek64
713 #define _open open
714 #define _read read
715 #define _sbrk sbrk
716--- a/newlib/libc/include/reent.h.orig 2008-08-07 16:28:49.846502000 +0100
717+++ b/newlib/libc/include/reent.h 2008-08-07 16:29:02.096586000 +0100
718@@ -87,6 +87,9 @@
719 #if defined(__CYGWIN__) && defined(_COMPILING_NEWLIB)
720 #define stat64 __stat64
721 #endif
722+#if defined(__MINIOS__)
723+#define stat64 stat
724+#endif
725
726 struct stat64;
727
diff --git a/recipes-extended/xen/newlib.inc b/recipes-extended/xen/newlib.inc
new file mode 100644
index 00000000..1fdbd0aa
--- /dev/null
+++ b/recipes-extended/xen/newlib.inc
@@ -0,0 +1,64 @@
1# Copyright (C) 2017 Kurt Bodiker <kurt.bodiker@braintrust-us.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4require stubdom.inc
5
6CPPFLAGS_INCLUDE_DIR = "-isystem `${HOST_PREFIX}gcc -print-file-name=include`"
7STUBDOM_CFLAGS += "-D_I386MACH_ALLOW_HW_INTERRUPTS"
8
9export ac_cv_path_CC_FOR_TARGET="${HOST_PREFIX}gcc --sysroot=${RECIPE_SYSROOT} ${STUBDOM_CPPFLAGS} ${STUBDOM_CFLAGS}"
10export CC_FOR_TARGET="${HOST_PREFIX}gcc --sysroot=${RECIPE_SYSROOT} ${STUBDOM_CPPFLAGS} ${STUBDOM_CFLAGS}"
11
12export ac_cv_path_CXX_FOR_TARGET="${HOST_PREFIX}g++ --sysroot=${RECIPE_SYSROOT}"
13export CXX_FOR_TARGET="${HOST_PREFIX}g++ --sysroot=${RECIPE_SYSROOT}"
14
15export ac_cv_path_CPP_FOR_TARGET="${HOST_PREFIX}gcc -E --sysroot=${RECIPE_SYSROOT}"
16export CPP_FOR_TARGET="${HOST_PREFIX}gcc -E --sysroot=${RECIPE_SYSROOT}"
17
18export ac_cv_path_LD_FOR_TARGET="${HOST_PREFIX}ld --sysroot=${RECIPE_SYSROOT}"
19export LD_FOR_TARGET="${HOST_PREFIX}ld --sysroot=${RECIPE_SYSROOT}"
20
21export ac_cv_path_AS_FOR_TARGET="${HOST_PREFIX}as"
22export AS_FOR_TARGET="${HOST_PREFIX}as"
23
24export ac_cv_path_AR_FOR_TARGET="${HOST_PREFIX}ar"
25export AR_FOR_TARGET="${HOST_PREFIX}ar"
26
27export ac_cv_path_NM_FOR_TARGET="${HOST_PREFIX}nm"
28export NM_FOR_TARGET="${HOST_PREFIX}nm"
29
30export ac_cv_path_RANLIB_FOR_TARGET="${HOST_PREFIX}ranlib"
31export RANLIB_FOR_TARGET="${HOST_PREFIX}ranlib"
32
33export ac_cv_path_OBJDUMP_FOR_TARGET="${HOST_PREFIX}objdump"
34export OBJDUMP_FOR_TARGET="${HOST_PREFIX}objdump"
35
36export ac_cv_path_OBJCOPY_FOR_TARGET="${HOST_PREFIX}objcopy"
37export OBJCOPY_FOR_TARGET="${HOST_PREFIX}objcopy"
38
39export ac_cv_path_STRIP_FOR_TARGET="${HOST_PREFIX}strip"
40export STRIP_FOR_TARGET="${HOST_PREFIX}strip"
41
42export ac_cv_path_STRINGS_FOR_TARGET="${HOST_PREFIX}strings"
43export STRINGS_FOR_TARGET="${HOST_PREFIX}strings"
44
45export ac_cv_path_READELF_FOR_TARGET="${HOST_PREFIX}readelf"
46export READELF_FOR_TARGET="${HOST_PREFIX}readelf"
47
48do_configure() {
49 ${S}/configure --verbose --prefix=${prefix} --target=${GNU_TARGET_ARCH}-xen-elf --enable-newlib-io-long-long --disable-multilib
50 find ${S} -type f | xargs perl -i.bak -pe 's/\b_(tzname|daylight|timezone)\b/$1/g'
51}
52
53do_compile() {
54 ${MAKE}
55}
56
57do_install() {
58 ${MAKE} DESTDIR=${D} install
59 rm -rf ${D}/cross-root-${GNU_TARGET_ARCH}/share
60 rm -rf ${D}/cross-root-${GNU_TARGET_ARCH}/info
61 install -m 644 `${HOST_PREFIX}gcc -print-file-name=include`/stdarg.h -t ${D}/${includedir}
62 install -m 644 `${HOST_PREFIX}gcc -print-file-name=include`/stddef.h -t ${D}/${includedir}
63 install -m 644 `${HOST_PREFIX}gcc -print-file-name=include`/stdbool.h -t ${D}/${includedir}
64}
diff --git a/recipes-extended/xen/newlib_1.16.0.bb b/recipes-extended/xen/newlib_1.16.0.bb
new file mode 100644
index 00000000..60672bea
--- /dev/null
+++ b/recipes-extended/xen/newlib_1.16.0.bb
@@ -0,0 +1,21 @@
1# Copyright (C) 2017 Kurt Bodiker <kurt.bodiker@braintrust-us.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4DESCRIPTION = "Newlib is a C library intended for use on embedded systems."
5HOMEPAGE = "http://sourceware.org/newlib"
6LICENSE = "GPLv2 & LGPLv3 & GPLv3 & LGPLv2"
7LIC_FILES_CHKSUM = "file://COPYING.NEWLIB;md5=950f50b290e8fcf7a2d3fff61775de9b"
8
9# this is the hash of version tag 1_16_0
10SRCREV_newlib = "07b4b67a88f386ce4716a14e0ff2c2bce992b985"
11SRC_URI = "\
12 git://sourceware.org/git/newlib-cygwin.git;protocol=git;nobranch=1;destsuffix=newlib;name=newlib \
13 file://newlib.patch \
14 file://newlib-chk.patch \
15 file://newlib-stdint-size_max-fix-from-1.17.0.patch \
16"
17
18S="${WORKDIR}/newlib"
19B="${WORKDIR}/build"
20
21require newlib.inc