This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix ColdFire support for GCC 3.4 in libgloss


Bernardo,

I'm afraid I can't accept this change as-is. The problem is that gcc code is under the GPL license and newlib does not accept GPL licensed contributions. If you want to make your own set of macros based on your "observations of gcc" or if you were to copy from a BSD-licensed source, that would be fine, but to copy the macros (plus/minus comments) directly from the gcc code is not.

I would also like to see any such replacement macros placed into a header file included by the two files rather than copied multiple times.

-- Jeff J.

Bernardo Innocenti wrote:
Hello,

this patch is required to build libgloss for ColdFire with
GCC 3.4. It takes care of two changes:

- The __m5200__ predefine is now only present for 52xx ColdFire
  processors. __mcoldfire__ has to be used instead.

- PIC code is now supported on m68k-uclinux and multilibbed versions of
  libgloss need to handle this.

The GAS macros used here are copied over from gcc/config/m68k/lb1sf68.asm.
I think trying to share this code is not worth the effort. Also, not all
the macros are used in both sources, but I've left all them for consistency.


Please commit this patch to CVS for me if it looks OK. I have no write
access to sources.redhat.com yet.


2003-10-12 Bernardo Innocenti <bernie@develer.com>


    * m68k/crt0.S: Add -fPIC, -msep-data and -mid-shared-library support.
    * m68k/sim-crt0.S: Likewise.

diff -u -3 -p -u -p -r1.1 crt0.S
--- m68k/crt0.S    17 Mar 2000 22:48:50 -0000    1.1
+++ m68k/crt0.S    12 Oct 2003 01:57:45 -0000
@@ -16,6 +16,75 @@

#include "asm.h"

+/* Provide a few macros to allow for PIC code support.
+ * With PIC, data is stored A5 relative so we've got to take a bit of special
+ * care to ensure that all loads of global data is via A5. PIC also requires
+ * jumps and subroutine calls to be PC relative rather than absolute. We cheat
+ * a little on this and in the PIC case, we use short offset branches and
+ * hope that the final object code is within range (which it should be).
+ */
+#ifndef __PIC__
+
+ /* Non PIC (absolute/relocatable) versions */
+
+ .macro PICCALL addr
+ jbsr \addr
+ .endm
+
+ .macro PICJUMP addr
+ jmp \addr
+ .endm
+
+ .macro PICLEA sym, reg
+ lea \sym, \reg
+ .endm
+
+ .macro PICPEA sym, areg
+ pea \sym
+ .endm
+
+#else /* __PIC__ */
+
+ /* Common for -mid-shared-libary and -msep-data */
+
+ .macro PICCALL addr
+ bsr \addr
+ .endm
+
+ .macro PICJUMP addr
+ bra \addr
+ .endm
+
+# if defined(__ID_SHARED_LIBRARY__)
+
+ /* -mid-shared-library versions */
+
+ .macro PICLEA sym, reg
+ movel a5@(_current_shared_library_a5_offset_), \reg
+ movel \sym@GOT(\reg), \reg
+ .endm
+
+ .macro PICPEA sym, areg
+ movel a5@(_current_shared_library_a5_offset_), \areg
+ movel \sym@GOT(\areg), sp@-
+ .endm
+
+# else /* !__ID_SHARED_LIBRARY__ */
+
+ /* Versions for -msep-data */
+
+ .macro PICLEA sym, reg
+ movel \sym@GOT(a5), \reg
+ .endm
+
+ .macro PICPEA sym, areg
+ movel \sym@GOT(a5), sp@-
+ .endm
+
+# endif /* !__ID_SHARED_LIBRARY__ */
+#endif /* __PIC__ */
+
+
.title "crt0.S for m68k-coff"
#define STACKSIZE 0x4000


@@ -84,7 +153,7 @@ SYM (start):
    subql    IMM(1), d0
2:
    clrb    (a0)+
-#ifndef __mcf5200__
+#if !defined(__mcoldfire__) && !defined(__mcf5200__)
    dbra    d0, 2b
    clrw    d0
    subql    IMM(1), d0
@@ -100,13 +169,13 @@ SYM (start):
 * initialize target specific stuff. Only execute these
 * functions it they exist.
 */
-    lea    SYM (hardware_init_hook), a0
+    PICLEA    SYM (hardware_init_hook), a0
    cmpl    IMM(0),a0
    jbeq    4f
    jsr     (a0)
4:

- lea SYM (software_init_hook), a0
+ PICLEA SYM (software_init_hook), a0
cmpl IMM(0),a0
jbeq 5f
jsr (a0)
@@ -121,18 +190,18 @@ SYM (start):
#ifdef ADD_DTORS
/* put __do_global_dtors in the atexit list so the destructors get run */
movel IMM (SYM(__do_global_dtors)),(sp)
- jsr SYM (atexit)
+ PICCALL SYM (atexit)
#endif
movel IMM (__FINI_SECTION__),(sp)
- jsr SYM (atexit)
+ PICCALL SYM (atexit)


-    jsr    __INIT_SECTION__
+    PICCALL    __INIT_SECTION__

        pea     0
-        pea     SYM (environ)
+    PICPEA    SYM (environ),a0
        pea     sp@(4)
        pea     0
-    jsr    SYM (main)
+    PICCALL    SYM (main)
    movel    d0, sp@-

/*
@@ -140,4 +209,4 @@ SYM (start):
 * control back to the ROM monitor, if there is one. This calls the
 * exit() from the C library so the C++ tables get cleaned up right.
 */
-        jsr     SYM (exit)
+    PICCALL    SYM (exit)
diff -u -3 -p -u -p -r1.1 sim-crt0.S
--- m68k/sim-crt0.S    28 Feb 2001 18:41:57 -0000    1.1
+++ m68k/sim-crt0.S    12 Oct 2003 01:57:46 -0000
@@ -16,6 +16,75 @@

#include "asm.h"

+/* Provide a few macros to allow for PIC code support.
+ * With PIC, data is stored A5 relative so we've got to take a bit of special
+ * care to ensure that all loads of global data is via A5. PIC also requires
+ * jumps and subroutine calls to be PC relative rather than absolute. We cheat
+ * a little on this and in the PIC case, we use short offset branches and
+ * hope that the final object code is within range (which it should be).
+ */
+#ifndef __PIC__
+
+ /* Non PIC (absolute/relocatable) versions */
+
+ .macro PICCALL addr
+ jbsr \addr
+ .endm
+
+ .macro PICJUMP addr
+ jmp \addr
+ .endm
+
+ .macro PICLEA sym, reg
+ lea \sym, \reg
+ .endm
+
+ .macro PICPEA sym, areg
+ pea \sym
+ .endm
+
+#else /* __PIC__ */
+
+ /* Common for -mid-shared-libary and -msep-data */
+
+ .macro PICCALL addr
+ bsr \addr
+ .endm
+
+ .macro PICJUMP addr
+ bra \addr
+ .endm
+
+# if defined(__ID_SHARED_LIBRARY__)
+
+ /* -mid-shared-library versions */
+
+ .macro PICLEA sym, reg
+ movel a5@(_current_shared_library_a5_offset_), \reg
+ movel \sym@GOT(\reg), \reg
+ .endm
+
+ .macro PICPEA sym, areg
+ movel a5@(_current_shared_library_a5_offset_), \areg
+ movel \sym@GOT(\areg), sp@-
+ .endm
+
+# else /* !__ID_SHARED_LIBRARY__ */
+
+ /* Versions for -msep-data */
+
+ .macro PICLEA sym, reg
+ movel \sym@GOT(a5), \reg
+ .endm
+
+ .macro PICPEA sym, areg
+ movel \sym@GOT(a5), sp@-
+ .endm
+
+# endif /* !__ID_SHARED_LIBRARY__ */
+#endif /* __PIC__ */
+
+
.title "crt0.S for m68k-coff"
#define STACKSIZE 0x4000


@@ -78,7 +147,7 @@ SYM (start):
subql IMM(1), d0
2:
clrb (a0)+
-#ifndef __mcf5200__
+#if !defined(__mcoldfire__) && !defined(__mcf5200__)
dbra d0, 2b
clrw d0
subql IMM(1), d0
@@ -99,18 +168,18 @@ SYM (start):
#ifdef ADD_DTORS
/* put __do_global_dtors in the atexit list so the destructors get run */
movel IMM (SYM(__do_global_dtors)),(sp)
- jsr SYM (atexit)
+ PICCALL SYM (atexit)
#endif
movel IMM (__FINI_SECTION__),(sp)
- jsr SYM (atexit)
+ PICCALL SYM (atexit)


-    jsr    __INIT_SECTION__
+    PICCALL    __INIT_SECTION__

        pea     0
-        pea     SYM (environ)
+    PICPEA    SYM (environ),a0
        pea     sp@(4)
        pea     0
-    jsr    SYM (main)
+    PICCALL    SYM (main)
    movel    d0, sp@-

/*
@@ -118,4 +187,4 @@ SYM (start):
 * control back to the ROM monitor, if there is one. This calls the
 * exit() from the C library so the C++ tables get cleaned up right.
 */
-        jsr     SYM (exit)
+    PICCALL    SYM (exit)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]