blob: c62a9919ad67d482c053b2eb2fe4453458c495ac [file] [log] [blame]
Andrew Geissler84ad7c52020-06-27 00:00:16 -05001From eab8d664224d134b2c4d638d9c6bebb84ae777ad Mon Sep 17 00:00:00 2001
2From: Mahesh Bodapati <mbodapat@xilinx.com>
3Date: Tue, 11 Sep 2018 14:32:20 +0530
4Subject: [PATCH 07/11] [Patch, Microblaze]: newlib port for microblaze m64
5 flag...
6
7Conflicts:
8 libgloss/microblaze/_hw_exception_handler.S
9 libgloss/microblaze/_interrupt_handler.S
10---
11 libgloss/microblaze/_exception_handler.S | 6 +-
12 libgloss/microblaze/_hw_exception_handler.S | 7 +-
13 libgloss/microblaze/_interrupt_handler.S | 7 +-
14 libgloss/microblaze/_program_clean.S | 6 +-
15 libgloss/microblaze/_program_init.S | 6 +-
16 libgloss/microblaze/crt0.S | 53 ++++++++++--
17 libgloss/microblaze/crt1.S | 54 +++++++++++--
18 libgloss/microblaze/crt2.S | 52 ++++++++++--
19 libgloss/microblaze/crt3.S | 32 +++++++-
20 libgloss/microblaze/crt4.S | 37 +++++++--
21 libgloss/microblaze/crtinit.S | 120 ++++++++++++++++++++--------
22 libgloss/microblaze/linux-crt0.S | 60 +++++++++++---
23 libgloss/microblaze/linux-syscalls.S | 15 +++-
24 libgloss/microblaze/pgcrtinit.S | 59 +++++++++++++-
25 libgloss/microblaze/sim-crtinit.S | 31 +++++++
26 libgloss/microblaze/sim-pgcrtinit.S | 31 +++++++
27 newlib/libc/machine/microblaze/longjmp.S | 45 +++++++++--
28 newlib/libc/machine/microblaze/setjmp.S | 33 +++++++-
29 18 files changed, 563 insertions(+), 91 deletions(-)
30
31diff --git a/libgloss/microblaze/_exception_handler.S b/libgloss/microblaze/_exception_handler.S
32index 7a91a78..0fdff3f 100644
33--- a/libgloss/microblaze/_exception_handler.S
34+++ b/libgloss/microblaze/_exception_handler.S
35@@ -30,7 +30,11 @@
36 */
37
38 .text
39- .align 2
40+#ifdef __arch64__
41+ .align 3
42+#else
43+ .align 2
44+#endif
45 .weakext _exception_handler
46 .ent _exception_handler
47 .type _exception_handler, @function
48diff --git a/libgloss/microblaze/_hw_exception_handler.S b/libgloss/microblaze/_hw_exception_handler.S
49index 47df945..b951a63 100644
50--- a/libgloss/microblaze/_hw_exception_handler.S
51+++ b/libgloss/microblaze/_hw_exception_handler.S
52@@ -32,8 +32,11 @@
53 .text
54 .weakext _hw_exception_handler # HW Exception Handler Label
55 .type _hw_exception_handler, %function
56- .align 2
57-
58+#ifdef __arch64__
59+ .align 3
60+#else
61+ .align 2
62+#endif
63 _hw_exception_handler:
64 rted r17, 0
65 nop
66diff --git a/libgloss/microblaze/_interrupt_handler.S b/libgloss/microblaze/_interrupt_handler.S
67index 5bb7329..a0ef92d 100644
68--- a/libgloss/microblaze/_interrupt_handler.S
69+++ b/libgloss/microblaze/_interrupt_handler.S
70@@ -32,8 +32,11 @@
71 .text
72 .weakext _interrupt_handler # Interrupt Handler Label
73 .type _interrupt_handler, %function
74- .align 2
75-
76+#ifdef __arch64__
77+ .align 3
78+#else
79+ .align 2
80+#endif
81 _interrupt_handler:
82 rtid r14, 0
83 nop
84diff --git a/libgloss/microblaze/_program_clean.S b/libgloss/microblaze/_program_clean.S
85index c460594..0d55d8a 100644
86--- a/libgloss/microblaze/_program_clean.S
87+++ b/libgloss/microblaze/_program_clean.S
88@@ -33,7 +33,11 @@
89 #
90
91 .text
92- .align 2
93+#ifdef __arch64__
94+ .align 3
95+#else
96+ .align 2
97+#endif
98 .globl _program_clean
99 .ent _program_clean
100 _program_clean:
101diff --git a/libgloss/microblaze/_program_init.S b/libgloss/microblaze/_program_init.S
102index 0daa42e..862ef78 100644
103--- a/libgloss/microblaze/_program_init.S
104+++ b/libgloss/microblaze/_program_init.S
105@@ -32,7 +32,11 @@
106 # Dummy file to be replaced by LibGen
107
108 .text
109- .align 2
110+#ifdef __arch64__
111+ .align 3
112+#else
113+ .align 2
114+#endif
115 .globl _program_init
116 .ent _program_init
117 _program_init:
118diff --git a/libgloss/microblaze/crt0.S b/libgloss/microblaze/crt0.S
119index 865a8c2..e4df73b 100644
120--- a/libgloss/microblaze/crt0.S
121+++ b/libgloss/microblaze/crt0.S
122@@ -54,7 +54,11 @@
123
124 .globl _start
125 .section .vectors.reset, "ax"
126- .align 2
127+#ifdef __arch64__
128+ .align 3
129+#else
130+ .align 2
131+#endif
132 .ent _start
133 .type _start, @function
134 _start:
135@@ -62,36 +66,64 @@ _start:
136 .end _start
137
138 .section .vectors.sw_exception, "ax"
139+#ifdef __arch64__
140+ .align 3
141+#else
142 .align 2
143+#endif
144 _vector_sw_exception:
145 brai _exception_handler
146
147 .section .vectors.interrupt, "ax"
148+#ifdef __arch64__
149+ .align 3
150+#else
151 .align 2
152+#endif
153+
154 _vector_interrupt:
155 brai _interrupt_handler
156
157 .section .vectors.hw_exception, "ax"
158+#ifdef __arch64__
159+ .align 3
160+#else
161 .align 2
162+#endif
163+
164 _vector_hw_exception:
165 brai _hw_exception_handler
166
167 .section .text
168 .globl _start1
169+#ifdef __arch64__
170+ .align 3
171+#else
172 .align 2
173+#endif
174+
175 .ent _start1
176 .type _start1, @function
177 _start1:
178+#ifdef __arch64__
179+ lli r13, r0, _SDA_BASE_
180+ lli r2, r0, _SDA2_BASE_
181+ lli r1, r0, _stack-32
182+ brealid r15, _crtinit
183+ nop
184+ addlik r5, r3, 0
185+ brealid r15, exit
186+ nop
187+#else
188 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
189 la r2, r0, _SDA2_BASE_
190 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
191-
192 brlid r15, _crtinit /* Initialize BSS and run program */
193 nop
194
195- brlid r15, exit /* Call exit with the return value of main */
196- addik r5, r3, 0
197-
198+ brlid r15, exit /* Call exit with the return value of main */
199+ addik r5, r3, 0
200+#endif
201 /* Control does not reach here */
202 .end _start1
203
204@@ -101,9 +133,18 @@ _start1:
205 Our simple _exit
206 */
207 .globl _exit
208+#ifdef __arch64__
209+ .align 3
210+#else
211 .align 2
212+#endif
213+
214 .ent _exit
215 .type _exit, @function
216 _exit:
217- bri 0
218+#ifdef __arch64__
219+ breai 0
220+#else
221+ bri 0
222+#endif
223 .end _exit
224diff --git a/libgloss/microblaze/crt1.S b/libgloss/microblaze/crt1.S
225index a8bf749..b24eeb5 100644
226--- a/libgloss/microblaze/crt1.S
227+++ b/libgloss/microblaze/crt1.S
228@@ -53,36 +53,67 @@
229
230
231 .section .vectors.sw_exception, "ax"
232- .align 2
233+#ifdef __arch64__
234+ .align 3
235+#else
236+ .align 2
237+#endif
238+
239 _vector_sw_exception:
240 brai _exception_handler
241
242 .section .vectors.interrupt, "ax"
243- .align 2
244+#ifdef __arch64__
245+ .align 3
246+#else
247+ .align 2
248+#endif
249+
250 _vector_interrupt:
251 brai _interrupt_handler
252
253 .section .vectors.hw_exception, "ax"
254- .align 2
255+#ifdef __arch64__
256+ .align 3
257+#else
258+ .align 2
259+#endif
260+
261 _vector_hw_exception:
262 brai _hw_exception_handler
263
264 .section .text
265 .globl _start
266- .align 2
267+#ifdef __arch64__
268+ .align 3
269+#else
270+ .align 2
271+#endif
272+
273 .ent _start
274 .type _start, @function
275 _start:
276+#ifdef __arch64__
277+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
278+ lli r2, r0, _SDA2_BASE_
279+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
280+
281+ brealid r15, _crtinit /* Initialize BSS and run program */
282+ nop
283+ addlik r5, r3, 0
284+ brealid r15, exit
285+ nop
286+#else
287 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
288 la r2, r0, _SDA2_BASE_
289- la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
290+ la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
291
292 brlid r15, _crtinit /* Initialize BSS and run program */
293 nop
294
295 brlid r15, exit /* Call exit with the return value of main */
296 addik r5, r3, 0
297-
298+#endif
299 /* Control does not reach here */
300 .end _start
301
302@@ -92,11 +123,18 @@ _start:
303 Our simple _exit
304 */
305 .globl _exit
306- .align 2
307+#ifdef __arch64__
308+ .align 3
309+#else
310+ .align 2
311+#endif
312 .ent _exit
313 .type _exit, @function
314 _exit:
315+#ifdef __arch64__
316+ addl r3, r0, r5
317+#else
318 add r3, r0, r5
319+#endif
320 brki r16, 0x4 /* Return to hook in XMDSTUB */
321 .end _exit
322-
323diff --git a/libgloss/microblaze/crt2.S b/libgloss/microblaze/crt2.S
324index 34d9f95..ae4c89e 100644
325--- a/libgloss/microblaze/crt2.S
326+++ b/libgloss/microblaze/crt2.S
327@@ -51,26 +51,56 @@
328 */
329
330 .section .vectors.sw_exception, "ax"
331- .align 2
332+#ifdef __arch64__
333+ .align 3
334+#else
335+ .align 2
336+#endif
337+
338 _vector_sw_exception:
339 brai _exception_handler
340
341 .section .vectors.interrupt, "ax"
342- .align 2
343+#ifdef __arch64__
344+ .align 3
345+#else
346+ .align 2
347+#endif
348+
349 _vector_interrupt:
350 brai _interrupt_handler
351
352 .section .vectors.hw_exception, "ax"
353- .align 2
354+#ifdef __arch64__
355+ .align 3
356+#else
357+ .align 2
358+#endif
359+
360 _vector_hw_exception:
361 brai _hw_exception_handler
362
363 .section .text
364 .globl _start
365- .align 2
366+#ifdef __arch64__
367+ .align 3
368+#else
369+ .align 2
370+#endif
371+
372 .ent _start
373 .type _start, @function
374 _start:
375+#ifdef __arch64__
376+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
377+ lli r2, r0, _SDA2_BASE_
378+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
379+ brealid r15, _crtinit /* Initialize BSS and run program */
380+ nop
381+ addlik r5, r3, 0
382+ brealid r15, exit
383+ nop
384+#else
385 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
386 la r2, r0, _SDA2_BASE_
387 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
388@@ -80,7 +110,7 @@ _start:
389
390 brlid r15, exit /* Call exit with the return value of main */
391 addik r5, r3, 0
392-
393+#endif
394 /* Control does not reach here */
395
396 .end _start
397@@ -90,9 +120,17 @@ _start:
398 Our simple _exit
399 */
400 .globl _exit
401- .align 2
402+#ifdef __arch64__
403+ .align 3
404+#else
405+ .align 2
406+#endif
407 .ent _exit
408 .type _exit, @function
409 _exit:
410- bri 0
411+#ifdef __arch64__
412+ breai 0
413+#else
414+ bri 0
415+#endif
416 .end _exit
417diff --git a/libgloss/microblaze/crt3.S b/libgloss/microblaze/crt3.S
418index ebcf207..a8bc783 100644
419--- a/libgloss/microblaze/crt3.S
420+++ b/libgloss/microblaze/crt3.S
421@@ -53,10 +53,26 @@
422
423 .section .text
424 .globl _start
425- .align 2
426+#ifdef __arch64__
427+ .align 3
428+#else
429+ .align 2
430+#endif
431 .ent _start
432 .type _start, @function
433 _start:
434+#ifdef __arch64__
435+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
436+ lli r2, r0, _SDA2_BASE_
437+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
438+
439+ brealid r15, _crtinit /* Initialize BSS and run program */
440+ nop
441+
442+ addlik r5, r3, 0
443+ brealid r15, exit /* Call exit with the return value of main */
444+ nop
445+#else
446 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
447 la r2, r0, _SDA2_BASE_
448 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
449@@ -66,7 +82,7 @@ _start:
450
451 brlid r15, exit /* Call exit with the return value of main */
452 addik r5, r3, 0
453-
454+#endif
455 /* Control does not reach here */
456 .end _start
457
458@@ -76,9 +92,17 @@ _start:
459 Our simple _exit
460 */
461 .globl _exit
462- .align 2
463+#ifdef __arch64__
464+ .align 3
465+#else
466+ .align 2
467+#endif
468 .ent _exit
469 .type _exit, @function
470 _exit:
471- bri 0
472+#ifdef __arch64__
473+ breai 0
474+#else
475+ bri 0
476+#endif
477 .end _exit
478diff --git a/libgloss/microblaze/crt4.S b/libgloss/microblaze/crt4.S
479index 4cf0b01..54ba473 100644
480--- a/libgloss/microblaze/crt4.S
481+++ b/libgloss/microblaze/crt4.S
482@@ -53,10 +53,27 @@
483
484 .section .text
485 .globl _start
486- .align 2
487+#ifdef __arch64__
488+ .align 3
489+#else
490+ .align 2
491+#endif
492+
493 .ent _start
494 .type _start, @function
495 _start:
496+#ifdef __arch64__
497+ lli r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
498+ lli r2, r0, _SDA2_BASE_
499+ lli r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
500+
501+ brealid r15, _crtinit /* Initialize BSS and run program */
502+ nop
503+
504+ addlik r5, r3, 0
505+ brealid r15, exit /* Call exit with the return value of main */
506+ nop
507+#else
508 la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */
509 la r2, r0, _SDA2_BASE_
510 la r1, r0, _stack-32 /* 16 bytes (4 words are needed by crtinit for args and link reg */
511@@ -68,19 +85,27 @@ _start:
512 addik r5, r3, 0
513
514 /* Control does not reach here */
515-
516+#endif
517 .end _start
518
519-
520 /*
521 _exit
522 Our simple _exit
523 */
524 .globl _exit
525- .align 2
526+#ifdef __arch64__
527+ .align 3
528+#else
529+ .align 2
530+#endif
531 .ent _exit
532 .type _exit, @function
533 _exit:
534- brlid r15,elf_process_exit
535- nop
536+#ifdef __arch64__
537+ brealid r15,elf_process_exit
538+ nop
539+#else
540+ brlid r15,elf_process_exit
541+ nop
542+#endif
543 .end _exit
544diff --git a/libgloss/microblaze/crtinit.S b/libgloss/microblaze/crtinit.S
545index 86c6dfc..8541175 100644
546--- a/libgloss/microblaze/crtinit.S
547+++ b/libgloss/microblaze/crtinit.S
548@@ -29,59 +29,115 @@
549 */
550
551 .globl _crtinit
552+#ifdef __arch64__
553+ .align 3
554+#else
555 .align 2
556+#endif
557 .ent _crtinit
558 .type _crtinit, @function
559 _crtinit:
560- addi r1, r1, -40 /* Save Link register */
561- swi r15, r1, 0
562+#ifdef __arch64__
563+ addli r1, r1, -40 /* Save Link register */
564+ sli r15, r1, 0
565
566- addi r6, r0, __sbss_start /* clear SBSS */
567- addi r7, r0, __sbss_end
568- rsub r18, r6, r7
569- blei r18, .Lendsbss
570+ addli r6, r0, __sbss_start /* clear SBSS */
571+ addli r7, r0, __sbss_end
572+ rsubl r18, r6, r7
573+ bealei r18, .Lendsbss
574
575 .Lloopsbss:
576- swi r0, r6, 0
577- addi r6, r6, 4
578- rsub r18, r6, r7
579- bgti r18, .Lloopsbss
580+ sli r0, r6, 0
581+ addli r6, r6, 4
582+ rsubl r18, r6, r7
583+ beagti r18, .Lloopsbss
584 .Lendsbss:
585-
586- addi r6, r0, __bss_start /* clear BSS */
587- addi r7, r0, __bss_end
588- rsub r18, r6, r7
589- blei r18, .Lendbss
590+ addli r6, r0, __bss_start /* clear BSS */
591+ addli r7, r0, __bss_end
592+ rsubl r18, r6, r7
593+ bealei r18, .Lendbss
594 .Lloopbss:
595- swi r0, r6, 0
596- addi r6, r6, 4
597- rsub r18, r6, r7
598- bgti r18, .Lloopbss
599+ sli r0, r6, 0
600+ addli r6, r6, 4
601+ rsubl r18, r6, r7
602+ beagti r18, .Lloopbss
603 .Lendbss:
604
605- brlid r15, _program_init /* Initialize the program */
606+ brealid r15, _program_init /* Initialize the program */
607+ nop
608+ brealid r15, __init /* Invoke language initialization functions */
609+ nop
610+
611+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
612+ addli r7, r0, 0
613+ addli r5, r0, 0
614+ brealid r15, main /* Execute the program */
615 nop
616+ addlik r19, r3, 0 /* Save return value */
617+
618+ brealid r15, __fini /* Invoke language cleanup functions */
619+ nop
620+
621+ brealid r15, _program_clean /* Cleanup the program */
622+ nop
623+
624+ ll r15, r1, r0 /* Return back to CRT */
625+
626+ addlik r3, r19, 0 /* Restore return value */
627+ addli r1, r1, 40
628+ rtsd r15, 8
629+ nop
630+#else
631+ addi r1, r1, -40 /* Save Link register */
632+ swi r15, r1, 0
633+
634+ addi r6, r0, __sbss_start /* clear SBSS */
635+ addi r7, r0, __sbss_end
636+ rsub r18, r6, r7
637+ blei r18, .Lendsbss
638+
639+.Lloopsbss:
640+ swi r0, r6, 0
641+ addi r6, r6, 4
642+ rsub r18, r6, r7
643+ bgti r18, .Lloopsbss
644+.Lendsbss:
645+
646+ addi r6, r0, __bss_start /* clear BSS */
647+ addi r7, r0, __bss_end
648+ rsub r18, r6, r7
649+ blei r18, .Lendbss
650+.Lloopbss:
651+ swi r0, r6, 0
652+ addi r6, r6, 4
653+ rsub r18, r6, r7
654+ bgti r18, .Lloopbss
655+.Lendbss:
656+
657+ brlid r15, _program_init /* Initialize the program */
658+ nop
659
660 brlid r15, __init /* Invoke language initialization functions */
661 nop
662-
663- addi r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
664- addi r7, r0, 0
665- brlid r15, main /* Execute the program */
666- addi r5, r0, 0
667+
668+ addi r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
669+ addi r7, r0, 0
670+ brlid r15, main /* Execute the program */
671+ addi r5, r0, 0
672
673 addik r19, r3, 0 /* Save return value */
674-
675+
676 brlid r15, __fini /* Invoke language cleanup functions */
677 nop
678-
679- brlid r15, _program_clean /* Cleanup the program */
680- nop
681
682- lw r15, r1, r0 /* Return back to CRT */
683+ brlid r15, _program_clean /* Cleanup the program */
684+ nop
685+
686+ lw r15, r1, r0 /* Return back to CRT */
687
688 addik r3, r19, 0 /* Restore return value */
689- rtsd r15, 8
690- addi r1, r1, 40
691+ rtsd r15, 8
692+ addi r1, r1, 40
693+#endif
694 .end _crtinit
695
696diff --git a/libgloss/microblaze/linux-crt0.S b/libgloss/microblaze/linux-crt0.S
697index 8650bb5..503439b 100644
698--- a/libgloss/microblaze/linux-crt0.S
699+++ b/libgloss/microblaze/linux-crt0.S
700@@ -18,26 +18,50 @@
701 .ent _start
702 .type _start, @function
703 _start:
704- la r13, r0, _SDA_BASE_
705- la r2, r0, _SDA2_BASE_
706+#ifdef __arch64__
707+ lli r13, r0, _SDA_BASE_
708+ lli r2, r0, _SDA2_BASE_
709
710- brlid r15, __init
711+ brealid r15, __init
712 nop
713
714- lwi r5, r1, 0
715- addik r6, r1, 4
716+ lli r5, r1, 0
717+ addlik r6, r1, 4
718
719 # Add argc * 4.
720- addk r7, r5, r5
721- addk r7, r7, r7
722+ addlk r7, r5, r5
723+ addlk r7, r7, r7
724
725- brlid r15, main
726 # Now add 4 + r1 (i.e r6) in the delayslot.
727- addk r7, r7, r6
728+ addlk r7, r7, r6
729+ brealid r15, main
730+ nop
731+ addlik r5, r3, 0
732+ brealid r15, exit
733+ nop
734+ .size _start, . - _start
735+#else
736+ la r13, r0, _SDA_BASE_
737+ la r2, r0, _SDA2_BASE_
738+
739+ brlid r15, __init
740+ nop
741+
742+ lwi r5, r1, 0
743+ addik r6, r1, 4
744
745- brlid r15, exit
746+ # Add argc * 4.
747+ addk r7, r5, r5
748+ addk r7, r7, r7
749+
750+ brlid r15, main
751+ # Now add 4 + r1 (i.e r6) in the delayslot.
752+ addk r7, r7, r6
753+
754+ brlid r15, exit
755 addik r5, r3, 0
756- .size _start, . - _start
757+ .size _start, . - _start
758+#endif
759 .end _start
760
761 /* Replacement for the GCC provided crti.S. This one avoids the
762@@ -45,14 +69,28 @@ _start:
763 insn exceptions when running in user-space). */
764 .section .init, "ax"
765 .global __init
766+#ifdef __arch64__
767+ .align 3
768+__init:
769+ addlik r1, r1, -8
770+ sl r15, r0, r1
771+#else
772 .align 2
773 __init:
774 addik r1, r1, -8
775 sw r15, r0, r1
776
777+#endif
778 .section .fini, "ax"
779 .global __fini
780+#ifdef __arch64__
781+ .align 3
782+__fini:
783+ addlik r1, r1, -8
784+ sl r15, r0, r1
785+#else
786 .align 2
787 __fini:
788 addik r1, r1, -8
789 sw r15, r0, r1
790+#endif
791diff --git a/libgloss/microblaze/linux-syscalls.S b/libgloss/microblaze/linux-syscalls.S
792index 506de78..8594f13 100644
793--- a/libgloss/microblaze/linux-syscalls.S
794+++ b/libgloss/microblaze/linux-syscalls.S
795@@ -20,8 +20,9 @@
796 #define GLOBAL(name) .global name; FUNC(name)
797 #define SIZE(name) .size name, .-name
798
799+#ifdef __arch64__
800 # define SYSCALL_BODY(name) \
801- addik r12, r0, SYS_ ## name; \
802+ addlik r12, r0, SYS_ ## name; \
803 brki r14, 8; \
804 rtsd r15, 8; \
805 nop;
806@@ -31,6 +32,18 @@
807 SYSCALL_BODY(name); \
808 SIZE(_ ## name)
809
810+#else
811+# define SYSCALL_BODY(name) \
812+ addik r12, r0, SYS_ ## name; \
813+ brki r14, 8; \
814+ rtsd r15, 8; \
815+ nop;
816+
817+# define SYSCALL(name) \
818+ GLOBAL(_ ## name); \
819+ SYSCALL_BODY(name); \
820+ SIZE(_ ## name)
821+#endif
822 SYSCALL(brk)
823 SYSCALL(exit)
824 SYSCALL(read)
825diff --git a/libgloss/microblaze/pgcrtinit.S b/libgloss/microblaze/pgcrtinit.S
826index 2593082..638dbd3 100644
827--- a/libgloss/microblaze/pgcrtinit.S
828+++ b/libgloss/microblaze/pgcrtinit.S
829@@ -29,10 +29,66 @@
830
831
832 .globl _crtinit
833+#ifdef __arch64__
834+ .align 3
835+#else
836 .align 2
837+#endif
838 .ent _crtinit
839
840 _crtinit:
841+#ifdef __arch64__
842+
843+ addli r1, r1, -40 /* Save Link register */
844+ sli r15, r1, 0
845+
846+ addli r6, r0, __sbss_start /* clear SBSS */
847+ addli r7, r0, __sbss_end
848+ rsubl r18, r6, r7
849+ bealei r18, .Lendsbss
850+.Lloopsbss:
851+ sli r0, r6, 0
852+ addli r6, r6, 4
853+ rsubl r18, r6, r7
854+ beagti r18, .Lloopsbss
855+.Lendsbss:
856+
857+ addli r6, r0, __bss_start /* clear BSS */
858+ addli r7, r0, __bss_end
859+ rsubl r18, r6, r7
860+ bealei r18, .Lendbss
861+.Lloopbss:
862+ sli r0, r6, 0
863+ addli r6, r6, 4
864+ rsubl r18, r6, r7
865+ beagti r18, .Lloopbss
866+.Lendbss:
867+
868+ brealid r15, _program_init /* Initialize the program */
869+ nop
870+ brealid r15, _profile_init /* Initialize profiling library */
871+ nop
872+ brealid r15, __init /* Invoke language initialization functions */
873+ nop
874+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
875+ addli r7, r0, 0
876+ addli r5, r0, 0
877+ brealid r15, main /* Execute the program */
878+ nop
879+ addlik r19, r3, 0 /* Save return value */
880+
881+ brealid r15, __fini /* Invoke language cleanup functions */
882+ nop
883+ brealid r15, _profile_clean /* Cleanup profiling library */
884+ nop
885+ brealid r15, _program_clean /* Cleanup the program */
886+ nop
887+ ll r15, r1, r0 /* Return back to CRT */
888+ addlik r3, r19, 0 /* Restore return value */
889+ addli r1, r1, 40
890+ rtsd r15, 8
891+ nop
892+#else
893 addi r1, r1, -40 /* Save Link register */
894 swi r15, r1, 0
895
896@@ -86,7 +142,8 @@ _crtinit:
897
898 lw r15, r1, r0 /* Return back to CRT */
899 addik r3, r19, 0 /* Restore return value */
900- rtsd r15, 8
901+ rtsd r15, 8
902 addi r1, r1, 40
903+#endif
904 .end _crtinit
905
906diff --git a/libgloss/microblaze/sim-crtinit.S b/libgloss/microblaze/sim-crtinit.S
907index 74586d9..9892cb0 100644
908--- a/libgloss/microblaze/sim-crtinit.S
909+++ b/libgloss/microblaze/sim-crtinit.S
910@@ -35,10 +35,39 @@
911 #
912
913 .globl _crtinit
914+#ifdef __arch64__
915+ .align 3
916+#else
917 .align 2
918+#endif
919 .ent _crtinit
920
921 _crtinit:
922+#ifdef __arch64__
923+ addli r1, r1, -40 /* Save Link register */
924+ sli r15, r1, 0
925+
926+ brealid r15, _program_init /* Initialize the program */
927+ nop
928+ brealid r15, __init /* Invoke language initialization functions */
929+ nop
930+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
931+ addli r7, r0, 0
932+ addli r5, r0, 0
933+ brealid r15, main /* Execute the program */
934+ nop
935+ addlik r19, r3, 0 /* Save return value */
936+
937+ brealid r15, __fini /* Invoke language cleanup functions */
938+ nop
939+ brealid r15, _program_clean /* Cleanup the program */
940+ nop
941+ ll r15, r1, r0 /* Return back to CRT */
942+ addlik r3, r19, 0 /* Restore return value */
943+ addli r1, r1, 40
944+ rtsd r15, 8
945+ nop
946+#else
947 addi r1, r1, -40 /* Save Link register */
948 swi r15, r1, 0
949
950@@ -63,7 +92,9 @@ _crtinit:
951
952 lw r15, r1, r0 /* Return back to CRT */
953 addik r3, r19, 0 /* Restore return value */
954+
955 rtsd r15, 8
956 addi r1, r1, 40
957+#endif
958 .end _crtinit
959
960diff --git a/libgloss/microblaze/sim-pgcrtinit.S b/libgloss/microblaze/sim-pgcrtinit.S
961index 82ebcca..939f537 100644
962--- a/libgloss/microblaze/sim-pgcrtinit.S
963+++ b/libgloss/microblaze/sim-pgcrtinit.S
964@@ -35,10 +35,40 @@
965 #
966
967 .globl _crtinit
968+#ifdef __arch64__
969+ .align 3
970+#else
971 .align 2
972+#endif
973 .ent _crtinit
974
975 _crtinit:
976+#ifdef __arch64__
977+ addli r1, r1, -40 /* Save Link register */
978+ sli r15, r1, 0
979+
980+ brealid r15, _program_init /* Initialize the program */
981+ nop
982+ brealid r15, _profile_init /* Initialize profiling library */
983+ nop
984+ brealid r15, __init /* Invoke language initialization functions */
985+ nop
986+ addli r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */
987+ addli r7, r0, 0
988+ addli r5, r0, 0
989+ brealid r15, main /* Execute the program */
990+ nop
991+ brealid r15, __fini /* Invoke language cleanup functions */
992+ nop
993+ brealid r15, _profile_clean /* Cleanup profiling library */
994+ nop
995+ brealid r15, _program_clean /* Cleanup the program */
996+ nop
997+ ll r15, r1, r0 /* Return back to CRT */
998+ addli r1, r1, 40
999+ rtsd r15, 8
1000+ nop
1001+#else
1002 addi r1, r1, -40 /* Save Link register */
1003 swi r15, r1, 0
1004
1005@@ -68,5 +98,6 @@ _crtinit:
1006 lw r15, r1, r0 /* Return back to CRT */
1007 rtsd r15, 8
1008 addi r1, r1, 40
1009+#endif
1010 .end _crtinit
1011
1012diff --git a/newlib/libc/machine/microblaze/longjmp.S b/newlib/libc/machine/microblaze/longjmp.S
1013index f972bbd..5ed1c26 100644
1014--- a/newlib/libc/machine/microblaze/longjmp.S
1015+++ b/newlib/libc/machine/microblaze/longjmp.S
1016@@ -51,16 +51,46 @@
1017
1018 .globl longjmp
1019 .section .text
1020-.align 2
1021+#ifdef __arch64__
1022+.align 3
1023+#else
1024+.align 2
1025+#endif
1026 .ent longjmp
1027 longjmp:
1028+#ifdef __arch64__
1029+ lli r1, r5, 0
1030+ lli r13, r5, 4
1031+ lli r14, r5, 8
1032+ lli r15, r5, 12
1033+ lli r16, r5, 16
1034+ lli r17, r5, 20
1035+ lli r18, r5, 24
1036+ lli r19, r5, 28
1037+ lli r20, r5, 32
1038+ lli r21, r5, 36
1039+ lli r22, r5, 40
1040+ lli r23, r5, 44
1041+ lli r24, r5, 48
1042+ lli r25, r5, 52
1043+ lli r26, r5, 56
1044+ lli r27, r5, 60
1045+ lli r28, r5, 64
1046+ lli r29, r5, 68
1047+ lli r30, r5, 72
1048+ lli r31, r5, 76
1049+
1050+ or r3, r0, r6
1051+ rtsd r15, 8
1052+ nop
1053+#else
1054 lwi r1, r5, 0
1055 lwi r13, r5, 4
1056 lwi r14, r5, 8
1057- lwi r15, r5, 12
1058+ lwi r15, r5, 12
1059 lwi r16, r5, 16
1060 lwi r17, r5, 20
1061- lwi r18, r5, 24
1062+ lwi r18, r5, 24
1063 lwi r19, r5, 28
1064 lwi r20, r5, 32
1065 lwi r21, r5, 36
1066@@ -69,12 +99,13 @@ longjmp:
1067 lwi r24, r5, 48
1068 lwi r25, r5, 52
1069 lwi r26, r5, 56
1070- lwi r27, r5, 60
1071- lwi r28, r5, 64
1072- lwi r29, r5, 68
1073+ lwi r27, r5, 60
1074+ lwi r28, r5, 64
1075+ lwi r29, r5, 68
1076 lwi r30, r5, 72
1077- lwi r31, r5, 76
1078+ lwi r31, r5, 76
1079
1080 rtsd r15, 8
1081 or r3, r0, r6
1082+#endif
1083 .end longjmp
1084diff --git a/newlib/libc/machine/microblaze/setjmp.S b/newlib/libc/machine/microblaze/setjmp.S
1085index cdd87c7..971862b 100644
1086--- a/newlib/libc/machine/microblaze/setjmp.S
1087+++ b/newlib/libc/machine/microblaze/setjmp.S
1088@@ -50,9 +50,39 @@
1089
1090 .globl setjmp
1091 .section .text
1092-.align 2
1093+#ifdef __arch64__
1094+.align 3
1095+#else
1096+.align 2
1097+#endif
1098 .ent setjmp
1099 setjmp:
1100+#ifdef __arch64__
1101+ sli r1, r5, 0
1102+ sli r13, r5, 4
1103+ sli r14, r5, 8
1104+ sli r15, r5, 12
1105+ sli r16, r5, 16
1106+ sli r17, r5, 20
1107+ sli r18, r5, 24
1108+ sli r19, r5, 28
1109+ sli r20, r5, 32
1110+ sli r21, r5, 36
1111+ sli r22, r5, 40
1112+ sli r23, r5, 44
1113+ sli r24, r5, 48
1114+ sli r25, r5, 52
1115+ sli r26, r5, 56
1116+ sli r27, r5, 60
1117+ sli r28, r5, 64
1118+ sli r29, r5, 68
1119+ sli r30, r5, 72
1120+ sli r31, r5, 76
1121+
1122+ or r3, r0, r0
1123+ rtsd r15, 8
1124+ nop
1125+#else
1126 swi r1, r5, 0
1127 swi r13, r5, 4
1128 swi r14, r5, 8
1129@@ -76,4 +106,5 @@ setjmp:
1130
1131 rtsd r15, 8
1132 or r3, r0, r0
1133+#endif
1134 .end setjmp
1135--
11362.7.4
1137