This is the mail archive of the newlib@sourceware.org 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]

[patch] libgloss/m68k/{fido,cf}*: s/__INIT_SECTION__/_init/.


Hi,

Attached is a patch to replace __INIT_SECTION__ and __FINI_SECTION__
with _init and _fini, respectively.

newlib/libc/misc/init.c assumes that the initializer and finalizer
functions are called _init and _fini, respectively.  Without this
patch, newlib/libc/misc/init.c is incompatible with cf.sc or fido.sc
because cf.sc and fido.sc use different names.

This patch fixes the problem by replacing __INIT_SECTION__ and
__FINI_SECTION__ with _init and _fini, respectively.

Tested by running "Hello, world".  OK to apply?

Kazu Hirata

2007-05-22  Kazu Hirata  <kazu@codesourcery.com>

	* m68k/cf-crt1.C, m68k/cf.sc, m68k/fido.sc, m68k/fido-crt0.S:
	Replace __INIT_SECTION__ and __FINI_SECTION__ with _init and
	_fini, respectively.

Index: libgloss/m68k/cf-crt1.c
===================================================================
RCS file: /cvs/src/src/libgloss/m68k/cf-crt1.c,v
retrieving revision 1.2
diff -u -d -p -r1.2 cf-crt1.c
--- libgloss/m68k/cf-crt1.c	11 Dec 2006 19:58:01 -0000	1.2
+++ libgloss/m68k/cf-crt1.c	22 May 2007 15:57:05 -0000
@@ -25,8 +25,8 @@ extern char __end[] __attribute__ ((alig
 void *__heap_limit;
 extern void software_init_hook (void) __attribute__ ((weak));
 extern void hardware_init_hook (void) __attribute__ ((weak));
-extern void __INIT_SECTION__ (void);
-extern void __FINI_SECTION__ (void);
+extern void _init (void);
+extern void _fini (void);
 
 extern int main (int, char **, char **);
 
@@ -48,11 +48,11 @@ void __start1 (void *heap_limit)
   if (software_init_hook)
     software_init_hook ();
 
-  __INIT_SECTION__ ();
+  _init ();
 
   /* I'm not sure how useful it is to have a fini_section in an
      embedded system.  */
-  atexit (__FINI_SECTION__);
+  atexit (_fini);
   
   ix = main (0, NULL, NULL);
   exit (ix);
Index: libgloss/m68k/cf.sc
===================================================================
RCS file: /cvs/src/src/libgloss/m68k/cf.sc,v
retrieving revision 1.4
diff -u -d -p -r1.4 cf.sc
--- libgloss/m68k/cf.sc	4 Jan 2007 18:05:56 -0000	1.4
+++ libgloss/m68k/cf.sc	22 May 2007 15:57:05 -0000
@@ -61,14 +61,14 @@ SECTIONS
     *(.eh_frame)
 
     . = ALIGN(0x4);
-    __INIT_SECTION__ = . ;
+    _init = . ;
     LONG (0x4e560000)	/* linkw %fp,#0 */
     *(.init)
     SHORT (0x4e5e)	/* unlk %fp */
     SHORT (0x4e75)	/* rts */
 
     . = ALIGN(0x4);
-    __FINI_SECTION__ = . ;
+    _fini = . ;
     LONG (0x4e560000)	/* linkw %fp,#0 */
     *(.fini)
     SHORT (0x4e5e)	/* unlk %fp */
Index: libgloss/m68k/fido-crt0.S
===================================================================
RCS file: /cvs/src/src/libgloss/m68k/fido-crt0.S,v
retrieving revision 1.2
diff -u -d -p -r1.2 fido-crt0.S
--- libgloss/m68k/fido-crt0.S	18 Dec 2006 21:48:18 -0000	1.2
+++ libgloss/m68k/fido-crt0.S	22 May 2007 15:57:05 -0000
@@ -283,10 +283,10 @@ SYM (_start):
 	movel	IMM (SYM(__do_global_dtors)),(sp)
 	jsr	SYM (atexit)
 #endif
-	movel	IMM (__FINI_SECTION__),(sp)
+	movel	IMM (_fini),(sp)
 	jsr	SYM (atexit)
 
-	jsr	__INIT_SECTION__
+	jsr	_init
 
 /*
  * call the main routine from the application to get it going.
Index: libgloss/m68k/fido.sc
===================================================================
RCS file: /cvs/src/src/libgloss/m68k/fido.sc,v
retrieving revision 1.3
diff -u -d -p -r1.3 fido.sc
--- libgloss/m68k/fido.sc	27 Apr 2007 16:00:45 -0000	1.3
+++ libgloss/m68k/fido.sc	22 May 2007 15:57:05 -0000
@@ -162,13 +162,13 @@ SECTIONS {
     *(.eh_frame)
 
     . = ALIGN(0x2);
-    __INIT_SECTION__ = . ;
+    _init = . ;
     LONG (0x4e560000)	/* linkw %fp,#0 */
     *(.init)
     SHORT (0x4e5e)	/* unlk %fp */
     SHORT (0x4e75)	/* rts */
 
-    __FINI_SECTION__ = . ;
+    _fini = . ;
     LONG (0x4e560000)	/* linkw %fp,#0 */
     *(.fini)
     SHORT (0x4e5e)	/* unlk %fp */


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