The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: Adamanteus on December 23, 2007, 07:14:27 PM

Title: Building alternate RTL for MASM32
Post by: Adamanteus on December 23, 2007, 07:14:27 PM
 Deal is about msvcrt.inc that is used substitutions to somehow strange named functions _imp___kbhit.
I want to emulate this, but don't know how it's originally made ?
Possible, and good idea to remap it to names as _kbhit - as default leading underscore added automatically for C routines. But assembler adds more one so making __kbhit. Is it possible to avoid add underscore to some options, except syscall, because it's not linked with c-functions, as I defined externdef syscall _kbhit. ::)
Title: Re: Building alternate RTL for MASM32
Post by: hutch-- on December 23, 2007, 07:29:52 PM
The problem is many of the names in MSVCRT are illegal names in MASM, thats why the method for using in the masm32 project prefixed the names with crt_*****. Apart from a minor increase in typing it works fine.
Title: Re: Building alternate RTL for MASM32
Post by: Adamanteus on December 23, 2007, 07:52:39 PM
It's clear that if to delete all prefixes in msvcrt.inc will be keywords, but hows to lib file that building not by def file, but by sources is to make substitutes to crt__xxx. Them remap possible only throw one leading underscore, but it's doubling by assembler. So not to delete not to use - only with some long prefix, that I don't know how's to add - not found this option if it is at all.
Title: Re: Building alternate RTL for MASM32
Post by: Vortex on December 23, 2007, 08:16:03 PM
Adamanteus,

Can you be more specific? Maybe, I can help you to if you would give an example about what you would like to achieve.
Title: Re: Building alternate RTL for MASM32
Post by: Adamanteus on December 23, 2007, 08:42:52 PM
It's need make tool makecimp that to make alternate msvcrt.inc, than make own lib by normal named functions for example kbhit. Than is need to substitute this functions to crt__kbhit in m32lib library.

[attachment deleted by admin]
Title: Re: Building alternate RTL for MASM32
Post by: Vortex on December 23, 2007, 09:03:04 PM
Adamanteus,

Could this project (http://www.masm32.com/board/index.php?topic=1638.msg49345#msg49345) help you?
Title: Re: Building alternate RTL for MASM32
Post by: Adamanteus on December 24, 2007, 12:08:56 PM
Yes, thank You. It helped such that was need to write proto syscall insted of externdef syscall - by what is difference difficult to understand, it seems Microsoft fault.
But sorry appaped new hidden mistake under name "_strerror" - referenced from masm32.lib - but not found in it's code. I'm not sure that somebody met such problem, but if is ? :dazzled:
Title: Re: Building alternate RTL for MASM32
Post by: hutch-- on December 25, 2007, 12:17:05 PM
Adamanteus,

There are a couple of simple choices for you if you want closer to the original names. Both Vortex and I have produced tools to make the include files and as they simply produce equates for names you can change them to whatever you like.

I personally prefer the crt_ prefix because it allows you to use any of the other CRT runtime libraries which often have the same names for some functions. Just change the prefix for any DLL you can get the function names for and you can run parallel DLLs with identical function names just be changing the prefix on the equate name.
Title: Re: Building alternate RTL for MASM32
Post by: Vortex on December 25, 2007, 06:53:05 PM
Hi Adamanteus,

_strerror is not a member of masm32.lib This function is exported by msvcrt.dll
Title: Re: Building alternate RTL for MASM32
Post by: Adamanteus on December 26, 2007, 05:39:57 PM
Thanks, it's I also found - except it strange linking to programs that absolutely not using it. Linked I already everything successfully but happend to copy stubs of libraries with names fmtcmt.lib and oldnames.lib to lib folder. Found option /NODEFAULTLIB for librarian, but it seems absolutely not helping that do discard referenced on this libraries in my clear of it indeed.
Title: Re: Building alternate RTL for MASM32
Post by: Vortex on December 26, 2007, 06:15:36 PM
Adamanteus,

I guess you are using libraries from Visual Studio. Try to use the version of msvcrt.lib supplied with the Masm32 package, it does not depend on other libraries.
Title: Re: Building alternate RTL for MASM32
Post by: Adamanteus on December 27, 2007, 01:10:12 AM
No I'm using msvcrt.lib of my own it's K-Lib, and everything now well working, except that on it 2.5K program becalmed 64K, but it's as used such and I don't know why on original is mach smaller ?
Title: Re: Building alternate RTL for MASM32
Post by: hutch-- on December 27, 2007, 01:23:39 AM
Without knowing the details it sounds like you have pulled in the C runtime libraries which will bloat your code with its size.
Title: Re: Building alternate RTL for MASM32
Post by: Adamanteus on December 28, 2007, 12:22:31 PM
Yes it so, here is attached bloat example, also I just begun porting code and working only it.

[attachment deleted by admin]
Title: Re: Building alternate RTL for MASM32
Post by: Vortex on December 28, 2007, 06:29:54 PM
Hi Adamanteus,

I removed the macros from the source file. I see that you are using another version of msvcrt.lib, it has a different set of exported functions :

LIBRARY msvcrt
EXPORTS
"FIARQQ"
"FICRQQ"
"FIDRQQ"
"FIERQQ"
"FISRQQ"
"FIWRQQ"
"FJARQQ"
"FJCRQQ"
"FJERQQ"
"FJSRQQ"
"DosErrorOperating"
.
.
.


Size decreased from 66048 bytes to 1536 bytes.


[attachment deleted by admin]
Title: Re: Building alternate RTL for MASM32
Post by: Adamanteus on December 29, 2007, 05:28:20 PM
It's you decreased it on original msvcrt.lib on 1K. But I asked hows it is linking with my lib. So you build.bat file with polink linker are giving such output on me :

POLINK: error: Symbol '$LN2' is multiply defined ('msvcrt:ERRORDIA.OBJ' and 'msvcrt:ERRORDIA.OBJ').
POLINK: error: Symbol '$LN3' is multiply defined ('msvcrt:ERRORDIA.OBJ' and 'msvcrt:ERRORDIA.OBJ').
POLINK: error: Symbol '$LN4' is multiply defined ('msvcrt:ERRORDIA.OBJ' and 'msvcrt:ERRORDIA.OBJ').
POLINK: error: Symbol '$LN5' is multiply defined ('msvcrt:ERRORDIA.OBJ' and 'msvcrt:ERRORDIA.OBJ').
POLINK: error: Symbol '$LN6' is multiply defined ('msvcrt:ERRORDIA.OBJ' and 'msvcrt:ERRORDIA.OBJ').
POLINK: error: Symbol '$LN16' is multiply defined ('msvcrt:ERRORDIA.OBJ' and 'msvcrt:ERRORDIA.OBJ').
POLINK: error: Symbol '$LN7' is multiply defined ('msvcrt:STRINGZ.OBJ' and 'msvcrt:STRINGZ.OBJ').
POLINK: error: Symbol '$LN8' is multiply defined ('msvcrt:STRINGZ.OBJ' and 'msvcrt:STRINGZ.OBJ').
POLINK: error: Unresolved external symbol '_RegOpenKeyExA'.
POLINK: error: Unresolved external symbol '_RegCloseKey'.
POLINK: error: Unresolved external symbol '_RegQueryValueExA'.
POLINK: fatal error: 3 unresolved external(s).

Exactly mean : Marry Christmas day, to my RTLĀ  :bdg
Title: Re: Building alternate RTL for MASM32
Post by: Vortex on December 29, 2007, 07:28:41 PM
Could you give information about how you built your version of msvcrt.lib? Another question, why do link with advapi32.lib?
Title: Re: Building alternate RTL for MASM32
Post by: Adamanteus on December 29, 2007, 08:30:18 PM
 Build throw my sources by asm and c compiler directly. Advapi32.lib require linker for it's referenced from getCountry function in library, even it's not require for the program seems that linker pouted it to there for unknown reasons.