Index: gcc.mak
===================================================================
RCS file: /cvsroot/ldg/ldg/src/devel/gcc.mak,v
retrieving revision 1.3
diff -u -r1.3 gcc.mak
--- gcc.mak	19 Oct 2005 20:32:05 -0000	1.3
+++ gcc.mak	12 Aug 2008 22:55:23 -0000
@@ -29,7 +29,7 @@
 AR     = ar
 endif
 
-CFLAGS   = -W -Wall -O -I../../include -I.. -I.
+CFLAGS   = -W -Wall -O -I../../include -I.. -I. -D_GNU_SOURCE=1
 ARFLAGS  = crus
 OBJDIR   = .gcc
 TARGET   = ../../lib/gcc/libldg.a
Index: ldgload.c
===================================================================
RCS file: /cvsroot/ldg/ldg/src/devel/ldgload.c,v
retrieving revision 1.1
diff -u -r1.1 ldgload.c
--- ldgload.c	25 Jul 2005 19:37:07 -0000	1.1
+++ ldgload.c	12 Aug 2008 22:55:23 -0000
@@ -24,6 +24,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <stdio.h>
 #ifdef __PUREC__
 # include <tos.h>
@@ -54,6 +55,7 @@
 	BASPAG *module;
 	LDG **addr = NULL;
 	char offsetxt[24];
+	char *new_env = NULL;
 
 	/* 
 	 * L'adresse du descripteur de la lib (LDG) 
@@ -72,14 +74,34 @@
 	
 	/* on met directement addr */
 #ifdef __GNUC__
-	sprintf(offsetxt,"OFFSETLDG=%ld%c%c",(long)addr,'\0','\0');
+	sprintf(offsetxt,"OFFSETLDG=%ld",(long)addr);
+	putenv(offsetxt);
+
+	/* Create new env string */
+	{
+		int i, new_len, cur_len=1;
+		new_env = malloc(1);	/* For final zero */
+		for (i=0; environ[i]; ++i) {
+			new_len = strlen(environ[i])+1;
+			new_env = realloc(new_env, cur_len+new_len);
+			strcpy(&new_env[cur_len-1], environ[i]);
+			cur_len += new_len;
+		}
+		new_env[cur_len-1]=0;
+	}
 #else
 	strcpy(offsetxt,"OFFSETLDG=");
   	ltoa( (long)addr, offsetxt+10, 10);
   	offsetxt[strlen( offsetxt) + 1] = '\0';
 #endif
 
-	module = (BASPAG *)Pexec( 3, path, NULL, offsetxt);
+  	module = (BASPAG *)Pexec( 3, path, NULL,
+#ifdef __GNUC__
+		new_env
+#else
+		offsetxt
+#endif
+	);
 	if( (long)module < 0L) {
 		set_error( LDG_ERR_EXEC);
 		return NULL;	/* echec de Pexec */
