This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
FRV FDPIC ABI changes
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: newlib at sources dot redhat dot com
- Date: 26 Dec 2003 13:11:26 -0200
- Subject: FRV FDPIC ABI changes
- Organization: GCC Team, Red Hat
This patch adds code to binutils to support a new ABI designed for the
FR-V architecture, that enables text segments of executables and
shared libraries to be shared by multiple processes on an OS such as
uClinux, that can run on FR-V processors without an MMU.
Patches for binutils and GCC have just been posted, and patches for
uClibc will follow shortly, in the corresponding mailing lists.
This patch is just meant to enable newlib to also be usable as a test
platform for the FDPIC ABI.
Ok to install?
Index: libgloss/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
2003-12-02 Richard Sandiford <rsandifo@redhat.com>
* frv/crt0.S (_start): Fix use of FDPIC conditionals. Move the set of
gr11 outside the FDPIC conditional. Avoid clobbering gr4 too early.
2003-11-14 Richard Sandiford <rsandifo@redhat.com>
* frv/crt0.S: Fix fdpic sp calculation.
2003-11-05 Alexandre Oliva <aoliva@redhat.com>
* frv/crt0.S: Use __stacksize, not __stack, to initialize sp on
FDPIC. Update comments on computing _GLOBAL_OFFSET_TABLE_. Don't
fixup ctors nor dtors on FDPIC.
2003-09-19 Alexandre Oliva <aoliva@redhat.com>
* frv/crt0.S (_start): Set up gr15 only for FDPIC.
* frv/crt0.S (_start): Save _GLOBAL_OFFSET_TABLE_ in gr17, and set
gr15 before function calls.
2003-09-19 DJ Delorie <dj@redhat.com>, Alexandre Oliva <aoliva@redhat.com>
* frv/crt0.S (_start): Set up gr15 with _GLOBAL_OFFSET_TABLE_'s
value.
Index: libgloss/frv/crt0.S
===================================================================
RCS file: /cvs/uberbaum/libgloss/frv/crt0.S,v
retrieving revision 1.1
diff -u -p -r1.1 crt0.S
--- libgloss/frv/crt0.S 18 Jun 2002 21:19:17 -0000 1.1
+++ libgloss/frv/crt0.S 26 Dec 2003 15:09:00 -0000
@@ -1,6 +1,6 @@
/* crt0.S -- startup file for frv.
*
- * Copyright (c) 2002 Red Hat, Inc
+ * Copyright (c) 2002, 2003 Red Hat, Inc
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
@@ -36,11 +36,41 @@ _start:
setlo #gprello(.Lcall), gr5
P(sub) gr4, gr5, gr16
+#if ! __FRV_FDPIC__
sethi #gprelhi(EXT(_stack)), sp /* load up stack pointer */
P(setlo) #gprello(EXT(_stack)), sp
setlos #0, fp /* zero fp to allow unwinders to stop */
P(add) sp, gr16, sp
+#define FDPIC(...)
+#else
+#define FDPIC(...) __VA_ARGS__
+
+ /* The assembler will rightfully claim that
+ #hi/lo(__stacksize) are unsafe for PIC, but since __stacksize
+ is absolute, and we don't want it to be relocated, we should
+ be fine. */
+
+ sethi #gprelhi(EXT(__end)), gr6
+ P(sethi) #hi(EXT(__stacksize+7)), gr5
+ setlo #gprello(EXT(__end)), gr6
+ P(setlo) #lo(EXT(__stacksize+7)), gr5
+ add gr6, gr16, gr6
+ add gr6, gr5, gr5
+ andi gr5, -8, sp
+
+ /* Using GPREL to compute _GLOBAL_OFFSET_TABLE_'s will force
+ the entire program to relocate as a unit, which is fine for
+ frv-elf. */
+
+ P(sethi) #gprelhi(EXT(_GLOBAL_OFFSET_TABLE_)), gr15
+ setlo #gprello(EXT(_GLOBAL_OFFSET_TABLE_)), gr15
+ /* We compute the value in a call-saved register (that happens
+ to be the PIC register in the EABI, and copy it to gr15 before
+ every call. */
+ add gr15, gr16, gr17
+#endif
+
sethi #gprelhi(EXT(__start_cmp)), gr5
setlo #gprello(EXT(__start_cmp)), gr5
ld @(gr5,gr16), gr6
@@ -48,6 +78,9 @@ _start:
beq icc0, 0, .Lfixed
P(st) gr4, @(gr5, gr16) /* update so if we restart no need to fixup */
+ setlos 4, gr11
+
+#if ! __FRV_FDPIC__
/* fixup the .ctors list */
sethi #gprelhi(EXT(__CTOR_LIST__)), gr9
@@ -58,7 +91,6 @@ _start:
P(add) gr10, gr16, gr10
addi gr9, 4, gr9
P(subi) gr10, 4, gr10
- setlos 4, gr11
call EXT(__frv_fixptrs)
/* fixup the .dtors list */
@@ -71,6 +103,7 @@ _start:
P(addi) gr9, 4, gr9
subi gr10, 4, gr10
call EXT(__frv_fixptrs)
+#endif /* ! __FRV_FDPIC__ */
/* fixup the .dtors list */
P(sethi) #gprelhi(EXT(__ROFIXUP_LIST__)), gr9
@@ -79,6 +112,7 @@ _start:
setlo #gprello(EXT(__ROFIXUP_END__)), gr10
P(add) gr9, gr16, gr9
add gr10, gr16, gr10
+ FDPIC(mov gr17, gr15)
call EXT(__frv_fix_usrptrs)
.Lfixed:
@@ -166,17 +200,21 @@ _start:
add gr4, gr16, gr4
P(setlos) #0, gr9
sub gr4, gr8, gr10
+ FDPIC(mov gr17, gr15)
call EXT(memset)
P(setlos) #0, gr8 /* zero argc, argv, envp */
setlos #0, gr9
P(setlos) #0, gr10
+ FDPIC(mov gr17, gr15)
call EXT(main)
+ FDPIC(mov gr17, gr15)
call EXT(exit)
.Lend:
.size __start,(.Lend-__start)
+#if ! __FRV_FDPIC__
/* Routine to adjust pointers
gr8 = difference to adjust by
gr9 = starting address
@@ -199,6 +237,7 @@ EXT(__frv_fixptrs):
.Lret2: ret
.Lend2:
.size EXT(__frv_fixptrs),.Lend2-EXT(__frv_fixptrs)
+#endif /* ! __FRV_FDPIC__ */
/* Routine to adjust statically initialized pointers
Note since these are pointers to pointers, they
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer