Skip to content

Commit

Permalink
omf format: incorrect special handling of assembly-time variable fixu…
Browse files Browse the repository at this point in the history
…ps corrected.
  • Loading branch information
Baron-von-Riedesel committed Dec 7, 2024
1 parent 131e738 commit b89db7e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
4 changes: 4 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
- regression in v2.05-v2.18, DUP operator: if an undefined symbol was
contained in first operand, error message may have been omitted; see
struct43.asm.
- local labels were accepted by PUBLIC directive without -Zm being set;
see public3.asm.
- omf format: incorrect special handling of assembly-time variable fixups
removed; see label9.asm.

Other changes:
- write listing reworked.
Expand Down
5 changes: 4 additions & 1 deletion Html/Manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,10 @@ <H2 ID="CMDOPTZG"> Option -Zg: Masm-compatible Code Generation </H2>
</LI>
<LI> OPATTR will return the language type bits 8-10 for PROCs and PROTOs only.
</LI>
</UL>
</UL>
Those changes won't achieve an exact copy in all cases. Some instructions can be
encoded in more than one way ( i.e. CMP AL, AH ), and the JWasm code generator
may select a different encoding.

<H2 ID="CMDOPTZI"> Option -Zi: Emit Symbolic Debugging Info </H2>

Expand Down
6 changes: 5 additions & 1 deletion src/listing.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,18 @@ void LstWrite( enum lsttype type, uint_32 oldofs, void *value )
for ( p1 = sym->string_ptr, p2 = &ll.buffer[3], pll = &ll; *p1; ) {
if ( p2 >= &pll->buffer[28] ) {
struct lstleft *next = myalloca( sizeof( struct lstleft ) );
if ( p2 != &ll.buffer[28] ) *p2 = 0; /* v2.19: additional line, terminate header */
pll->next = next;
pll = next;
pll->next = NULL;
memset( pll->buffer, ' ', sizeof( pll->buffer) );
/* v2.19: header of multi-line is variable in size */
//memset( pll->buffer, ' ', sizeof( pll->buffer) );
memset( pll->buffer, ' ', 3 );
p2 = &pll->buffer[3];
}
*p2++ = *p1++;
}
if ( p2 != &ll.buffer[28] ) *p2 = 0; /* v2.19: additional line, terminate header */
break;
case LSTTYPE_MACROLINE:
ll.buffer[1] = '>';
Expand Down
2 changes: 2 additions & 0 deletions src/omf.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ static void omf_write_fixupp( struct dsym *seg, char is32 )
enum fixgen_types type = ( is32 ? FIX_GEN_MS386 : FIX_GEN_INTEL );
struct omf_rec obj;

//DebugMsg1(("omf_write_fixupp( %s )\n", seg->sym.name ));

fix = seg->e.seginfo->FixupList.head;
while ( fix ) {
for( data = (uint_8 *)StringBufferEnd, size = 0; fix; fix = fix->nextrlc ) {
Expand Down
8 changes: 5 additions & 3 deletions src/omffixup.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,17 +338,19 @@ static int omf_set_logref( const struct fixup *fixup, struct logref *lr )
if ( sym->segment && ((struct dsym *)sym->segment)->e.seginfo->group )
DebugMsg1(("omf_seg_logref: group=%s\n", ((struct dsym *)sym->segment)->e.seginfo->group->name ));
#endif
#if 0 /* v2.19: "isvariable" branch disabled; see label9.asm */
/* v2.08: don't use info from assembly-time variables */
/* v2.16: the '$' is NO assembly-time variable; however, flag "isvariable" is TRUE!
* Are assembly-time variables defined by '=' supposed to create a fixup at all???
* Why should their (final) value be defined at link time???
* Variables defined by '=' directive may define a label, hence need a fixup then!
*/
//if ( sym->isvariable ) {
if ( sym->isvariable && sym->isequate ) {
lr->target_meth = ( fixup->frame_type == FRAME_GRP ? TARGET_GRP : TARGET_SEG );
lr->target_datum = fixup->frame_datum;
DebugMsg1(("omf_seg_logref: assembly-time variable branch\n" ));
} else if ( sym->segment == NULL ) { /* shouldn't happen */
} else
#endif
if ( sym->segment == NULL ) { /* shouldn't happen */
EmitErr( SEGMENT_MISSING_FOR_FIXUP, sym->name );
return ( 0 );
#if COMDATSUPP
Expand Down

0 comments on commit b89db7e

Please sign in to comment.