This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]: More precisely control crt* output on Sparc.


I noticed this while hacking on Gold sparc support a few
weeks ago.

If we're generating an 32-bit sparc glibc, with v9 optimizations,
the base CSU files should still only use the most basic sparc
instructions so that they do not get marked as v8+.

Otherwise, every application linked in userland gets marked this way
too.

Because doing things this way avoids the call_gmon_start() function in
the output, I did this for 64-bit sparc as well.

I did extra testing on this by installing the generated CSU files,
and running the Gold testsuite on 32-bit and 64-bit sparc.

Please apply, thanks!

2008-05-01  David S. Miller  <davem@davemloft.net>

	* sysdeps/sparc/sparc32/elf/initfini.c: New file.
	* sysdeps/sparc/sparc64/elf/initfini.c: Likewise.

--- /dev/null	2008-03-03 20:22:44.000000000 -0800
+++ ./sysdeps/sparc/sparc32/elf/initfini.c	2008-04-20 20:03:34.000000000 -0700
@@ -0,0 +1,105 @@
+/* Special .init and .fini section support for sparc 32-bit.
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   In addition to the permissions in the GNU Lesser General Public
+   License, the Free Software Foundation gives you unlimited
+   permission to link the compiled version of this file with other
+   programs, and to distribute those programs without any restriction
+   coming from the use of this file. (The GNU Lesser General Public
+   License restrictions do apply in other respects; for example, they
+   cover modification of the file, and distribution when not linked
+   into another program.)
+
+   Note that people who make modified versions of this file are not
+   obligated to grant this special exception for their modified
+   versions; it is their choice whether to do so. The GNU Lesser
+   General Public License gives permission to release a modified
+   version without this exception; this exception also makes it
+   possible to release a modified version which carries forward this
+   exception.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This file is compiled into assembly code which is then munged by a sed
+   script into two files: crti.s and crtn.s.
+
+   * crti.s puts a function prologue at the beginning of the
+   .init and .fini sections and defines global symbols for
+   those addresses, so they can be called as functions.
+
+   * crtn.s puts the corresponding function epilogues
+   in the .init and .fini sections.
+
+   We have special version for sparc because we want to use the most
+   minimal instruction set ISA so this doesn't get marked with using
+   v8plus or later.  Otherwise, every application linked ends up
+   needing v8plus.  */
+
+__asm__("						\n\
+#include \"defs.h\"					\n\
+							\n\
+/*@HEADER_ENDS*/					\n\
+/*@_init_PROLOG_BEGINS*/				\n\
+	.section .init					\n\
+	.section \".init\",#alloc,#execinstr		\n\
+	.align	4					\n\
+	.globl	_init					\n\
+	.type	_init, #function			\n\
+_init:							\n\
+	save	%sp, -112, %sp				\n\
+	sethi	%hi(__gmon_start__), %o1		\n\
+	sethi	%hi(_GLOBAL_OFFSET_TABLE_-4), %o0	\n\
+	call	1f					\n\
+	 add	%o0, %lo(_GLOBAL_OFFSET_TABLE_+4), %o0	\n\
+1:	or	%o1, %lo(__gmon_start__), %o1		\n\
+	add	%o7, %o0, %o0				\n\
+	ld	[%o0 + %o1], %o3			\n\
+	cmp	%o3, 0					\n\
+	be	1f					\n\
+	 nop						\n\
+	call	__gmon_start__				\n\
+	 nop						\n\
+1:	END_INIT					\n\
+/*@_init_PROLOG_ENDS*/					\n\
+							\n\
+/*@_init_EPILOG_BEGINS*/				\n\
+	.section .init					\n\
+	ret						\n\
+	 restore					\n\
+	END_INIT					\n\
+/*@_init_EPILOG_ENDS*/					\n\
+							\n\
+/*@_fini_PROLOG_BEGINS*/				\n\
+	.section .fini					\n\
+	.section \".fini\",#alloc,#execinstr		\n\
+	.align	4					\n\
+	.globl	_fini					\n\
+	.type	_fini, #function			\n\
+_fini:							\n\
+	save	%sp, -112, %sp				\n\
+	END_FINI					\n\
+/*@_fini_PROLOG_ENDS*/					\n\
+							\n\
+/*@_fini_EPILOG_BEGINS*/				\n\
+	.section .fini					\n\
+	ret						\n\
+	 restore					\n\
+	END_FINI					\n\
+/*@_fini_EPILOG_ENDS*/					\n\
+/*@TRAILER_BEGINS*/					\n\
+	.weak	__gmon_start__				\n\
+");
--- /dev/null	2008-03-03 20:22:44.000000000 -0800
+++ ./sysdeps/sparc/sparc64/elf/initfini.c	2008-04-20 20:33:30.000000000 -0700
@@ -0,0 +1,99 @@
+/* Special .init and .fini section support for sparc 64-bit.
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   In addition to the permissions in the GNU Lesser General Public
+   License, the Free Software Foundation gives you unlimited
+   permission to link the compiled version of this file with other
+   programs, and to distribute those programs without any restriction
+   coming from the use of this file. (The GNU Lesser General Public
+   License restrictions do apply in other respects; for example, they
+   cover modification of the file, and distribution when not linked
+   into another program.)
+
+   Note that people who make modified versions of this file are not
+   obligated to grant this special exception for their modified
+   versions; it is their choice whether to do so. The GNU Lesser
+   General Public License gives permission to release a modified
+   version without this exception; this exception also makes it
+   possible to release a modified version which carries forward this
+   exception.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+/* This file is compiled into assembly code which is then munged by a sed
+   script into two files: crti.s and crtn.s.
+
+   * crti.s puts a function prologue at the beginning of the
+   .init and .fini sections and defines global symbols for
+   those addresses, so they can be called as functions.
+
+   * crtn.s puts the corresponding function epilogues
+   in the .init and .fini sections.  */
+
+__asm__("						\n\
+#include \"defs.h\"					\n\
+							\n\
+/*@HEADER_ENDS*/					\n\
+/*@_init_PROLOG_BEGINS*/				\n\
+	.section .init					\n\
+	.section \".init\",#alloc,#execinstr		\n\
+	.align	4					\n\
+	.globl	_init					\n\
+	.type	_init, #function			\n\
+_init:							\n\
+	save	%sp, -192, %sp				\n\
+	sethi	%hi(__gmon_start__), %o1		\n\
+	sethi	%hi(_GLOBAL_OFFSET_TABLE_-4), %o0	\n\
+	call	1f					\n\
+	 add	%o0, %lo(_GLOBAL_OFFSET_TABLE_+4), %o0	\n\
+1:	or	%o1, %lo(__gmon_start__), %o1		\n\
+	add	%o7, %o0, %o0				\n\
+	ldx	[%o0 + %o1], %o3			\n\
+	brz,pn	%o3, 1f					\n\
+	 nop						\n\
+	call	__gmon_start__				\n\
+	 nop						\n\
+1:	END_INIT					\n\
+/*@_init_PROLOG_ENDS*/					\n\
+							\n\
+/*@_init_EPILOG_BEGINS*/				\n\
+	.section .init					\n\
+	ret						\n\
+	 restore					\n\
+	END_INIT					\n\
+/*@_init_EPILOG_ENDS*/					\n\
+							\n\
+/*@_fini_PROLOG_BEGINS*/				\n\
+	.section .fini					\n\
+	.section \".fini\",#alloc,#execinstr		\n\
+	.align	4					\n\
+	.globl	_fini					\n\
+	.type	_fini, #function			\n\
+_fini:							\n\
+	save	%sp, -192, %sp				\n\
+	END_FINI					\n\
+/*@_fini_PROLOG_ENDS*/					\n\
+							\n\
+/*@_fini_EPILOG_BEGINS*/				\n\
+	.section .fini					\n\
+	ret						\n\
+	 restore					\n\
+	END_FINI					\n\
+/*@_fini_EPILOG_ENDS*/					\n\
+/*@TRAILER_BEGINS*/					\n\
+	.weak	__gmon_start__				\n\
+");


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