From cfd001aea60f54e49d9beae0f941c513f45c202b Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Tue, 29 Aug 2017 12:20:17 -0500 Subject: [PATCH] Fix for section alignment values in ELF objects. Thanks to SainT for the patch. :-) --- 6502.c | 2 +- amode.c | 14 +++++++------- amode.h | 8 ++++---- direct.c | 56 +++++++++++++++++++++++++++++++++++++------------------ direct.h | 5 +++-- eagen0.c | 6 +++--- expr.c | 16 ++++++++-------- expr.h | 4 ++-- listing.c | 14 +++++++------- listing.h | 6 +++--- mach.c | 24 ++++++++++++------------ macro.c | 4 ++-- object.c | 13 +++++++------ procln.c | 8 ++++---- procln.h | 2 +- riscasm.c | 4 ++-- rmac.c | 2 +- rmac.h | 1 - sect.c | 6 +++--- token.c | 4 ++-- token.h | 2 +- version.h | 4 ++-- 22 files changed, 113 insertions(+), 92 deletions(-) diff --git a/6502.c b/6502.c index 24000c2..f7078b8 100644 --- a/6502.c +++ b/6502.c @@ -247,7 +247,7 @@ void m6502cg(int op) { register int amode; // (Parsed) addressing mode register int i; - VALUE eval; // Expression value + uint32_t eval; // Expression value WORD eattr; // Expression attributes int zpreq; // 1, optimize instr to zero-page form register char * p; // (Temp) string usage diff --git a/amode.c b/amode.c index 5681412..3d789af 100644 --- a/amode.c +++ b/amode.c @@ -27,16 +27,16 @@ int nmodes; // Number of addr'ing modes found int am0; // Addressing mode int a0reg; // Register TOKEN a0expr[EXPRSIZE]; // Expression -VALUE a0exval; // Expression's value +uint32_t a0exval; // Expression's value WORD a0exattr; // Expression's attribute int a0ixreg; // Index register int a0ixsiz; // Index register size (and scale) TOKEN a0oexpr[EXPRSIZE]; // Outer displacement expression -VALUE a0oexval; // Outer displacement value +uint32_t a0oexval; // Outer displacement value WORD a0oexattr; // Outer displacement attribute SYM * a0esym; // External symbol involved in expr TOKEN a0bexpr[EXPRSIZE]; // Base displacement expression -VALUE a0bexval; // Base displacement value +uint32_t a0bexval; // Base displacement value WORD a0bexattr; // Base displacement attribute WORD a0bsize; // Base displacement size WORD a0extension; // 020+ extension address word @@ -45,16 +45,16 @@ WORD am0_030; // ea bits for 020+ addressing modes int am1; // Addressing mode int a1reg; // Register TOKEN a1expr[EXPRSIZE]; // Expression -VALUE a1exval; // Expression's value +uint32_t a1exval; // Expression's value WORD a1exattr; // Expression's attribute int a1ixreg; // Index register int a1ixsiz; // Index register size (and scale) TOKEN a1oexpr[EXPRSIZE]; // Outer displacement expression -VALUE a1oexval; // Outer displacement value +uint32_t a1oexval; // Outer displacement value WORD a1oexattr; // Outer displacement attribute SYM * a1esym; // External symbol involved in expr TOKEN a1bexpr[EXPRSIZE]; // Base displacement expression -VALUE a1bexval; // Base displacement value +uint32_t a1bexval; // Base displacement value WORD a1bexattr; // Base displacement attribute WORD a1bsize; // Base displacement size WORD a1extension; // 020+ extension address word @@ -68,7 +68,7 @@ int bfparam2; // bfxxx / fmove instruction parameter 2 int bfval1; //bfxxx / fmove value 1 int bfval2; //bfxxx / fmove value 2 TOKEN bf0expr[EXPRSIZE]; // Expression -VALUE bf0exval; // Expression's value +uint32_t bf0exval; // Expression's value WORD bf0exattr; // Expression's attribute SYM * bf0esym; // External symbol involved in expr diff --git a/amode.h b/amode.h index ae93cfa..f1a47a8 100644 --- a/amode.h +++ b/amode.h @@ -137,15 +137,15 @@ extern int nmodes; extern int am0, am1; extern int a0reg, a1reg, a2reg; extern TOKEN a0expr[], a1expr[]; -extern VALUE a0exval, a1exval; +extern uint32_t a0exval, a1exval; extern WORD a0exattr, a1exattr; extern int a0ixreg, a1ixreg; extern int a0ixsiz, a1ixsiz; extern TOKEN a0oexpr[], a1oexpr[]; -extern VALUE a0oexval, a1oexval; +extern uint32_t a0oexval, a1oexval; extern WORD a0oexattr, a1oexattr; extern SYM * a0esym, * a1esym; -extern VALUE a0bexval, a1bexval; +extern uint32_t a0bexval, a1bexval; extern WORD a0bexattr, a1bexattr; extern WORD a0bsize, a1bsize; extern TOKEN a0bexpr[], a1bexpr[]; @@ -155,7 +155,7 @@ extern int bfparam1; extern int bfparam2; extern int bfval1; extern int bfval2; -extern VALUE bf0exval; +extern uint32_t bf0exval; // mnattr: #define CGSPECIAL 0x8000 // Special (don't parse addr modes) diff --git a/direct.c b/direct.c index c9a82d9..54c09d6 100644 --- a/direct.c +++ b/direct.c @@ -28,6 +28,7 @@ TOKEN exprbuf[128]; // Expression buffer SYM * symbolPtr[1000000]; // Symbol pointers table static long unused; // For supressing 'write' warnings char buffer[256]; // Scratch buffer for messages +int largestAlign[3] = { 2, 2, 2 }; // Largest alignment value seen per section // Function prototypes int d_unimpl(void); @@ -77,6 +78,7 @@ int d_cstruct(void); int d_prgflags(void); int d_opt(void); int d_dsp(void); +void SetLargestAlignment(int); // Directive handler table int (*dirtab[])() = { @@ -150,6 +152,20 @@ int (*dirtab[])() = { }; +// +// Set the largest alignment seen in the current section +// +void SetLargestAlignment(int size) +{ + if ((scattr & TEXT) && (largestAlign[0] < size)) + largestAlign[0] = size; + else if ((scattr & DATA) && (largestAlign[1] < size)) + largestAlign[1] = size; + else if ((scattr & BSS) && (largestAlign[2] < size)) + largestAlign[2] = size; +} + + // // .error - Abort compilation, printing an error message // @@ -197,7 +213,7 @@ int d_warn(char *str) // int d_org(void) { - VALUE address; + uint32_t address; if (!rgpu && !rdsp && !m6502) return error(".org permitted only in gpu/dsp and 6502 sections"); @@ -250,7 +266,7 @@ int d_print(void) int wordlong = 0; // WORD = 0, LONG = 1 int outtype = 0; // 0:hex, 1:decimal, 2:unsigned - VALUE eval; // Expression value + uint32_t eval; // Expression value WORD eattr; // Expression attributes SYM * esym; // External symbol involved in expr. TOKEN r_expr[EXPRSIZE]; @@ -577,6 +593,7 @@ int d_long(void) unsigned lower2Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x03; unsigned bytesToSkip = (0x04 - lower2Bits) & 0x03; SkipBytes(bytesToSkip); + SetLargestAlignment(4); return 0; } @@ -599,6 +616,7 @@ int d_phrase(void) unsigned lower3Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x07; unsigned bytesToSkip = (0x08 - lower3Bits) & 0x07; SkipBytes(bytesToSkip); + SetLargestAlignment(8); return 0; } @@ -612,6 +630,7 @@ int d_dphrase(void) unsigned lower4Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x0F; unsigned bytesToSkip = (0x10 - lower4Bits) & 0x0F; SkipBytes(bytesToSkip); + SetLargestAlignment(16); return 0; } @@ -625,6 +644,7 @@ int d_qphrase(void) unsigned lower5Bits = (rgpu || rdsp ? orgaddr : sloc) & 0x1F; unsigned bytesToSkip = (0x20 - lower5Bits) & 0x1F; SkipBytes(bytesToSkip); + SetLargestAlignment(32); return 0; } @@ -667,7 +687,7 @@ int d_unimpl(void) // // Return absolute (not TDB) and defined expression or return an error // -int abs_expr(VALUE * a_eval) +int abs_expr(uint32_t * a_eval) { WORD eattr; @@ -775,7 +795,7 @@ allright: int d_assert(void) { WORD eattr; - VALUE eval; + uint32_t eval; for(; expr(exprbuf, &eval, &eattr, NULL)==OK; ++tok) { @@ -833,7 +853,7 @@ int d_globl(void) // int d_prgflags(void) { - VALUE eval; + uint32_t eval; if (*tok == EOL) return error("PRGFLAGS requires value"); @@ -854,7 +874,7 @@ int d_prgflags(void) // int d_abs(void) { - VALUE eval; + uint32_t eval; if (m6502) return error(in_6502mode); @@ -933,7 +953,7 @@ int d_ds(WORD siz) { DEBUG { printf("Directive: .ds.[size] = %u, sloc = $%X\n", siz, sloc); } - VALUE eval; + uint32_t eval; if (cursect != M6502) { @@ -946,7 +966,7 @@ int d_ds(WORD siz) // Check to see if the value being passed in is negative (who the hell does // that?--nobody does; it's the code gremlins, or rum, that does it) - // N.B.: Since VALUE is of type uint32_t, if it goes negative, it will have + // N.B.: Since 'eval' is of type uint32_t, if it goes negative, it will have // its high bit set. if (eval & 0x80000000) return error("negative sizes not allowed"); @@ -967,7 +987,7 @@ int d_ds(WORD siz) } else { - dep_block(eval, siz, (VALUE)0, (WORD)(DEFINED | ABS), NULL); + dep_block(eval, siz, 0, (WORD)(DEFINED | ABS), NULL); } at_eol(); @@ -981,7 +1001,7 @@ int d_ds(WORD siz) int d_dc(WORD siz) { WORD eattr; - VALUE eval; + uint32_t eval; uint8_t * p; if ((scattr & SBSS) != 0) @@ -1132,7 +1152,7 @@ comma: // int d_dcb(WORD siz) { - VALUE evalc, eval; + uint32_t evalc, eval; WORD eattr; DEBUG { printf("dcb: section is %s%s%s (scattr=$%X)\n", (cursect & TEXT ? "TEXT" : ""), (cursect & DATA ? " DATA" : ""), (cursect & BSS ? "BSS" : ""), scattr); } @@ -1169,8 +1189,8 @@ int d_dcb(WORD siz) // int d_init(WORD def_siz) { - VALUE count; - VALUE eval; + uint32_t count; + uint32_t eval; WORD eattr; WORD siz; @@ -1230,7 +1250,7 @@ int d_init(WORD def_siz) // // Deposit 'count' values of size 'siz' in the current (non-BSS) segment // -int dep_block(VALUE count, WORD siz, VALUE eval, WORD eattr, TOKEN * exprbuf) +int dep_block(uint32_t count, WORD siz, uint32_t eval, WORD eattr, TOKEN * exprbuf) { WORD tdb; WORD defined; @@ -1319,7 +1339,7 @@ int d_comm(void) { SYM * sym; char * p; - VALUE eval; + uint32_t eval; if (m6502) return error(in_6502mode); @@ -1546,7 +1566,7 @@ int d_dsp(void) // int d_cargs(void) { - VALUE eval = 4; // Default to 4 if no offset specified (to account for + uint32_t eval = 4; // Default to 4 if no offset specified (to account for // return address) WORD rlist; SYM * symbol; @@ -1661,7 +1681,7 @@ int d_cargs(void) // int d_cstruct(void) { - VALUE eval = 0; // Default, if no offset specified, is zero + uint32_t eval = 0; // Default, if no offset specified, is zero WORD rlist; SYM * symbol; char * symbolName; @@ -1850,7 +1870,7 @@ int d_opt(void) int d_if(void) { WORD eattr; - VALUE eval; + uint32_t eval; SYM * esym; IFENT * rif = f_ifent; diff --git a/direct.h b/direct.h index 654c580..0f9615e 100644 --- a/direct.h +++ b/direct.h @@ -15,12 +15,13 @@ extern TOKEN exprbuf[]; extern SYM * symbolPtr[]; extern int (* dirtab[])(); +extern int largestAlign[]; // Exported functions void auto_even(void); -int dep_block(VALUE, WORD, VALUE, WORD, TOKEN *); +int dep_block(uint32_t, WORD, uint32_t, WORD, TOKEN *); int eject(void); -int abs_expr(VALUE *); +int abs_expr(uint32_t *); int symlist(int(*)()); int d_even(void); diff --git a/eagen0.c b/eagen0.c index 1bb00ba..9293a9f 100644 --- a/eagen0.c +++ b/eagen0.c @@ -9,7 +9,7 @@ int eaNgen(WORD siz) { - VALUE vbd, v = aNexval; + uint32_t vbd, v = aNexval; WORD wbd, w = (WORD)(aNexattr & DEFINED); WORD tdbbd, tdb = (WORD)(aNexattr & TDB); vbd = aNbdexval; @@ -86,7 +86,7 @@ int eaNgen(WORD siz) { // Just deposit it if ((aNexattr & TDB) == cursect) - v -= (VALUE)sloc; + v -= (uint32_t)sloc; else if ((aNexattr & TDB) != ABS) error(rel_error); @@ -136,7 +136,7 @@ int eaNgen(WORD siz) { // Deposit a byte... if ((aNexattr & TDB) == cursect) - v -= (VALUE)sloc; + v -= (uint32_t)sloc; else if ((aNexattr & TDB) != ABS) error(rel_error); diff --git a/expr.c b/expr.c index c89b182..8d18a67 100644 --- a/expr.c +++ b/expr.c @@ -23,7 +23,7 @@ // N.B.: The size of tokenClass should be identical to the largest value of // a token; we're assuming 256 but not 100% sure! static char tokenClass[256]; // Generated table of token classes -static VALUE evstk[EVSTACKSIZE]; // Evaluator value stack +static uint32_t evstk[EVSTACKSIZE]; // Evaluator value stack static WORD evattr[EVSTACKSIZE]; // Evaluator attribute stack // Token-class initialization list @@ -61,9 +61,9 @@ static int symbolNum; // Pointer to the entry in symbolPtr[] // // Obtain a string value // -static VALUE str_value(char * p) +static uint32_t str_value(char * p) { - VALUE v; + uint32_t v; for(v=0; *p; p++) v = (v << 8) | (*p & 0xFF); @@ -313,7 +313,7 @@ int expr2(void) // // Recursive-descent expression analyzer (with some simple speed hacks) // -int expr(TOKEN * otk, VALUE * a_value, WORD * a_attr, SYM ** a_esym) +int expr(TOKEN * otk, uint32_t * a_value, WORD * a_attr, SYM ** a_esym) { // Passed in values (once derefenced, that is) can all be zero. They are // there so that the expression analyzer can fill them in as needed. The @@ -476,11 +476,11 @@ thrown away right here. What the hell is it for? // UNDEFINED, but it's value includes everything but the symbol value, and // `a_esym' is set to the external symbol. // -int evexpr(TOKEN * tk, VALUE * a_value, WORD * a_attr, SYM ** a_esym) +int evexpr(TOKEN * tk, uint32_t * a_value, WORD * a_attr, SYM ** a_esym) { WORD attr; SYM * sy; - VALUE * sval = evstk; // (Empty) initial stack + uint32_t * sval = evstk; // (Empty) initial stack WORD * sattr = evattr; SYM * esym = NULL; // No external symbol involved WORD sym_seg = 0; @@ -700,8 +700,8 @@ printf("EVEXPR (-): sym1 = %X, sym2 = %X\n", attr, sattr[1]); // Compiler is picky here: Without casting these, it discards // the sign if dividing a negative # by a positive one, // creating a bad result. :-/ - // Probably a side effect of using VALUE intead of ints. - *sval = (int)sval[0] / (int)sval[1]; + // Definitely a side effect of using uint32_ts intead of ints. + *sval = (int32_t)sval[0] / (int32_t)sval[1]; //printf("%i\n", *sval); break; case '%': diff --git a/expr.h b/expr.h index ee94dad..190fbe4 100644 --- a/expr.h +++ b/expr.h @@ -34,7 +34,7 @@ void InitExpression(void); int expr1(void); int expr2(void); -int expr(TOKEN *, VALUE *, WORD *, SYM **); -int evexpr(TOKEN *, VALUE *, WORD *, SYM **); +int expr(TOKEN *, uint32_t *, WORD *, SYM **); +int evexpr(TOKEN *, uint32_t *, WORD *, SYM **); #endif // __EXPR_H__ diff --git a/listing.c b/listing.c index f2c61f6..77226c7 100644 --- a/listing.c +++ b/listing.c @@ -66,9 +66,9 @@ int eject(void) // // Return GEMDOS format date // -VALUE dos_date(void) +uint32_t dos_date(void) { - VALUE v; + uint32_t v; struct tm * tm; time_t tloc; @@ -83,9 +83,9 @@ VALUE dos_date(void) // // Return GEMDOS format time // -VALUE dos_time(void) +uint32_t dos_time(void) { - VALUE v; + uint32_t v; struct tm * tm; time_t tloc; @@ -100,7 +100,7 @@ VALUE dos_time(void) // // Generate a time string // -void time_string(char * buf, VALUE time) +void time_string(char * buf, uint32_t time) { int hour; char * ampm; @@ -123,7 +123,7 @@ void time_string(char * buf, VALUE time) // // Generate a date string // -void date_string(char * buf, VALUE date) +void date_string(char * buf, uint32_t date) { sprintf(buf, "%d-%s-%d", (int)(date & 0x1F), month[(date >> 5) & 0xF], (int)((date >> 9) + 1980)); @@ -410,7 +410,7 @@ void lstout(char tag) // // Output a value to listing // -int listvalue(VALUE v) +int listvalue(uint32_t v) { sprintf(buf, "=%08X", v); strncpy(lnimage + DATA_COL - 1, buf, 9); diff --git a/listing.h b/listing.h index 75be73d..54cafb5 100644 --- a/listing.h +++ b/listing.h @@ -32,15 +32,15 @@ extern uint8_t subttl[]; // Exported functions int eject(void); -VALUE dos_date(void); -VALUE dos_time(void); +uint32_t dos_date(void); +uint32_t dos_time(void); void taglist(char); void println(const char *); void ship_ln(const char *); void InitListing(void); void listeol(void); void lstout(char); -int listvalue(VALUE); +int listvalue(uint32_t); int d_subttl(void); int d_title(void); diff --git a/mach.c b/mach.c index c3f6d83..2da58ec 100644 --- a/mach.c +++ b/mach.c @@ -705,7 +705,7 @@ int m_bitop(WORD inst, WORD siz) int m_dbra(WORD inst, WORD siz) { - VALUE v; + uint32_t v; siz = siz; inst |= a0reg; @@ -969,7 +969,7 @@ int m_movep(WORD inst, WORD siz) // int m_br(WORD inst, WORD siz) { - VALUE v; + uint32_t v; if (a0exattr & DEFINED) { @@ -1105,7 +1105,7 @@ int m_trap(WORD inst, WORD siz) // int m_movem(WORD inst, WORD siz) { - VALUE eval; + uint32_t eval; WORD i; WORD w; WORD rmask; @@ -1229,7 +1229,7 @@ int m_br30(WORD inst, WORD siz) if ((a0exattr & TDB) != cursect) return error(rel_error); - VALUE v = a0exval - (sloc + 2); + uint32_t v = a0exval - (sloc + 2); D_word(inst); D_long(v); @@ -1628,7 +1628,7 @@ int m_cpbr(WORD inst, WORD siz) if ((a0exattr & TDB) != cursect) return error(rel_error); - VALUE v = a0exval - (sloc + 2); + uint32_t v = a0exval - (sloc + 2); // Optimize branch instr. size if (siz == SIZL) @@ -1682,7 +1682,7 @@ int m_cpdbr(WORD inst, WORD siz) { CHECK00; - VALUE v; + uint32_t v; WORD condition = inst & 0x1f; // Grab condition sneakily placed in the lower 5 bits of inst inst &= 0xffe0; // And then mask them out - you ain't seen me, roit? @@ -2182,14 +2182,14 @@ int m_pack(WORD inst, WORD siz) return error(undef_error); if (a0exval + 0x8000 > 0x10000) - return error(""); + return error(""); if (*tok != EOL) return error(extra_stuff); D_word((a0exval & 0xffff)); - + return OK; @@ -2575,7 +2575,7 @@ int m_pflush(WORD inst, WORD siz) // hardcoded in 68ktab but there is aliasing // between 68030 and 68040 opcode. So we just // set the 3 lower bits to 1 in pflushn inside - // 68ktab and detect it here. + // 68ktab and detect it here. inst = (inst & 0xff8) | 8; inst |= (tok[1] & 7) | (5 << 8); if (tok[3] != EOL) @@ -2651,7 +2651,7 @@ int m_pload(WORD inst, WORD siz, WORD extension) // a 68020 + 68551 socket and since this is // an Atari targetted assembler.... CHECKNO30; - + inst |= am1; D_word(inst); @@ -2684,7 +2684,7 @@ int m_pload(WORD inst, WORD siz, WORD extension) D_word(inst); ea1gen(siz); - + return OK; } @@ -3106,7 +3106,7 @@ int m_fdbcc(WORD inst, WORD siz) if ((a1exattr & TDB) != cursect) return error(rel_error); - VALUE v = a1exval - sloc; + uint32_t v = a1exval - sloc; if ((v + 0x8000) > 0x10000) return error(range_error); diff --git a/macro.c b/macro.c index 38dfecd..469a88c 100644 --- a/macro.c +++ b/macro.c @@ -22,7 +22,7 @@ int macnum; // Unique number for macro definition static LONG macuniq; // Unique-per-macro number static SYM * curmac; // Macro currently being defined -static VALUE argno; // Formal argument count +static uint32_t argno; // Formal argument count static LLIST * firstrpt; // First .rept line static LLIST * nextrpt; // Last .rept line @@ -244,7 +244,7 @@ WARNING("!!! Casting (char *) as LONG !!!") // int HandleRept(void) { - VALUE eval; + uint32_t eval; // Evaluate repeat expression if (abs_expr(&eval) != OK) diff --git a/object.c b/object.c index bc3ae22..522a4d9 100644 --- a/object.c +++ b/object.c @@ -8,6 +8,7 @@ #include "object.h" #include "6502.h" +#include "direct.h" #include "error.h" #include "mark.h" #include "riscasm.h" @@ -520,7 +521,7 @@ int WriteObject(int fd) { elfHdrNum[ES_TEXT] = shstIndex; shstTab[ES_TEXT] = shstSize; - shstSize += DepositELFSHSTEntry(&shstPtr, "TEXT"); + shstSize += DepositELFSHSTEntry(&shstPtr, ".text"); shstIndex++; numEntries++; } @@ -529,7 +530,7 @@ int WriteObject(int fd) { elfHdrNum[ES_DATA] = shstIndex; shstTab[ES_DATA] = shstSize; - shstSize += DepositELFSHSTEntry(&shstPtr, "DATA"); + shstSize += DepositELFSHSTEntry(&shstPtr, ".data"); shstIndex++; numEntries++; } @@ -538,7 +539,7 @@ int WriteObject(int fd) { elfHdrNum[ES_BSS] = shstIndex; shstTab[ES_BSS] = shstSize; - shstSize += DepositELFSHSTEntry(&shstPtr, "BSS"); + shstSize += DepositELFSHSTEntry(&shstPtr, ".bss"); shstIndex++; numEntries++; } @@ -619,7 +620,7 @@ for(int j=0; j 0) { - headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_TEXT], 1, 6, 0, elfSize, sect[TEXT].sloc, 0, 0, 2, 0); + headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_TEXT], 1, 6, 0, elfSize, sect[TEXT].sloc, 0, 0, largestAlign[0], 0); for(CHUNK * cp=sect[TEXT].sfcode; cp!=NULL; cp=cp->chnext) { @@ -636,7 +637,7 @@ for(int j=0; j 0) { - headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_DATA], 1, 3, 0, elfSize, sect[DATA].sloc, 0, 0, 1, 0); + headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_DATA], 1, 3, 0, elfSize, sect[DATA].sloc, 0, 0, largestAlign[1], 0); for(CHUNK * cp=sect[DATA].sfcode; cp!=NULL; cp=cp->chnext) { @@ -651,7 +652,7 @@ for(int j=0; j 0) { - headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_BSS], 8, 3, 0, elfSize, sect[BSS].sloc, 0, 0, 2, 0); + headerSize += DepositELFSectionHeader(headers + headerSize, shstTab[ES_BSS], 8, 3, 0, elfSize, sect[BSS].sloc, 0, 0, largestAlign[2], 0); } int textrelLoc = headerSize; diff --git a/procln.c b/procln.c index 5b5e18a..3a4aac8 100644 --- a/procln.c +++ b/procln.c @@ -39,7 +39,7 @@ static IFENT ifent0; // Root ifent IFENT * f_ifent; // Freelist of ifents int disabled; // Assembly conditionally disabled int just_bss; // 1, ds.b in microprocessor mode -VALUE pcloc; // Value of "PC" at beginning of line +uint32_t pcloc; // Value of "PC" at beginning of line SYM * lab_sym; // Label on line (or NULL) const char extra_stuff[] = "extra (unexpected) text found after addressing mode"; @@ -131,7 +131,7 @@ void Assemble(void) char * equate; // Symbol (or NULL) int labtyp = 0; // Label type (':', DCOLON) int equtyp = 0; // Equ type ('=', DEQUALS) - VALUE eval; // Expression value + uint32_t eval; // Expression value WORD eattr; // Expression attributes SYM * esym; // External symbol involved in expr. WORD siz = 0; // Size suffix to mnem/diretve/macro @@ -177,7 +177,7 @@ DEBUG { printf("Assemble: Found TKEOF flag...\n"); } lab_sym = NULL; // No (exported) label equate = NULL; // No equate tk = tok; // Save first token in line - pcloc = (VALUE)sloc; // Set beginning-of-line PC + pcloc = (uint32_t)sloc; // Set beginning-of-line PC loop1: // Internal line processing loop @@ -521,7 +521,7 @@ When checking to see if it's already been equated, issue a warning. if (reglist(&rmask) < 0) goto loop; - eval = (VALUE)rmask; + eval = (uint32_t)rmask; eattr = ABS | DEFINED; } else if (equtyp == CCDEF) diff --git a/procln.h b/procln.h index c8c89cb..559081f 100644 --- a/procln.h +++ b/procln.h @@ -18,7 +18,7 @@ extern const char locgl_error[]; extern const char syntax_error[]; extern const char extra_stuff[]; extern int just_bss; -extern VALUE pcloc; +extern uint32_t pcloc; extern SYM * lab_sym; extern LONG amsktab[]; extern IFENT * ifent; diff --git a/riscasm.c b/riscasm.c index 33c8cd3..79f9ae2 100644 --- a/riscasm.c +++ b/riscasm.c @@ -174,7 +174,7 @@ void BuildRISCIntructionWord(unsigned short opcode, int reg1, int reg2) // int GetRegister(WORD rattr) { - VALUE eval; // Expression value + uint32_t eval; // Expression value WORD eattr; // Expression attributes SYM * esym; // External symbol involved in expr. TOKEN r_expr[EXPRSIZE]; // Expression token list @@ -217,7 +217,7 @@ int GenerateRISCCode(int state) WORD attrflg; int indexed; // Indexed register flag - VALUE eval; // Expression value + uint32_t eval; // Expression value WORD eattr; // Expression attributes SYM * esym; // External symbol involved in expr. TOKEN r_expr[EXPRSIZE]; // Expression token list diff --git a/rmac.c b/rmac.c index 3dc0f07..16af05c 100644 --- a/rmac.c +++ b/rmac.c @@ -308,7 +308,7 @@ int Process(int argc, char ** argv) } sy->sattr = DEFINED | EQUATED | ABS; - sy->svalue = (*s ? (VALUE)atoi(s) : 0); + sy->svalue = (*s ? (uint32_t)atoi(s) : 0); break; case 'e': // Redirect error message output case 'E': diff --git a/rmac.h b/rmac.h index 31cbb85..d5775cc 100644 --- a/rmac.h +++ b/rmac.h @@ -153,7 +153,6 @@ #define SPACE ' ' // ASCII space #define SLASHCHAR '/' #define SLASHSTRING "/" -#define VALUE uint32_t // Assembler value #define TOKEN uint32_t // Assembler token #define FNSIZ 128 // Maximum size of a filename #define OK 0 // OK return diff --git a/sect.c b/sect.c index b5bd6ec..e010ff2 100644 --- a/sect.c +++ b/sect.c @@ -388,7 +388,7 @@ int AddFixup(uint16_t attr, uint32_t loc, TOKEN * fexpr) int ResolveFixups(int sno) { PTR fup; // Current fixup - VALUE eval; // Expression value + uint32_t eval; // Expression value SYM * sy; // (Temp) pointer to a symbol uint16_t i; // (Temp) word int reg2; @@ -514,7 +514,7 @@ int ResolveFixups(int sno) if (eattr & DEFINED) { if (tdb == sno) - eval -= (VALUE)loc; + eval -= (uint32_t)loc; else if (tdb) { error("PC-relative expr across sections"); @@ -525,7 +525,7 @@ int ResolveFixups(int sno) warn("unoptimized short branch"); } else if (obj_format == MWC) - eval -= (VALUE)loc; + eval -= (uint32_t)loc; tdb = 0; eattr &= ~TDB; diff --git a/token.c b/token.c index 091aea4..6246a74 100644 --- a/token.c +++ b/token.c @@ -949,7 +949,7 @@ int TokenizeLine(void) int state = 0; // State for keyword detector int j = 0; // Var for keyword detector uint8_t c; // Random char - VALUE v; // Random value + uint32_t v; // Random value uint8_t * nullspot = NULL; // Spot to clobber for SYMBOL termination int stuffnull; // 1:terminate SYMBOL '\0' at *nullspot uint8_t c1; @@ -1133,7 +1133,7 @@ DEBUG { printf("TokenizeLine: Calling fpop() from SRC_IFILE...\n"); } if (((chrtab[*ln] & DOT) == 0) || (dotxtab[*ln] == 0)) return error("[bwsl] must follow '.' in symbol"); - v = (VALUE)dotxtab[*ln++]; + v = (uint32_t)dotxtab[*ln++]; if (chrtab[*ln] & CTSYM) return error("misuse of '.'; not allowed in symbols"); diff --git a/token.h b/token.h index f8df49a..cbacccf 100644 --- a/token.h +++ b/token.h @@ -144,7 +144,7 @@ IMACRO { IREPT { LLIST * ir_firstln; // Pointer to first line LLIST * ir_nextln; // Pointer to next line - VALUE ir_count; // Repeat count (decrements) + uint32_t ir_count; // Repeat count (decrements) }; // Exported variables diff --git a/version.h b/version.h index dc91187..9db7472 100644 --- a/version.h +++ b/version.h @@ -5,7 +5,7 @@ // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986 // Source utilised with the kind permission of Landon Dyer // -// Contributors: James Hammons, George Nakos, Graeme Hinchliffe, SCPCD +// Contributors: James Hammons, George Nakos, Graeme Hinchliffe, SCPCD, SainT // #ifndef __VERSION_H__ @@ -15,7 +15,7 @@ #define MAJOR 1 // Major version number #define MINOR 8 // Minor version number -#define PATCH 4 // Patch release number +#define PATCH 5 // Patch release number #endif // __VERSION_H__ -- 2.37.2