rink/nm patch

Peter Naulls peter at chocky.org
Sat Mar 30 07:49:39 PST 2002


You guessed right.  Same again.

Index: riscos-aof/nm/nm.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/nm/Attic/nm.c,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 nm.c
--- riscos-aof/nm/nm.c	2002/03/01 16:48:22	1.1.2.2
+++ riscos-aof/nm/nm.c	2002/03/30 15:13:50
@@ -115,7 +115,7 @@
 /*
  * check for EOF or write/read errors on stream.
  */
-Ferror
+static Ferror
 check_stream (FILE *fp)
 {
   int ret = FNOERR;
@@ -132,7 +132,7 @@
 /*
  * read a byte from the input stream.
  */
-unsigned char
+static unsigned char
 read_byte (FILE *ifp)
 {
   return (unsigned char) getc (ifp);
@@ -141,7 +141,7 @@
 /*
  * read a little-endian 2-byte halfword from the input stream.
  */
-unsigned short
+static unsigned short
 read_halfword (FILE *ifp)
 {
   union
@@ -163,7 +163,7 @@
 /*
  * read a little-endian 4-byte word from the input stream.
  */
-unsigned long
+static unsigned long
 read_word (FILE *ifp)
 {
   union
@@ -187,7 +187,7 @@
 /*
  * read in the chunk header
  */
-struct chunkhdr *
+static struct chunkhdr *
 read_chunkhdr (FILE *ifp)
 {
   static struct chunkhdr hdr;
@@ -212,7 +212,7 @@
 /*
  * free the memory used by a chunk
  */
-int
+static int
 free_chunk_memory (char *ptr)
 {
   if (!ptr)
@@ -251,10 +251,10 @@
 /*
  * read in the chunk entries
  */
-struct chunkent *
+static struct chunkent *
 read_chunkents (FILE *ifp, struct chunkhdr *hdr)
 {
-  register int i;
+  register unsigned int i;
 
   if (ents)
     free (ents);
@@ -275,14 +275,14 @@
 /*
  * read in the string table
  */
-char *
+static char *
 read_stringtab (FILE *ifp, struct chunkent *strent)
 {
   if (strptr)
     free (strptr);
   strptr = xmalloc (strent->size);
   fseek (ifp, strent->offset, 0);
-  *(unsigned long *) strptr = read_word (ifp);	/* size in 1st word */
+  *(unsigned long *)(void *)strptr = read_word (ifp);	/* size in 1st word */
   fread (strptr + 4, 1, (int) strent->size - 4, ifp);
 
   return (check_stream (ifp) != FRWERR ? strptr : NULL);
@@ -291,7 +291,7 @@
 /*
  * read in the symbol table
  */
-struct symbol *
+static struct symbol *
 read_symboltab (FILE *ifp, struct chunkent *syment, int numsyms)
 {
   register int i;
@@ -315,7 +315,7 @@
 /*
  * read in the identification chunk
  */
-char *
+static char *
 read_ident (FILE *ifp, struct chunkent *ident)
 {
   if (idptr)
@@ -330,10 +330,10 @@
 /*
  * read in the AOF header
  */
-struct aofhdr *
+static struct aofhdr *
 read_aofhdr (FILE *ifp, struct chunkent *hdrent)
 {
-  register int i;
+  register unsigned int i;
   struct areahdr *areahdr;
 
   if (aofhdr)
@@ -363,7 +363,7 @@
 /*
  * read in a relocation directive
  */
-struct reloc *
+static struct reloc *
 read_reloc (FILE *ifp)
 {
   static struct reloc reloc;
@@ -380,7 +380,7 @@
 static char *
 string (const char *stringtab, unsigned long offset)
 {
-  if (!stringtab || offset < 4 || offset >= *(unsigned long *) stringtab)
+  if (!stringtab || offset < 4 || offset >= *(unsigned long *)(void *)stringtab)
     return (NULL);
   return ((char *) (stringtab + offset));
 }
@@ -388,10 +388,10 @@
 /*
  * locate a chunk entry by chunk ID
  */
-struct chunkent *
+static struct chunkent *
 find_ent (struct chunkhdr *hdr, struct chunkent *ents, const char *name)
 {
-  int i;
+  unsigned int i;
 
   for (i = 0; i < hdr->numchunks; i++)
     if (memcmp (ents[i].chunkid, name, 8) == 0)
@@ -400,7 +400,8 @@
 }
 
 /* Return -1 on error. 0 on success.  */
-int decode (const char *aof_file)
+static int
+decode (const char *aof_file)
 {
   FILE *handle;
   struct chunkhdr *hdr;
@@ -505,7 +506,7 @@
   /* Print the symbol table.  */
   if (aofhdr->numsyms)
     {
-      int i, flags;
+      unsigned int i, flags;
 
       for (i = 0; i < aofhdr->numsyms; i++)
 	{
Index: riscos-aof/rink/extractsym.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/rink/extractsym.c,v
retrieving revision 1.1
diff -u -r1.1 extractsym.c
--- riscos-aof/rink/extractsym.c	2001/01/02 09:37:16	1.1
+++ riscos-aof/rink/extractsym.c	2002/03/30 15:13:50
@@ -90,10 +90,10 @@
 
 /**********************************************************/
 
-static char *
-LoadEntry (char *EntryName, char *Header, int *Size)
+static void *
+LoadEntry (const char *EntryName, char *Header, int *Size)
 {
-  CFF_Header *TheHeader = (CFF_Header *) Header;
+  CFF_Header *TheHeader = (CFF_Header *)(void *) Header;
   CFF_Entry *Entries = (CFF_Entry *) (TheHeader + 1);
   int l = 0;
   BOOL Found = FALSE;
@@ -147,7 +147,7 @@
 }
 
 static char *
-LoadHeader ()
+LoadHeader (void)
 {
   char *FileHeader;
   CFF_Header TheHeader;
@@ -184,7 +184,7 @@
     }
 
   // copy the header
-  *((CFF_Header *) FileHeader) = TheHeader;
+  *((CFF_Header *)(void *) FileHeader) = TheHeader;
 
   // read in the entries
   if (fread
@@ -280,7 +280,7 @@
   if ((FileHeader = LoadHeader ()) == 0)
     return FALSE;
 
-  CFFHeader = (CFF_Header *) FileHeader;
+  CFFHeader = (CFF_Header *)(void *) FileHeader;
   CFFEntries = (CFF_Entry *) (CFFHeader + 1);
 
   // load the directory
@@ -335,7 +335,7 @@
   while (Offset < DirectorySize)
     {
       DoThisOne = FALSE;
-      Entry = (ALF_DirectoryEntry *) (Entries + Offset);
+      Entry = (ALF_DirectoryEntry *)(void *) (Entries + Offset);
 // printf("%d : %s\n", Entry->ChunkIndex, Entry->FileName);
 
       if (Entry->ChunkIndex != 0)
Index: riscos-aof/rink/rink.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/rink/rink.c,v
retrieving revision 1.1
diff -u -r1.1 rink.c
--- riscos-aof/rink/rink.c	2001/01/02 09:37:16	1.1
+++ riscos-aof/rink/rink.c	2002/03/30 15:13:53
@@ -42,7 +42,7 @@
 
 typedef struct
 {
-  int chunkfield;
+  unsigned int chunkfield;
   int maxchunks, numchunks;
 }
 chunk_file_hdr;
@@ -80,7 +80,7 @@
 
 typedef struct
 {
-  int object_file_type;
+  unsigned int object_file_type;
   int version;
   int n_areas;
   int n_symbols;
@@ -240,7 +240,7 @@
 
 #define MAX_PARAM 3
 char *params[] = { code_name, links_name, header_name, map_name };
-char *param_trans[] = { "code", "links", "header description", "map" };
+const char *param_trans[] = { "code", "links", "header description", "map" };
 
 typedef struct
 {
@@ -266,13 +266,13 @@
 char *header_cp;
 char *areas;
 char *identification;
-char *symbol_table;
+void *symbol_table;
 char *string_table;
 
 aof_header *header;
 
 char **aof_chunks[] =
-  { &header_cp, &areas, &identification, &symbol_table, &string_table };
+  { &header_cp, &areas, &identification, (char **)&symbol_table, &string_table };
 char aof_chunkids[7][9] =
   { "OBJ_HEAD", "OBJ_AREA", "OBJ_IDFN", "OBJ_SYMT", "OBJ_STRT", "" };
 #define OBJ_IDFN 2
@@ -317,7 +317,7 @@
 
 /* **************************************************************************** map functions */
 
-char *
+static char *
 map_find_name (int n)
 {
   int l, i;
@@ -331,7 +331,7 @@
   return map + i;
 }
 
-int
+static int
 map_lookup (char *symbol)
 {
   int l, i;
@@ -349,7 +349,7 @@
   return -1;
 }
 
-BOOL
+static BOOL
 map_load (char *filename)
 {
   FILE *f;
@@ -433,24 +433,26 @@
 
 /* *************************************************************************** misc functions */
 
-void
-delete_file (char *name)
+static void
+delete_file (const char *name)
 {
   unlink (name);
 }
 
-BOOL
+static BOOL
 save_file (char *name, char *start, int length, int type)
 {
   FILE *handle;
 
+  type = type;
+
   handle = fopen (name, "w");
   fwrite (start, 1, length, handle);
   fclose (handle);
   return TRUE;
 }
 
-char *
+static char *
 find_area_address (int index)
 {
   int l;
@@ -466,7 +468,7 @@
   return loc;
 }
 
-relocation *
+static relocation *
 find_area_reloc_address (int index)
 {
   int l;
@@ -490,10 +492,10 @@
 
   loc += t;
 
-  return (relocation *) loc;
+  return (relocation *)(void *)loc;
 }
 
-area_map_entry *
+static area_map_entry *
 find_area_search (char *name, area_map_entry * table, int entries)
 {
   int l;
@@ -509,7 +511,7 @@
   return 0;
 }
 
-char *
+static char *
 name_of_area (int index)
 {
   area_header_entry *ai = (area_header_entry *) (header + 1);
@@ -517,7 +519,8 @@
   return string_table + ai[index].name_offset;
 }
 
-area_map_entry *
+#if 0
+static area_map_entry *
 find_area_index (char *name)
 {
   area_map_entry *a;
@@ -531,6 +534,7 @@
 
   return 0;
 }
+#endif
 
 /* ********************************************************************* get info on a symbol */
 
@@ -547,7 +551,7 @@
 
   /* fills in a symbol_info given an index into the symbol table,
      returns TRUE if the symbol can be resolved (reports error to user, returns FALSE if not)  */
-BOOL
+static BOOL
 get_symbol_info (int s_index, symbol_info * info)
 {
   symbol_entry *se;
@@ -633,14 +637,14 @@
 
 /* ****************************************************************************** make header */
 
-BOOL
+static BOOL
 make_header (void)
 {
   int l, ll;
   rink_code_fn_entry *en =
-    (rink_code_fn_entry *) (code + sizeof (rink_code_hdr));
+    (rink_code_fn_entry *)(void *)(code + sizeof (rink_code_hdr));
   rink_code_named_fn_entry *nn =
-    (rink_code_named_fn_entry *) (((char *) en) +
+    (rink_code_named_fn_entry *)(void *)(((char *) en) +
 				  (sizeof (rink_code_fn_entry) *
 				   header_entries));
   char *named_sym =
@@ -745,7 +749,7 @@
 
 /* ********************************************************************** perform relocations */
 
-void
+static void
 links_check_size (int data_size)
 {
   if ((links_end + data_size + 4) > links_size)
@@ -758,7 +762,7 @@
     }
 }
 
-void
+static void
 add_link (rink_link * link)
 {
   links_check_size (sizeof (rink_link));
@@ -797,7 +801,7 @@
       pl.index = link->index;
       pl.type = TYPE_ADD_FN_PACKED;
 
-      *((link_info_packed *) (links + links_end)) = pl;
+      *((link_info_packed *) (void *)(links + links_end)) = pl;
       links_end += sizeof (link_info_packed);
       n_links++;
 
@@ -807,14 +811,14 @@
       return;
     }
 
-  *((rink_link *) (links + links_end)) = *link;
+  *((rink_link *)(void *)(links + links_end)) = *link;
   links_end +=
     (link->sys.type ==
      TYPE_ADD_BASE) ? sizeof (link_info) : sizeof (rink_link);
   n_links++;
 }
 
-BOOL
+static BOOL
 make_relocations (void)
 {
   char id[] = RINK_LINKS_ID;
@@ -844,10 +848,10 @@
     }
   links_size = LINKS_BLOCK;
   /* make links file header */
-  ((rink_links_hdr *) links)->id = *((int *) id);
-  ((rink_links_hdr *) links)->version = RINK_LINKS_VERSION;
+  ((rink_links_hdr *)(void *) links)->id = *((int *)(void *) id);
+  ((rink_links_hdr *)(void *) links)->version = RINK_LINKS_VERSION;
   n_links = 0;
-  ((rink_links_hdr *) links)->reserved = 0;
+  ((rink_links_hdr *)(void *) links)->reserved = 0;
 
   links_end = sizeof (rink_links_hdr);
 
@@ -913,7 +917,7 @@
 		    }
 
 		  /* next, add the offset of the base of the area from the field */
-		  *((int *) (code + real_map[area].start_offset + re->offset))
+		  *((int *)(void *)(code + real_map[area].start_offset + re->offset))
 		    += base;
 
 		  /* and then generate a run-time relocation directive to add the
@@ -952,7 +956,7 @@
 		  else if (si.absolute_value)
 		    {
 		      /* add constant to field */
-		      *((int *)
+		      *((int *)(void *)
 			(code + real_map[area].start_offset + re->offset)) +=
 			si.value;
 
@@ -960,7 +964,7 @@
 		  else
 		    {
 		      /* add address of location within an area */
-		      *((int *)
+		      *((int *)(void *)
 			(code + real_map[area].start_offset + re->offset)) +=
 			si.area_base + si.value;
 		      link.index = 0;
@@ -997,7 +1001,7 @@
 		  base = fa->start_offset;
 
 		  /* add offset of start base */
-		  *((int *) (code + real_map[area].start_offset + re->offset))
+		  *((int *)(void *) (code + real_map[area].start_offset + re->offset))
 		    += base - real_map[area].start_offset;
 
 
@@ -1049,7 +1053,7 @@
 		      if (
 			  (*
 			   ((unsigned
-			     int *) (code + real_map[area].start_offset +
+			     int *)(void *) (code + real_map[area].start_offset +
 				     re->offset)) & 0x0e000000) != 0x0a000000)
 			{
 			  // oh dear, it's not a branch...
@@ -1064,18 +1068,18 @@
 
 		      /* perform the relocation */
 		      nn =
-			*((unsigned int *)
+			*((unsigned int *)(void *)
 			  (code + real_map[area].start_offset +
 			   re->offset)) & 0xff000000;
 		      n =
 			((signed
 			  int) ((*
 				 ((unsigned
-				   int *) (code +
+				   int *)(void *) (code +
 					   real_map[area].start_offset +
 					   re->offset)) & 0x00ffffff) << 8)) +
 			(n << 8);
-		      *((unsigned int *)
+		      *((unsigned int *)(void *)
 			(code + real_map[area].start_offset + re->offset)) =
 			nn | (((unsigned int) n) >> 8);
 
@@ -1099,7 +1103,7 @@
 	}
     }
 
-  ((rink_links_hdr *) links)->n_links = n_links;
+  ((rink_links_hdr *)(void *) links)->n_links = n_links;
 
   if (vverbose)
     printf ("\n\n\n");
@@ -1109,7 +1113,7 @@
 
 /* ********************************************************** copy areas into real code block */
 
-BOOL
+static BOOL
 make_code (void)
 {
   int l;
@@ -1122,18 +1126,18 @@
     }
 
   /* set up the header */
-  strcpy (((rink_code_hdr *) code)->id, code_id);
-  ((rink_code_hdr *) code)->main_version = main_version;
-  ((rink_code_hdr *) code)->code_version = code_version;
-  ((rink_code_hdr *) code)->fn_entries = header_entries;
-  ((rink_code_hdr *) code)->code_size = real_size;
-  ((rink_code_hdr *) code)->zero_init_size = zero_size;
-  ((rink_code_hdr *) code)->named_entries = named_entries;
+  strcpy (((rink_code_hdr *)(void *)code)->id, code_id);
+  ((rink_code_hdr *)(void *) code)->main_version = main_version;
+  ((rink_code_hdr *)(void *) code)->code_version = code_version;
+  ((rink_code_hdr *)(void *) code)->fn_entries = header_entries;
+  ((rink_code_hdr *)(void *) code)->code_size = real_size;
+  ((rink_code_hdr *)(void *) code)->zero_init_size = zero_size;
+  ((rink_code_hdr *)(void *) code)->named_entries = named_entries;
   
-    ((rink_code_hdr *) code)->named_offset =
+    ((rink_code_hdr *)(void *) code)->named_offset =
     sizeof (rink_code_hdr) + (sizeof (rink_code_fn_entry) * header_entries);
-  ((rink_code_hdr *) code)->reserved1 = 0;
-  ((rink_code_hdr *) code)->reserved2 = 0;
+  ((rink_code_hdr *)(void *) code)->reserved1 = 0;
+  ((rink_code_hdr *)(void *) code)->reserved2 = 0;
 
   ae = (area_header_entry *) (header + 1);
 
@@ -1150,7 +1154,7 @@
 
 /* ************************************************** generate maps for real and zeroed areas */
 
-BOOL
+static BOOL
 generate_area_map (void)
 {
   int l;
@@ -1286,7 +1290,7 @@
 /* ************************************************************ parse header description file */
 
 #define MAX_TOKEN_LEN 32
-BOOL
+static BOOL
 parse_header_file (char *filename)
 {
   FILE *f;
@@ -1439,7 +1443,7 @@
 
 /* *********************************************************************** parse command line */
 
-BOOL
+static BOOL
 parse_commandline (int argc, char *argv[])
 {
   int l, ll;
@@ -1613,13 +1617,13 @@
   fclose (handle);
 
   /* set up pointers to the areas within the file */
-  if (((chunk_file_hdr *) aof)->chunkfield != 0xC3CBC6C5)
+  if (((chunk_file_hdr *)(void *) aof)->chunkfield != 0xC3CBC6C5)
     {
       printf ("rink: source 'aof' file is not an aof file\n\n");
       return 1;
     }
-  ce = (chunk_entry *) (((chunk_file_hdr *) aof) + 1);
-  for (l = 0; l < ((chunk_file_hdr *) aof)->numchunks; l++)
+  ce = (chunk_entry *)(void *) (((chunk_file_hdr *)(void *) aof) + 1);
+  for (l = 0; l < ((chunk_file_hdr *)(void *) aof)->numchunks; l++)
     {
       n = 0;
       while (aof_chunkids[n][0] != '\0')
@@ -1647,7 +1651,7 @@
       printf ("rink: source aof file created by '%s'\n\n", identification);
     }
 
-  header = (aof_header *) header_cp;
+  header = (aof_header *)(void *) header_cp;
 
   if (header->version == 311)
     areas += link_bug_patch;
Index: riscos-aof/rink/rinkptr.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/rink/rinkptr.c,v
retrieving revision 1.1
diff -u -r1.1 rinkptr.c
--- riscos-aof/rink/rinkptr.c	2001/01/02 09:37:16	1.1
+++ riscos-aof/rink/rinkptr.c	2002/03/30 15:13:54
@@ -152,7 +152,7 @@
 static int id_chunk_size;
 
 static char *chunk_file;
-static int chunk_file_size;
+static unsigned int chunk_file_size;
 
 char alloc_fn[256] = "malloc";
 char free_fn[256] = "free";
@@ -180,7 +180,7 @@
 
 #define MAX_PARAM 1
 char *params[] = { map_name, aof_name };
-char *param_trans[] = { "pointer block map", "output AOF file" };
+const char *param_trans[] = { "pointer block map", "output AOF file" };
 
 static char *symbols;
 static int sym_len;
@@ -192,7 +192,7 @@
 
 /* **************************************************************************** misc functions */
 
-void
+static void
 add_symbol (char *symbol)
 {
   int l;
@@ -215,7 +215,7 @@
 
 /* *************************************************************************** create aof file */
 
-BOOL
+static BOOL
 create_aof_file (void)
 {
   FILE *output;
@@ -298,7 +298,7 @@
 
   string_table = aof_symbols;
   string_table_size = (aof_sym_i + 4) & (~3);
-  *((int *) aof_symbols) = string_table_size;
+  *((int *)(void *) aof_symbols) = string_table_size;
 
 
   printf ("rinkptr: size of _rink_pointerblock: %d\n\n",
@@ -317,9 +317,9 @@
     }
   memset (area_chunk, '\0', (n_aof_symbols * sizeof (int *)));
   for (l = n_aof_symbols; l < (n_aof_symbols + N_SUGARS); l++)
-    ((int *) area_chunk)[l] = BRANCH;
+    ((int *)(void *) area_chunk)[l] = BRANCH;
   re =
-    (relocation *) (area_chunk +
+    (relocation *)(void *) (area_chunk +
 		    ((n_aof_symbols + N_SUGARS) * sizeof (int *)));
   for (l = 0; l < (n_aof_symbols + N_SUGARS); l++)
     {
@@ -351,7 +351,7 @@
       return 1;
     }
   i = sizeof (int);
-  se = (symbol_entry *) symbol_table;
+  se = (symbol_entry *)(void *) symbol_table;
   for (l = 0; l < (n_aof_symbols + (N_SUGARS * 2)); l++)
     {
       se->name_offset = i;
@@ -406,7 +406,7 @@
       printf ("rinkptr: no room\n\n");
       return 1;
     }
-  ah = (aof_header *) header;
+  ah = (aof_header *)(void *) header;
   he = (area_header_entry *) (ah + 1);
   ah->object_file_type = 0xC5E2D080;
   ah->version = 150;
@@ -445,7 +445,7 @@
       return 1;
     }
   i = sizeof (chunk_file_hdr) + (sizeof (chunk_entry) * CHUNKS_IN_FILE);
-  ch = (chunk_file_hdr *) chunk_file;
+  ch = (chunk_file_hdr *)(void *) chunk_file;
   ce = (chunk_entry *) (ch + 1);
 
   ch->chunkfield = 0xC3CBC6C5;
@@ -507,7 +507,7 @@
 
 /* ************************************************************************ parse command line */
 
-BOOL
+static BOOL
 parse_commandline (int argc, char *argv[])
 {
   int l, ll;


-- 
------------------------------------------------------------------------
 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