ld patch

Peter Naulls peter at chocky.org
Sat Mar 30 07:46:23 PST 2002


More of the same exciting patches.

I've simplified the #if logic around choosing a linker.
But note the commenting I've added.  The point here is to call "drlink"
and not "GCCbin:drlink".  This is a fix for ld used with lcc.  Drlink is
placed in the Run$Path by both GCC and LCC so this seems to work fine.

Nick, if you agree that that's correct, remove the commented section.

Peter


Index: riscos-aof/ld/ld.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/ld/ld.c,v
retrieving revision 1.7.2.9
diff -u -r1.7.2.9 ld.c
--- riscos-aof/ld/ld.c	2002/03/30 09:24:46	1.7.2.9
+++ riscos-aof/ld/ld.c	2002/03/30 15:13:47
@@ -71,7 +71,7 @@
 
 static char *ldout;	  /* pathname for linker errors */
 static char *ld_viafile;  /* pathname for linker -via <file> object list  */
-static char *c_file_name; /* pathname of gcc.  */
+static const char *c_file_name; /* pathname of gcc.  */
 static struct obstack temporary_obstack;
 static struct obstack permanent_obstack;
 static char *temporary_firstobj;
@@ -112,8 +112,8 @@
 static void llist_free (llist *list);
 static void append_arg (args *, int *, const char *);
 static void tlink_init (void);
-static int tlink_execute (char *prog, char **argv, char *redir, char *viafile);
-static void do_tlink (char *, char **, args *);
+static int tlink_execute (const char *prog, char **argv, char *redir, char *viafile);
+static void do_tlink (const char *, char **, args *);
 static int choose_temp_base (void);
 static void dump_file (char *);
 static void ldversion (int);
@@ -124,10 +124,10 @@
 
 /* Same as `malloc' but report error if no memory available.  */
 
-char *
+static void *
 xmalloc (unsigned size)
 {
-  register char *value = (char *) malloc (size);
+  void *value = malloc (size);
   if (value == 0)
     ld_error ("virtual memory exhausted");
   return value;
@@ -135,10 +135,10 @@
 
 /* Same as `realloc' but report error if no memory available.  */
 
-char *
+static void *
 xrealloc (char *ptr, int size)
 {
-  char *result = (char *) realloc (ptr, size);
+  void *result = realloc (ptr, size);
   if (!result)
     ld_error ("virtual memory exhausted");
   return result;
@@ -201,7 +201,7 @@
 int
 main (int argc, char *argv[])
 {
-  char *requested_linker;
+  const char *requested_linker;
 
   tlink_init ();
   linker_initialise ();
@@ -209,23 +209,19 @@
   if (tlink_verbose > 0)
     ldversion (0);
 
+#ifndef STANDARD_EXEC_PREFIX
+#define STANDARD_EXEC_PREFIX ""
+#endif
+
 #ifdef CROSS_COMPILE
-#ifdef STANDARD_EXEC_PREFIX
   requested_linker = STANDARD_EXEC_PREFIX "drlink";
-#else
-  requested_linker = "drlink";
-#endif
 #else /* CROSS_COMPILE */
   requested_linker = getenv ("GCC$Linker");
 
   /* No linker has been specified, try finding one on the Run$Path.  */
   if (requested_linker == NULL || *requested_linker == '\0')
     {
-#ifdef STANDARD_EXEC_PREFIX
-      requested_linker = STANDARD_EXEC_PREFIX "drlink";
-#else
-      requested_linker = "drlink";
-#endif
+      requested_linker = /*STANDARD_EXEC_PREFIX*/ "drlink";
     }
 #endif /* CROSS_COMPILE */
 
@@ -679,12 +675,13 @@
 }
 
 static int
-tlink_execute (char *prog, char **argv, char *redir, char *viafile)
+tlink_execute (const char *prog, char **argv, char *redir, char *viafile)
 {
   char *command, *temp;
   char **p_argv, *str, *s = NULL, filename[256];
   FILE *handle;
-  int system_result, command_size;
+  int system_result;
+  unsigned int command_size;
 #ifdef __riscos__
   pid_t pid;
 #endif
@@ -1288,7 +1285,7 @@
 
 
 void
-do_tlink (char *linker, char **ld_argv, args *object_lst)
+do_tlink (const char *linker, char **ld_argv, args *object_lst)
 {
   int exit_code = tlink_execute (linker, ld_argv, ldout, ld_viafile);
 
@@ -1327,7 +1324,7 @@
 static int
 choose_temp_base (void)
 {
-  char *base = getenv ("TMPDIR");
+  const char *base = getenv ("TMPDIR");
   int len;
 
   if (base == (char *)0)
@@ -1336,7 +1333,7 @@
       if (access (P_tmpdir, R_OK | W_OK) == 0)
 	base = P_tmpdir;
 #endif
-      if (base == (char *)0)
+      if (base == NULL)
 	{
 	  if (access ("/usr/tmp", R_OK | W_OK) == 0)
 	    base = "/usr/tmp/";
@@ -1427,7 +1424,7 @@
     fprintf (stdout, "\n");
 }
 
-static void out (char *s)
+static void out (const char *s)
 {
   fprintf (stdout, "%s\n", s);
 }
Index: riscos-aof/ld/rname.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/ld/rname.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 rname.c
--- riscos-aof/ld/rname.c	2000/11/08 09:38:58	1.1.1.1
+++ riscos-aof/ld/rname.c	2002/03/30 15:13:48
@@ -16,9 +16,12 @@
 #include <string.h>
 #include <ctype.h>
 
+char *riscos_to_unix (const char *, char *);
+
+
 /* A list of prefixes we will try and swap round.  */
 
-static char *prefixes[] =
+static const char *prefixes[] =
 {
   "f", "for", "fpp", "p", "pas", "ph", "gpi",
   "cc", "cxx", "cpp", "c++", "c", "m", "rpo",


-- 
------------------------------------------------------------------------
 Peter Naulls - peter at chocky.org
 Homepage                     -  http://www.chocky.org/
 RISC OS Projects Initiative  -  http://initiative.chocky.org/
 RISC OS C Programming        -  http://www.riscos.info/
------------------------------------------------------------------------



More information about the gcc mailing list