uFmod "minimal.exe" size

Тема в разделе "WASM.BEGINNERS", создана пользователем CDW, 1 мар 2006.

  1. CDW

    CDW New Member

    Публикаций:
    0
    Регистрация:
    1 мар 2006
    Сообщения:
    5
    Адрес:
    Germany
    Using minifmod for a long time, yesterday, i detected uFmod.



    The example executable in uFmod folder (MASM32 example) have only 8 KB and is not packed.



    But if i rebuild the example (using the build.bat), i get a 11.5KB Exe. The question is: Why? And how i can fix it? ;)



    Ok, this is a lot better than minifmod (simple XM-playing Exe: with minifmod 16KB, using uFmod: 12KB), but i want to "have it all" :lol: .



    Playing around with MEW11 i figured out that MEW-packed "original" executable from uFmod have only 5.56KB, the "new generated" 7.7KB -> so i think there is some needless code.



    What i have tried:

    Search & Found some new version of uFmod:

    ufmod-1.08

    Correkt the build.bat in

    ufmod-1.08\masm32\winmm (some paths,so i can be sure it uses my newest MASM Installation ;) )

    download MASM32 SP2 and install it.

    Using polink.



    Again: i am using the "orinal" uFmod example (but uFmod works with my sources too ;) ) and trying to get the "original" example size (8KB) of the generated executable.

    But my MASM generates only a 11.5KB big executable.





    You can answer me in russian too ;) (i have a german keyboard and no idea (and no skills) how to type some Cyrillic)







    PS: "fixed" makit.bat:
    Код (Text):
    1. @echo off
    2. E:\masm32\bin\ml /c /coff /Cp minimal.asm
    3. E:\masm32\bin\link /SUBSYSTEM:WINDOWS /RELEASE /OPT:nowin98 /LIBPATH:E:\masm32\lib /MERGE:.rdata=.text -ignore:4078 minimal.obj
    4. del minimal.obj
    5. pause
    6. cls
     
  2. Vasil

    Vasil Василь

    Публикаций:
    0
    Регистрация:
    7 янв 2006
    Сообщения:
    228
    Адрес:
    Ижевск
    CDW

    You can answer me in russian too - OK!



    Зачем ты объединяешь секцию кода и секцию данных?

    /MERGE:.rdata=.text -ignore:4078

    И убери это:

    /OPT:nowin98



    in BAD English

    Why you unite the section of the code and section data?

    /MERGE:.rdata=.text -ignore:4078

    And take away this:

    /OPT:nowin98



    PS: Shall teach english... :)
     
  3. Quantum

    Quantum Паладин дзена

    Публикаций:
    0
    Регистрация:
    6 янв 2003
    Сообщения:
    3.143
    Адрес:
    Ukraine
    CDW



    That sample minimal.exe uses some kind of "insane" optimization. To get an 8K exe you need to accomplish the following steps:

    <ol type=1>

    <li>Use the EFF utility to check the unused effects and functions for a particular applicaction and a particular XM file. EFF will generate a header EFF.INC. Place it into the UFMODLIB directory.

    <li>Use MASM32 and VC++ to recompile the library.

    <li>Compile your project using this new library.

    </ol>

    But remember! It's a lot smaller, but it won't work fine with other XM files.



    Additionally it's possible to merge the executable code and the XM stream to save some bytes. The MASM32 minimal example shows how (using EFF once again).



    BTW, next uFMOD release will be about 200 bytes smaller!



    Vasil



    .rdata - это read-only data. Там IAT. Согласно стандарту, IAT не обязана находиться в отдельной секции. Её можно объединить с секцией кода (.text) для уменьшения размера экзешника.





    Это для уменьшения выравнивания секций. В старых версиях линкера этот флаг ничего не даёт, а в новых очень актуален.
     
  4. CDW

    CDW New Member

    Публикаций:
    0
    Регистрация:
    1 мар 2006
    Сообщения:
    5
    Адрес:
    Germany
    @Vasil: "hotshesh tshitat po russki latinkskimi bukwami? ;)"



    i posted only the "makit.bat" from this example. On my own, i dont use the "nowin98" flag. Merging is,as Quantum says, ok - for smaller executables (i have read it in some Iczelion's tutorials and i am using it for years - it works with win95/98 too).

    Here is some example (with source) - 2KB Exe with GUI and some "non system colors" -there are no "complex" optimization.



    @Quantum: thx, i thought that the Lib in this example folder is the "optimized".



    Additionally it's possible to merge the executable code and the XM stream to save some bytes. The MASM32 minimal example shows how (using EFF once again).

    it is something for freaks ;)



    # Use MASM32 and VC++ to recompile the library.

    # Compile your project using this new library.


    I am using Vc++ 6.0, recompiling the lib give me no errors, but reassembly my project give me some:

    Код (Text):
    1.  
    2. ufmod.lib(xmformat.obj) : error LNK2001: unresolved external symbol ___pfnBkChec
    3. k
    4. musik.exe : fatal error LNK1120: 1 unresolved externals


    my project works fine with your "original/universale" Lib.

    I can fix it (the "spezial" Lib) manually (with my hexeditor and whitespaces *g*) and it works too.

    Anyway, good work of yours and Asterix. *thubs up*



    EDIT: now, using EFF and recompiling the lib(and fixing it manually) for the example (minimal.exe) give me a 9.5 KB Exe. I think its ok.



    [​IMG] _183071093__Example.rar
     
  5. Quantum

    Quantum Паладин дзена

    Публикаций:
    0
    Регистрация:
    6 янв 2003
    Сообщения:
    3.143
    Адрес:
    Ukraine
    CDW



    I agree





    That symbol shouldn't be there. Compiling the c source directly from the project workspace produces no such externals. Though, I've seen a similar behaviour in VC6 some time ago, even when correctly loading the workspace. Maybe, it's a VC6 bug. So, it's better to compile everything from the command line. Latest uFMOD MAKECOFF.BAT does so.
     
  6. CDW

    CDW New Member

    Публикаций:
    0
    Регистрация:
    1 мар 2006
    Сообщения:
    5
    Адрес:
    Germany
    Quantum

    Though, I've seen a similar behaviour in VC6 some time ago,



    Google says it too (for some other projects) - seems to be a VC6 Bug.



    I download the newest version and it works fine - rebuilding the example give me a 8.5KB Exe.



    EDIT:

    i tried the intel compiler - seems be all right, no "unresolved" errors and a fine 8 KB executable ;)
     
  7. Quantum

    Quantum Паладин дзена

    Публикаций:
    0
    Регистрация:
    6 янв 2003
    Сообщения:
    3.143
    Адрес:
    Ukraine
    CDW



    That's a good idea. Thanks! I was thinking about using ICC in Linux, 'cause GCC produces a lot of garbage code. I hope ICC whould become freeware sooner or later.