Minimalist executable

Discussion in 'C Programming' started by Sam, Aug 15, 2003.

  1. Sam

    Sam Guest

    Hello,

    I am programming for Windows, using MinGW (GCC 3.2.3) and I have just read
    "Techniques for reducing Executable size"
    (http://www.catch22.org.uk/tuts/minexe.asp). I want to write the smallest
    program with gcc, and I will use neither command line arguments (argc and
    argv) nor memory functions (malloc, ...) (I will take advantage of
    HeapAlloc) nor exception handling so that I do need the functions that are
    called before main(). As a consequence I just wote

    int mainCRTStartup()
    {
    return 0;
    }

    which is exactly 2 048 bytes, telling the linker I did not want any standard
    or startup library.

    I would like to get even smaller executables, by changing the FILEALIGN and
    ALIGN of the executable, as explained in catch22's article. They use, for
    Visual C++ 6.0 :

    //---------------
    // Make section alignment really small
    #pragma comment(linker, "/FILEALIGN:16")
    #pragma comment(linker, "/ALIGN:16")

    // Merge sections
    #pragma comment(linker, "/MERGE:.rdata=.text")
    #pragma comment(linker, "/MERGE:.text=.text")
    #pragma comment(linker, "/MERGE:.reloc=.text")
    //---------------

    How could I "translate" this for the MinGW linker ?

    Thanks,
    Sam.
    Sam, Aug 15, 2003
    #1
    1. Advertising

  2. Sam

    Daniel Haude Guest

    On Fri, 15 Aug 2003 14:34:56 +0200,
    Sam <> wrote
    in Msg. <3f3cd373$0$26422$>

    > I want to write the smallest program with gcc,


    That's off-topic in comp.lang.c. Please try to limit this thread to
    comp.os.ms-windows.programmer.misc where it belongs (f'up set)

    --Daniel

    --
    "With me is nothing wrong! And with you?" (from r.a.m.p)
    Daniel Haude, Aug 15, 2003
    #2
    1. Advertising

  3. Sam

    Sven Semmler Guest

    Sam wrote:

    > int mainCRTStartup()

    ^

    In C you need to write "(void)".

    > #pragma comment(linker, "/MERGE:.rdata=.text")
    > #pragma comment(linker, "/MERGE:.text=.text")
    > #pragma comment(linker, "/MERGE:.reloc=.text")
    > //---------------
    >
    > How could I "translate" this for the MinGW linker ?


    Search a group or mailing list for that compiler, since this is about the
    linker not the C language.

    /Sven

    --
    Sven Semmler http://www.semmlerconsulting.com/
    GPG Fingerprint: 72CA E26D C2A3 1FEB 7AFC 10EA F769 A9A4 937F 5E67
    Sven Semmler, Aug 15, 2003
    #3
  4. On Fri, 15 Aug 2003 14:34:56 +0200, in comp.lang.c , "Sam"
    <> wrote:

    >Hello,
    >
    >I am programming for Windows, using MinGW (GCC 3.2.3) and I have just read
    >"Techniques for reducing Executable size"

    .....
    >I would like to get even smaller executables, by changing the FILEALIGN and
    >ALIGN of the executable, as explained in catch22's article.

    .....
    >How could I "translate" this for the MinGW linker ?


    This has /ABSOLUTELY/ nothing to do with C, you need to ask in a group
    specialising in MinGW, whatever that is. Be prepared for
    disappointment.
    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
    Mark McIntyre, Aug 16, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Uncle Bob (Robert C. Martin)

    Use Cases -- A minimalist's View

    Uncle Bob (Robert C. Martin), Jul 2, 2003, in forum: Java
    Replies:
    0
    Views:
    753
    Uncle Bob (Robert C. Martin)
    Jul 2, 2003
  2. Replies:
    10
    Views:
    553
  3. Chris Thomasson

    Very Simple, Minimalist Technique For OOP in C...

    Chris Thomasson, Jun 21, 2007, in forum: C Programming
    Replies:
    10
    Views:
    655
    Johan Bengtsson
    Jun 24, 2007
  4. rtk
    Replies:
    16
    Views:
    1,042
    Cameron Laird
    Jul 6, 2007
  5. Daniel Fetchinson

    [OT] minimalist web server

    Daniel Fetchinson, Dec 2, 2007, in forum: Python
    Replies:
    12
    Views:
    708
    MonkeeSage
    Dec 3, 2007
Loading...

Share This Page