Skip to content

Commit

Permalink
add extra flag for export/import by name instead of ordinal number
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalak committed Feb 27, 2023
1 parent 6abfb12 commit 7bcd317
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 34 deletions.
8 changes: 4 additions & 4 deletions bld/wl/c/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -988,8 +988,8 @@ static void BufImpWrite( const char *buffer, size_t len )
}
}

void AddImpLibEntry( const char *intname, const char *extname, ordinal_t ordinal )
/********************************************************************************/
void AddImpLibEntry( const char *intname, const char *extname, ordinal_t ordinal, bool by_name )
/**********************************************************************************************/
{
size_t intlen;
size_t otherlen;
Expand All @@ -1000,7 +1000,7 @@ void AddImpLibEntry( const char *intname, const char *extname, ordinal_t ordinal
return;
ImpLib.didone = true;
intlen = strlen( intname );
if( ordinal == NOT_IMP_BY_ORDINAL ) {
if( by_name ) {
otherlen = strlen( extname );
} else {
otherlen = 10; // max length of a 32-bit int.
Expand All @@ -1019,7 +1019,7 @@ void AddImpLibEntry( const char *intname, const char *extname, ordinal_t ordinal
currpos += ImpLib.module_name_len;
*currpos++ = '\'';
*currpos++ = '.';
if( ordinal == NOT_IMP_BY_ORDINAL ) {
if( by_name ) {
*currpos++ = '.';
*currpos++ = '\'';
memcpy( currpos, extname, otherlen );
Expand Down
4 changes: 2 additions & 2 deletions bld/wl/c/loadnov.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-2023 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -179,7 +179,7 @@ static unsigned_32 WriteNovExports( fixed_header *header )
wrote += sizeof( unsigned_32 );
count++;

AddImpLibEntry( sym->name.u.ptr, ext_name, NOT_IMP_BY_ORDINAL );
AddImpLibEntry( sym->name.u.ptr, ext_name, 0, true );
}
}
header->numberOfPublics = count;
Expand Down
6 changes: 3 additions & 3 deletions bld/wl/c/loados2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2002-2022 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2002-2023 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -654,9 +654,9 @@ unsigned long ResNonResNameTable( bool dores )
size += 2;
if( !exp->isprivate ) {
if( exp->impname != NULL ) {
AddImpLibEntry( exp->impname, ext_name, NOT_IMP_BY_ORDINAL );
AddImpLibEntry( exp->impname, ext_name, 0, true );
} else {
AddImpLibEntry( exp->sym->name.u.ptr, NULL, exp->ordinal );
AddImpLibEntry( exp->sym->name.u.ptr, NULL, exp->ordinal, false );
}
}
}
Expand Down
26 changes: 9 additions & 17 deletions bld/wl/c/loadpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,9 @@ static unsigned_32 WriteExportInfo( pe_object *object, unsigned_32 file_align, p
++num_entries;
if( !exp->isprivate ) {
if( exp->impname != NULL ) {
AddImpLibEntry( exp->impname, exp->name.u.ptr, NOT_IMP_BY_ORDINAL );
AddImpLibEntry( exp->impname, exp->name.u.ptr, 0, true );
} else {
AddImpLibEntry( exp->sym->name.u.ptr, exp->name.u.ptr, NOT_IMP_BY_ORDINAL );
AddImpLibEntry( exp->sym->name.u.ptr, exp->name.u.ptr, 0, true );
}
}
}
Expand Down Expand Up @@ -1556,20 +1556,17 @@ static void CreateIDataSection( void )
{
segdata *sdata;
class_entry *class;
byte bits;

PrepareToc();
if( 0 != CalcIDataSize() ) {
IDataGroup = GetGroup( IDataGrpName );
class = FindClass( Root, CoffIDataClassName, BITS_32, false );
bits = ( LinkState & LS_HAVE_X64_CODE ) ? BITS_64 : BITS_32;
class = FindClass( Root, CoffIDataClassName, bits, false );
class->flags |= CLASS_IDATA | CLASS_LXDATA_SEEN;
sdata = AllocSegData();
if( LinkState & LS_HAVE_X64_CODE ) {
sdata->align = 4;
sdata->bits = BITS_64;
} else {
sdata->align = 2;
sdata->bits = BITS_32;
}
sdata->align = ( LinkState & LS_HAVE_X64_CODE ) ? 4 : 2;
sdata->bits = bits;
sdata->length = IData.total_size;
sdata->u.name.u.ptr = CoffIDataSegName;
sdata->combine = COMBINE_ADD;
Expand Down Expand Up @@ -1661,13 +1658,8 @@ static void CreateTransferSegment( class_entry *class )
if( size != 0 ) {
class->flags |= CLASS_TRANSFER;
sdata = AllocSegData();
if( LinkState & LS_HAVE_X64_CODE ) {
sdata->align = 4;
sdata->bits = BITS_64;
} else {
sdata->align = 2;
sdata->bits = BITS_32;
}
sdata->align = ( LinkState & LS_HAVE_X64_CODE ) ? 4 : 2;
sdata->bits = ( LinkState & LS_HAVE_X64_CODE ) ? BITS_64 : BITS_32;
sdata->length = size;
sdata->u.name.u.ptr = TRANSFER_SEGNAME;
sdata->combine = COMBINE_ADD;
Expand Down
4 changes: 2 additions & 2 deletions bld/wl/h/loadfile.h
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-2023 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -68,7 +68,7 @@ extern void OrderGroups( bool (*)(targ_addr *, targ_addr *) );
extern bool WriteGroup( group_entry * );
extern unsigned_32 MemorySize( void );
extern unsigned_32 AppendToLoadFile( const char * );
extern void AddImpLibEntry( const char *, const char *, ordinal_t ordinal );
extern void AddImpLibEntry( const char *, const char *, ordinal_t ordinal, bool by_name );
extern void BuildImpLib( void );
extern void SetStartSym( const char * );
extern offset CalcGroupSize( group_entry * );
Expand Down
2 changes: 1 addition & 1 deletion bld/wl/h/objpass1.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern void Set16BitMode( void );
extern void AllocateSegment( segnode *, const char *clname );
extern void AddSegment( segdata *, class_entry * );
extern class_entry *DuplicateClass( class_entry *class );
extern class_entry *FindClass( section *, const char *, byte bits, bool );
extern class_entry *FindClass( section *, const char *, byte bits, bool iscode );
extern seg_leader *InitLeader( const char * );
extern void FreeLeader( void * );
extern void AddToGroup( group_entry *, seg_leader * );
Expand Down
10 changes: 5 additions & 5 deletions bld/wl/h/objstruc.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ typedef struct class_entry {
SEG_LEADER *segs;
name_strtab name;
class_status flags;
unsigned bits : 2; // segment bitnese
byte bits; // segment bitnese
section *section;
targ_addr BaseAddr; // Fixed location to of this class for loadfile
CLASS_ENTRY *DupClass; // Class to get data from for output
Expand Down Expand Up @@ -408,14 +408,14 @@ enum {
SEG_ABSOLUTE = 0x0001,
SEG_COMDAT = 0x0002, /* seg is a comdat */
SEG_OVERLAYED = 0x0040, /* segment belongs to an overlay class */
MAKE_ADDR_INFO = 0x0080, /* set if making an addr info next time*/
SEG_DEAD = 0x0080, /* mark a segdef as being "dead"(pass 2)*/
MAKE_ADDR_INFO = 0x0080, /* set if making an addr info next time */
SEG_DEAD = 0x0080, /* mark a segdef as being "dead"(pass 2) */
SEG_CODE = 0x0200, /* segment is a code segment. */
USE_32 = 0x0400, /* segment uses 32 bit addresses */
LAST_SEGMENT = 0x0800, /* force last segment in a code group */
SEG_LXDATA_SEEN = 0x8000, /* LxDATA rec. seen for this segment */
SEG_FIXED = 0x1000, /* Segment should start at seg_addr, not next addr */
SEG_NOEMIT = 0x2000, /* Segment should not generate output */
SEG_LXDATA_SEEN = 0x8000, /* LxDATA rec. seen for this segment */
SEG_BOTH_MASK = 0x8641, /* flags common to both structures */
};

Expand Down Expand Up @@ -479,7 +479,7 @@ typedef struct segdata {
unsigned select : 3; // comdat: selection type
unsigned combine : 2; // how to combine segment with others
unsigned alloc : 2; // comdat: where to allocate segment.
unsigned bits : 2; // segment bitnese
byte bits; // segment bitnese

boolbit iscode : 1; // true if a code segment.
boolbit isabs : 1; // true if this is an absolute segment.
Expand Down

0 comments on commit 7bcd317

Please sign in to comment.