MASM -> /ALIGN:4 doesn't work

This is a discussion on MASM -> /ALIGN:4 doesn't work within the Windows Programming forums, part of the Platform Specific Boards category; Hey, if there are any MASM coders, please help me out! i'm trying to achieve smaller executable sizes using /ALIGN:4 ...

  1. #1
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244

    MASM -> /ALIGN:4 doesn't work

    Hey,
    if there are any MASM coders, please help me out!

    i'm trying to achieve smaller executable sizes using /ALIGN:4
    but all i get is an application error (0xc0000018), when the executable is run.
    this example runs fine under winXP, but not under windows 7.

    you'd say i have to use at lease 512 align, but i've seen handcrafted PE stubs with no align at all, yet working.
    so how do i manage this? do i have to write the PE header myself, or is there any other option to remove the align?

    any ideas?


    code:
    Code:
    .386
    .model flat, stdcall
    option casemap :none
    
    include \masm32\include\kernel32.inc
    includelib \masm32\lib\kernel32.lib
    
    .code
    start:
    	invoke ExitProcess, 0
    end start
    compiled with that commandline:
    Code:
    \masm32\bin\ml /c /coff /nologo test.asm
    \masm32\bin\Link /SUBSYSTEM:WINDOWS /MERGE:.rdata=.text /ALIGN:4 test.obj > nul
    Last edited by Devils Child; 02-07-2011 at 11:16 AM.

  2. #2
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    I just got the weird feeling it has to do with x64 bit systems. but /align:8 doesn't help either...

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Funny feeling that ALIGN is not guaranteed compatible over different versions of windows

    Linker Tools Warning LNK4108 (C++)

  4. #4
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    Hm...

    do you have any other ideas?
    like hand-crafted PE binaries? i haven't found any examples yet... do you have any?

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Quote Originally Posted by Devils Child View Post
    Hm...

    do you have any other ideas?
    like hand-crafted PE binaries? i haven't found any examples yet... do you have any?
    There are examples out there but they will probably suffer the same problems when moving between platforms.

    I believe there's a minimum size of about 1Kb that a program must be to conform to the PE format. You can get it below this but its not portable. COM files can be smaller but they are run in a dos emulator and so are restricted in what they can do.

    Why would you need such a small exe and need to move it between machines?

  6. #6
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    Well, if it really can't go below 1 KB without compability issues, then i guess i can live with that

    thanks for helping!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  3. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 10:39 PM
  4. Problems in getting OpenGL to work
    By zonf in forum C Programming
    Replies: 5
    Last Post: 02-13-2006, 03:48 AM
  5. Replies: 10
    Last Post: 12-03-2005, 09:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21