Skip to content

Commit

Permalink
omftools: correct OMF tools to properly handle multiple THEADR record…
Browse files Browse the repository at this point in the history
…s per module
  • Loading branch information
jmalak committed Oct 8, 2024
1 parent 9f7d55a commit c2b5b23
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
20 changes: 13 additions & 7 deletions bld/omftools/c/objfind.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -62,10 +62,12 @@ static bool ProcFileModRef( FILE *fp )
char *module_name;
bool ok;
int rc;
bool first;

page_len = 0;
ReadRecInit();
module_name = NULL;
first = true;
ok = true;
while( ok ) {
offset = ftell( fp );
Expand All @@ -77,12 +79,15 @@ static bool ProcFileModRef( FILE *fp )
}
switch( RecHdr[0] & ~1 ) {
case CMD_THEADR:
if( module_name != NULL )
free( module_name );
GetName();
NameTerm();
module_name = malloc( strlen( NamePtr ) + 1 );
strcpy( module_name, NamePtr );
if( first ) {
if( module_name != NULL )
free( module_name );
GetName();
NameTerm();
module_name = malloc( strlen( NamePtr ) + 1 );
strcpy( module_name, NamePtr );
first = false;
}
break;
case CMD_MODEND:
if( page_len != 0 ) {
Expand All @@ -92,6 +97,7 @@ static bool ProcFileModRef( FILE *fp )
fseek( fp, offset, SEEK_CUR );
}
}
first = true;
break;
case CMD_PUBDEF:
if( module_name == NULL )
Expand Down
14 changes: 10 additions & 4 deletions bld/omftools/c/objlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2020 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -55,9 +55,11 @@ static bool ProcFile( FILE *fp )
unsigned_32 offset;
bool ok;
int rc;
bool first;

page_len = 0;
ReadRecInit();
first = true;
ok = true;
while( ok ) {
offset = ftell( fp );
Expand All @@ -69,9 +71,12 @@ static bool ProcFile( FILE *fp )
}
switch( RecHdr[0] & ~1 ) {
case CMD_THEADR:
GetName();
NameTerm();
printf( "%s\n", NamePtr );
if( first ) {
GetName();
NameTerm();
printf( "%s\n", NamePtr );
first = false;
}
break;
case CMD_MODEND:
if( page_len != 0 ) {
Expand All @@ -81,6 +86,7 @@ static bool ProcFile( FILE *fp )
fseek( fp, offset, SEEK_CUR );
}
}
first = true;
break;
case LIB_HEADER_REC:
if( RecHdr[0] & 1 ) {
Expand Down

0 comments on commit c2b5b23

Please sign in to comment.