X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=rln;a=blobdiff_plain;f=rln.h;h=6e2b0925d1164bbea5ff04a9643fcca155fbd613;hp=94475a849261a9541c3461d76b77e2353b97cc1d;hb=e0c5bd18176b70031fd7fce877c6ca1d8b093a8c;hpb=5c7a0db5a2628d9b30607ddeb0d22d543b400f2e diff --git a/rln.h b/rln.h index 94475a8..6e2b092 100644 --- a/rln.h +++ b/rln.h @@ -1,17 +1,11 @@ // -// RLN - Reboot's Linker for the Atari Jaguar Console System -// RLN.H - Application Header -// Copyright (C) 199x Allan K. Pratt, 2011 Reboot & Friends +// RLN - Reboot's Linker for the Atari Jaguar console system +// Copyright (C) 199x Allan K. Pratt, 2011-2018 Reboot & Friends // #ifndef __RLN_H__ #define __RLN_H__ -// Required Include Files - -// Macro Definitions - -// Requirements for Windows Compilation #ifdef WIN32 //#define _OPEN_FLAGS _O_BINARY|_O_RDWR @@ -33,8 +27,6 @@ #include #endif -// Requirements for Mac OS-X or Linux Compilation - #ifdef __GCCUNIX__ //#define _OPEN_FLAGS O_RDWR #define _OPEN_FLAGS O_RDONLY @@ -51,8 +43,8 @@ #endif #define MAJOR 1 // Major version number -#define MINOR 3 // Minor version number -#define PATCH 6 // Patch release number +#define MINOR 6 // Minor version number +#define PATCH 3 // Patch release number #ifdef WIN32 #define PLATFORM "Win32" // Release platform - Windows @@ -89,6 +81,7 @@ // Rather than rely on dodgy compilers for something that's now a C99 standard, // let's do this: #include +#include struct OHEADER { @@ -98,22 +91,22 @@ struct OHEADER uint32_t bsize; uint32_t ssize; union { - struct { // For .o + 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 + 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 + uint8_t * ostbase; // Base of output symbol table uint32_t fsize; // Length of fixups - uint8_t * fixups; // Start of fixups + uint8_t * fixups; // Start of fixups }; #define new_oheader() (struct OHEADER *)malloc(sizeof(struct OHEADER)) @@ -126,12 +119,14 @@ struct ARHEADER uint8_t a_gid; uint16_t a_fimode; uint32_t a_fsize; - uint16_t reserved; // Two bytes zeroes btwn header & file + uint16_t reserved; // Two bytes zeroes btwn header & file }; #define new_arheader() (struct ARHEADER *)malloc(sizeof(struct ARHEADER)) -// Object File Structure and Related Items +// Object file structure and related items + +enum { TEXT=0, DATA=1, BSS=2 }; struct OFILE { @@ -144,6 +139,10 @@ struct OFILE struct OHEADER o_header; // Header of this file uint8_t * o_image; // Image of this file uint8_t isArchiveFile; // Temporary extra flag +//These are likely redundant, and can probably be removed with judicious +//editing of where they are used (in favor of OHEADER vars) + uint32_t segSize[3]; // Size of TEXT, DATA & BSS (aligned) + uint32_t segBase[3]; // Accumulated base address of TDB }; #define new_ofile() (struct OFILE *)malloc(sizeof(struct OFILE)) @@ -151,6 +150,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 +// N.B.: This is *never* set anywhere in the linker code... #define O_ARCHIVE 0x0002 // This is a dummy archive entry // Symbol Record @@ -163,7 +163,7 @@ struct OFILE 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; @@ -224,26 +224,32 @@ struct HREC //#define T_COMMON (T_GLOBAL | T_EXTERN) // Symbol Table - Type Definitions -// N.B.: T_EXT can be ORed with any of T_ABS, T_TEXT, TDATA, or T_BSS! - -#define T_UNDF 0x00000000 // Undefined 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 +// N.B.: T_GLBL can be ORed with any of T_ABS, T_TEXT, TDATA, or T_BSS! +// Also, these are really a mashup of a struct, consisting of the +// following items: type (1 byte), other (1 byte), & descr. (2 bytes). +// Also, the type is not enough to distinguish between external & +// common symbols; for this, you need to go to the value field to see +// what's there (0=external, !0=common). + +#define T_UNDF 0x00000000 // Undefined symbol +#define T_GLBL 0x01000000 // Scoping 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 #define T_SEG (T_DATA | T_TEXT | T_BSS) // segment bits // These macros are used with the TYPE field of a SYMBOL. +// They are also mostly WRONG /* Absolutes (equates) can't be externals (line 434) -- they are non-relocatable */ -#define iscommon(type) (((type) & T_EXT) == 0) -#define islocal(type) (((type) & T_EXT) == 0) -#define isglobal(type) ((type) & T_EXT) -#define isextern(type) ((type) & T_EXT) +#define iscommon(type) (((type) & T_GLBL) == 0) +#define islocal(type) (((type) & T_GLBL) == 0) +#define isglobal(type) ((type) & T_GLBL) +#define isextern(type) ((type) & T_GLBL) /* Shamus: