Minimal executable

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

  1. Joon

    Joon 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.
     
    Joon, Aug 15, 2003
    #1
    1. Advertisements

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. Ken Barrett
    Replies:
    5
    Views:
    1,006
  2. Guadala Harry

    Minimal Shopping Cart

    Guadala Harry, Sep 27, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    645
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Sep 27, 2004
  3. Rolf
    Replies:
    2
    Views:
    429
    Steve C. Orr [MVP, MCSD]
    Feb 7, 2005
  4. Krick
    Replies:
    5
    Views:
    2,275
    Robert Olofsson
    Aug 13, 2003
  5. Replies:
    15
    Views:
    666
    Dave Thompson
    Aug 21, 2006
  6. pratap
    Replies:
    20
    Views:
    1,042
    Flash Gordon
    Mar 7, 2007
  7. Jason Cavett
    Replies:
    8
    Views:
    947
    Sanjay
    May 16, 2007
  8. Replies:
    0
    Views:
    603
Loading...