]> Shamusworld >> Repos - rln/blobdiff - rln.h
Fixed warning that did not respect -w flag.
[rln] / rln.h
diff --git a/rln.h b/rln.h
index 88848ea71811bd922f4aca87d83139d24bfa7774..095e81322558053bb858b7e68bb2d9bc7163e8b9 100644 (file)
--- a/rln.h
+++ b/rln.h
@@ -16,7 +16,7 @@
 #ifdef WIN32
 //#define _OPEN_FLAGS  _O_BINARY|_O_RDWR
 #define _OPEN_FLAGS  _O_BINARY|_O_RDONLY
-#define _BACKSLASH   '\\'
+#define PATH_DELIMITER   '\\'
 #ifdef _MSC_VER
    #if _MSC_VER > 1000
       #pragma warning(disable:4996)
@@ -38,7 +38,7 @@
 #ifdef __GCCUNIX__
 //#define _OPEN_FLAGS  O_RDWR
 #define _OPEN_FLAGS  O_RDONLY
-#define _BACKSLASH   '/'
+#define PATH_DELIMITER   '/'
 #include <sys/fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -51,8 +51,8 @@
 #endif
 
 #define MAJOR        1                          // Major version number
-#define MINOR        0                          // Minor version number
-#define PATCH        2                          // Patch release number
+#define MINOR        2                          // Minor version number
+#define PATCH        1                          // Patch release number
 
 #ifdef WIN32
 #define PLATFORM     "Win32"                    // Release platform - Windows
@@ -68,9 +68,9 @@
 #define warn(x, f) printf("Warning: repeated flag `%c'%s\n", x, f ? "; previous one(s) ignored." : ".")
 
 // Macro for max: good because longs, shorts, or pointers can be compared
-#ifndef max
-#define max(a,b) ((a) > (b) ? (a) : (b))
-#endif // max
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
 
 // Macro to swap the 16-bit words of a 32-bit integer
 #define _SWAPWORD(x) (((unsigned)(x) >> 16) | ((unsigned)(x) << 16))
 // will have to read the file into a buffer and stuff the values into the
 // structure (see slongio.c).
 
+// Rather than rely on dodgy compilers for something that's now a C99 standard,
+// let's do this:
+#include <stdint.h>
+
 struct OHEADER
 {
-   long magic;                                         // $0107 for .o, $601B for abs
-   long tsize;
-   long dsize;
-   long bsize;
-   long ssize;
-   union {
-      struct {                                         // For .o
-         long tsize;                            // Text relocation size
-         long dsize;                            // Data relocation size
-         char reserved[12];
-      } reloc;
-      struct {                                         // For .abs
-         long stksize;                             // Unused
-         long tstart;                           // Start of TEXT
-         long rbflag;                           // -1 if no fixups at all
-         long dstart;                           // Start of DATA
-         long bstart;                           // Start of BSS
-      } abs;
-   } absrel;
-   char * ostbase;                              // Base of output symbol table
-   long fsize;                                  // Length of fixups
-   char * fixups;                               // Start of fixups
+       uint32_t magic;                                                         // $0107 for .o, $601B for abs
+       uint32_t tsize;
+       uint32_t dsize;
+       uint32_t bsize;
+       uint32_t ssize;
+       union {
+               struct {                                                                // For .o 
+                       uint32_t tsize;                                         // Text relocation size
+                       uint32_t dsize;                                         // Data relocation size
+                       uint8_t reserved[12];
+               } reloc;
+               struct {                                                                // For .abs 
+                       uint32_t stksize;                                       // Unused 
+                       uint32_t tstart;                                        // Start of TEXT 
+                       uint32_t rbflag;                                        // -1 if no fixups at all 
+                       uint32_t dstart;                                        // Start of DATA 
+                       uint32_t bstart;                                        // Start of BSS
+               } abs;
+       } absrel;
+       uint8_t * ostbase;                                                      // Base of output symbol table 
+       uint32_t fsize;                                                         // Length of fixups
+       uint8_t * fixups;                                                       // Start of fixups 
 };
 
-#define new_oheader()   (struct OHEADER *)malloc((long)sizeof(struct OHEADER))
+#define new_oheader()   (struct OHEADER *)malloc((uint32_t)sizeof(struct OHEADER))
 
 struct ARHEADER
 {
-   char a_fname[14];
-   long a_modti;
-   char a_userid;
-   char a_gid;
-   int a_fimode;
-   long a_fsize;
-   int reserved;                                // Two bytes zeroes btw header & file
+       uint8_t a_fname[14];
+       uint32_t a_modti;
+       uint8_t a_userid;
+       uint8_t a_gid;
+       uint16_t a_fimode;
+       uint32_t a_fsize;
+       uint16_t reserved;                                                      // Two bytes zeroes btw header & file 
 };
 
-#define new_arheader()  (struct ARHEADER *)malloc((long)sizeof(struct ARHEADER))
+#define new_arheader()  (struct ARHEADER *)malloc((uint32_t)sizeof(struct ARHEADER))
 
 // Object File Structure and Related Items
 
 struct OFILE
 {
-   char o_name[FNLEN];                          // Fixed-length names
-   char o_arname[FNLEN];                        // Name of archive this is from
-   struct OFILE * o_next;                       // Next object file
-   long o_tbase, o_dbase, o_bbase;              // Computed bases for this ofile
-   int o_symstart;                              // First sym in image is nth in out
-   int o_flags;                                 // Flags (see O_*)
-   struct OHEADER o_header;                     // Header of this file
-   char * o_image;                              // Image of this file
+       uint8_t o_name[FNLEN];                                          // Fixed-length names
+       uint8_t o_arname[FNLEN];                                        // Name of archive this is from
+       struct OFILE * o_next;                                          // Next object file
+       uint32_t o_tbase, o_dbase, o_bbase;                     // Computed bases for this ofile
+       uint16_t o_symstart;                                            // First sym in image is nth in out
+       uint16_t o_flags;                                                       // Flags (see O_*)
+       struct OHEADER o_header;                                        // Header of this file
+       uint8_t * o_image;                                                      // Image of this file
 };
 
-#define new_ofile()  (struct OFILE *)malloc((long)sizeof(struct OFILE))
+#define new_ofile()  (struct OFILE *)malloc((uint32_t)sizeof(struct OFILE))
 
 // Flags in an Object File's o_flags field
 // O_USED: means this ofile is used or is on the command line or in a -x
-#define O_USED       0x0001
+#define O_USED       0x0001
 #define O_ARCHIVE    0x0002                     // This is a dummy archive entry
 
 // Symbol Record
@@ -163,13 +167,13 @@ struct OFILE
 
 struct SYMREC
 {
-   char s_name[SYMLEN];                         // Including null terminator
-   int s_type;
-   long s_value;
-   struct SYMREC *s_next;
+       uint8_t s_name[SYMLEN];                                         // Including null terminator 
+       uint16_t s_type;
+       uint32_t s_value;
+       struct SYMREC * s_next;
 };
 
-#define new_symrec() (struct SYMREC *)malloc((long)sizeof(struct SYMREC))
+#define new_symrec() (struct SYMREC *)malloc((uint32_t)sizeof(struct SYMREC))
 
 // Hash Record
 
@@ -179,14 +183,16 @@ struct SYMREC
 
 struct HREC
 {
-   char h_sym[SYMLEN];
-   struct HREC * h_next;
-   struct OFILE * h_ofile;
-   long h_value;
-   int h_type;
+       uint8_t h_sym[SYMLEN];
+       struct HREC * h_next;
+       struct OFILE * h_ofile;
+       uint32_t h_value;
+//Shamus: This was an "int" but as per above, should have been a 16-bit value.
+//        Changing it to a 32-bit value (as per compiler warning).
+       uint32_t h_type;
 };
 
-#define new_hrec()   (struct HREC *)malloc((long)sizeof(struct HREC))
+#define new_hrec()   (struct HREC *)malloc((uint32_t)sizeof(struct HREC))
 
 #define NBUCKETS     1024                       // Number of hash buckets
 
@@ -216,28 +222,47 @@ struct HREC
 #define ABST_DATA       0x0400 /* data-based relocatable */
 #define ABST_TEXT       0x0200 /* text-based relocatable */
 #define ABST_BSS        0x0100 /* bss-based relocatable  */
-#define ABST_FILE       0x0080                  // file symbol
-#define ABST_ARCHIVE    0x0040                  // only when FILE set: archive file or no
-#define ABST_OST        0x0001                  // private: "symbol is in ost": see above
+#define ABST_FILE       0x0080 // file symbol
+#define ABST_ARCHIVE    0x0040 // only when FILE set: archive file or no
+#define ABST_OST        0x0001 // private: "symbol is in ost": see above
 #define T_COMMON       (T_GLOBAL | T_EXTERN)
 #define T_SEG          (T_DATA | T_TEXT | T_BSS)   // segment bits
 
 // Symbol Table - Type Definitions
 
 #define T_UNDF          0x00000000     // Undefined Symbol
-#define T_EXT           0x01000000     // External Bit, OR\92ed In
-#define T_ABS           0x02000000     // Absolute Symbol
+#define T_EXT           0x01000000     // External Bit, OR'ed In (Global)
+#define T_ABS           0x02000000     // Absolute Symbol (Equated)
 #define T_TEXT          0x04000000     // TEXT Segment
 #define T_DATA          0x06000000     // DATA Segment
 #define T_BSS           0x08000000     // BSS Segment
 
 // These macros are used with the TYPE field of a SYMBOL.
+/*
+Absolutes (equates) can't be externals (line 434)
+-- they are non-relocatable
+*/
 
-#define iscommon(type) (((type) & T_EXT) == T_EXT)
+//#define iscommon(type) (((type) & T_EXT) == T_EXT)
+#define iscommon(type) (((type) & T_EXT) == 0)
 #define isglobal(type) (((type) & T_EXT) == T_EXT)
 #define isextern(type) (((type) & T_EXT) == T_EXT)
 #define islocal(type)  (((type) & T_EXT) == 0)
 
+/*
+Shamus:
+Just look at this. I can't believe that somebody actually wrote this piece of
+failure and thought it was a good idea. I'm leaving it here as a testament to
+complete, total, and utter failure. :-)
+*/
+
+// This macro is used to compare two symbols for equality. It depends on
+// symcopy remaining as it is (copies two longs plus a null)
+
+//#define symcmp(a,b) ((*(long *)(a) == *(long *)(b)) && \
+//                                     (*(long *)((a) + sizeof(long)) == \
+//                                     *(long *)((b) + sizeof(long))))
+
 // Function Prototypes
 
 int doargs(int, char *[]);
@@ -256,3 +281,4 @@ int segmentpad(FILE *, long, int);
 int ost_lookup(char *);
 
 #endif // __RLH_H__
+