Skip to content

Commit

Permalink
wlib: rename symbol to be consistent in project
Browse files Browse the repository at this point in the history
set symbol name buffer to maximum length of 256 characters
  • Loading branch information
jmalak committed Mar 9, 2024
1 parent 7d2bf31 commit eb28535
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 34 deletions.
34 changes: 17 additions & 17 deletions bld/nwlib/c/coffwrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static signed_16 AddCoffSection( coff_lib_file *c_file, name_len *secname, unsig
return( c_file->header.num_sections );
}

static unsigned AddCoffSymbol( coff_lib_file *c_file, signed_16 sec_num, name_len *symname,
static unsigned AddCoffSymbol( coff_lib_file *c_file, signed_16 sec_num, name_len *symName,
unsigned_32 value, unsigned_16 type, unsigned_8 class, unsigned_8 num_aux )
/*****************************************************************************************
* input sec_num is 1-based
Expand All @@ -145,12 +145,12 @@ static unsigned AddCoffSymbol( coff_lib_file *c_file, signed_16 sec_num, name_le
coff_symbol _WCUNALIGNED *sym;

sym = c_file->symbols + c_file->header.num_symbols;
if( symname->len > COFF_SYM_NAME_LEN ) {
if( symName->len > COFF_SYM_NAME_LEN ) {
sym->name.non_name.zeros = 0;
sym->name.non_name.offset = c_file->string_table_size + 4;
AddCoffString( c_file, symname );
AddCoffString( c_file, symName );
} else {
strncpy( sym->name.name_string, symname->name, COFF_SYM_NAME_LEN );
strncpy( sym->name.name_string, symName->name, COFF_SYM_NAME_LEN );
}
sym->value = value;
sym->sec_num = sec_num; /* 1-based, 0 is special value */
Expand All @@ -171,7 +171,7 @@ static unsigned AddCoffSymSec( coff_lib_file *c_file, signed_16 sec_num, unsigne
char name[COFF_SEC_NAME_LEN + 1];
coff_section_header *section;
unsigned symb_idx;
name_len symname;
name_len symName;

/*
* get section name
Expand All @@ -180,12 +180,12 @@ static unsigned AddCoffSymSec( coff_lib_file *c_file, signed_16 sec_num, unsigne
section = c_file->sections + sec_num - 1;
strncpy( name, section->name, COFF_SEC_NAME_LEN );
name[COFF_SEC_NAME_LEN] = '\0';
symname.name = name;
symname.len = strlen( name );
symName.name = name;
symName.len = strlen( name );
/*
* add section symbol record
*/
symb_idx = AddCoffSymbol( c_file, sec_num, &symname, 0x0, COFF_IMAGE_SYM_TYPE_NULL, COFF_IMAGE_SYM_CLASS_STATIC, 1 );
symb_idx = AddCoffSymbol( c_file, sec_num, &symName, 0x0, COFF_IMAGE_SYM_TYPE_NULL, COFF_IMAGE_SYM_CLASS_STATIC, 1 );
/*
* add section auxiliary record
*/
Expand Down Expand Up @@ -324,25 +324,25 @@ static void WriteCoffOptHeader( libfile io, sym_file *sfile )

static unsigned AddCoffSymbol2( coff_lib_file *c_file, signed_16 sec_num, name_len *n1, name_len *n2, unsigned_16 type )
{
name_len symname;
name_len symName;
char *p;

symname.len = n1->len + n2->len;
symname.name = p = alloca( symname.len + 1 );
symName.len = n1->len + n2->len;
symName.name = p = alloca( symName.len + 1 );
strcpy( strcpy( p, n1->name ) + n1->len, n2->name );
return( AddCoffSymbol( c_file, sec_num, &symname, 0x0, type, COFF_IMAGE_SYM_CLASS_EXTERNAL, 0 ) );
return( AddCoffSymbol( c_file, sec_num, &symName, 0x0, type, COFF_IMAGE_SYM_CLASS_EXTERNAL, 0 ) );
}

static unsigned AddCoffSymbolNullThunkData( coff_lib_file *c_file, signed_16 sec_num, name_len *modName )
{
name_len symname;
name_len symName;
char *p;

symname.len = 1 + modName->len + str_coff_null_thunk_data.len;
symname.name = p = alloca( symname.len + 1 );
symName.len = 1 + modName->len + str_coff_null_thunk_data.len;
symName.name = p = alloca( symName.len + 1 );
p[0] = 0x7f;
strcpy( strcpy( p + 1, modName->name ) + modName->len, str_coff_null_thunk_data.name );
return( AddCoffSymbol( c_file, sec_num, &symname, 0x0, COFF_IMAGE_SYM_TYPE_NULL, COFF_IMAGE_SYM_CLASS_EXTERNAL, 0 ) );
return( AddCoffSymbol( c_file, sec_num, &symName, 0x0, COFF_IMAGE_SYM_TYPE_NULL, COFF_IMAGE_SYM_CLASS_EXTERNAL, 0 ) );
}

static void WriteImportDescriptor( libfile io, sym_file *sfile, coff_lib_file *c_file, name_len *modName, name_len *dllName, bool long_format )
Expand Down Expand Up @@ -825,7 +825,7 @@ void CoffWriteImport( libfile io, sym_file *sfile, bool long_format )
}
modName.len = 0;
modName.name = MakeFName( sfile->import->dllName );
if( modName.name != NULL ) {
if( *modName.name != '\0' ) {
modName.len = strlen( modName.name );
p = alloca( modName.len + 1 );
modName.name = strcpy( p, modName.name );
Expand Down
14 changes: 7 additions & 7 deletions bld/nwlib/c/implib.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static bool elfAddImport( libfile io, long header_offset, arch_header *arch )
static void importOs2Table( libfile io, arch_header *arch, const char *dll_name, bool coff_obj, importType type, unsigned length )
{
unsigned_16 ordinal;
char symbol[256];
char symbol[256]; /* maximum name len is 255 characters */
unsigned bytes_read;
unsigned total_read;

Expand Down Expand Up @@ -244,8 +244,8 @@ static void importOs2Table( libfile io, arch_header *arch, const char *dll_name,
static void os2AddImport( libfile io, long header_offset, arch_header *arch )
{
os2_exe_header os2_header;
char dll_name[_MAX_FNAME + _MAX_EXT + 1];
char junk[256];
char dll_name[256]; /* maximum name len is 255 characters */
char junk[256]; /* maximum name len is 255 characters */
importType type;
unsigned bytes_read;

Expand All @@ -265,7 +265,7 @@ static void os2AddImport( libfile io, long header_offset, arch_header *arch )
bytes_read = getLenSymbol( io, junk );
getU16( io );
importOs2Table( io, arch, dll_name, false, type,
os2_header.nonres_size - bytes_read - 1 - sizeof( unsigned_16 ) );
os2_header.nonres_size - ( bytes_read + 1 + sizeof( unsigned_16 ) ) );
}
}

Expand Down Expand Up @@ -301,7 +301,7 @@ static void coffAddImportOverhead( arch_header *arch, const char *dllName, proce
static void os2FlatAddImport( libfile io, long header_offset, arch_header *arch )
{
os2_flat_header os2_header;
char dll_name[256];
char dll_name[256]; /* maximum name len is 255 characters */
bool coff_obj;
importType type;

Expand All @@ -326,8 +326,8 @@ static void os2FlatAddImport( libfile io, long header_offset, arch_header *arch
static bool nlmAddImport( libfile io, long header_offset, arch_header *arch )
{
nlm_header nlm;
char dll_name[_MAX_FNAME + _MAX_EXT + 1];
char symbol[256];
char dll_name[256]; /* maximum name len is 255 characters */
char symbol[256]; /* maximum name len is 255 characters */

LibSeek( io, header_offset, SEEK_SET );
LibRead( io, &nlm, sizeof( nlm ) );
Expand Down
24 changes: 14 additions & 10 deletions bld/nwlib/c/omfutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* Open Watcom Project
*
* Copyright (c) 2024-2024 The Open Watcom Contributors. All Rights Reserved.
* Copyright (c) 2024 The Open Watcom Contributors. All Rights Reserved.
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
Expand Down Expand Up @@ -172,25 +172,29 @@ static bool InsertOmfDict( OmfLibBlock *lib_block, unsigned num_blocks, const ch

static bool HashOmfSymbols( OmfLibBlock *lib_block, unsigned num_blocks, sym_file *sfile )
{
bool ret = true;
bool ret;
sym_entry *sym;
unsigned str_len;
char *fname;
const char *cp;
char fname[256]; /* OMF maximum name len is 255 characters */

ret = true;
for( ; sfile != NULL; sfile = sfile->next ) {
if( sfile->import == NULL ) {
fname = MakeFName( sfile->full_name );
cp = MakeFName( sfile->full_name );
} else {
#ifdef IMP_MODULENAME_DLL
fname = sfile->import->dllName;
cp = sfile->import->dllName;
#else
fname = sfile->import->u.omf_coff.symName;
cp = sfile->import->u.omf_coff.symName;
#endif
}
str_len = strlen( fname );
fname[str_len] ='!';
ret = InsertOmfDict( lib_block, num_blocks, fname, str_len + 1, sfile->u.new_offset_omf );
fname[str_len] = 0;
str_len = 0;
while( *cp != '\0' ) {
fname[str_len++] = *cp++;
}
fname[str_len++] = '!';
ret = InsertOmfDict( lib_block, num_blocks, fname, str_len, sfile->u.new_offset_omf );
if( !ret ) {
return( ret );
}
Expand Down

0 comments on commit eb28535

Please sign in to comment.