X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rln;a=blobdiff_plain;f=rln.h;h=a962789638c3ee517c8f1d39914c9395c42d685d;hp=d4591b329c4bd51ceea6670b9874d0caea1eb616;hb=a1f6a3912c5907ca0b7d7d1404adc575c84da57f;hpb=4d8573013a97d0353447f959c14ccaddc1ff8c14 diff --git a/rln.h b/rln.h index d4591b3..a962789 100644 --- 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 #include #include @@ -50,9 +50,9 @@ #include #endif -#define MAJOR 1 // Major version number -#define MINOR 1 // Minor version number -#define PATCH 0 // Patch release number +#define MAJOR 1 // Major version number +#define MINOR 2 // Minor version number +#define PATCH 3 // Patch release number #ifdef WIN32 #define PLATFORM "Win32" // Release platform - Windows @@ -68,20 +68,20 @@ #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)) -#define FARGSIZE 1024 // Number of chars in filename argument -#define FNLEN 1024 // Size of a file name -#define NHANDLES 256 // Number of open file handles at once -#define OST_BLOCK 0x400000 // Output symbol table block (4MB) -#define DSTSEG_D 1 // Include file destination seg (DATA) -#define DSTSEG_T 2 // Include file destination seg (TEXT) -#define MAXARGS 256 // Max number of args in a command file +#define FARGSIZE 1024 // Number of chars in filename argument +#define FNLEN 1024 // Size of a file name +#define NHANDLES 256 // Number of open file handles at once +#define OST_BLOCK 0x400000 // Output symbol table block (4MB) +#define DSTSEG_D 1 // Include file destination seg (DATA) +#define DSTSEG_T 2 // Include file destination seg (TEXT) +#define MAXARGS 256 // Max number of args in a command file // Headers @@ -97,28 +97,28 @@ struct OHEADER { - uint32_t magic; // $0107 for .o, $601B for abs + 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 + 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 + 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 + 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((uint32_t)sizeof(struct OHEADER)) @@ -131,7 +131,7 @@ struct ARHEADER uint8_t a_gid; uint16_t a_fimode; uint32_t a_fsize; - uint16_t reserved; // Two bytes zeroes btw header & file + uint16_t reserved; // Two bytes zeroes btw header & file }; #define new_arheader() (struct ARHEADER *)malloc((uint32_t)sizeof(struct ARHEADER)) @@ -140,14 +140,14 @@ struct ARHEADER struct OFILE { - 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 + 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((uint32_t)sizeof(struct OFILE)) @@ -155,7 +155,7 @@ 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_ARCHIVE 0x0002 // This is a dummy archive entry +#define O_ARCHIVE 0x0002 // This is a dummy archive entry // Symbol Record @@ -163,11 +163,11 @@ struct OFILE // linker for the output symbol table (that's why there are type and value // fields, unused in builddir) -#define SYMLEN 100 // Symbol name size (incl null) +#define SYMLEN 100 // Symbol name size (incl null) struct SYMREC { - uint8_t s_name[SYMLEN]; // Including null terminator + uint8_t s_name[SYMLEN]; // Including null terminator uint16_t s_type; uint32_t s_value; struct SYMREC * s_next; @@ -222,24 +222,29 @@ 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'ed 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) @@ -276,3 +281,4 @@ int segmentpad(FILE *, long, int); int ost_lookup(char *); #endif // __RLH_H__ +