[Mono-dev] [PATCH]: Avoid --with-static_mono=no problems on Linux/Sparc

David S. Miller davem at davemloft.net
Wed Mar 29 02:55:15 EST 2006


Currently, on sparc*-*-linux*, libgc uses _etext to try and figure
out where the data section starts.  This is problematic for two
reasons.

There is a more portable and better performing version of this
being used by other Linux platforms, so Sparc should use it as
well.

Using _etext is problematic for another reason.  We end up with a
reference to _etext in the libgc shared object, and when the mono JIT
binary is build non-static, we end up with a funny versioned symbol
entry for _etext in the binary because of the versioning linker
scripts used.  This causes problems for the glibc dynamic linker, and
in fact a crash.

I am working that glibc dynamic linker issue out with the libc folks
independantly, it could very well be a binutils bug.

This patch cures both issues.  I intend to pass this up to the
main Boehm-GC sources and into gcc's copy eventually as well.

Thanks.

2006-03-28  David S. Miller  <davem at sunset.davemloft.net>

	* include/private/gcconfig.h (LINUX and SPARC): Do not
	use _etest and GC_SysVGetDataStart() to figure out DATASTART.
	Instead use either SEARCH_FOR_DATA_START or __environ, based
	upin GLIBC version.

--- libgc/include/private/gcconfig.h.~1~	2005-12-26 10:45:29.000000000 -0800
+++ libgc/include/private/gcconfig.h	2006-03-29 04:10:35.000000000 -0800
@@ -907,17 +907,28 @@
 #     else
           Linux Sparc/a.out not supported
 #     endif
+#     define SVR4
+#     include <features.h>
+#     if defined(__GLIBC__) && __GLIBC__ >= 2
+#	 define SEARCH_FOR_DATA_START
+#     else
+          extern char **__environ;
+#         define DATASTART ((ptr_t)(&__environ))
+		      /* hideous kludge: __environ is the first */
+		      /* word in crt0.o, and delimits the start */
+		      /* of the data segment, no matter which   */
+		      /* ld options were passed through.        */
+		      /* We could use _etext instead, but that  */
+		      /* would include .rodata, which may       */
+		      /* contain large read-only data tables    */
+		      /* that we'd rather not scan.		*/
+#     endif
       extern int _end[];
-      extern int _etext[];
 #     define DATAEND (_end)
-#     define SVR4
-      extern ptr_t GC_SysVGetDataStart();
 #     ifdef __arch64__
-#	define DATASTART GC_SysVGetDataStart(0x100000, _etext)
 	/* libc_stack_end is not set reliably for sparc64 */
 #       define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
 #     else
-#       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
 #	define LINUX_STACKBOTTOM
 #     endif
 #   endif



More information about the Mono-devel-list mailing list