This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Fix section selection in crt objects


When compiling with gcc 4.2 the call to call_gmon_start is inlined into
_init in initfini.c.  This is normally not a problem, but on ppc64 a TOC
entry needs to be allocated, and because gcc does not know about the
manually changed section it just switches back to .text afterwards.  So
we better tell gcc about the nonstandard sections.  Currently only _init
in sysdeps/generic/initfini.c is affected, but for future-proofness I've
changed _fini and the uses in nptl as well.

Andreas.

2007-06-17  Andreas Schwab  <schwab@suse.de>

	* sysdeps/pthread/pt-initfini.c: Tell gcc about the nonstandard
	sections.

--- nptl/sysdeps/pthread/pt-initfini.c.~1.4.~	2005-02-28 14:18:03.000000000 +0100
+++ nptl/sysdeps/pthread/pt-initfini.c	2007-06-17 12:35:07.000000000 +0200
@@ -72,7 +72,7 @@ call_initialize_minimal (void)
 }
 
 SECTION (".init");
-extern void _init (void);
+extern void __attribute__ ((section (".init"))) _init (void);
 void
 _init (void)
 {
@@ -93,7 +93,7 @@ asm ("\n/*@_init_EPILOG_ENDS*/");
 asm ("\n/*@_fini_PROLOG_BEGINS*/");
 
 SECTION (".fini");
-extern void _fini (void);
+extern void __attribute__ ((section (".fini"))) _fini (void);
 void
 _fini (void)
 {


2007-06-17  Andreas Schwab  <schwab@suse.de>

	* sysdeps/generic/initfini.c: Tell gcc about the nonstandard
	sections.

--- sysdeps/generic/initfini.c.~1.9.~	2004-08-16 11:08:09.000000000 +0200
+++ sysdeps/generic/initfini.c	2007-06-17 12:24:24.000000000 +0200
@@ -81,7 +81,7 @@ call_gmon_start(void)
 }
 
 SECTION (".init");
-extern void _init (void);
+extern void __attribute__ ((section (".init"))) _init (void);
 void
 _init (void)
 {
@@ -107,7 +107,7 @@ asm ("\n/*@_init_EPILOG_ENDS*/");
 asm ("\n/*@_fini_PROLOG_BEGINS*/");
 
 SECTION (".fini");
-extern void _fini (void);
+extern void __attribute__ ((section (".fini"))) _fini (void);
 void
 _fini (void)
 {

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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