changeset 22:fd4acc376c45

Implemented object file output and linking on linux.
author Robert Clipsham <robert@octarineparrot.com>
date Thu, 08 Apr 2010 04:21:03 +0100
parents 26b9f97f6162
children 460959608115
files commands.linux.txt dmd/AssertExp.d dmd/ClassDeclaration.d dmd/Declaration.d dmd/EnumDeclaration.d dmd/File.d dmd/FuncDeclaration.d dmd/InterfaceDeclaration.d dmd/Module.d dmd/PragmaDeclaration.d dmd/StringExp.d dmd/Type.d dmd/TypeBasic.d dmd/TypeFunction.d dmd/TypeInfoDeclaration.d dmd/TypedefDeclaration.d dmd/Util.d dmd/VarDeclaration.d dmd/backend/Config.d dmd/backend/SFL.d dmd/backend/Symbol.d dmd/backend/TYPE.d dmd/backend/Util.d dmd/backend/iasm.d dmd/codegen/Util.d main.d
diffstat 26 files changed, 123 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/commands.linux.txt	Wed Apr 07 00:51:29 2010 +0100
+++ b/commands.linux.txt	Thu Apr 08 04:21:03 2010 +0100
@@ -9,6 +9,8 @@
 -version=MARS
 -version=TARGET_LINUX
 -version=POSIX
+-version=ELFOBJ
+-version=ELFOBJ_OR_MACHOBJ
 -version=NobodyCares
 -version=DumbClone
 -version=STRUCTTHISREF
--- a/dmd/AssertExp.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/AssertExp.d	Thu Apr 08 04:21:03 2010 +0100
@@ -157,7 +157,7 @@
 			if (global.params.useInvariants && t1.ty == Tclass &&
 				!(cast(TypeClass)t1).sym.isInterfaceDeclaration())
 			{
-		version (XXX) {///TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+		version (POSIX) {///TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
 				e = el_bin(OPcall, TYvoid, el_var(rtlsym[RTLSYM__DINVARIANT]), e);
 		} else {
 				e = el_bin(OPcall, TYvoid, el_var(rtlsym[RTLSYM_DINVARIANT]), e);
@@ -207,10 +207,10 @@
 						assertexp_sfilename.Sdt = dt;
 						assertexp_sfilename.Sfl = FLdata;
 			version (ELFOBJ) {
-						assertexp_sfilename.Sseg = CDATA;
+						assertexp_sfilename.Sseg = Segment.CDATA;
 			}
 			version (MACHOBJ) {
-						assertexp_sfilename.Sseg = DATA;
+						assertexp_sfilename.Sseg = Segment.DATA;
 			}
 						outdata(assertexp_sfilename);
 
--- a/dmd/ClassDeclaration.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/ClassDeclaration.d	Thu Apr 08 04:21:03 2010 +0100
@@ -1242,10 +1242,10 @@
 		sinit.Sclass = scclass;
 		sinit.Sfl = FLdata;
 	version (ELFOBJ) { // Burton
-		sinit.Sseg = CDATA;
+		sinit.Sseg = Segment.CDATA;
 	}
 	version (MACHOBJ) {
-		sinit.Sseg = DATA;
+		sinit.Sseg = Segment.DATA;
 	}
 		toDt(&sinit.Sdt);
 		outdata(sinit);
@@ -1568,7 +1568,7 @@
 		csym.Sdt = dt;
 	version (ELFOBJ_OR_MACHOBJ) { // Burton
 		// ClassInfo cannot be const data, because we use the monitor on it
-		csym.Sseg = DATA;
+		csym.Sseg = Segment.DATA;
 	}
 		outdata(csym);
 		if (isExport())
@@ -1635,10 +1635,10 @@
 		vtblsym.Sclass = scclass;
 		vtblsym.Sfl = FLdata;
 	version (ELFOBJ) {
-		vtblsym.Sseg = CDATA;
+		vtblsym.Sseg = Segment.CDATA;
 	}
 	version (MACHOBJ) {
-		vtblsym.Sseg = DATA;
+		vtblsym.Sseg = Segment.DATA;
 	}
 		outdata(vtblsym);
 		if (isExport())
--- a/dmd/Declaration.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/Declaration.d	Thu Apr 08 04:21:03 2010 +0100
@@ -198,7 +198,7 @@
 	}
 	body+/
 	{
-version(Bug3602) { writef( "Bug3602: Uncomment outblock when fixed" );  }
+version(Bug3602) { writef( "Bug3602: Uncomment outblock when fixed\n" );  }
 		//writef("Declaration.mangle(this = %p, '%s', parent = '%s', linkage = %d)\n", this, toChars(), parent ? parent.toChars() : "null", linkage);
 		if (!parent || parent.isModule() || linkage == LINK.LINKcpp) // if at global scope
 		{
--- a/dmd/EnumDeclaration.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/EnumDeclaration.d	Thu Apr 08 04:21:03 2010 +0100
@@ -19,6 +19,7 @@
 import dmd.HdrGenState;
 import dmd.Global;
 import dmd.Loc;
+import dmd.Module;
 import dmd.TypeEnum;
 import dmd.EnumMember;
 import dmd.DYNCAST;
--- a/dmd/File.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/File.d	Thu Apr 08 04:21:03 2010 +0100
@@ -243,18 +243,16 @@
     int write()
 	{
 version (POSIX) {
-		assert(false);
-		/+
+		//assert(false);
+		
 		int fd;
 		ssize_t numwritten;
-		char *name;
-
-		name = this->name->toChars();
+		const(char)* name = toStringz(this.name.toChars());
 		fd = open(name, O_CREAT | O_WRONLY | O_TRUNC, 0644);
 		if (fd == -1)
 		goto err;
 
-		numwritten = ::write(fd, buffer, len);
+		numwritten = core.sys.posix.unistd.write(fd, buffer, len);
 		if (len != numwritten)
 		goto err2;
 		
@@ -262,10 +260,10 @@
 		goto err;
 
 		if (touchtime)
-		{   struct utimbuf ubuf;
+		{   utimbuf ubuf;
 
-			ubuf.actime = ((struct stat *)touchtime)->st_atime;
-			ubuf.modtime = ((struct stat *)touchtime)->st_mtime;
+			ubuf.actime = (cast(stat_t *)touchtime).st_atime;
+			ubuf.modtime = (cast(stat_t *)touchtime).st_mtime;
 		if (utime(name, &ubuf))
 			goto err;
 		}
@@ -273,10 +271,10 @@
 
 	err2:
 		close(fd);
-		::remove(name);
+		.remove(name);
 	err:
 		return 1;
-		+/
+		
 } else version (_WIN32) {
 		HANDLE h;
 		DWORD numwritten;
--- a/dmd/FuncDeclaration.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/FuncDeclaration.d	Thu Apr 08 04:21:03 2010 +0100
@@ -2742,7 +2742,7 @@
 			// Pull in RTL startup code
 			if (func.isMain())
 			{   objextdef("_main");
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 				obj_ehsections();	// initialize exception handling sections
 } else {
 				objextdef("__acrtused_con");
@@ -3084,7 +3084,7 @@
 			ss.toObjFile(0);
 		}
 
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 		// A hack to get a pointer to this function put in the .dtors segment
 		if (ident && ident.toChars() == "_STD") {
 			obj_staticdtor(s);
--- a/dmd/InterfaceDeclaration.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/InterfaceDeclaration.d	Thu Apr 08 04:21:03 2010 +0100
@@ -17,6 +17,7 @@
 import dmd.Dsymbol;
 import dmd.Scope;
 import dmd.Global;
+import dmd.Module;
 import dmd.BaseClass;
 import dmd.Id;
 
@@ -476,10 +477,10 @@
 
 		csym.Sdt = dt;
 	version (ELFOBJ) {
-		csym.Sseg = CDATA;
+		csym.Sseg = Segment.CDATA;
 	}
 	version (MACHOBJ) {
-		csym.Sseg = DATA;
+		csym.Sseg = Segment.DATA;
 	}
 		outdata(csym);
 		if (isExport())
@@ -508,4 +509,4 @@
 	}
 
     InterfaceDeclaration isInterfaceDeclaration() { return this; }
-}
\ No newline at end of file
+}
--- a/dmd/Module.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/Module.d	Thu Apr 08 04:21:03 2010 +0100
@@ -899,9 +899,9 @@
 					/* This should work, but causes optlink to fail in common/newlib.asm */
 					objextdef(s.Sident);
 } else {
-	version (XXX) {///ELFOBJ || MACHOBJ
-				int nbytes = reftoident(DATA, Offset(DATA), s, 0, CFoff);
-				Offset(DATA) += nbytes;
+	version (ELFOBJ_OR_MACHOBJ) {///ELFOBJ || MACHOBJ
+				int nbytes = reftoident(Segment.DATA, Offset(Segment.DATA), s, 0, CF.CFoff);
+				Offset(Segment.DATA) += nbytes;
 	} else {
 				int nbytes = reftoident(Segment.DATA, Doffset, s, 0, CF.CFoff);
 				Doffset() += nbytes;
--- a/dmd/PragmaDeclaration.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/PragmaDeclaration.d	Thu Apr 08 04:21:03 2010 +0100
@@ -62,7 +62,7 @@
 					if (e.op == TOKstring)
 					{
 						StringExp se = cast(StringExp)e;
-						writef("%.*s", cast(int)se.len, cast(char*)se.string_);
+						writef("%s", se.toChars()[1..$-3] /*se.len, cast(char*)se.string_*/);
 					}
 					else
 						error("string expected for message, not '%s'", e.toChars());
@@ -286,4 +286,4 @@
 ///	}
 		AttribDeclaration.toObjFile(multiobj);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/StringExp.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/StringExp.d	Thu Apr 08 04:21:03 2010 +0100
@@ -10,6 +10,7 @@
 import dmd.TypeDArray;
 import dmd.Type;
 import dmd.TOK;
+import dmd.Module;
 import dmd.OutBuffer;
 import dmd.Loc;
 import dmd.Scope;
--- a/dmd/Type.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/Type.d	Thu Apr 08 04:21:03 2010 +0100
@@ -82,7 +82,7 @@
 	int REALSIZE = 16;
 	int REALPAD = 6;
 	int REALALIGNSIZE = 16;
-} else version (XXX) { /// TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
+} else version (POSIX) { /// TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS
 	int REALSIZE = 12;
 	int REALPAD = 2;
 	int REALALIGNSIZE = 4;
--- a/dmd/TypeBasic.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/TypeBasic.d	Thu Apr 08 04:21:03 2010 +0100
@@ -211,7 +211,7 @@
 			sz = REALALIGNSIZE;
 			break;
 
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 		case TY.Tint64:
 		case TY.Tuns64:
 		case TY.Tfloat64:
@@ -776,4 +776,4 @@
 	{
 		return this;
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TypeFunction.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/TypeFunction.d	Thu Apr 08 04:21:03 2010 +0100
@@ -707,7 +707,7 @@
 
 		case LINK.LINKc:
 			tyf = TYM.TYnfunc;
-	version (XXX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+	version (POSIX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 			if (retStyle() == RET.RETstack)
 				tyf = TYM.TYhfunc;
 	}
@@ -731,4 +731,4 @@
 	}
 		return tyf;
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TypeInfoDeclaration.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/TypeInfoDeclaration.d	Thu Apr 08 04:21:03 2010 +0100
@@ -3,6 +3,7 @@
 import dmd.VarDeclaration;
 import dmd.Type;
 import dmd.Dsymbol;
+import dmd.Module;
 import dmd.Scope;
 import dmd.Loc;
 import dmd.STC;
@@ -96,7 +97,7 @@
 			s.Sdt.dt = DT.DT_common;
 		}
 
-version (XXX) { ///ELFOBJ || MACHOBJ // Burton
+version (ELFOBJ_OR_MACHOBJ) { ///ELFOBJ || MACHOBJ // Burton
 		if (s.Sdt && s.Sdt.dt == DT_azeros && s.Sdt.DTnext == null)
 			s.Sseg = Segment.UDATA;
 		else
@@ -111,4 +112,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/TypedefDeclaration.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/TypedefDeclaration.d	Thu Apr 08 04:21:03 2010 +0100
@@ -6,6 +6,7 @@
 import dmd.Loc;
 import dmd.Identifier;
 import dmd.Dsymbol;
+import dmd.Module;
 import dmd.Scope;
 import dmd.OutBuffer;
 import dmd.ExpInitializer;
@@ -176,4 +177,4 @@
 	{
 		assert(false);
 	}
-}
\ No newline at end of file
+}
--- a/dmd/Util.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/Util.d	Thu Apr 08 04:21:03 2010 +0100
@@ -17,6 +17,10 @@
 {
     import std.c.process : spawnl, spawnlp;
 }
+version (POSIX)
+{
+    import core.sys.posix.unistd;
+}
 import core.stdc.stdlib;
 import core.stdc.ctype;
 import core.stdc.stdarg;
@@ -814,62 +818,54 @@
     }
     return status;
 } else version (POSIX) {/// linux || __APPLE__ || __FreeBSD__ || __sun&&__SVR4
-	assert(false, "Unimplemented");
-	/+
     pid_t childpid;
     int i;
     int status;
 
     // Build argv[]
-    Array argv;
+    Array argv = new Array();
 
-    const char *cc = getenv("CC");
+    const(char)* cc = core.stdc.stdlib.getenv("CC");
     if (!cc)
 	cc = "gcc";
-    argv.push((void *)cc);
-    argv.insert(1, global.params.objfiles);
+    argv.push(cast(void *)cc);
+    Array objfiles = new Array;
+    for( i = 0; i < global.params.objfiles.dim; i++ )
+    {   string str = (cast(String)global.params.objfiles.data[i]).str; 
+    	objfiles.push(cast(void*)toStringz(str));
+    }
+    argv.insert(1, objfiles);
 
     // None of that a.out stuff. Use explicit exe file name, or
     // generate one from name of first source file.
-    argv.push((void *)"-o");
+    argv.push(cast(void *)cast(char*)"-o");
     if (global.params.exefile)
     {
-	argv.push(global.params.exefile);
+	argv.push(cast(void*)toStringz(global.params.exefile));
     }
     else
     {	// Generate exe file name from first obj name
-	char *n = (char *)global.params.objfiles.data[0];
-	char *e;
-	char *ex;
-
+	string n = (cast(String)global.params.objfiles.data[0]).str;
 	n = FileName.name(n);
-	e = FileName.ext(n);
-	if (e)
-	{
-	    e--;			// back up over '.'
-	    ex = (char *)mem.malloc(e - n + 1);
-	    memcpy(ex, n, e - n);
-	    ex[e - n] = 0;
-	}
-	else
-	    ex = (char *)"a.out";	// no extension, so give up
-	argv.push(ex);
+	string e = FileName.ext(n);
+	string ex = e ? n[0..$-(e.length+1)] : "a.out";
+
+	argv.push(cast(void*)toStringz(ex));
 	global.params.exefile = ex;
     }
 
     // Make sure path to exe file exists
-    {	char *p = FileName.path(global.params.exefile);
+    {	string p = FileName.path(global.params.exefile);
 	FileName.ensurePathExists(p);
-	mem.free(p);
     }
 
     if (global.params.symdebug)
-	argv.push((void *)"-g");
+	argv.push(cast(void *)cast(char*)"-g");
 
     if (global.params.isX86_64)
-	argv.push((void *)"-m64");
+	argv.push(cast(void *)cast(char*)"-m64");
     else
-	argv.push((void *)"-m32");
+	argv.push(cast(void *)cast(char*)"-m32");
 
     if (0 && global.params.exefile)
     {
@@ -882,16 +878,16 @@
 	 * Thomas Kuehne has verified that it works with ld 2.16.1.
 	 * BUG: disabled because it causes exception handling to fail
 	 */
-	argv.push((void *)"-Xlinker");
-	argv.push((void *)"--gc-sections");
+	argv.push(cast(void *)cast(char*)"-Xlinker");
+	argv.push(cast(void *)cast(char*)"--gc-sections");
     }
 
     for (i = 0; i < global.params.linkswitches.dim; i++)
-    {	char *p = (char *)global.params.linkswitches.data[i];
+    {	char *p = cast(char *)global.params.linkswitches.data[i];
 	if (!p || !p[0] || !(p[0] == '-' && p[1] == 'l'))
 	    // Don't need -Xlinker if switch starts with -l
-	    argv.push((void *)"-Xlinker");
-	argv.push((void *) p);
+	    argv.push(cast(void *)cast(char*)"-Xlinker");
+	argv.push(cast(void *) p);
     }
 
     /* Add each library, prefixing it with "-l".
@@ -903,17 +899,17 @@
      *  4. standard libraries.
      */
     for (i = 0; i < global.params.libfiles.dim; i++)
-    {	char *p = (char *)global.params.libfiles.data[i];
+    {	char *p = cast(char *)global.params.libfiles.data[i];
 	size_t plen = strlen(p);
 	if (plen > 2 && p[plen - 2] == '.' && p[plen -1] == 'a')
-	    argv.push((void *)p);
+	    argv.push(cast(void *)p);
 	else
 	{
-	    char *s = (char *)mem.malloc(plen + 3);
+	    char *s = cast(char *)malloc(plen + 3);
 	    s[0] = '-';
 	    s[1] = 'l';
 	    memcpy(s + 2, p, plen + 1);
-	    argv.push((void *)s);
+	    argv.push(cast(void *)s);
 	}
     }
 
@@ -923,20 +919,20 @@
     const char *libname = (global.params.symdebug)
 				? global.params.debuglibname
 				: global.params.defaultlibname;
-    char *buf = (char *)malloc(2 + strlen(libname) + 1);
+    char *buf = cast(char *)malloc(2 + strlen(libname) + 1);
     strcpy(buf, "-l");
     strcpy(buf + 2, libname);
-    argv.push((void *)buf);		// turns into /usr/lib/libphobos2.a
+    argv.push(cast(void *)buf);		// turns into /usr/lib/libphobos2.a
 
 //    argv.push((void *)"-ldruntime");
-    argv.push((void *)"-lpthread");
-    argv.push((void *)"-lm");
+    argv.push(cast(void *)cast(char*)"-lpthread");
+    argv.push(cast(void *)cast(char*)"-lm");
 
     if (!global.params.quiet || global.params.verbose)
     {
 	// Print it
 	for (i = 0; i < argv.dim; i++)
-	    printf("%s ", (char *)argv.data[i]);
+	    printf("%s ", cast(char *)argv.data[i]);
 	printf("\n");
 	fflush(stdout);
     }
@@ -945,8 +941,8 @@
     childpid = fork();
     if (childpid == 0)
     {
-	execvp((char *)argv.data[0], (char **)argv.data);
-	perror((char *)argv.data[0]);		// failed to execute
+	execvp(cast(char *)argv.data[0], cast(char **)argv.data);
+	perror(cast(char *)argv.data[0]);		// failed to execute
 	return -1;
     }
 
@@ -956,7 +952,7 @@
     if (status)
 	printf("--- errorlevel %d\n", status);
     return status;
-	+/
+	
 } else {
     writef ("Linking is not yet supported for this version of DMD.\n");
     return -1;
--- a/dmd/VarDeclaration.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/VarDeclaration.d	Thu Apr 08 04:21:03 2010 +0100
@@ -40,6 +40,7 @@
 import dmd.TOK;
 import dmd.TupleExp;
 import dmd.Global;
+import dmd.Module;
 import dmd.FuncDeclaration;
 import dmd.Type;
 import dmd.TY;
--- a/dmd/backend/Config.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/backend/Config.d	Thu Apr 08 04:21:03 2010 +0100
@@ -62,7 +62,7 @@
 enum CFG3relax = 0x200;	// relaxed type checking (C only)
 enum CFG3cpp = 0x400;	// C++ compile
 enum CFG3igninc = 0x800;	// ignore standard include directory
-version (XXX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS) {
+version (POSIX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS) {
 enum CFG3mars = 0x1000;	// use mars libs and headers
 enum NO_FAR	= true;	// always ignore __far and __huge keywords
 } else {
@@ -129,8 +129,6 @@
 
 mixin(BringToCurrentScope!(TARGET));
 
-enum CV4 = 2;		// Codeview 4 symbolic info
-
 struct Config
 {
     char language;		// 'C' = C, 'D' = C++
@@ -195,13 +193,13 @@
 extern (C) extern __gshared Config config;
 
 enum CVNONE = 0;		// No symbolic info
-///enum CVOLD = 1;		// Codeview 1 symbolic info
-///enum CV4 = 2;		// Codeview 4 symbolic info
-///enum CVSYM = 3;		// Symantec format
-///enum CVTDB = 4;		// Symantec format written to file
-///enum CVDWARF_C = 5;		// Dwarf in C format
-///enum CVDWARF_D = 6;		// Dwarf in D format
-///enum CVSTABS = 7;		// Elf Stabs in C format
+enum CVOLD = 1;		// Codeview 1 symbolic info
+enum CV4 = 2;		// Codeview 4 symbolic info
+enum CVSYM = 3;		// Symantec format
+enum CVTDB = 4;		// Symantec format written to file
+enum CVDWARF_C = 5;		// Dwarf in C format
+enum CVDWARF_D = 6;		// Dwarf in D format
+enum CVSTABS = 7;		// Elf Stabs in C format
 
 enum CFGuchar = 1;	// chars are unsigned
 enum CFGsegs = 2;	// new code seg for each far func
--- a/dmd/backend/SFL.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/backend/SFL.d	Thu Apr 08 04:21:03 2010 +0100
@@ -27,7 +27,7 @@
 	SFLdyninit = 0x200000,	// symbol has dynamic initializer
 	SFLtmp = 0x400000,	// symbol is a generated temporary
 
-///version (XXX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+///version (POSIX) {///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 ///    SFLthunk = 0x40000, // symbol is temporary for thunk
 ///}
 
@@ -64,4 +64,4 @@
 }
 
 import dmd.EnumUtils;
-mixin(BringToCurrentScope!(SFL));
\ No newline at end of file
+mixin(BringToCurrentScope!(SFL));
--- a/dmd/backend/Symbol.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/backend/Symbol.d	Thu Apr 08 04:21:03 2010 +0100
@@ -82,6 +82,18 @@
 
     const(char)* prettyIdent;	// the symbol identifer as the user sees it
 
+version (ELFOBJ_OR_MACHOBJ)
+{
+    ptrdiff_t     obj_si;       // Symbol index of coff or elf symbol
+    size_t        dwarf_off;    // offset into .debug section
+    targ_size_t   code_off;	// rel. offset from start of block where var is initialized
+    targ_size_t   last_off;	// last offset using var
+}
+version (TARGET_OSX)
+{
+    targ_size_t Slocalgotoffset;
+}
+
     enum_SC Sclass;		// storage class (SCxxxx)
     char Sfl;			// flavor (FLxxxx)
     SYMFLGS Sflags;		// flag bits (SFLxxxx)
@@ -385,4 +397,4 @@
 		assert(false);
 	}
 }
-+/
\ No newline at end of file
++/
--- a/dmd/backend/TYPE.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/backend/TYPE.d	Thu Apr 08 04:21:03 2010 +0100
@@ -23,7 +23,7 @@
     ushort Tflags;	// TFxxxxx
 
 version (TX86) {
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 ///#define mTYnoret	0x010000	// function has no return
 ///#define mTYtransu	0x010000	// transparent union
 } else {
@@ -37,7 +37,7 @@
 ///#define mTYsyscall	0x400000
 ///#define mTYjava		0x800000
 
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
 ///#define mTYTFF		0xFE0000
 } else {
 ///#define mTYTFF		0xFF0000
--- a/dmd/backend/Util.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/backend/Util.d	Thu Apr 08 04:21:03 2010 +0100
@@ -125,6 +125,8 @@
 
 extern (C++) {
 //__gshared:
+	void obj_ehsections();
+	void obj_staticdtor(Symbol *s);
 	void* mem_fcalloc(uint numbytes);
 	type* type_fake(tym_t);
 	dt_t** dtnzeros(dt_t** pdtend, targ_size_t size);
--- a/dmd/backend/iasm.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/backend/iasm.d	Thu Apr 08 04:21:03 2010 +0100
@@ -191,15 +191,15 @@
 enum mST0 = (1 << ST0);	// 0x4000
 enum mST01 = (1 << ST01);	// 0x8000
 
-version (XXX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
+version (POSIX) { ///TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS
     // To support positional independent code,
     // must be able to remove BX from available registers
-///extern regm_t ALLREGS;			
-///#define ALLREGS_INIT		(mAX|mBX|mCX|mDX|mSI|mDI)
-///#define ALLREGS_INIT_PIC	(mAX|mCX|mDX|mSI|mDI)
-///extern regm_t BYTEREGS;			
-///#define BYTEREGS_INIT		(mAX|mBX|mCX|mDX)
-///#define BYTEREGS_INIT_PIC	(mAX|mCX|mDX)
+extern (C) extern __gshared regm_t ALLREGS;			
+enum ALLREGS_INIT = (mAX|mBX|mCX|mDX|mSI|mDI);
+enum ALLREGS_INIT_PIC = (mAX|mCX|mDX|mSI|mDI);
+extern (C) extern regm_t BYTEREGS;			
+enum BYTEREGS_INIT = (mAX|mBX|mCX|mDX);
+enum BYTEREGS_INIT_PIC = (mAX|mCX|mDX);
 } else {
 enum ALLREGS = (mAX|mBX|mCX|mDX|mSI|mDI);
 ///#define ALLREGS_INIT		ALLREGS
--- a/dmd/codegen/Util.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/dmd/codegen/Util.d	Thu Apr 08 04:21:03 2010 +0100
@@ -14,6 +14,7 @@
 import dmd.Argument;
 import dmd.STC;
 import dmd.Global;
+import dmd.Module;
 import dmd.InterfaceDeclaration;
 import dmd.AggregateDeclaration;
 import dmd.AttribDeclaration;
@@ -1121,7 +1122,7 @@
     s.Sflags |= SFLnodebug;
     s.Stype = t;
 version (ELFOBJ_OR_MACHOBJ) {
-    s.Sseg = DATA;
+    s.Sseg = Segment.DATA;
 }
     slist_add(s);
     return s;
@@ -1149,4 +1150,4 @@
 			s.lblock.Btry = null;
     }
     return s.lblock;
-}
\ No newline at end of file
+}
--- a/main.d	Wed Apr 07 00:51:29 2010 +0100
+++ b/main.d	Thu Apr 08 04:21:03 2010 +0100
@@ -148,6 +148,7 @@
 +/
 int main(string[] args)
 {
+    GC.disable();
     Array files = new Array();
     Array libmodules = new Array();
     Module m;